Commit b12fe3f8 by konghaorui

修复线上bug

parent bbb23593
......@@ -63,17 +63,17 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
override fun initDataAndEvent() {
YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830")
//YDLavManager.instances.init(this, "3387e9b251f3491e9221a9877e8f7830")
bindService()
reLoadData()
requestPermission()
tv_user.setOnClickListener {
reLoadData()
mPresenter.loadFmMusic()
}
tv_home.setOnClickListener {
mPresenter?.loadHome()
mPresenter.loadHome()
}
bt_to_other.setOnClickListener {
......
......@@ -26,8 +26,8 @@ public final class DemoGlobalConfig implements IConfigModule {
@Override
public void applyOptions(@NotNull Context context, @NotNull GlobalConfig.Builder builder) {
// String env = YDLConstants.ENV_AUTO_TEST;
// String env = YDLConstants.ENV_PROD;
String env = YDLConstants.ENV_TEST;
String env = YDLConstants.ENV_PROD;
// String env = YDLConstants.ENV_TEST;
builder.setFrom( "ydl".equals(BuildConfig.FLAVOR) ?YDLConstants.FROM_YDL :YDLConstants.FROM_XLZX)
.addUrl("github", APP_DOMAIN)
......
......@@ -20,7 +20,9 @@ class DemoModel : BaseModel(), DemoContract.Model {
return YDLHttpUtils.obtainApi(DemoService::class.java)
.getFMData()
.compose(RxUtils.resultJavaData())
.map {
throw RuntimeException("runtime exception")
}
}
override fun getHome(): Observable<JsonObject> {
......
......@@ -7,6 +7,7 @@ import com.ydl.media.audio.AudioPlayer
import com.ydl.media.audio.model.Music
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlnet.client.observer.CommonObserver
/**
......@@ -21,15 +22,18 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(),
.compose(RxUtils.applySchedulers(mView))
.subscribe(object : CommonObserver<HomeFMBean>() {
override fun onError(errorMsg: String) {
LogUtil.d("RxJava loadUsers ---->: $errorMsg")
}
override fun onSuccess(homeFMBean: HomeFMBean) {
throw RuntimeException("runtime exception")
homeFMBean.list?.let {
AudioPlayer.get().addPlayList(stringToMusicPlayerList(it))
mView.setData("")
}
}
})
}
override fun loadHome() = mModel.getHome()
......@@ -52,6 +56,7 @@ class DemoPresenter : BasePresenter<DemoContract.View,DemoContract.Model>(),
.compose(RxUtils.applySchedulers(mView))//使用 Rxlifecycle,使 Disposable 和 Activity 一起销毁
.subscribe(object : CommonObserver<JsonArray>() {
override fun onError(errorMsg: String) {
LogUtil.d("RxJava loadUsers ---->: $errorMsg")
}
override fun onSuccess(users: JsonArray) {
......
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......
......@@ -17,6 +17,7 @@ import com.ydl.ydlnet.client.interfaces.BuildHeadersListener;
import java.io.File;
import java.io.InputStream;
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.TimeUnit;
......@@ -25,6 +26,7 @@ import javax.net.ssl.HostnameVerifier;
import okhttp3.Cache;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Protocol;
/**
* Created by haorui on 2019-09-02 .
......@@ -45,7 +47,7 @@ public class OkHttpConfig {
private static OkHttpClient okHttpClient;
public OkHttpConfig() {
okHttpClientBuilder = new OkHttpClient.Builder();
okHttpClientBuilder = new OkHttpClient.Builder().protocols(Collections.singletonList(Protocol.HTTP_1_1));
}
public static OkHttpConfig getInstance() {
......
......@@ -29,7 +29,11 @@ public abstract class BaseObserver<T> implements Observer<T>, ISubscriber<T> {
@Override
public void onNext(@NonNull T t) {
doOnNext(t);
try {
doOnNext(t);
} catch (Exception e) {
onError(e);
}
}
@Override
......
......@@ -2,8 +2,10 @@ package com.yidianling.ydl_pay.toast
import android.content.Context
import android.support.annotation.StringRes
import android.text.TextUtils
import android.widget.Toast
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.utils.LogUtil
import com.yidianling.common.tools.ToastUtil
/**
* author : Zhangwenchao
......@@ -31,16 +33,16 @@ class ToastHelper private constructor() {
}
private fun show(context: Context, text: CharSequence) {
if (TextUtils.isEmpty(text)) return
if (toast == null) toast = Toast.makeText(context, text, Toast.LENGTH_SHORT)
else toast?.setText(text)
toast?.show()
ToastUtil.toastShort(text.toString())
}
private fun show(context: Context, @StringRes resId: Int) {
if (toast == null) toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT)
else toast?.setText(resId)
toast?.show()
try {
val text = BaseApp.getApp().resources.getString(resId)
ToastUtil.toastShort(text)
} catch (e: Exception) {
LogUtil.e(e.message)
}
}
private object Holder {
......
......@@ -8,10 +8,13 @@ import com.lzy.imagepicker.view.CropImageView
import com.ydl.devicesidlib.DeviceIDHelper
import com.ydl.ydlcommon.actions.imagepicker.YdlImageLoader
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.UpLoadLogUtils
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlnet.client.exception.ApiException
import com.yidianling.common.tools.RxTool
import io.reactivex.plugins.RxJavaPlugins
/**
......@@ -41,6 +44,22 @@ object YdlRepository {
// }
// refWatcher = LeakCanary.install(app)
initARouter(app, isDebug)
initRxPlugin()
}
private fun initRxPlugin() {
//保障RxJava调用链流程不会崩溃
RxJavaPlugins.setErrorHandler {
LogUtil.e("RxJava ErrorHandler ---->: $it")
try {
val apiException = ApiException.handleException(it)
UpLoadLogUtils.upLoadLog(
"RxJava Error Handler ", apiException.code, apiException.message?:""
)
} catch (e: Exception) {
LogUtil.d("RxJava ErrorHandler UpLoad Log Error ---->: $it")
}
}
}
/**
......
package com.ydl.ydlcommon.data.http
import android.text.TextUtils
import com.ydl.ydlcommon.R
import com.ydl.ydlcommon.base.BaseApp
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxNetTool
import com.ydl.ydlcommon.R
import io.reactivex.functions.Consumer
/**
......
package com.ydl.ydlcommon.utils.remind
import android.support.annotation.StringRes
import android.text.TextUtils
import android.widget.Toast
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.utils.LogUtil
import com.yidianling.common.tools.ToastUtil
/**
* author : Zhangwenchao
......@@ -14,8 +14,6 @@ import com.ydl.ydlcommon.base.BaseApp
*/
class ToastHelper private constructor() {
private var toast: Toast? = null
companion object {
private fun getInstance(): ToastHelper {
return Holder.INSTANCE
......@@ -31,16 +29,16 @@ class ToastHelper private constructor() {
}
private fun show(text: CharSequence) {
if (TextUtils.isEmpty(text)) return
if (toast == null) toast = Toast.makeText(BaseApp.getApp(), text, Toast.LENGTH_SHORT)
else toast?.setText(text)
toast?.show()
ToastUtil.toastShort(text.toString())
}
private fun show(@StringRes resId: Int) {
if (toast == null) toast = Toast.makeText(BaseApp.getApp(), resId, Toast.LENGTH_SHORT)
else toast?.setText(resId)
toast?.show()
try {
val text = BaseApp.getApp().resources.getString(resId)
ToastUtil.toastShort(text)
} catch (e: Exception) {
LogUtil.e(e.message)
}
}
private object Holder {
......
package com.yidianling.common.tools;
import android.content.Context;
import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
......@@ -42,6 +41,7 @@ public class ToastUtil {
handler.post(() -> toastShort(RxTool.getContext(), msg));
}
}
private static void showShortToast(Context mContext, String msg) {
if (toast == null) {
toast = Toast.makeText(mContext.getApplicationContext(), msg, Toast.LENGTH_SHORT);
......
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