forked from tome34/frameDemoMo2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1,整理常用工具类 2,增加retrofit2 网络请求公共参数及文件上传 3,新增mvc模式,简单页面可以使用mvc模式,提高开发效率 4,新增部分自定义常用控件
- Loading branch information
Showing
141 changed files
with
30,262 additions
and
1,806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
184 changes: 184 additions & 0 deletions
184
component_base/src/main/java/com/example/tome/component_base/base/mvc/BaseMVCActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
package com.example.tome.component_base.base.mvc; | ||
|
||
|
||
import android.graphics.Color; | ||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.View; | ||
|
||
import com.example.tome.component_base.base.inter.AbstractPresenter; | ||
import com.example.tome.component_base.base.inter.BaseView; | ||
import com.example.tome.component_base.constants.BaseApplication; | ||
import com.example.tome.component_base.helper.HUDFactory; | ||
import com.example.tome.component_base.util.StatuBarCompat; | ||
import com.example.tome.component_base.util.ToastUtils; | ||
import com.example.tome.component_data.constant.BaseEventbusBean; | ||
import com.kaopiz.kprogresshud.KProgressHUD; | ||
import com.orhanobut.logger.Logger; | ||
|
||
import org.greenrobot.eventbus.EventBus; | ||
import org.greenrobot.eventbus.Subscribe; | ||
import org.greenrobot.eventbus.ThreadMode; | ||
|
||
import butterknife.ButterKnife; | ||
import butterknife.Unbinder; | ||
import io.reactivex.disposables.CompositeDisposable; | ||
import io.reactivex.disposables.Disposable; | ||
|
||
/** | ||
* @Created by TOME . | ||
* @时间 2018/6/26 17:40 | ||
* @描述 ${MVC模式的Base Activity} | ||
*/ | ||
|
||
public abstract class BaseMVCActivity extends AppCompatActivity implements BaseView { | ||
|
||
private Unbinder unBinder; | ||
protected boolean regEvent; | ||
public BaseMVCActivity mActivity ; | ||
public KProgressHUD kProgressHUD; | ||
protected boolean isDestory = false; | ||
//管理事件流订阅的生命周期CompositeDisposable | ||
private CompositeDisposable compositeDisposable; | ||
|
||
public BaseView mView = this; | ||
|
||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(getLayoutId()); | ||
unBinder = ButterKnife.bind(this); | ||
//加入activity管理 | ||
BaseApplication.getAppContext().getActivityControl().addActivity(this); | ||
//沉浸式状态栏 | ||
//setImmeriveStatuBar(); | ||
mActivity = this ; | ||
|
||
initTitle(); | ||
initView(); | ||
if (regEvent){ | ||
EventBus.getDefault().register(this); | ||
} | ||
} | ||
|
||
/** | ||
* 订阅关系 | ||
*/ | ||
protected void addSubscribe(Disposable disposable) { | ||
if (compositeDisposable == null) { | ||
compositeDisposable = new CompositeDisposable(); | ||
} | ||
compositeDisposable.add(disposable); | ||
} | ||
|
||
@Subscribe(threadMode = ThreadMode.MAIN) | ||
public void onMessageEvent(BaseEventbusBean event) { | ||
onEvent(event); | ||
} | ||
|
||
protected void onEvent(BaseEventbusBean event) { | ||
|
||
} | ||
|
||
|
||
|
||
@Override | ||
public void showHUD(String msg) { | ||
if (isDestory){ | ||
return; | ||
} | ||
kProgressHUD = HUDFactory.getInstance().creatHUD(this); | ||
kProgressHUD.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE) | ||
// .setLabel(getString(R.string.loading)) | ||
.setLabel(msg) | ||
// .setLabel(null) | ||
.setCancellable(true) | ||
.setAnimationSpeed(2) | ||
.setDimAmount(0.3f).show(); | ||
} | ||
|
||
@Override | ||
public void dismissHUD() { | ||
if (null != kProgressHUD && kProgressHUD.isShowing()) { | ||
kProgressHUD.dismiss(); | ||
} | ||
} | ||
|
||
/** | ||
* 提示网络请求错误信息 | ||
* @param msg | ||
* @param code | ||
*/ | ||
@Override | ||
public void showError(String msg, String code) { | ||
String mCode ="-1"; | ||
if (mCode.equals(code)){ | ||
ToastUtils.showShort(mActivity, msg); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
Logger.i("当前运行的activity:" + getClass().getName()); | ||
} | ||
|
||
public void back(View v) { | ||
finish(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
//解除订阅关系 | ||
if (compositeDisposable != null) { | ||
compositeDisposable.clear(); | ||
} | ||
|
||
if (unBinder != null) { | ||
unBinder.unbind(); | ||
} | ||
if (regEvent) { | ||
EventBus.getDefault().unregister(this); | ||
} | ||
isDestory = true; | ||
dismissHUD(); | ||
//移除类 | ||
BaseApplication.getAppContext().getActivityControl().removeActivity(this); | ||
|
||
} | ||
|
||
/** | ||
* 沉浸式状态栏 | ||
*/ | ||
protected void setImmeriveStatuBar() { | ||
StatuBarCompat.setImmersiveStatusBar(true, Color.WHITE, this); | ||
|
||
} | ||
|
||
/** | ||
* 获取当前Activity的UI布局 | ||
* | ||
* @return 布局id | ||
*/ | ||
protected abstract int getLayoutId(); | ||
|
||
/** | ||
* 初始化标题 | ||
*/ | ||
protected abstract void initTitle(); | ||
|
||
/** | ||
* 初始化数据 | ||
*/ | ||
protected abstract void initView(); | ||
|
||
/** | ||
* 加载数据 | ||
*/ | ||
protected abstract void loadData(); | ||
|
||
} |
Oops, something went wrong.