Commit e85544c8 by 罗翻

mactivity.finish替换为mview.dumpback

parent 0765eacd
......@@ -63,7 +63,7 @@ public abstract class BaseActivity<P extends BasePresenter, B extends ViewDataBi
ProgressUtil.stopLoad();
}
public void dumbBack() {
public void dumpBack() {
mActivity.finish();
}
......
......@@ -40,6 +40,10 @@ public abstract class BaseFragment<P extends BasePresenter, B extends ViewDataBi
if (mPresenter != null) mPresenter.onDetached();
}
public void dumpBack() {
mActivity.finish();
}
public void showToast(int resId) {
ToastUtils.showShortToast(resId);
}
......
......@@ -163,7 +163,7 @@ public abstract class BasePresenter<V> {
public void dumpBack() {
if (mView instanceof BaseActivity) {
((BaseActivity) mView).dumbBack();
((BaseActivity) mView).dumpBack();
}
}
}
......@@ -17,6 +17,8 @@ public interface BaseView {
void hideDialog();
void dumpBack();
void startActivity(Class cls);
void startActivity(Class<?> clz, Bundle bundle);
......
......@@ -60,7 +60,7 @@ public class WithdrawalsPresenter extends WithdrawalsContract.Presenter {
@Override
public void accept(Boolean aBoolean) throws Exception {
mView.showToast(R.string.comfirm_alipay_account_success);
mActivity.finish();
mView.dumpBack();
}
}));
}
......@@ -71,7 +71,7 @@ public class WithdrawalsPresenter extends WithdrawalsContract.Presenter {
@Override
public void accept(Boolean aBoolean) throws Exception {
mView.showToast(R.string.modify_alipay_account_success);
mActivity.finish();
mView.dumpBack();
}
}));
}
......
......@@ -10,7 +10,6 @@ import com.dayu.bigfish.base.BaseView;
public interface AccountBalanceContract {
interface View extends BaseView {
}
abstract class Presenter extends BaseListPresenter<View> {
......
package com.dayu.bigfish.presenter.accountbalance;
import android.content.Intent;
import android.databinding.ObservableField;
import com.app.annotation.apt.InstanceFactory;
......@@ -62,7 +61,6 @@ public class AccountBalancePresenter extends AccountBalanceContract.Presenter {
@Override
public void dumpToWithdrawal() {
Intent intent = new Intent(mActivity, WithdrawalsActivity.class);
mActivity.startActivity(intent);
mView.startActivity(WithdrawalsActivity.class);
}
}
......@@ -58,7 +58,7 @@ public class FeedBackPresenter extends FeedBackContract.Presenter {
@Override
public void accept(Boolean aBoolean) throws Exception {
mView.showToast(R.string.commite_success);
mActivity.finish();
mView.dumpBack();
}
}));
}
......
......@@ -55,8 +55,8 @@ public class MainPresenter extends MainContract.Presenter {
}
private void request() {
commitVersionInfo(mAccountId, AppUtils.getIMEI(mActivity), "2", AppUtils.getPackageNum(mActivity));
getNewVersion(AppUtils.getPackageNum(mActivity));
commitVersionInfo(mAccountId, AppUtils.getIMEI(), "2", AppUtils.getPackageNum());
getNewVersion(AppUtils.getPackageNum());
getReceiveOrder(Constants.WATING_ORDER, mAccountId, mSiteId, 1, 20);
getHxNum(mUser.getHxAccount());
}
......@@ -86,7 +86,7 @@ public class MainPresenter extends MainContract.Presenter {
@Override
public void commitVersionInfo(int accoutId, String imei, String platform, String versionCode) {
if (SPUtils.get(Constants.OLD_PAKAGENUM, "").equals(mActivity.getPackageName())) {
if (SPUtils.get(Constants.OLD_PAKAGENUM, "").equals(MyApplication.getAppContext().getPackageName())) {
return;
}
JSONObject jsonObject = new JSONObject();
......@@ -102,7 +102,7 @@ public class MainPresenter extends MainContract.Presenter {
ApiFactory.commitVersionInfo(requestBody).subscribe(baseObserver(new Consumer<Boolean>() {
@Override
public void accept(Boolean aBoolean) throws Exception {
SPUtils.put(Constants.OLD_PAKAGENUM, mActivity.getPackageName());
SPUtils.put(Constants.OLD_PAKAGENUM, MyApplication.getAppContext().getPackageName());
}
}));
}
......@@ -164,7 +164,7 @@ public class MainPresenter extends MainContract.Presenter {
MobclickAgent.onEvent(MyApplication.getContext(), "sure_update_app");
} else {
if (info.getType() == 2) {
mActivity.finish();
mView.dumpBack();
}
MobclickAgent.onEvent(MyApplication.getContext(), "cancle_update_app");
}
......
......@@ -9,6 +9,7 @@ import android.text.TextUtils;
import com.app.annotation.apt.InstanceFactory;
import com.apt.ApiFactory;
import com.dayu.bigfish.Constants;
import com.dayu.bigfish.MyApplication;
import com.dayu.bigfish.R;
import com.dayu.bigfish.bean.OrderDetail;
import com.dayu.bigfish.bean.UserInfo;
......@@ -100,7 +101,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
mOrderField.get().setOtherPrice("");
mOrderField.get().setOtherInfo("");
}
MobclickAgent.onEvent(mActivity, "get_customer_money");
MobclickAgent.onEvent(MyApplication.getContext(), "get_customer_money");
}
@Override
......@@ -160,7 +161,7 @@ public class ProcessOrderPresenter extends ProcessOrderContract.Presenter {
EventBus.getDefault().post(new OrderState(status, mPosition));
mOrderInfoDao.deleteByKey((long) orderId);
PictureFileUtils.deleteCacheDirFile(mActivity);
mActivity.finish();
mView.dumpBack();
}
}));
}
......
......@@ -82,7 +82,7 @@ public class ReceivingPresenter extends ReceivingContract.Presenter {
int num = mTotalRows - 1;
mView.showToast(R.string.receive_order_success);
EventBus.getDefault().post(new SwtichFragment(1));
mActivity.finish();
mView.dumpBack();
mDisPosable = Observable.timer(300, TimeUnit.MILLISECONDS).subscribe(aLong -> {
EventBus.getDefault().post(new RefreshTab(0));
EventBus.getDefault().post(new RefreshReceivingNum(num < 0 ? 0 : num));
......
......@@ -10,6 +10,7 @@ import android.text.TextUtils;
import com.app.annotation.apt.InstanceFactory;
import com.apt.ApiFactory;
import com.dayu.bigfish.Constants;
import com.dayu.bigfish.MyApplication;
import com.dayu.bigfish.R;
import com.dayu.bigfish.bean.UserInfo;
import com.dayu.bigfish.ui.AboutUsActivity;
......@@ -72,7 +73,7 @@ public class SettingPresenter extends SettingContract.Presenter {
} else {
EMClient.getInstance().logout(true);
}
MobclickAgent.onEvent(mActivity, "swtich_message_button");
MobclickAgent.onEvent(MyApplication.getContext(), "swtich_message_button");
}
......@@ -81,7 +82,7 @@ public class SettingPresenter extends SettingContract.Presenter {
ApiFactory.checkVersion("dayushifua_dayu").subscribe(baseObserver(new Consumer<String>() {
@Override
public void accept(String s) throws Exception {
if (s.equals(AppUtils.getPackageNum(mActivity))) {
if (s.equals(AppUtils.getPackageNum())) {
mView.showToast(R.string.is_newversion);
} else {
mView.showToast(mActivity.getString(R.string.newversion_code) + s);
......
......@@ -102,7 +102,7 @@ public class SubcribeTimePresenter extends SubcribeContract.Presenter {
} else if (mState == ORDER_YUYUE || mState == ORDER_DOING) {
EventBus.getDefault().post(new OrderState(ORDER_YUYUE, mPosition, mTime));
}
mActivity.finish();
mView.dumpBack();
}
}, responeThrowable -> {
if ("ORDER0004".equals(responeThrowable.subCode)) {
......@@ -113,7 +113,7 @@ public class SubcribeTimePresenter extends SubcribeContract.Presenter {
EventBus.getDefault().post(new RefreshTab(3));
EventBus.getDefault().post(new RefreshServe(1));
}
mActivity.finish();
mView.dumpBack();
}
}));
}
......
package com.dayu.bigfish.utils;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.telephony.TelephonyManager;
import com.dayu.bigfish.MyApplication;
/**
* Created by luofan on 2017/11/7.
*/
public class AppUtils {
public static final int REQUEST_PHONE_STATE_PERMISSION = 0;
/**
* 获取设备IMEI编号
*/
public static String getIMEI(Context context) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE);
public static String getIMEI() {
TelephonyManager telephonyManager = (TelephonyManager) MyApplication.getAppContext().getSystemService(MyApplication.getAppContext().TELEPHONY_SERVICE);
String imei = telephonyManager.getDeviceId();
return imei;
......@@ -28,9 +27,9 @@ public class AppUtils {
/**
* 获取当前应用的版本号
*/
public static String getPackageNum(Context context) {
public static String getPackageNum() {
try {
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
PackageInfo packageInfo = MyApplication.getAppContext().getPackageManager().getPackageInfo(MyApplication.getAppContext().getPackageName(), 0);
String packageName = packageInfo.versionName;
return packageName;
} catch (PackageManager.NameNotFoundException e) {
......
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 sign in to comment