Commit 6e0534da authored by 王雷's avatar 王雷

调整log库上传方式增加回调

parent b531f904
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="PLATFORM" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="$USER_HOME$/gradle/gradle-6.6.1" />
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/dialog.iml" filepath="$PROJECT_DIR$/.idea/modules/dialog.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="BranchesTreeState">
<expand>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
</path>
<path>
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" />
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" />
</path>
</expand>
<select />
</component>
<component name="ChangeListManager">
<list default="true" id="1cc0b028-264c-427a-920d-c062fe647ff7" name="Default Changelist" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectId" id="1jo5pt83hlsJBr0tVtpUgezX9dW" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
<option name="showMembers" value="true" />
<option name="showVisibilityIcons" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="android.sdk.path" value="$USER_HOME$/Library/Android/sdk" />
<property name="settings.editor.selected.configurable" value="AndroidSdkUpdater" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="1cc0b028-264c-427a-920d-c062fe647ff7" name="Default Changelist" comment="" />
<created>1604457789806</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1604457789806</updated>
</task>
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "com.whl.gradle-publish-plugin"
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
group 'com.qmai.android.dialog'
version '1.0.0.3-SNAPSHOT'
gradlePublish {
sourceJarEnabled = true
javaDocEnabled = false
signEnabled = false
releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-releases/"
userName = "wanglei1"
password = "woshiwanglei123"
}
snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wanglei1"
password = "woshiwanglei123"
}
}
## This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Wed Nov 04 10:43:09 CST 2020
sdk.dir=/Users/leiwang/Library/Android/sdk
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package zs.qimai.com.dialog
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("zs.qimai.com.dialog", appContext.packageName)
}
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="zs.qimai.com.dialog">
</manifest>
\ No newline at end of file
package zs.qimai.com.dialog
import android.os.Bundle
import android.view.*
import androidx.fragment.app.DialogFragment
abstract class BaseDialogFragment : DialogFragment() {
private var containerView: View? = null
abstract fun getLayoutId(): Int
abstract fun bindView(v: View)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.QmDialogTheme)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
containerView = layoutInflater.inflate(getLayoutId(), container, false)
// return super.onCreateView(inflater, container, savedInstanceState)
bindView(containerView!!)
return containerView
}
override fun onStart() {
super.onStart()
val windowManager = dialog!!.window
//设置宽高
val layoutParams = windowManager?.attributes
//设置gravity
layoutParams?.gravity = getGravity()
windowManager?.attributes = layoutParams
windowManager?.setLayout(getDialogWidth(), getDialogHeight())
}
fun <T : View> getView(id: Int): T? {
return containerView?.findViewById<T>(id)
}
open fun getGravity() = Gravity.CENTER
open fun getDialogWidth() = WindowManager.LayoutParams.MATCH_PARENT
open fun getDialogHeight() = WindowManager.LayoutParams.WRAP_CONTENT
}
\ No newline at end of file
package zs.qimai.com.dialog
import android.content.DialogInterface
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.FragmentManager
import java.util.ArrayList
class DialogController {
lateinit var fragmentManager: FragmentManager
var layoutResId: Int = 0
var width: Int = ViewGroup.LayoutParams.MATCH_PARENT
var height: Int = ViewGroup.LayoutParams.WRAP_CONTENT
var gravity: Int = 0
var onViewClickListener: OnViewClickListener? = null
var dismissListener: DialogInterface.OnDismissListener? = null
var positive: (View, DialogFragment) -> Unit = { a, b -> }
var negative: (View, DialogFragment) -> Unit = { a, b -> }
var dialogTheme: Int = R.style.QmDialogTheme
var onViewInflateFinish: QmDialogFragment.OnViewInflateFinish? = null
var onActivityResultListener: QmDialogFragment.OnActivityResultListener? = null
var canceledOnTouchOutside = true
var cancelable = true
var mDismissListenerList: ArrayList<OnDialogDismissListener> = ArrayList()
class Params {
lateinit var fragmentManager: FragmentManager
var layoutResId: Int = R.layout.ls_dialog_tips_layout
var width: Int = ViewGroup.LayoutParams.MATCH_PARENT
var widthPercentage:Float = 0f
var height: Int = ViewGroup.LayoutParams.WRAP_CONTENT
var gravity: Int = 0
var onViewClickListener: OnViewClickListener? = null
var dismissListener: DialogInterface.OnDismissListener? = null
var mDismissListenerList: ArrayList<OnDialogDismissListener> = ArrayList()
var positive: (View, DialogFragment) -> Unit = { a, b -> }
var negative: (View, DialogFragment) -> Unit = { a, b -> }
var dialogTheme: Int = R.style.QmDialogTheme
var onViewInflateFinish: QmDialogFragment.OnViewInflateFinish? = null
var onActivityResultListener: QmDialogFragment.OnActivityResultListener? = null
var canceledOnTouchOutside = true
var Cancelable = true
fun apply(dialogController: DialogController) {
dialogController.fragmentManager = this.fragmentManager
dialogController.gravity = this.gravity
dialogController.width = this.width
dialogController.height = this.height
dialogController.layoutResId = this.layoutResId
dialogController.onViewClickListener = this.onViewClickListener
dialogController.dismissListener = this.dismissListener
dialogController.positive = this.positive
dialogController.negative = this.negative
dialogController.dialogTheme = this.dialogTheme
dialogController.onViewInflateFinish = this.onViewInflateFinish
dialogController.onActivityResultListener = this.onActivityResultListener
dialogController.cancelable = this.Cancelable
dialogController.canceledOnTouchOutside = this.canceledOnTouchOutside
dialogController.mDismissListenerList = this.mDismissListenerList
}
}
}
\ No newline at end of file
package zs.qimai.com.dialog
import android.content.DialogInterface
import android.util.Log
import java.util.concurrent.ConcurrentLinkedQueue
/***
*
* Dialog管理类,管理多个Dialog按顺序出现
*
*
* * **/
class DialogManager {
private var isShowDialoging = false
val mDialogQueue: ConcurrentLinkedQueue<DialogParams> by lazy {
ConcurrentLinkedQueue<DialogParams>()
}
fun pushDialogToQueue(dialogFragment: QmDialogFragment, tag: String = "", priority: Int = 0) {
if (dialogFragment != null) {
var dialogParams = DialogParams(dialogFragment.apply {
dialogController.mDismissListenerList.add(
object : OnDialogDismissListener {
override fun onDismiss(dialog: DialogInterface?) {
Log.d(TAG, "onDismiss: ")
isShowDialoging = false
startShowDialog()
}
})
}, tag, priority)
mDialogQueue.add(dialogParams)
}
/* if (canShow()) {
startShowDialog()
}*/
}
fun startShowDialog() {
if (mDialogQueue.isNullOrEmpty()||isShowDialoging) {
return
}
else {
prioritySequence(mDialogQueue)
var dialogParams = mDialogQueue.poll()
dialogParams?.let {
it.dialogFragment?.show(it.tag)
isShowDialoging = true
}
}
}
private fun prioritySequence(mDialogQueue: ConcurrentLinkedQueue<DialogManager.DialogParams>) {
mDialogQueue.sortedBy {
it.priority
}
}
companion object {
private const val TAG = "DialogManager"
}
//判断是否可以显示弹窗
private fun canShow() = isShowDialoging
class DialogParams(
val dialogFragment: QmDialogFragment,
var tag: String = "",
var priority: Int = 0
)
//清除
fun clear() {
mDialogQueue?.forEach {
if (it.dialogFragment != null && it.dialogFragment?.dialog?.isShowing == true) {
it.dialogFragment.dismiss()
}
}
mDialogQueue.clear()
//mDialogQueue = null
}
}
\ No newline at end of file
package zs.qimai.com.dialog
import android.app.Activity
class DialogManagerUtils private constructor(){
private val mHashLinkedList by lazy {
HashMap<Activity, DialogManager>()
}
private var mDialogManagerUtils: DialogManagerUtils? = null
/***
*
* 创建全局唯一实例
* */
fun test(): DialogManagerUtils {
if (mDialogManagerUtils == null) {
mDialogManagerUtils = DialogManagerUtils()
}
return mDialogManagerUtils!!
}
/****
* 传入Activity 获取DialogManger 确保同一个Activity能有一个管理类,能按顺序排列
* @param activity Activity
* @return DialogManager?
*/
fun getDialogManager(activity: Activity): DialogManager? {
return if (mHashLinkedList.containsKey(activity)) {
mHashLinkedList[activity]
} else {
val manager = DialogManager()
mHashLinkedList[activity] = manager
manager
}
}
companion object{
val instance :DialogManagerUtils by lazy {
DialogManagerUtils()
}
}
}
\ No newline at end of file
package zs.qimai.com.dialog
interface LsChooseExpressInterface {
fun getData(): Array<String>
}
\ No newline at end of file
package zs.qimai.com.dialog
import android.content.DialogInterface
interface OnDialogDismissListener {
fun onDismiss(dialog: DialogInterface?)
}
\ No newline at end of file
package zs.qimai.com.dialog
import android.view.View
interface OnViewClickListener {
fun onViewClick(v: View, qmDialogFragment: QmDialogFragment)
}
\ No newline at end of file
package zs.qimai.com.dialog
import android.app.Activity
import android.content.DialogInterface
import android.content.Intent
import android.graphics.Point
import android.os.Build
import android.os.Bundle
import android.util.DisplayMetrics
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
class QmDialogFragment : BaseDialogFragment() {
var dialogController: DialogController = DialogController()
var mDialogTheme = R.style.QmDialogTheme
override fun getLayoutId() = dialogController.layoutResId
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, mDialogTheme)
}
override fun onDismiss(dialog: DialogInterface) {
dialogController.dismissListener?.onDismiss(dialog)
this.dialog?.setOnShowListener(null)
this.dialog?.setOnCancelListener(null)
this.dialog?.setOnDismissListener(null)
dialogController.mDismissListenerList.forEach {
it.onDismiss(dialog)
}
super.onDismiss(dialog)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = super.onCreateView(inflater, container, savedInstanceState)
dialogController.onViewInflateFinish?.onViewInflate(view, this)
dialog?.setCanceledOnTouchOutside(dialogController.canceledOnTouchOutside)
isCancelable = dialogController.cancelable
return view
}
override fun bindView(v: View) {
//设置取消,确认按钮监听事件
getDialogChildView<View>(R.id.tv_cancel, v)
?.setOnClickListener {
dialogController.negative(it, this)
dismiss()
}
getDialogChildView<View>(R.id.tv_ok, v)?.setOnClickListener {
dialogController.positive(it, this)
dismiss()
}
}
private fun <T : View> getDialogChildView(id: Int, v: View): T? {
val childView: View? = v.findViewById<T>(id)
return childView as? T
}
override fun getGravity(): Int {
return dialogController.gravity
}
override fun getDialogWidth(): Int {
return dialogController.width
}
override fun getDialogHeight(): Int {
return dialogController.height
}
open class Builder private constructor(private var fragmentManager: FragmentManager) {
constructor(fragmentActivity: FragmentActivity) : this(fragmentActivity.supportFragmentManager)
constructor(fragment: Fragment) : this(fragment.childFragmentManager)
private var params: DialogController.Params = DialogController.Params()
//控件名称改变
private var paramsMap: MutableMap<Int, String>? = null
var mDialogTheme = R.style.QmDialogTheme
init {
params.fragmentManager = this.fragmentManager
}
fun setGravity(gravity: Int): Builder {
params.gravity = gravity
return this
}
@Deprecated("使用addDismissListener()")
fun setOnDismissListener(listener: DialogInterface.OnDismissListener): Builder {
params.dismissListener = listener
return this
}
fun setOnViewInflateListener(listener: OnViewInflateFinish): Builder {
params.onViewInflateFinish = listener
return this
}
fun setOnActivityResultListener(listener: OnActivityResultListener): Builder {
params.onActivityResultListener = listener
return this
}
fun setWidth(width: Int): Builder {
params.width = width
return this
}
fun setWidthPercentage(activity: Activity, percentage: Float): Builder {
val width = getRootWidth(activity)
params.width = ((width * percentage).toInt())
return this
}
fun setHeight(height: Int): Builder {
params.height = height
return this
}
fun setLayoutRes(layout: Int): Builder {
params.layoutResId = layout
return this
}
fun create(): QmDialogFragment {
val qmDialogFragment = QmDialogFragment()
params.apply(qmDialogFragment.dialogController)
return qmDialogFragment
}
fun setItemViewClick(onViewClickListener: OnViewClickListener): Builder {
params.onViewClickListener = onViewClickListener
return this
}
fun withPositive(positive: (View, DialogFragment) -> Unit): Builder {
params.positive = positive
return this
}
fun withNegative(negative: (View, DialogFragment) -> Unit): Builder {
params.negative = negative
return this
}
fun setText(id: Int, text: String): Builder {
if (paramsMap == null) {
paramsMap = mutableMapOf()
}
//paramsMap!!.put(id,text)
return this
}
fun setContext(text: String): Builder {
if (paramsMap == null) {
paramsMap = mutableMapOf()
}
return this
}
fun setTitle(text: String): Builder {
if (paramsMap == null) {
paramsMap = mutableMapOf()
}
return this
}
fun setDialogDismiss(dismissListener: DialogInterface.OnDismissListener): Builder {
params.dismissListener = dismissListener
return this
}
fun setCancelable(status: Boolean): Builder {
params.Cancelable = status
return this
}
fun setCanceledOnTouchOutside(status: Boolean): Builder {
params.canceledOnTouchOutside = status
return this
}
fun addDismissListener(dialogDismissListener: OnDialogDismissListener): Builder {
params.mDismissListenerList.add(dialogDismissListener)
return this
}
protected fun getRootWidth(activity: Activity): Int {
var displayWidth = 0
val display = activity.windowManager.defaultDisplay
val point = Point()
displayWidth = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(point)
point.x
} else {
val dm = DisplayMetrics()
activity.windowManager.defaultDisplay.getMetrics(dm)
dm.widthPixels
}
return displayWidth
}
/*
protected fun getRootHeight(): Int {
var displayHeight = 0
val display = activity!!.windowManager.defaultDisplay
val point = Point()
displayHeight = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
display.getRealSize(point)
point.y
} else {
val dm = DisplayMetrics()
activity!!.windowManager.defaultDisplay.getMetrics(dm)
dm.heightPixels
}
return displayHeight
}*/
}
fun show(tag: String = "default"): QmDialogFragment {
dialogController.fragmentManager.beginTransaction()
.add(this, tag)
.commitAllowingStateLoss()
// show(fragmentManager)
return this
}
override fun onCancel(dialog: DialogInterface) {
super.onCancel(dialog)
this.dialog?.setOnShowListener(null)
this.dialog?.setOnCancelListener(null)
this.dialog?.setOnDismissListener(null)
}
override fun onDestroyView() {
super.onDestroyView()
dialog?.setOnShowListener(null)
dialog?.setOnCancelListener(null)
dialog?.setOnDismissListener(null)
if (dialog != null && dialog!!.isShowing()) {
dialog!!.dismiss()
}
}
/*var canceledOnTouchOutside = true
var cancelable = true*/
interface OnViewInflateFinish {
fun onViewInflate(view: View?, dialog: QmDialogFragment)
}
interface OnActivityResultListener {
fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
dialogController.onActivityResultListener?.onActivityResult(requestCode, resultCode, data)
}
companion object {
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white"/>
<corners android:radius="10dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_centerInParent="true"
android:background="@drawable/shape_round_solid_white"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tv_title"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:text="提示"
android:textSize="16sp"
android:textColor="@color/black"
/>
<TextView
android:id="@+id/tv_content"
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="wrap_content"
android:text="是否确认取消订单?"
android:textSize="16sp"
android:textColor="#8a000000"
/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="30dp"
android:background="@color/defaultgray"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:id="@+id/tv_cancel"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:text="取消"
android:textSize="16sp"
android:textColor="@color/black"
/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/defaultgray"
/>
<TextView
android:id="@+id/tv_ok"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:text="确认"
android:textSize="16sp"
android:textColor="@color/upsdk_blue_text_007dff"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>
<color name="white">#fff</color>
<color name="black">#000</color>
<color name="defaultgray">#f6f8f6</color>
<color name="upsdk_blue_text_007dff">#007dff</color>
</resources>
<resources>
<string name="app_name">dialog</string>
</resources>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="QmDialogTheme" parent="Theme.AppCompat.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
package zs.qimai.com.dialog
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
...@@ -70,7 +70,7 @@ dependencies { ...@@ -70,7 +70,7 @@ dependencies {
} }
group 'com.qmai.android.log' group 'com.qmai.android.log'
version '1.0.1.13-SNAPSHOT' version '1.0.1.19-SNAPSHOT'
gradlePublish { gradlePublish {
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<provider <provider
android:name="com.qimai.log.InitContentProvider" android:name="com.qimai.log.InitContentProvider"
android:authorities="{applicationId}.InitContentProvider1" android:authorities="${applicationId}.log.InitContentProvider1"
android:enabled="true" android:enabled="true"
android:exported="false"/> android:exported="false"/>
<service android:name="com.qimai.log.UploadService"/> <service android:name="com.qimai.log.UploadService"/>
......
...@@ -95,7 +95,6 @@ public class DBCopyUtils { ...@@ -95,7 +95,6 @@ public class DBCopyUtils {
, "Data2019@#%", , "Data2019@#%",
"/", tag, file.getName(), in); "/", tag, file.getName(), in);
Log.d(TAG, "copyLogToFTP: isUpload= " + isUpload); Log.d(TAG, "copyLogToFTP: isUpload= " + isUpload);
......
package com.qimai.log
import android.util.Log
import com.qimai.log.QmLog.getConfig
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.io.File
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.util.*
object FtpUpload {
fun upload(config: UploadConfig, uploadCallBack: UploadCallBack? = null) {
GlobalScope.launch(Dispatchers.Main){
uploadCallBack?.onLoading()
val logFiles = getLogFiles(config)
if (logFiles.isNullOrEmpty()) {
uploadCallBack?.onError("暂无可上传日志文件")
} else {
try {
for (i in logFiles.indices) {
val tempFile = logFiles[i]
if (tempFile != null) {
uploadFile(config.tag,tempFile)
}
}
uploadCallBack?.onSuccess()
} catch (e: FileNotFoundException) {
uploadCallBack?.onError(e.toString())
}catch (e: IOException) {
uploadCallBack?.onError(e.toString())
}
}
}
}
suspend fun uploadFile(tag: String, file: File) = withContext(Dispatchers.IO){
var `in`: FileInputStream? = null
try {
// File logFile =
if (!file.exists()) {
return@withContext
}
`in` = FileInputStream(file)
val isUpload = FtpUtil.uploadFile(
"119.29.25.121", 221, "dataftp", "Data2019@#%",
"/", tag, file.getName(), `in`
)
} catch (e: FileNotFoundException) {
throw e
} finally {
if (`in` != null) {
try {
`in`.close()
} catch (e: IOException) {
throw e
}
}
}
}
}
private fun getLogFiles(config: UploadConfig): Array<File?>? {
//DBCopyUtils.copyLogToFTP();
//int requestNum = receiverBean.getNum();
var file: File? = null
// final String logPath = SDCARD + "/ptcy/log";
val logPath: String
logPath = if (BuildConfig.DEBUG) {
getConfig().logDebugPath
} else {
getConfig().logReleasePath
}
file = File(logPath)
if (!file.exists()) {
return null
}
//file.lastModified();
val files: Array<File?>? = convertTimeDesc(file.listFiles())
if (files == null || files.size == 0) {
return null
}
return files
// int maxFile = files.length;
// int endNum = Math.min(maxFile,num);
/*for (i in files.indices) {
val tempFile = files[i]
DBCopyUtils.copyLogToFTP(tempFile, config.tag)
}*/
}
private fun convertTimeDesc(files: Array<File>): Array<File?>? {
if (files == null || files.size == 0) {
return null
}
val endNum = files.size
val filesAll = arrayOfNulls<File>(20)
val longFileTreeMap = TreeMap<Long, File>()
for (i in files.indices) {
val temp = files[i].lastModified()
if (files[i].exists()) {
longFileTreeMap[temp] = files[i]
}
}
val navigableSet = longFileTreeMap.descendingKeySet()
val iterator: Iterator<Long> = navigableSet.iterator()
var index = 0
while (iterator.hasNext()) {
val file = longFileTreeMap[iterator.next()]
// Log.d(UploadService.TAG, "convertTimeDesc: file name= " + file!!.name)
filesAll[index] = file
index++
if (index >= endNum) {
break
}
}
return filesAll
}
fun copyLogToFTP(file: File, tag: String?) {
var `in`: FileInputStream? = null
try {
// File logFile =
if (!file.exists()) {
return
}
`in` = FileInputStream(file)
val isUpload = FtpUtil.uploadFile(
"119.29.25.121", 221, "dataftp", "Data2019@#%",
"/", tag, file.name, `in`
)
} catch (e: FileNotFoundException) {
e.printStackTrace()
} finally {
if (`in` != null) {
try {
`in`.close()
} catch (e: IOException) {
e.printStackTrace()
}
}
}
}
...@@ -51,14 +51,17 @@ public class FtpUtil { ...@@ -51,14 +51,17 @@ public class FtpUtil {
return result; return result;
} }
// 切换到上传目录 // 切换到上传目录
if (!ftp.changeWorkingDirectory(basePath + filePath)) String onepath=new String((basePath + filePath).getBytes("GBK"),"iso-8859-1");
if (!ftp.changeWorkingDirectory(onepath))
{ {
ftp.makeDirectory(onepath);
Log.d(TAG, "uploadFile: 切换到上传目录"); ftp.changeWorkingDirectory(onepath);
/* Log.d(TAG, "uploadFile: 切换到上传目录");
// 如果目录不存在创建目录 // 如果目录不存在创建目录
String[] dirs = filePath.split("/"); String[] dirs = filePath.split("/");
String tempPath = basePath; String tempPath = basePath;*/
for (String dir : dirs)
/*for (String dir : dirs)
{ {
if (null == dir || "".equals(dir)) if (null == dir || "".equals(dir))
continue; continue;
...@@ -74,13 +77,13 @@ public class FtpUtil { ...@@ -74,13 +77,13 @@ public class FtpUtil {
ftp.changeWorkingDirectory(tempPath); ftp.changeWorkingDirectory(tempPath);
} }
} }
} }*/
} }
// 设置上传文件的类型为二进制类型 // 设置上传文件的类型为二进制类型
ftp.setFileType(FTP.BINARY_FILE_TYPE); ftp.setFileType(FTP.BINARY_FILE_TYPE);
// 上传文件 // 上传文件
ftp.enterLocalPassiveMode(); ftp.enterLocalPassiveMode();
if (!ftp.storeFile(filename, input)) { if (!ftp.storeFile(new String(filename.getBytes("GBK"),"iso-8859-1"), input)) {
Log.d(TAG, "uploadFile: upload fail"); Log.d(TAG, "uploadFile: upload fail");
return result; return result;
......
...@@ -39,7 +39,11 @@ object QmLog { ...@@ -39,7 +39,11 @@ object QmLog {
intent.putExtra("upload", config) intent.putExtra("upload", config)
getConfig().app.startService(intent) getConfig().app.startService(intent)
} }
fun uploadLog(config: UploadConfig,callBack: UploadCallBack) {
//刷新下
Log.appenderFlush(false)
FtpUpload.upload(config,callBack)
}
fun getConfig(): QmLogConfig { fun getConfig(): QmLogConfig {
val config: QmLogConfig? = LogInit.getInstance().getConfig() val config: QmLogConfig? = LogInit.getInstance().getConfig()
if (config == null) { if (config == null) {
......
package com.qimai.log
interface UploadCallBack {
fun onLoading()
fun onError(e:String)
fun onSuccess()
}
\ No newline at end of file
...@@ -33,7 +33,7 @@ android { ...@@ -33,7 +33,7 @@ android {
} }
group 'com.qmai.android.PickerView' group 'com.qmai.android.PickerView'
version '1.0.0-SNAPSHOT' version '1.0.1.3-SNAPSHOT'
gradlePublish { gradlePublish {
...@@ -56,7 +56,8 @@ gradlePublish { ...@@ -56,7 +56,8 @@ gradlePublish {
} }
dependencies { dependencies {
// compile fileTree(include: ['*.jar'], dir: 'libs') // compile fileTree(include: ['*.jar'], dir: 'libs')
api project(path: ':wheelview') //api project(path: ':wheelview')
api 'com.qmai.android.wheelview:wheelview:1.0.0-SNAPSHOT'
// api 'com.contrarywind:wheelview:4.1.0' // api 'com.contrarywind:wheelview:4.1.0'
implementation 'com.android.support:support-annotations:28.0.0' implementation 'com.android.support:support-annotations:28.0.0'
} }
\ No newline at end of file
...@@ -51,7 +51,7 @@ repositories { ...@@ -51,7 +51,7 @@ repositories {
} }
group 'com.qmai.android.print' group 'com.qmai.android.print'
version '1.1.13-SNAPSHOT' version '1.1.22-SNAPSHOT'
gradlePublish { gradlePublish {
......
...@@ -5,10 +5,10 @@ import zs.qimai.com.printer2.enmu.FontSizeType ...@@ -5,10 +5,10 @@ import zs.qimai.com.printer2.enmu.FontSizeType
import zs.qimai.com.printer2.paint.PrintWriter import zs.qimai.com.printer2.paint.PrintWriter
import java.util.ArrayList import java.util.ArrayList
class TestPrintTemplate : PrintTemplate<Any> { class TestPrintTemplate (var maxLineChars:Int = 32): PrintTemplate<Any> {
override fun getPrintData(data: Any): ByteArray? { override fun getPrintData(data: Any): ByteArray? {
var datas = ArrayList<ByteArray>() var datas = ArrayList<ByteArray>()
var printWriter = PrintWriter().apply { var printWriter = PrintWriter(maxLineChars).apply {
//编号 //编号
writelnLineText("#22", aligin = FontAligin.CENTER, fontSizeType = FontSizeType.FONT_3) writelnLineText("#22", aligin = FontAligin.CENTER, fontSizeType = FontSizeType.FONT_3)
writelnLineText("企迈店铺", aligin = FontAligin.CENTER, fontSizeType = FontSizeType.FONT_3) writelnLineText("企迈店铺", aligin = FontAligin.CENTER, fontSizeType = FontSizeType.FONT_3)
......
...@@ -12,9 +12,11 @@ abstract class DeviceManager { ...@@ -12,9 +12,11 @@ abstract class DeviceManager {
var mInPutStream: InputStream? = null var mInPutStream: InputStream? = null
var mStatus = false var mStatus = false
var address: String? = null var address: String? = null
var deviceId = "" var deviceId: String = ""
var mPrintMode: Int? = null var mPrintMode: Int? = null
abstract var mType: Int abstract var mType: Int
var name: String? = null
var maxLineChars: Int = 55
companion object { companion object {
//小票模式 //小票模式
......
...@@ -36,7 +36,7 @@ class DeviceManagerUtils { ...@@ -36,7 +36,7 @@ class DeviceManagerUtils {
removingDevice.add(deviceManager) removingDevice.add(deviceManager)
} }
} }
if (removingDevice.isNotEmpty()){ if (removingDevice.isNotEmpty()) {
lists.removeAll(removingDevice) lists.removeAll(removingDevice)
removingDevice.forEach { device -> removingDevice.forEach { device ->
notifyRemoveObserver(device) notifyRemoveObserver(device)
...@@ -97,6 +97,7 @@ class DeviceManagerUtils { ...@@ -97,6 +97,7 @@ class DeviceManagerUtils {
} }
return null return null
} }
internal fun removeUsbDevice(address: String) { internal fun removeUsbDevice(address: String) {
var device = getUsbDevice(address) var device = getUsbDevice(address)
device?.closePort() device?.closePort()
...@@ -254,4 +255,37 @@ class DeviceManagerUtils { ...@@ -254,4 +255,37 @@ class DeviceManagerUtils {
nums nums
} }
} }
//自己写过滤滤条件获取设备
fun getDevice(filter: (device: DeviceManager) -> Boolean): DeviceManager? {
return if (!lists.isNullOrEmpty()) {
lists.find {
filter(it)
}
} else {
null
}
}
//通过deviceId获取Usb设备
fun getUsbDeviceAccordDeviceId(deviceId: String): UsbDeviceManager? {
if (lists.isNullOrEmpty()) {
return null
}
val device = lists.find { it.deviceId == deviceId && it.mType == USB }
return if (device != null) (device as UsbDeviceManager) else null
}
fun getUsbDeviceList(): ArrayList<UsbDeviceManager> {
val tempList = ArrayList<UsbDeviceManager>()
lists.forEach {
if (it.mType == USB) {
tempList.add(it as UsbDeviceManager)
}
}
return tempList
}
} }
\ No newline at end of file
...@@ -48,8 +48,9 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() { ...@@ -48,8 +48,9 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() {
PrinterStatusUtils(this).apply { PrinterStatusUtils(this).apply {
mPrintStatusCallBack = object : PrintStatusCallBack { mPrintStatusCallBack = object : PrintStatusCallBack {
override fun searchResult(status: Int?) { override fun searchResult(status: Int?) {
mPrintMode = status ?: DeviceManager.ESC mPrintMode = status ?: ESC
mStatus = true mStatus = true
name = if (mPrintMode == ESC) "小票打印机" else "杯贴打印机"
DeviceManagerUtils.getInstance().addDevice(this@UsbDeviceManager) DeviceManagerUtils.getInstance().addDevice(this@UsbDeviceManager)
mUsbPrintConnCallBack?.onConnSucess(this@UsbDeviceManager) mUsbPrintConnCallBack?.onConnSucess(this@UsbDeviceManager)
} }
...@@ -96,7 +97,7 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() { ...@@ -96,7 +97,7 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() {
) )
} }
override fun equals(other: Any?): Boolean { /* override fun equals(other: Any?): Boolean {
if (other != null && other is UsbDeviceManager) { if (other != null && other is UsbDeviceManager) {
if ((other.address == this.address) && other.usbDevice == this.usbDevice) { if ((other.address == this.address) && other.usbDevice == this.usbDevice) {
return true return true
...@@ -108,11 +109,23 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() { ...@@ -108,11 +109,23 @@ class UsbDeviceManager(override var mType: Int = USB) : DeviceManager() {
override fun hashCode(): Int { override fun hashCode(): Int {
return address?.hashCode() ?: 0 + usbDevice.hashCode() return address?.hashCode() ?: 0 + usbDevice.hashCode()
} }*/
override fun toString(): String { override fun toString(): String {
return "UsbDeviceManager(mType=$mType, TAG='$TAG', usbDevice=$usbDevice, usbManager=$usbManager, mmConnection=$mmConnection, mmIntf=$mmIntf, mmEndIn=$mmEndIn, mmEndOut=$mmEndOut, mUsbPrintConnCallBack=$mUsbPrintConnCallBack)" return "UsbDeviceManager(mType=$mType, TAG='$TAG', usbDevice=$usbDevice, usbManager=$usbManager, mmConnection=$mmConnection, mmIntf=$mmIntf, mmEndIn=$mmEndIn, mmEndOut=$mmEndOut, mUsbPrintConnCallBack=$mUsbPrintConnCallBack)"
} }
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is UsbDeviceManager) return false
if (deviceId != other.deviceId) return false
return true
}
override fun hashCode(): Int {
return deviceId.hashCode()
}
} }
\ No newline at end of file
...@@ -14,7 +14,7 @@ import java.nio.charset.Charset ...@@ -14,7 +14,7 @@ import java.nio.charset.Charset
* 原理 -> 创建个ByteArrayOutputStream() 先写入其中,最后在转为字节数组 * 原理 -> 创建个ByteArrayOutputStream() 先写入其中,最后在转为字节数组
* *
* **/ * **/
open class PrintWriter(var maxLineChars:Int = 32 ) { open class PrintWriter(var maxLineChars: Int = 32) {
val CHARSET = "gbk" val CHARSET = "gbk"
val bos = ByteArrayOutputStream() val bos = ByteArrayOutputStream()
...@@ -161,7 +161,7 @@ open class PrintWriter(var maxLineChars:Int = 32 ) { ...@@ -161,7 +161,7 @@ open class PrintWriter(var maxLineChars:Int = 32 ) {
* ps 红烧肉 【*10】 100 * ps 红烧肉 【*10】 100
* **/ * **/
fun formatGoods(goodsName: String, nums: String, price: String,needBytes: Int = 16): String { fun formatGoods(goodsName: String, nums: String, price: String, needBytes: Int = 16): String {
var formatGoodsName = fixedNumberOfDigits(goodsName, needBytes) var formatGoodsName = fixedNumberOfDigits(goodsName, needBytes)
var numsLength = getPerLineMaxByteNums() - getBytesSize(formatGoodsName) - 10 var numsLength = getPerLineMaxByteNums() - getBytesSize(formatGoodsName) - 10
var formatNums = fixedNumberOfDigits(nums, numsLength, 2) var formatNums = fixedNumberOfDigits(nums, numsLength, 2)
...@@ -170,20 +170,21 @@ open class PrintWriter(var maxLineChars:Int = 32 ) { ...@@ -170,20 +170,21 @@ open class PrintWriter(var maxLineChars:Int = 32 ) {
if (formatGoodsName.length < goodsName.length) { if (formatGoodsName.length < goodsName.length) {
endGoodsName.append(goodsName.substring(formatGoodsName.length, goodsName.length)) endGoodsName.append(goodsName.substring(formatGoodsName.length, goodsName.length))
} }
if (endGoodsName.isNullOrBlank()){ if (endGoodsName.isNullOrBlank()) {
return StringBuilder(formatGoodsName) return StringBuilder(formatGoodsName)
.append(formatNums) .append(formatNums)
.append(formatPrice) .append(formatPrice)
.append(endGoodsName) .append(endGoodsName)
.toString() .toString()
}else{ } else {
return StringBuilder(formatGoodsName) return StringBuilder(formatGoodsName)
.append(formatNums) .append(formatNums)
.append(formatPrice) .append(formatPrice)
.append("\n") .append("\n")
.append(endGoodsName) .append(endGoodsName)
.toString() .toString()
}} }
}
/**** /****
* *
...@@ -258,6 +259,9 @@ open class PrintWriter(var maxLineChars:Int = 32 ) { ...@@ -258,6 +259,9 @@ open class PrintWriter(var maxLineChars:Int = 32 ) {
/** /**
* 获取每行最大字节数 * 获取每行最大字节数
* **/ * **/
open fun getPerLineMaxByteNums() =maxLineChars open fun getPerLineMaxByteNums(): Int = when (maxLineChars) {
55 -> 32
80 -> 48
else -> 32
}
} }
\ No newline at end of file
...@@ -4,3 +4,5 @@ include ':app', ':widgetlib', ':tools', ':smallwidget', ':usefulltool' ...@@ -4,3 +4,5 @@ include ':app', ':widgetlib', ':tools', ':smallwidget', ':usefulltool'
include ':log' include ':log'
include ':wheelview' include ':wheelview'
include ':pickerview' include ':pickerview'
include ':dialog'
...@@ -32,7 +32,28 @@ android { ...@@ -32,7 +32,28 @@ android {
} }
} }
group 'com.qmai.android.wheelview'
version '1.0.0-SNAPSHOT'
gradlePublish {
sourceJarEnabled = true
javaDocEnabled = false
signEnabled = false
releaseRepository {
url = "https://hub.zmcms.cn/repository/maven-releases/"
userName = "wanglei1"
password = "woshiwanglei123"
}
snapshotRepository {
url = "https://hub.zmcms.cn/repository/maven-snapshots/"
userName = "wanglei1"
password = "woshiwanglei123"
}
}
//allprojects { //allprojects {
// tasks.withType(Javadoc) {//兼容中文字符 // tasks.withType(Javadoc) {//兼容中文字符
// options{ // options{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment