| | |
| | | apply plugin: 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin' |
| | | |
| | | android { |
| | | compileSdkVersion 35 |
| | | buildToolsVersion "33.0.3" |
| | | compileSdkVersion 36 |
| | | buildToolsVersion "36.0.0" |
| | | namespace "com.igo.user" |
| | | //签名 |
| | | signingConfigs { |
| | |
| | | defaultConfig { |
| | | applicationId "com.gopost.user" |
| | | minSdkVersion 23 |
| | | targetSdkVersion 35 |
| | | versionCode 27 |
| | | versionName "1.27" |
| | | targetSdkVersion 36 |
| | | versionCode 28 |
| | | versionName "1.28" |
| | | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| | | } |
| | | |
| | |
| | | dependencies { |
| | | implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) |
| | | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
| | | api "androidx.appcompat:appcompat:$support_version" |
| | | implementation 'androidx.core:core-ktx:1.3.0' |
| | | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' |
| | | implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1") |
| | |
| | | // androidTestImplementation 'androidx.test.ext:junit:1.1.1' |
| | | // androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' |
| | | implementation project(path: ':xldutils-kotlin') |
| | | implementation 'com.google.android.material:material:1.3.0-alpha01' |
| | | implementation 'com.google.android.material:material:1.10.0' |
| | | implementation project(path: ':rxnetty') |
| | | // implementation project(path: ':umeng_sdk') |
| | | implementation 'com.youth.banner:banner:2.0.11' |
| | |
| | | implementation 'cn.bingoogolapple:bga-qrcode-zxing:1.3.7'//二维码 |
| | | implementation 'com.haibin:calendarview:3.6.9'//日历 |
| | | implementation project(path: ':download') |
| | | implementation 'com.google.android.libraries.places:places:2.7.0' |
| | | implementation 'com.google.android.libraries.places:places:3.0.0' |
| | | implementation 'com.facebook.android:facebook-share:12.2.0' //脸书分享 |
| | | implementation 'com.facebook.android:facebook-login:12.2.0' //脸书登录 |
| | | implementation 'com.twitter.sdk.android:twitter:3.1.1' |
| | |
| | | coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs_nio:2.0.3' |
| | | |
| | | //谷歌地图和乘客端sdk |
| | | implementation 'com.google.android.gms:play-services-maps:18.1.0' |
| | | implementation 'com.google.android.gms:play-services-maps:20.0.0' |
| | | implementation 'com.google.android.libraries.mapsplatform.transportation:transportation-consumer:3.0.0' |
| | | |
| | | |
| | |
| | | import android.content.Context |
| | | import android.content.Intent |
| | | import android.content.IntentFilter |
| | | import android.os.Build |
| | | import androidx.localbroadcastmanager.content.LocalBroadcastManager |
| | | import androidx.recyclerview.widget.LinearLayoutManager |
| | | import cn.sinata.xldutils.view.SwipeRefreshRecyclerLayout |
| | | import com.igo.user.R |
| | |
| | | private val isScan by lazy { //是否扫码下单 |
| | | intent.getBooleanExtra("isScan",false) |
| | | } |
| | | private var receiver: BroadcastReceiver? = null |
| | | private var receiver: BroadcastReceiver = object :BroadcastReceiver() { |
| | | override fun onReceive(context: Context?, intent: Intent?) { |
| | | finish() |
| | | } |
| | | } |
| | | |
| | | override fun initClick() { |
| | | adapter.setOnItemClickListener { view, position -> |
| | |
| | | lvLine.setLayoutManager(LinearLayoutManager(this)) |
| | | lvLine.setMode(SwipeRefreshRecyclerLayout.Mode.None) |
| | | lvLine.setAdapter(adapter) |
| | | receiver = object :BroadcastReceiver() { |
| | | override fun onReceive(context: Context?, intent: Intent?) { |
| | | finish() |
| | | } |
| | | } |
| | | registerReceiver(receiver, IntentFilter("crossOrderSuccess")) |
| | | |
| | | LocalBroadcastManager.getInstance(this).registerReceiver(receiver, IntentFilter("crossOrderSuccess")) |
| | | } |
| | | |
| | | override fun onDestroy() { |
| | | LocalBroadcastManager.getInstance(this).unregisterReceiver(receiver) |
| | | super.onDestroy() |
| | | if (receiver!=null) |
| | | unregisterReceiver(receiver) |
| | | } |
| | | } |
| | |
| | | private var endId:Int? = null //到达站点 |
| | | private var startCity = "" |
| | | private var endCity = "" |
| | | private var receiver:BroadcastReceiver? = null |
| | | |
| | | override fun onFirstVisibleToUser() { |
| | | |
| | | } |
| | | |
| | | |
| | | override fun onDestroy() { |
| | | super.onDestroy() |
| | | if (receiver!=null) |
| | | activity?.unregisterReceiver(receiver) |
| | | } |
| | | } |
| | |
| | | import cn.sinata.xldutils.utils.optInt |
| | | import cn.sinata.xldutils.utils.optString |
| | | import cn.sinata.xldutils.utils.showAllowingStateLoss |
| | | import com.google.recaptcha.sample.RecaptchaVisual |
| | | import com.google.recaptcha.sample.RecaptchaVisualException |
| | | import com.igo.user.utils.recaptcha.RecaptchaVisualException |
| | | import com.igo.user.R |
| | | import com.igo.user.dialog.ImageCodeDialog |
| | | import com.igo.user.dialog.SingleWheelDialog |
| | | import com.igo.user.interfaces.StringCallback |
| | | import com.igo.user.network.HttpManager |
| | | import com.igo.user.network.request |
| | | import com.igo.user.ui.TransparentStatusBarActivity |
| | | import com.igo.user.ui.login.LoginActivity.Companion.BASE_URL |
| | | import com.igo.user.ui.login.LoginActivity.Companion.WEB_SITE_KEY |
| | | import com.igo.user.utils.Const |
| | | import com.twitter.sdk.android.core.TwitterAuthConfig |
| | | import kotlinx.coroutines.launch |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.startActivityForResult |
| | |
| | | import android.widget.EditText |
| | | import android.widget.TextView |
| | | import androidx.activity.viewModels |
| | | import androidx.core.os.bundleOf |
| | | import androidx.lifecycle.lifecycleScope |
| | | import cn.sinata.xldutils.utils.LengthFilter |
| | | import cn.sinata.xldutils.utils.isValidPhone |
| | | import cn.sinata.xldutils.utils.myToast |
| | | import com.google.recaptcha.sample.RecaptchaVisual |
| | | import com.google.recaptcha.sample.RecaptchaVisualException |
| | | import com.igo.user.utils.recaptcha.RecaptchaVisualException |
| | | import com.igo.user.R |
| | | import com.igo.user.dialog.ImageCodeDialog |
| | | import com.igo.user.network.HttpManager |
| | | import com.igo.user.network.request |
| | | import com.igo.user.ui.TransparentStatusBarActivity |
| | | import com.igo.user.ui.login.LoginActivity.Companion.BASE_URL |
| | | import com.igo.user.ui.login.LoginActivity.Companion.WEB_SITE_KEY |
| | | import com.igo.user.utils.DisableSpaceInputFilter |
| | | import kotlinx.coroutines.launch |
| | | import org.jetbrains.anko.find |
| | |
| | | import MainActivityViewModel |
| | | import android.app.Activity |
| | | import android.content.Intent |
| | | import android.net.Uri |
| | | import android.os.CountDownTimer |
| | | import android.util.Log |
| | | import android.view.View |
| | |
| | | import com.google.android.gms.common.ConnectionResult |
| | | import com.google.android.gms.common.GoogleApiAvailability |
| | | import com.google.android.gms.recaptcha.RecaptchaClient |
| | | import com.google.recaptcha.sample.RecaptchaVisualException |
| | | import com.igo.user.utils.recaptcha.RecaptchaVisualException |
| | | import com.igo.user.BuildConfig |
| | | import com.igo.user.R |
| | | import com.igo.user.dialog.SingleWheelDialog |
| | |
| | | ) |
| | | uiSettings.isMyLocationButtonEnabled = false |
| | | setOnMyLocationChangeListener { |
| | | Log.e(Const.Tag, "物流:lat:" + it.latitude + ",lon:" + it.longitude) |
| | | Log.e(Const.Tag, "当前定位:lat:" + it.latitude + ",lon:" + it.longitude) |
| | | IGoApplication.setLocation(it.latitude, it.longitude) |
| | | // IGoApplication.address = it.address |
| | | // IGoApplication.cityCode = it.extras.getString("adcode")?:"" |
| | |
| | | import cn.sinata.xldutils.utils.isValidPhone |
| | | import cn.sinata.xldutils.utils.myToast |
| | | import cn.sinata.xldutils.utils.showAllowingStateLoss |
| | | import com.google.recaptcha.sample.RecaptchaVisual |
| | | import com.google.recaptcha.sample.RecaptchaVisualException |
| | | import com.igo.user.utils.recaptcha.RecaptchaVisualException |
| | | import com.igo.user.IGoApplication.Companion.phone |
| | | import com.igo.user.R |
| | | import com.igo.user.dialog.SingleWheelDialog |
| | |
| | | import com.igo.user.network.request |
| | | import com.igo.user.ui.TransparentStatusBarActivity |
| | | import com.igo.user.ui.login.AreaCodeActivity |
| | | import com.igo.user.ui.login.LoginActivity.Companion.BASE_URL |
| | | import com.igo.user.ui.login.LoginActivity.Companion.WEB_SITE_KEY |
| | | import kotlinx.coroutines.launch |
| | | import org.jetbrains.anko.find |
| | | import org.jetbrains.anko.sdk27.coroutines.onClick |
| | |
| | | import cn.sinata.xldutils.utils.hidePhone |
| | | import cn.sinata.xldutils.utils.myToast |
| | | import cn.sinata.xldutils.utils.optInt |
| | | import com.google.recaptcha.sample.RecaptchaVisualException |
| | | import com.igo.user.utils.recaptcha.RecaptchaVisualException |
| | | import com.igo.user.IGoApplication |
| | | import com.igo.user.R |
| | | import com.igo.user.extension.extIsEmptyOrNull |
| | |
| | | isMyLocationEnabled = true |
| | | uiSettings.isMyLocationButtonEnabled = false |
| | | setOnMyLocationChangeListener { |
| | | Log.e(Const.Tag, "出租车:lat:" + it.latitude + ",lon:" + it.longitude) |
| | | Log.e(Const.Tag, "当前定位:lat:" + it.latitude + ",lon:" + it.longitude) |
| | | IGoApplication.setLocation(it.latitude, it.longitude) |
| | | // IGoApplication.address = it.address |
| | | // IGoApplication.cityCode = it.extras.getString("adcode")?:"" |
| | |
| | | hadLoopRefresh = true |
| | | viewLifecycleOwner.lifecycleScope.launch { |
| | | while (true) { |
| | | delay(5000) |
| | | delay(10_000) |
| | | getDriverNum { _, data -> |
| | | val i = data?.optInt("number") ?: 0 |
| | | val t = getString(R.string.当前附近有n辆车可用, i) |
| | |
| | | import cn.sinata.xldutils.utils.optDouble |
| | | import cn.sinata.xldutils.utils.optInt |
| | | import cn.sinata.xldutils.utils.showAllowingStateLoss |
| | | import cn.sinata.xldutils.utils.urlDecode |
| | | import cn.sinata.xldutils.utils.urlEncode |
| | | import cn.sinata.xldutils.visible |
| | | import com.facebook.drawee.view.SimpleDraweeView |
| | | import com.igo.user.IGoApplication |
| | |
| | | tv_pay_offline.gone() |
| | | tv_confirm_fee.gone() |
| | | cl_driver.visible() |
| | | tv_action.gone() |
| | | tv_action2.gone() |
| | | when (order?.state) { |
| | | in (1..5) -> { |
| | |
| | | title = getString(R.string.支付费用) |
| | | if (order?.isFrozen != 2) { |
| | | tv_pay_offline.visible() //新增提示文字 |
| | | tv_action.visible() |
| | | //tv_action.visible() |
| | | } |
| | | tv_title.visible() |
| | | tv_action.text = getString(R.string.立即支付) |
| | |
| | | tv_tip.invisible() |
| | | } |
| | | tv_title.hide() |
| | | if (order!!.orderType == TripOrderFragment.TYPE_LOGISTICS) { |
| | | tv_action.visible() |
| | | } |
| | | tv_action.visible() |
| | | tv_action.text = getString(R.string.匿名评价) |
| | | titleBar.getRightButton(0)?.visible() |
| | | if (order?.isFrozen != 2) { |
| | |
| | | val view = layoutInflater.inflate(R.layout.item_score_label, null) as CheckBox |
| | | view.text = it |
| | | view.isEnabled = false |
| | | if (it in split) |
| | | view.isChecked = true |
| | | view.isChecked = !split.none { checkItem -> checkItem.equals(it, true) } |
| | | fl_label.addView(view) |
| | | } |
| | | tv_detail.visible() |
| | |
| | | // } |
| | | |
| | | override fun onStateChanged(id: Int, type: Int, state: Int) { |
| | | if (id == this.id && type == this.type && order?.state == 6) { //当前是待司机确认费用,需要重新获取订单信息 |
| | | if (id == this.id && type == this.type && (order?.state == 6 || order?.state == 7 || order?.state == 8)) { //当前是待司机确认费用,需要重新获取订单信息 |
| | | getData() |
| | | } |
| | | } |
| | |
| | | val view = layoutInflater.inflate(R.layout.item_score_label, null) as CheckBox |
| | | view.text = it |
| | | view.isEnabled = false |
| | | if (it in split) |
| | | view.isChecked = true |
| | | view.isChecked = !split.none { checkItem -> checkItem.equals(it, true) } |
| | | fl_label.addView(view) |
| | | } |
| | | } |
| | |
| | | import com.igo.user.utils.google.JsonAuthTokenFactory |
| | | import com.tbruyelle.rxpermissions2.RxPermissions |
| | | import kotlinx.coroutines.Dispatchers |
| | | import kotlinx.coroutines.flow.MutableSharedFlow |
| | | import kotlinx.coroutines.launch |
| | | import org.jetbrains.anko.dip |
| | | import org.jetbrains.anko.find |
| | |
| | | class TripActivity : BaseActivity(), Handler.Callback, |
| | | OrderStateChangeListener { |
| | | var aMap: ConsumerGoogleMap? = null |
| | | |
| | | private val noticeCancelFlow = MutableSharedFlow<Boolean>() |
| | | override fun onCreate(savedInstanceState: Bundle?) { |
| | | super.onCreate(savedInstanceState) |
| | | setContentView(R.layout.activity_trip) |
| | | initView() |
| | | initClick() |
| | | lifecycleScope.launch(Dispatchers.Main) { |
| | | repeatOnLifecycle(Lifecycle.State.RESUMED) { |
| | | noticeCancelFlow.collect { |
| | | if (noResponseDialog.dialog?.isShowing != true) { |
| | | noResponseDialog.show(supportFragmentManager, "noResponse") |
| | | LogHelper.logRecord("显示超时无应答弹窗orderId:${id} orderType:${type}") |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private val app by lazy { |
| | |
| | | * 超时无应答 |
| | | */ |
| | | fun noResponse(id: Int) { |
| | | if (isFinishing || isDestroyed) { |
| | | if (isFinishing || isDestroyed || id != this.id) { |
| | | return |
| | | } |
| | | lifecycleScope.launch(Dispatchers.Main) { |
| | | // 等待生命周期至少达到 RESUMED(即 onResume 之后) |
| | | if (id == this@TripActivity.id && !noResponseDialog.isAdded) { |
| | | repeatOnLifecycle(Lifecycle.State.RESUMED) { |
| | | noResponseDialog.show(supportFragmentManager, "noResponse") |
| | | LogHelper.logRecord("显示超时无应答弹窗orderId:${id} orderType:${type}") |
| | | } |
| | | } |
| | | lifecycleScope.launch { |
| | | noticeCancelFlow.emit(true) |
| | | } |
| | | } |
| | | |
| | |
| | | NettyClient.getInstance().checkNettyState() |
| | | } |
| | | |
| | | override fun finish() { |
| | | IGoApplication.tripId = "" |
| | | super.finish() |
| | | } |
| | | |
| | | override fun onDestroy() { |
| | | handler.removeMessages(0) |
| | |
| | | handler.removeMessages(2) |
| | | handler.removeMessages(3) |
| | | app.removeTripStateListener(this) |
| | | IGoApplication.tripId = "" |
| | | session?.stop() |
| | | super.onDestroy() |
| | | } |
| | | |
| | | override fun onBackPressed() { |
| | | if (ll_progress.visibility == View.VISIBLE) |
| | | override fun onBackPressHandle() { |
| | | if (ll_progress.isVisible) |
| | | ll_progress.gone() |
| | | else |
| | | super.onBackPressed() |
| | | super.onBackPressHandle() |
| | | } |
| | | } |
| | |
| | | import androidx.lifecycle.LiveData |
| | | import androidx.lifecycle.MutableLiveData |
| | | import androidx.lifecycle.viewModelScope |
| | | import com.google.recaptcha.sample.RecaptchaVisualException |
| | | import com.igo.user.utils.recaptcha.RecaptchaVisualException |
| | | import kotlinx.coroutines.launch |
| | | |
| | | class MainActivityViewModel( |
| | |
| | | package com.google.recaptcha.sample |
| | | package com.igo.user.utils.recaptcha |
| | | |
| | | import android.webkit.JavascriptInterface |
| | | |
| | |
| | | package com.google.recaptcha.sample |
| | | package com.igo.user.utils.recaptcha |
| | | |
| | | interface RecaptchaListener { |
| | | fun onLoad() |
| | |
| | | package com.google.recaptcha.sample |
| | | package com.igo.user.utils.recaptcha |
| | | |
| | | import androidx.fragment.app.FragmentManager |
| | | import java.util.Locale |
| | |
| | | |
| | | fun runCaptcha(): Deferred<String> { |
| | | onDone = CompletableDeferred() |
| | | val fragment = RecaptchaVisualFragment.newInstance(siteKey, baseUrl, lang) |
| | | val fragment = RecaptchaVisualFragment.Companion.newInstance(siteKey, baseUrl, lang) |
| | | fragment.configure(this) |
| | | fragment.show(fragmentManager, "RecaptchaVisual") |
| | | return onDone |
| | |
| | | package com.google.recaptcha.sample |
| | | package com.igo.user.utils.recaptcha |
| | | |
| | | class RecaptchaVisualException : Exception { |
| | | constructor() : super() |
| | |
| | | package com.google.recaptcha.sample |
| | | package com.igo.user.utils.recaptcha |
| | | |
| | | import android.annotation.SuppressLint |
| | | import android.app.Dialog |
| | |
| | | fun newInstance(siteKey: String, baseUrl: String, lang: String?): RecaptchaVisualFragment { |
| | | val f = RecaptchaVisualFragment() |
| | | val args = Bundle() |
| | | args.putString(RecaptchaWebView.SITE_KEY, siteKey) |
| | | args.putString(RecaptchaWebView.BASE_URL, baseUrl) |
| | | args.putString(RecaptchaWebView.LANG, lang) |
| | | args.putString(RecaptchaWebView.Companion.SITE_KEY, siteKey) |
| | | args.putString(RecaptchaWebView.Companion.BASE_URL, baseUrl) |
| | | args.putString(RecaptchaWebView.Companion.LANG, lang) |
| | | f.arguments = args |
| | | return f |
| | | } |
| | |
| | | package com.google.recaptcha.sample |
| | | package com.igo.user.utils.recaptcha |
| | | |
| | | import android.content.Context |
| | | import android.os.Bundle |
| | |
| | | apply plugin: 'com.android.library' |
| | | |
| | | android { |
| | | compileSdkVersion 28 |
| | | compileSdkVersion 36 |
| | | namespace "com.sinata.download" |
| | | |
| | | defaultConfig { |
| | | minSdkVersion 16 |
| | | targetSdkVersion 28 |
| | | targetSdkVersion 36 |
| | | } |
| | | |
| | | buildTypes { |
| | |
| | | apply plugin: 'com.android.library' |
| | | |
| | | android { |
| | | compileSdkVersion 35 |
| | | compileSdkVersion 36 |
| | | namespace "cn.sinata.rxnetty" |
| | | |
| | | defaultConfig { |
| | | minSdkVersion 23 |
| | | targetSdkVersion 35 |
| | | targetSdkVersion 36 |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | dependencies { |
| | | api fileTree(include: ['*.jar'], dir: 'libs') |
| | | implementation 'com.google.android.material:material:1.10.0' |
| | | implementation 'androidx.appcompat:appcompat:1.6.1' |
| | | api 'io.reactivex:rxnetty:0.4.20' |
| | | api 'androidx.appcompat:appcompat:1.1.0' |
| | | api 'io.netty:netty-buffer:4.1.5.Final' |
| | | api 'io.netty:netty-handler:4.1.5.Final' |
| | | api 'io.reactivex:rxandroid:1.2.1' |
| | |
| | | import android.os.Looper; |
| | | |
| | | import androidx.annotation.RequiresApi; |
| | | import androidx.localbroadcastmanager.content.LocalBroadcastManager; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | IntentFilter filter = new IntentFilter(); |
| | | filter.addAction(CUSTOM_ANDROID_NET_CHANGE_ACTION); |
| | | filter.addAction(ANDROID_NET_CHANGE_ACTION); |
| | | mAppContext.registerReceiver(getReceiver(), filter); |
| | | LocalBroadcastManager.getInstance(mAppContext).registerReceiver(getReceiver(), filter); |
| | | } |
| | | updateNetworkState(mAppContext); |
| | | } |
| | |
| | | } |
| | | if (mBroadcastReceiver != null) { |
| | | try { |
| | | appContext.unregisterReceiver(mBroadcastReceiver); |
| | | LocalBroadcastManager.getInstance(appContext).unregisterReceiver(mBroadcastReceiver); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | filter.addAction(ANDROID_NET_CHANGE_ACTION); |
| | | try { |
| | | // 使用应用上下文注册广播,避免持有服务实例 由AI生成 |
| | | context.getApplicationContext().registerReceiver(getReceiver(), filter); |
| | | LocalBroadcastManager.getInstance(context.getApplicationContext()).registerReceiver(getReceiver(), filter); |
| | | } catch (Exception e) { |
| | | // 注册失败时输出异常,避免影响长连接服务启动 由AI生成 |
| | | e.printStackTrace(); |
| | |
| | | apply plugin: 'com.android.library' |
| | | |
| | | android { |
| | | compileSdkVersion 29 |
| | | compileSdkVersion 36 |
| | | namespace "com.umeng.sdk" |
| | | |
| | | defaultConfig { |
| | | minSdkVersion 19 |
| | | targetSdkVersion 28 |
| | | targetSdkVersion 36 |
| | | } |
| | | buildTypes { |
| | | release { |
| | |
| | | apply plugin: 'kotlin-android' |
| | | |
| | | android { |
| | | compileSdkVersion 33 |
| | | compileSdkVersion 36 |
| | | namespace "cn.sinata.xldutils" |
| | | |
| | | defaultConfig { |
| | | minSdkVersion 21 |
| | | targetSdkVersion 29 |
| | | targetSdkVersion 36 |
| | | } |
| | | buildTypes { |
| | | release { |
| | |
| | | import android.view.Window |
| | | import android.view.inputmethod.InputMethodManager |
| | | import android.widget.EditText |
| | | import androidx.activity.OnBackPressedCallback |
| | | import androidx.appcompat.app.AppCompatActivity |
| | | import androidx.localbroadcastmanager.content.LocalBroadcastManager |
| | | import cn.sinata.xldutils.R |
| | |
| | | closeSelfBroadcastReceiver, |
| | | IntentFilter(ACTION_CLOSE_ALL) |
| | | ) |
| | | onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) { |
| | | override fun handleOnBackPressed() { |
| | | onBackPressHandle() |
| | | } |
| | | }) |
| | | } |
| | | |
| | | protected open fun onBackPressHandle() { |
| | | finish() |
| | | } |
| | | override fun onRequestPermissionsResult( |
| | | requestCode: Int, |
| | | permissions: Array<out String>, |
| | |
| | | // } |
| | | //取消 |
| | | find<TextView>(R.id.tv_cancel).onClick { |
| | | onBackPressed() |
| | | onBackPressHandle() |
| | | } |
| | | } |
| | | |
| | |
| | | val intent = Intent() |
| | | intent.putExtra(PATH, tempFile!!.absolutePath) |
| | | setResult(RESULT_OK, intent) |
| | | onBackPressed() |
| | | onBackPressHandle() |
| | | overridePendingTransition(0, 0) |
| | | } |
| | | } |
| | |
| | | package cn.sinata.xldutils.utils |
| | | |
| | | import android.content.Context |
| | | import android.view.Gravity |
| | | import android.view.LayoutInflater |
| | | import android.widget.TextView |
| | | import android.widget.Toast |
| | |
| | | ft.commitAllowingStateLoss() |
| | | } |
| | | |
| | | fun Fragment.myToast(text: CharSequence, longTime:Boolean=false) = activity?.myToast(text,longTime) |
| | | fun Fragment.myToast(text: CharSequence, longTime: Boolean = false) = activity?.myToast(text, longTime) |
| | | |
| | | fun Context.myToast(message: CharSequence,longTime:Boolean=false) { |
| | | fun Context.myToast(message: CharSequence, longTime: Boolean = false) { |
| | | val toast = Toast(this) |
| | | toast.duration = if (longTime)Toast.LENGTH_LONG else Toast.LENGTH_SHORT |
| | | toast.setGravity(Gravity.CENTER, 0, 0) |
| | | toast.duration = if (longTime) Toast.LENGTH_LONG else Toast.LENGTH_SHORT |
| | | // toast.setGravity(Gravity.CENTER, 0, 0) |
| | | val toastLayout = LayoutInflater.from(this).inflate(R.layout.layout_center_toast, null) |
| | | val txtToast: TextView = toastLayout.findViewById(R.id.txt_toast) |
| | | txtToast.text = message |
| | |
| | | * urlEncode |
| | | */ |
| | | fun String?.urlEncode(): String { |
| | | return if (isNullOrEmpty()) "" else URLEncoder.encode(this, "utf-8") |
| | | return if (isNullOrEmpty()) "" else try { |
| | | URLEncoder.encode(this, "utf-8") |
| | | }catch (e: Exception){ |
| | | e.printStackTrace() |
| | | this |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * urlDecode |
| | | */ |
| | | fun String?.urlDecode(): String { |
| | | return if (isNullOrEmpty()) "" else URLDecoder.decode(this, "utf-8") |
| | | return if (isNullOrEmpty()) "" else try { |
| | | URLDecoder.decode(this, "utf-8") |
| | | }catch (e: Exception){ |
| | | e.printStackTrace() |
| | | this |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | return try { |
| | | val manager = this.packageManager |
| | | val info = manager.getPackageInfo(this.packageName, 0) |
| | | info.versionName |
| | | info.versionName!! |
| | | } catch (e: Exception) { |
| | | e.printStackTrace() |
| | | "--" |
| | |
| | | titleView.backgroundDrawable = null |
| | | //默认左键点击关闭页面 |
| | | leftView.setOnClickListener { |
| | | (context as Activity).onBackPressed() |
| | | (context as Activity).finish() |
| | | } |
| | | } |
| | | |