|
@@ -8,22 +8,22 @@ package com.wdkl.ncs.android.lib.utils
|
|
|
*/
|
|
|
|
|
|
import android.app.Activity
|
|
|
-import android.app.Fragment
|
|
|
+import android.app.Service
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
-import android.databinding.ObservableField
|
|
|
import android.os.Looper
|
|
|
-import android.support.v4.content.ContextCompat
|
|
|
-import android.support.v7.app.AppCompatActivity
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
|
import android.view.animation.Animation
|
|
|
import android.widget.Toast
|
|
|
+import androidx.appcompat.app.AppCompatActivity
|
|
|
+import androidx.core.content.ContextCompat
|
|
|
+import androidx.databinding.ObservableField
|
|
|
+import androidx.fragment.app.Fragment
|
|
|
import com.alibaba.android.vlayout.DelegateAdapter
|
|
|
import com.alibaba.android.vlayout.VirtualLayoutManager
|
|
|
import com.enation.javashop.android.jrouter.JRouter
|
|
|
import com.enation.javashop.android.jrouter.logic.datainfo.Postcard
|
|
|
-import com.wdkl.ncs.android.lib.R
|
|
|
import com.wdkl.ncs.android.lib.adapter.BaseDelegateAdapter
|
|
|
import com.wdkl.ncs.android.lib.base.BaseApplication
|
|
|
import com.wdkl.ncs.android.lib.base.DisposableManager
|
|
@@ -31,6 +31,7 @@ import com.enation.javashop.net.engine.plugin.rxbus.RxBus
|
|
|
import com.enation.javashop.utils.base.tool.CommonTool
|
|
|
import com.enation.javashop.utils.base.tool.ScreenTool
|
|
|
import com.enation.javashop.utils.logger.LoggerFactory
|
|
|
+import com.wdkl.ncs.android.lib.R
|
|
|
import io.reactivex.disposables.Disposable
|
|
|
import okhttp3.ResponseBody
|
|
|
import org.json.JSONArray
|
|
@@ -131,7 +132,7 @@ fun <T> acquireInstance(path: String): T {
|
|
|
* @param _block 更多操作
|
|
|
* @param requstCode 返回码
|
|
|
*/
|
|
|
-fun AppCompatActivity.push(path: String, _block: ((Postcard) -> Unit)? = null, requstCode: Int = -1 , isNeedLogin :Boolean = false) {
|
|
|
+fun AppCompatActivity.push(path: String, _block: ((Postcard) -> Unit)? = null, requstCode: Int = -1, isNeedLogin :Boolean = false) {
|
|
|
if (isNeedLogin){
|
|
|
JRouter.prepare().create("/member/login/main").withTransition(R.anim.push_left_in, R.anim.push_left_out).then { postcard ->
|
|
|
_block?.invoke(postcard)
|
|
@@ -174,6 +175,11 @@ fun Activity.push(path: String, _block: ((Postcard) -> Unit)? = null, requstCode
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+fun Service.push(path: String, _block: ((Postcard) -> Unit)? = null) {
|
|
|
+ JRouter.prepare().create(path).withTransition(R.anim.push_left_in, R.anim.push_left_out).then { postcard ->
|
|
|
+ _block?.invoke(postcard)
|
|
|
+ }.seek(this)
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* @author LDD
|
|
@@ -183,7 +189,7 @@ fun Activity.push(path: String, _block: ((Postcard) -> Unit)? = null, requstCode
|
|
|
* @param path Activity注册到JRouter中的路径
|
|
|
* @param _block 更多操作
|
|
|
*/
|
|
|
-fun android.support.v4.app.Fragment.push(path: String, _block: ((Postcard) -> Unit)? = null , isNeedLogin :Boolean = false) {
|
|
|
+fun Fragment.push(path: String, _block: ((Postcard) -> Unit)? = null, isNeedLogin :Boolean = false) {
|
|
|
if (isNeedLogin){
|
|
|
JRouter.prepare().create("/member/login/main").withTransition(R.anim.push_left_in, R.anim.push_left_out).then { postcard ->
|
|
|
_block?.invoke(postcard)
|
|
@@ -203,7 +209,7 @@ fun android.support.v4.app.Fragment.push(path: String, _block: ((Postcard) -> Un
|
|
|
* @param _block 更多操作
|
|
|
* @param path Activity注册到JRouter中的路径
|
|
|
*/
|
|
|
-fun Fragment.push(path: String, _block: ((Postcard) -> Unit)? = null , isNeedLogin :Boolean = false) {
|
|
|
+/*fun Fragment.push(path: String, _block: ((Postcard) -> Unit)? = null , isNeedLogin :Boolean = false) {
|
|
|
if (isNeedLogin){
|
|
|
JRouter.prepare().create("/member/login/main").withTransition(R.anim.push_left_in, R.anim.push_left_out).then { postcard ->
|
|
|
_block?.invoke(postcard)
|
|
@@ -213,7 +219,7 @@ fun Fragment.push(path: String, _block: ((Postcard) -> Unit)? = null , isNeedLog
|
|
|
JRouter.prepare().create(path).withTransition(R.anim.push_left_in, R.anim.push_left_out).then { postcard ->
|
|
|
_block?.invoke(postcard)
|
|
|
}.seek(activity)
|
|
|
-}
|
|
|
+}*/
|
|
|
|
|
|
/**
|
|
|
* @author LDD
|
|
@@ -595,7 +601,7 @@ fun <T> Intent.getObjectForGson(key: String, cls: Class<T>): T? {
|
|
|
return if (hasExtra(key)) {
|
|
|
val json = getStringExtra(key)
|
|
|
try {
|
|
|
- JsonTranforHelper.toObject(json, cls)
|
|
|
+ JsonTranforHelper.toObject(json!!, cls)
|
|
|
} catch (e: Exception) {
|
|
|
null
|
|
|
}
|