[Modify]优化登录和主页逻辑
This commit is contained in:
@@ -250,9 +250,9 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
|||||||
.doOnError(throwable -> onNeedLogin())
|
.doOnError(throwable -> onNeedLogin())
|
||||||
.subscribe();
|
.subscribe();
|
||||||
initView();
|
initView();
|
||||||
InitialModel.get().getMainTabInfosLiveData().observeForever(mainTabInfos -> {
|
InitialModel.get().getMainTabInfosLiveData().observeForever(mainTabInfo -> {
|
||||||
if (mainTabInfos != null) {
|
if (mainTabInfo != null) {
|
||||||
mMainTabLayout.setMainTabInfoList(mainTabInfos);
|
mMainTabLayout.setMainTabInfoList(mainTabInfo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//检测更新
|
//检测更新
|
||||||
@@ -530,6 +530,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
|||||||
getMvpPresenter().exitRoom();
|
getMvpPresenter().exitRoom();
|
||||||
LoginActivity.start(MainActivity.this);
|
LoginActivity.start(MainActivity.this);
|
||||||
PmDialogShowMrg.get().onLogout();
|
PmDialogShowMrg.get().onLogout();
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNeedLogin() {
|
public void onNeedLogin() {
|
||||||
|
@@ -22,6 +22,9 @@ import com.yizhuan.erban.application.XChatApplication;
|
|||||||
import com.yizhuan.erban.databinding.ActivitySplashBinding;
|
import com.yizhuan.erban.databinding.ActivitySplashBinding;
|
||||||
import com.yizhuan.erban.other.SplashBitmapTransformation;
|
import com.yizhuan.erban.other.SplashBitmapTransformation;
|
||||||
import com.yizhuan.erban.other.dialog.PrivacyAgreementDialog;
|
import com.yizhuan.erban.other.dialog.PrivacyAgreementDialog;
|
||||||
|
import com.yizhuan.erban.ui.login.LoginActivity;
|
||||||
|
import com.yizhuan.xchat_android_core.DemoCache;
|
||||||
|
import com.yizhuan.xchat_android_core.auth.entity.AccountInfo;
|
||||||
import com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel;
|
import com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel;
|
||||||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||||||
import com.yizhuan.xchat_android_core.initial.SplashComponent;
|
import com.yizhuan.xchat_android_core.initial.SplashComponent;
|
||||||
@@ -53,7 +56,12 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
//修复 https://blog.csdn.net/u011153817/article/details/77335255
|
//修复 https://blog.csdn.net/u011153817/article/details/77335255
|
||||||
// https://blog.csdn.net/zhangcanyan/article/details/52777265 这样的启动异常问题.
|
// https://blog.csdn.net/zhangcanyan/article/details/52777265 这样的启动异常问题.
|
||||||
if (!isTaskRoot()) {
|
if (!isTaskRoot()) {
|
||||||
MainActivity.start(SplashActivity.this);
|
AccountInfo currentAccountInfo = DemoCache.readCurrentAccountInfo();
|
||||||
|
if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) {
|
||||||
|
LoginActivity.start(this);
|
||||||
|
} else {
|
||||||
|
MainActivity.start(SplashActivity.this);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,9 +123,7 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
mBinding.tvJump.setVisibility(View.VISIBLE);
|
mBinding.tvJump.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NimMiddleActivity.delayOpenCommunity = false;
|
jumpActivity(null);
|
||||||
MainActivity.start(SplashActivity.this);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,12 +135,28 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
if (needJump) {
|
if (needJump) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NimMiddleActivity.delayOpenCommunity = false;
|
jumpActivity(null);
|
||||||
MainActivity.start(SplashActivity.this);
|
|
||||||
finish();
|
|
||||||
}, COUNT_DOWN_TIME * 1000);
|
}, COUNT_DOWN_TIME * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void jumpActivity(Intent intent) {
|
||||||
|
AccountInfo currentAccountInfo = DemoCache.readCurrentAccountInfo();
|
||||||
|
if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) {
|
||||||
|
NimMiddleActivity.openCommunity = false;
|
||||||
|
LoginActivity.start(this);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
if (intent != null) {
|
||||||
|
NimMiddleActivity.delayOpenCommunity = false;
|
||||||
|
MainActivity.start(this, intent);
|
||||||
|
finish();
|
||||||
|
} else {
|
||||||
|
NimMiddleActivity.delayOpenCommunity = false;
|
||||||
|
MainActivity.start(SplashActivity.this);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -148,18 +170,14 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis
|
|||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra("url", link);
|
intent.putExtra("url", link);
|
||||||
intent.putExtra("type", type);
|
intent.putExtra("type", type);
|
||||||
NimMiddleActivity.delayOpenCommunity = false;
|
jumpActivity(intent);
|
||||||
MainActivity.start(this, intent);
|
|
||||||
finish();
|
|
||||||
break;
|
break;
|
||||||
case R.id.tv_skip:
|
case R.id.tv_skip:
|
||||||
if (mLocalSplashVo == null) {
|
if (mLocalSplashVo == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
needJump = true;
|
needJump = true;
|
||||||
NimMiddleActivity.delayOpenCommunity = false;
|
jumpActivity(null);
|
||||||
MainActivity.start(this);
|
|
||||||
finish();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@@ -20,6 +20,8 @@ import com.google.firebase.analytics.FirebaseAnalytics;
|
|||||||
import com.netease.nim.uikit.StatusBarUtil;
|
import com.netease.nim.uikit.StatusBarUtil;
|
||||||
import com.tongdaxing.erban.upgrade.AppUpgradeHelper;
|
import com.tongdaxing.erban.upgrade.AppUpgradeHelper;
|
||||||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||||||
|
import com.yizhuan.erban.MainActivity;
|
||||||
|
import com.yizhuan.erban.NimMiddleActivity;
|
||||||
import com.yizhuan.erban.R;
|
import com.yizhuan.erban.R;
|
||||||
import com.yizhuan.erban.application.IReportConstants;
|
import com.yizhuan.erban.application.IReportConstants;
|
||||||
import com.yizhuan.erban.application.ReportManager;
|
import com.yizhuan.erban.application.ReportManager;
|
||||||
@@ -183,7 +185,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
||||||
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
||||||
getDialogManager().dismissDialog();
|
getDialogManager().dismissDialog();
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -213,7 +214,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
||||||
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
||||||
getDialogManager().dismissDialog();
|
getDialogManager().dismissDialog();
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -244,7 +244,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
||||||
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
||||||
getDialogManager().dismissDialog();
|
getDialogManager().dismissDialog();
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -336,7 +335,8 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLoginEvent(LoginEvent event) {
|
public void onLoginEvent(LoginEvent event) {
|
||||||
getDialogManager().dismissDialog();
|
getDialogManager().dismissDialog();
|
||||||
setResult(RESULT_OK);
|
NimMiddleActivity.delayOpenCommunity = false;
|
||||||
|
MainActivity.start(this);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,8 @@ import com.coorchice.library.utils.LogUtils
|
|||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
import com.netease.nim.uikit.StatusBarUtil
|
import com.netease.nim.uikit.StatusBarUtil
|
||||||
import com.trello.rxlifecycle3.android.ActivityEvent
|
import com.trello.rxlifecycle3.android.ActivityEvent
|
||||||
|
import com.yizhuan.erban.MainActivity
|
||||||
|
import com.yizhuan.erban.NimMiddleActivity
|
||||||
import com.yizhuan.erban.R
|
import com.yizhuan.erban.R
|
||||||
import com.yizhuan.erban.application.IReportConstants
|
import com.yizhuan.erban.application.IReportConstants
|
||||||
import com.yizhuan.erban.application.ReportManager
|
import com.yizhuan.erban.application.ReportManager
|
||||||
@@ -209,8 +211,6 @@ class LoginCodeActivity : BaseViewBindingActivity<ActivityLoginCodeBinding>() {
|
|||||||
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map)
|
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map)
|
||||||
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN)
|
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN)
|
||||||
stopCounter()
|
stopCounter()
|
||||||
setResult(RESULT_OK)
|
|
||||||
finish()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
@@ -256,7 +256,8 @@ class LoginCodeActivity : BaseViewBindingActivity<ActivityLoginCodeBinding>() {
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
fun onLoginEvent(event: LoginEvent?) {
|
fun onLoginEvent(event: LoginEvent?) {
|
||||||
dialogManager.dismissDialog()
|
dialogManager.dismissDialog()
|
||||||
setResult(RESULT_OK)
|
NimMiddleActivity.delayOpenCommunity = false
|
||||||
|
MainActivity.start(this)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,10 +8,11 @@ import android.text.TextUtils;
|
|||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||||
import com.netease.nim.uikit.StatusBarUtil;
|
import com.netease.nim.uikit.StatusBarUtil;
|
||||||
|
import com.yizhuan.erban.MainActivity;
|
||||||
|
import com.yizhuan.erban.NimMiddleActivity;
|
||||||
import com.yizhuan.erban.R;
|
import com.yizhuan.erban.R;
|
||||||
import com.yizhuan.erban.application.IReportConstants;
|
import com.yizhuan.erban.application.IReportConstants;
|
||||||
import com.yizhuan.erban.application.ReportManager;
|
import com.yizhuan.erban.application.ReportManager;
|
||||||
@@ -72,10 +73,7 @@ public class LoginPasswordActivity extends BaseActivity {
|
|||||||
findViewById(R.id.iv_back).setOnClickListener(v -> finish());
|
findViewById(R.id.iv_back).setOnClickListener(v -> finish());
|
||||||
btnNext.setOnClickListener(v -> login());
|
btnNext.setOnClickListener(v -> login());
|
||||||
findViewById(R.id.tv_forget_password).setOnClickListener(v ->
|
findViewById(R.id.tv_forget_password).setOnClickListener(v ->
|
||||||
ResetPasswordActivity.start(context, ResetPasswordActivity.FROM_NOT_LOGIN)
|
ResetPasswordActivity.start(context, ResetPasswordActivity.FROM_NOT_LOGIN)
|
||||||
// getDialogManager().showOkCancelWithTitleDialog(getString(R.string.login_contact_service), "LINE:pekoyuyin", getString(R.string.button_ok), "", true, () -> {
|
|
||||||
//
|
|
||||||
// })
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,8 +124,6 @@ public class LoginPasswordActivity extends BaseActivity {
|
|||||||
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
ReportManager.get().reportEvent(FirebaseAnalytics.Event.LOGIN, map);
|
||||||
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
ReportManager.get().reportAdjustEvent(IReportConstants.ADJUST_LOGIN);
|
||||||
getDialogManager().dismissDialog();
|
getDialogManager().dismissDialog();
|
||||||
setResult(RESULT_OK);
|
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -141,6 +137,7 @@ public class LoginPasswordActivity extends BaseActivity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 上报登录结果
|
* 上报登录结果
|
||||||
|
*
|
||||||
* @param result
|
* @param result
|
||||||
* @param failDetail
|
* @param failDetail
|
||||||
*/
|
*/
|
||||||
@@ -149,7 +146,7 @@ public class LoginPasswordActivity extends BaseActivity {
|
|||||||
map.put(IReportConstants.LOGIN_TYPE, IReportConstants.FIVE);
|
map.put(IReportConstants.LOGIN_TYPE, IReportConstants.FIVE);
|
||||||
map.put(IReportConstants.MODULE, IReportConstants.PEKO_LOGIN);
|
map.put(IReportConstants.MODULE, IReportConstants.PEKO_LOGIN);
|
||||||
map.put(IReportConstants.RESULT, result);
|
map.put(IReportConstants.RESULT, result);
|
||||||
if(result == IReportConstants.ZERO){
|
if (result == IReportConstants.ZERO) {
|
||||||
map.put(IReportConstants.FAIL_DETAIL, failDetail);
|
map.put(IReportConstants.FAIL_DETAIL, failDetail);
|
||||||
}
|
}
|
||||||
ReportManager.get().reportEvent(IReportConstants.LOGIN_RESULT, map);
|
ReportManager.get().reportEvent(IReportConstants.LOGIN_RESULT, map);
|
||||||
@@ -165,7 +162,8 @@ public class LoginPasswordActivity extends BaseActivity {
|
|||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLoginEvent(LoginEvent event) {
|
public void onLoginEvent(LoginEvent event) {
|
||||||
getDialogManager().dismissDialog();
|
getDialogManager().dismissDialog();
|
||||||
setResult(RESULT_OK);
|
NimMiddleActivity.delayOpenCommunity = false;
|
||||||
|
MainActivity.start(LoginPasswordActivity.this);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -9,6 +9,8 @@ import android.widget.EditText
|
|||||||
import com.coorchice.library.utils.LogUtils
|
import com.coorchice.library.utils.LogUtils
|
||||||
import com.netease.nim.uikit.StatusBarUtil
|
import com.netease.nim.uikit.StatusBarUtil
|
||||||
import com.trello.rxlifecycle3.android.ActivityEvent
|
import com.trello.rxlifecycle3.android.ActivityEvent
|
||||||
|
import com.yizhuan.erban.MainActivity
|
||||||
|
import com.yizhuan.erban.NimMiddleActivity
|
||||||
import com.yizhuan.erban.R
|
import com.yizhuan.erban.R
|
||||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||||
import com.yizhuan.erban.databinding.ActivityLoginPhoneBinding
|
import com.yizhuan.erban.databinding.ActivityLoginPhoneBinding
|
||||||
@@ -143,7 +145,8 @@ class LoginPhoneActivity : BaseViewBindingActivity<ActivityLoginPhoneBinding>(),
|
|||||||
*/
|
*/
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
fun onLoginEvent(event: LoginEvent?) {
|
fun onLoginEvent(event: LoginEvent?) {
|
||||||
setResult(RESULT_OK)
|
NimMiddleActivity.delayOpenCommunity = false
|
||||||
|
MainActivity.start(this)
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ import java.lang.reflect.Field;
|
|||||||
public class CleanLeakUtils {
|
public class CleanLeakUtils {
|
||||||
public static void fixInputMethodManagerLeak(Context destContext) {
|
public static void fixInputMethodManagerLeak(Context destContext) {
|
||||||
//在15<=API<=23中都存在
|
//在15<=API<=23中都存在
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT || Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -399,14 +399,6 @@ object HomeModel : BaseModel() {
|
|||||||
@GET("/single/broadcast/morePopularityAnchorList")
|
@GET("/single/broadcast/morePopularityAnchorList")
|
||||||
suspend fun getMoreSingleAnchorList(@Query("singleRoomSortId") id: Long?): ServiceResult<List<HomeRoomInfo>>
|
suspend fun getMoreSingleAnchorList(@Query("singleRoomSortId") id: Long?): ServiceResult<List<HomeRoomInfo>>
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取首页Tab配置
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@GET("/app/bottomBar/getCurrentAppBottomBar")
|
|
||||||
suspend fun getMainTabList(): ServiceResult<List<MainTabInfo>>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@@ -52,25 +52,6 @@ public class MarketVerifyModel extends BaseModel implements IMarketVerifyModel{
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLogin(LoginEvent event){
|
public void onLogin(LoginEvent event){
|
||||||
// loadVersionConfigFromServer(
|
|
||||||
// String.valueOf(AuthModel.get().getCurrentUid())
|
|
||||||
// )
|
|
||||||
// .subscribe(new SingleObserver<Boolean>() {
|
|
||||||
// @Override
|
|
||||||
// public void onSubscribe(Disposable d) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(Boolean aBoolean) {
|
|
||||||
// EventBus.getDefault().post(new MarketVerifyUpdateEvent());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError(Throwable e) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -219,25 +219,19 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
|||||||
if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) {
|
if (currentAccountInfo == null || TextUtils.isEmpty(currentAccountInfo.getAccess_token())) {
|
||||||
return Single.error(new Throwable(""));//没有账号信息
|
return Single.error(new Throwable(""));//没有账号信息
|
||||||
}
|
}
|
||||||
return requestTicket().flatMap(new Function<TicketResult, SingleSource<? extends String>>() {
|
return requestTicket().flatMap(ticketResult -> {
|
||||||
@Override
|
if (!ticketResult.isSuccess()) {
|
||||||
public SingleSource<? extends String> apply(TicketResult ticketResult) throws Exception {
|
return Single.error(new Throwable(ticketResult.getMessage()));
|
||||||
if (!ticketResult.isSuccess()) {
|
}
|
||||||
return Single.error(new Throwable(ticketResult.getMessage()));
|
ticketInfo = ticketResult.getData();
|
||||||
}
|
DemoCache.saveTicketInfo(ticketInfo);
|
||||||
ticketInfo = ticketResult.getData();
|
return Single.just(ResUtil.getString(R.string.xchat_android_core_auth_authmodel_01));
|
||||||
DemoCache.saveTicketInfo(ticketInfo);
|
})
|
||||||
return Single.just(ResUtil.getString(R.string.xchat_android_core_auth_authmodel_01));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.flatMap(new Function<String, SingleSource<String>>() {
|
.flatMap((Function<String, SingleSource<String>>) s -> {
|
||||||
@Override
|
Log.i("IMLogin", "apply");
|
||||||
public SingleSource<String> apply(String s) throws Exception {
|
return imLogin(currentAccountInfo);
|
||||||
Log.i("IMLogin", "apply");
|
|
||||||
return imLogin(currentAccountInfo);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.doOnSuccess(s -> {
|
.doOnSuccess(s -> {
|
||||||
EventBus.getDefault().post(new LoginEvent());
|
EventBus.getDefault().post(new LoginEvent());
|
||||||
@@ -258,66 +252,63 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Single<String> login(String phoneAreaCode, String account, String password, String code, String yiDunToken, String shuMeiDeviceId) {
|
public Single<String> login(String phoneAreaCode, String account, String password, String code, String yiDunToken, String shuMeiDeviceId) {
|
||||||
return Single.create(new SingleOnSubscribe<String>() {
|
return Single.create((SingleOnSubscribe<String>) emitter -> {
|
||||||
@Override
|
//获取登录信息
|
||||||
public void subscribe(SingleEmitter<String> emitter) throws Exception {
|
try {
|
||||||
//获取登录信息
|
LoginResult loginResult = api.login(
|
||||||
try {
|
phoneAreaCode,
|
||||||
LoginResult loginResult = api.login(
|
DESUtils.DESAndBase64(account),
|
||||||
phoneAreaCode,
|
VersionUtil.getLocalName(BasicConfig.INSTANCE.getAppContext()),
|
||||||
DESUtils.DESAndBase64(account),
|
"erban-client",
|
||||||
VersionUtil.getLocalName(BasicConfig.INSTANCE.getAppContext()),
|
DESUtils.DESAndBase64(account),
|
||||||
"erban-client",
|
DESAndBase64(password),
|
||||||
DESUtils.DESAndBase64(account),
|
"password",
|
||||||
DESAndBase64(password),
|
"uyzjdhds",
|
||||||
"password",
|
code,
|
||||||
"uyzjdhds",
|
yiDunToken,
|
||||||
code,
|
shuMeiDeviceId
|
||||||
yiDunToken,
|
).blockingGet();
|
||||||
shuMeiDeviceId
|
if (!loginResult.isSuccess()) {
|
||||||
).blockingGet();
|
if (loginResult.getCode() == CODE_BAN_ACCOUNT || loginResult.getCode() == CODE_BAN_DEVICE) {
|
||||||
if (!loginResult.isSuccess()) {
|
emitter.onError(new BanAccountException(loginResult.getReason(), loginResult.getDate()));
|
||||||
if (loginResult.getCode() == CODE_BAN_ACCOUNT || loginResult.getCode() == CODE_BAN_DEVICE) {
|
} else if (loginResult.getCode() == CODE_ACCOUNT_CANCEL) {
|
||||||
emitter.onError(new BanAccountException(loginResult.getReason(), loginResult.getDate()));
|
emitter.onError(new AccountCancelException(loginResult.getMessage(), loginResult.getErbanNo(), loginResult.getCancelDate()));
|
||||||
} else if (loginResult.getCode() == CODE_ACCOUNT_CANCEL) {
|
} else if (loginResult.getCode() == SUPER_CODE_SHOW_CODE) {
|
||||||
emitter.onError(new AccountCancelException(loginResult.getMessage(), loginResult.getErbanNo(), loginResult.getCancelDate()));
|
//是否是超管
|
||||||
} else if (loginResult.getCode() == SUPER_CODE_SHOW_CODE) {
|
if (loginResult.getSuperCodeVerify() == 1) {
|
||||||
//是否是超管
|
emitter.onError(new IsSuperAdminException(loginResult.getMessage()));
|
||||||
if (loginResult.getSuperCodeVerify() == 1) {
|
} else {
|
||||||
emitter.onError(new IsSuperAdminException(loginResult.getMessage()));
|
emitter.onError(new Throwable(loginResult.getMessage()));
|
||||||
} else {
|
|
||||||
emitter.onError(new Throwable(loginResult.getMessage()));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
emitter.onError(new Throwable(loginResult.getMessage()));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
currentAccountInfo = loginResult.getData();
|
|
||||||
DemoCache.saveCurrentAccountInfo(currentAccountInfo);
|
|
||||||
//成功获取到uid后,就通知首页刷新审核中状态的数据
|
|
||||||
EventBus.getDefault().post(new GetCurrentUidEvent(true));
|
|
||||||
} catch (Exception e) {
|
|
||||||
emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
//获取tick
|
} else {
|
||||||
try {
|
emitter.onError(new Throwable(loginResult.getMessage()));
|
||||||
TicketResult ticketResult = requestTicket().blockingGet();
|
|
||||||
if (!ticketResult.isSuccess()) {
|
|
||||||
emitter.onError(new Throwable(ticketResult.getMessage()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ticketInfo = ticketResult.getData();
|
|
||||||
DemoCache.saveTicketInfo(ticketInfo);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
emitter.onSuccess(ResUtil.getString(R.string.xchat_android_core_auth_authmodel_02));
|
|
||||||
}
|
}
|
||||||
})
|
return;
|
||||||
|
}
|
||||||
|
currentAccountInfo = loginResult.getData();
|
||||||
|
DemoCache.saveCurrentAccountInfo(currentAccountInfo);
|
||||||
|
//成功获取到uid后,就通知首页刷新审核中状态的数据
|
||||||
|
EventBus.getDefault().post(new GetCurrentUidEvent(true));
|
||||||
|
} catch (Exception e) {
|
||||||
|
emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//获取tick
|
||||||
|
try {
|
||||||
|
TicketResult ticketResult = requestTicket().blockingGet();
|
||||||
|
if (!ticketResult.isSuccess()) {
|
||||||
|
emitter.onError(new Throwable(ticketResult.getMessage()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ticketInfo = ticketResult.getData();
|
||||||
|
DemoCache.saveTicketInfo(ticketInfo);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
emitter.onError(new Throwable(OldHttpErrorHandleUtil.handle(e)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
emitter.onSuccess(ResUtil.getString(R.string.xchat_android_core_auth_authmodel_02));
|
||||||
|
})
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.flatMap(new Function<String, SingleSource<String>>() {
|
.flatMap(new Function<String, SingleSource<String>>() {
|
||||||
@@ -1150,31 +1141,6 @@ public class AuthModel extends BaseModel implements IAuthModel {
|
|||||||
@Field("shuMeiDeviceId") String shuMeiDeviceId
|
@Field("shuMeiDeviceId") String shuMeiDeviceId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 登录接口
|
|
||||||
*
|
|
||||||
* @param phone
|
|
||||||
* @param version
|
|
||||||
* @param client_id
|
|
||||||
* @param username
|
|
||||||
* @param password
|
|
||||||
* @param grant_type
|
|
||||||
* @param client_secret
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@FormUrlEncoded
|
|
||||||
@POST("/oauth/token")
|
|
||||||
Single<LoginResult> loginForOldMember(@Field("phone") String phone,
|
|
||||||
@Field("version") String version,
|
|
||||||
@Field("client_id") String client_id,
|
|
||||||
@Field("username") String username,
|
|
||||||
@Field("password") String password,
|
|
||||||
@Field("grant_type") String grant_type,
|
|
||||||
@Field("client_secret") String client_secret,
|
|
||||||
@Field("operateType") int type,
|
|
||||||
@Field("qqOpenid") String openid);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登出接口
|
* 登出接口
|
||||||
*
|
*
|
||||||
|
@@ -120,19 +120,12 @@ public class FamilyModel extends BaseModel implements IFamilyModel {
|
|||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLoginEvent(LoginEvent event) {
|
public void onLoginEvent(LoginEvent event) {
|
||||||
Logger.i("FamilyModel", ResUtil.getString(R.string.family_model_familymodel_01));
|
|
||||||
// syncMyFamilyFromServer().subscribe();
|
|
||||||
|
|
||||||
if (null == getCustomServiceInfo()){
|
|
||||||
// loadFamilyCustomServiceInfo().subscribe();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onLogoutEvent(LogoutEvent event) {
|
public void onLogoutEvent(LogoutEvent event) {
|
||||||
Logger.i("FamilyModel", ResUtil.getString(R.string.family_model_familymodel_02));
|
Logger.i("FamilyModel", ResUtil.getString(R.string.family_model_familymodel_02));
|
||||||
setMyFamily(null);
|
setMyFamily(null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user