Commit 69418b40 by konghaorui

Merge commit 'f699b29e' into feature/v3

# Conflicts:
#	app/src/main/java/com/ydl/component/MainActivity.kt
#	app/src/main/java/com/ydl/component/base/DemoGlobalConfig.java
#	config.gradle
#	m-user/src/main/java/com/yidianling/user/constants/UserBIConstants.kt
#	m-user/src/main/java/com/yidianling/user/ui/SmsLoginActivity.kt
#	m-user/src/main/java/com/yidianling/user/ui/login/presenter/InputPassWordPresenterImpl.kt
#	m-user/src/main/java/com/yidianling/user/ui/login/presenter/LoginPresenterImpl.kt
#	m-user/src/main/java/com/yidianling/user/ui/login/presenter/VerificationCodePresenterImpl.kt
parents 79079b9e f699b29e
......@@ -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) {
......
......@@ -19,8 +19,8 @@ class UserBIConstants {
//百度监测 用户注册行为
const val APP_REGISTER_PAGE = "app_register_page"
const val POSITION_LOGIN_CLICK = "login_main|login_click" //登录点击
const val POSITION_LOGIN_SUCCESS_CLICK = "login_main|login_success_click" //登录成功点击
const val POSITION_LOGIN_CLICK = PART_ID_LOGIN_MAIN_PREFIX+"login_click" //登录点击
const val POSITION_LOGIN_SUCCESS_CLICK = PART_ID_LOGIN_MAIN_PREFIX+"login_success_click" //登录成功点击
//百度监测 应用启动
const val POSITION_APP_START_UP_CLICK = "app_start_up_click" //应用启动
......
......@@ -57,7 +57,7 @@ class InputPassWordPresenterImpl : BasePresenter<IInputPassWordContract.View, II
} else {
ToastUtil.toastShort("修改密码成功")
saveUserData(it.data)
ActionCountUtils.count(UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK,UserBIConstants.ACTION_TYPE_RESET_PWD)
ActionCountUtils.countUid(UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK,it.data.uid!!,UserBIConstants.ACTION_TYPE_RESET_PWD)
if (it.data.firstLogin == 1) {//第一次登录:是注册
ModularServiceManager.provide(IHomeService::class.java).setDouble11ShowType(true)
// 重设密码登录已经不可能是首次登录,所以不进行百度埋点
......@@ -78,10 +78,7 @@ class InputPassWordPresenterImpl : BasePresenter<IInputPassWordContract.View, II
*/
@SuppressLint("CheckResult")
override fun userLoginByPassword(inputPassword: String, phone: String, phoneCountryCode: String) {
ActionCountUtils.count(UserBIConstants.ACTION_TYPE_PWD_LOGIN)
ActionCountUtils.count(UserBIConstants.POSITION_LOGIN_CLICK, UserBIConstants.ACTION_TYPE_RESET_PWD)
ActionCountUtils.count( UserBIConstants.POSITION_LOGIN_CLICK,UserBIConstants.ACTION_TYPE_PWD_LOGIN)
var param = PhoneLoginPwdParam(StringUtils.md5(inputPassword), phoneCountryCode, phone)
mModel.userLoginByPassword(param)
......
......@@ -59,7 +59,7 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra
@SuppressLint("CheckResult")
override fun autoLogin(bean: PhoneLoginAutoParam) {
ActionCountUtils.count(UserBIConstants.ACTION_TYPE_DIRECT_LOGIN)
ActionCountUtils.count( UserBIConstants.POSITION_LOGIN_CLICK,UserBIConstants.ACTION_TYPE_DIRECT_LOGIN)
mModel.autoLogin(bean)
.subscribeOn(Schedulers.io())
......@@ -177,7 +177,6 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra
val sign1 = if (media == SHARE_MEDIA.QQ) UserBIConstants.ACTION_TYPE_QQ_THIRD_LOGIN else UserBIConstants.ACTION_TYPE_WX_THIRD_LOGIN
ActionCountUtils.count(UserBIConstants.POSITION_LOGIN_CLICK, sign1)
UserHttpImpl.getInstance()
.umLogin(activity, media)
.doOnSubscribe { mView.showProgressView() }
......@@ -202,14 +201,14 @@ class LoginPresenterImpl(view: ILoginContract.View) : BasePresenter<ILoginContra
ModularServiceManager.provide(IHomeService::class.java).setDouble11ShowType(true)
mView.baiduActionBury(it.data.uid,UserBIConstants.POSITION_QQ_REGISTER_CLICK)
} else {
ActionCountUtils.count(UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK, sign1)
ActionCountUtils.countUid(UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK, it.data.uid!!,sign1)
}
} else {
if (it.data.firstLogin == 1) {//第一次登录:是注册
ModularServiceManager.provide(IHomeService::class.java).setDouble11ShowType(true)
mView.baiduActionBury(it.data.uid,UserBIConstants.POSITION_WX_REGISTER_CLICK)
} else {
ActionCountUtils.count(UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK, sign1)
ActionCountUtils.countUid(UserBIConstants.POSITION_LOGIN_SUCCESS_CLICK, it.data.uid!!,sign1)
}
}
}, {
......
......@@ -130,7 +130,7 @@ class VerificationCodePresenterImpl(view: IVerificationCodeContract.View) : Base
* 验证码验证码登录
*/
override fun loginByMsgCode(phone: String, phoneCountryCode: String, msgCode: String) {
ActionCountUtils.count(UserBIConstants.ACTION_TYPE_CODE_LOGIN)
ActionCountUtils.count(UserBIConstants.POSITION_LOGIN_CLICK,UserBIConstants.ACTION_TYPE_CODE_LOGIN)
var param = PhoneLoginCodeParam(msgCode, phoneCountryCode, phone)
mModel.loginByMsgCode(param)
.subscribeOn(Schedulers.io())
......
......@@ -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