Skip to content

Commit

Permalink
2018.6.26
Browse files Browse the repository at this point in the history
1,整理常用工具类
2,增加retrofit2 网络请求公共参数及文件上传
3,新增mvc模式,简单页面可以使用mvc模式,提高开发效率
4,新增部分自定义常用控件
  • Loading branch information
tome34 committed Jun 26, 2018
1 parent eaa0b77 commit 4e01d18
Show file tree
Hide file tree
Showing 141 changed files with 30,262 additions and 1,806 deletions.
10 changes: 10 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ android {
arguments = [moduleName: project.getName()]
}
}

sourceSets {
//设置依赖so库路径
main.jniLibs.srcDirs = ['libs']
}

ndk {
// 设置支持的SO库架构
abiFilters 'armeabi' //, 'x86', 'armeabi-v7a', 'x86_64', 'arm64-v8a'
}
}
buildTypes {
release {
Expand Down
4 changes: 3 additions & 1 deletion component_base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ dependencies {
//安卓调试神器-Stetho
api rootProject.ext.dependencies["stetho"]
api rootProject.ext.dependencies["stetho-okhttp3"]

//bugly sdk
api rootProject.ext.dependencies["tencent-bugly"]


implementation project(':component_data')
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;

import com.example.tome.component_base.util.CollectionUtils;
import com.example.tome.component_base.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -49,7 +49,7 @@ public void setFragments(FragmentManager fm, List<Fragment> fragments, List<Stri

@Override
public CharSequence getPageTitle(int position) {
return !CollectionUtils.isNullOrEmpty(mTitles) ? mTitles.get(position) : "";
return !ObjectUtils.isEmpty(mTitles) ? mTitles.get(position) : "";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.example.tome.component_base.util.CollectionUtils;

import com.example.tome.component_base.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -34,7 +35,7 @@ public BaseFragmentStateAdapter(FragmentManager fm, List<Fragment> fragmentList,
}
@Override
public CharSequence getPageTitle(int position) {
return !CollectionUtils.isNullOrEmpty(mTitles) ? mTitles.get(position) : "";
return !ObjectUtils.isEmpty(mTitles) ? mTitles.get(position) : "";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import android.widget.Toast;


import com.example.tome.component_base.R;
import com.example.tome.component_base.base.inter.BaseView;
import com.example.tome.component_base.base.inter.ILoadingDialogView;
import com.example.tome.component_base.util.ActivityUtil;
import com.example.tome.component_base.util.ActivityUtils;
import com.example.tome.component_base.util.L;
import com.example.tome.component_base.util.NetUtils;
import com.example.tome.component_data.ServerException.ServerException;
import com.example.tome.component_data.bean.BaseObj;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import io.reactivex.observers.ResourceObserver;
Expand All @@ -25,10 +23,10 @@
* @param <T>
*/

//public abstract class BaseObserver<R,T extends BaseObj<R>> extends ResourceObserver<T> {
//public abstract class BaseObserver<R,ToastUtils extends BaseObj<R>> extends ResourceObserver<ToastUtils> {
public abstract class BaseObserver<T> extends ResourceObserver<T> {
//public abstract class BaseObserver<T> extends DisposableObserver<T> {
//public abstract class BaseObserver<T> implements Observer<T> {
//public abstract class BaseObserver<ToastUtils> extends DisposableObserver<ToastUtils> {
//public abstract class BaseObserver<ToastUtils> implements Observer<ToastUtils> {

private BaseView mView;
private String mErrorMsg;
Expand Down Expand Up @@ -62,7 +60,7 @@ protected BaseObserver(BaseView view, SmartRefreshLayout rlRefresh ,boolean isSh


/* @Override
public void onNext(T t) {
public void onNext(ToastUtils t) {
if (t.getCode().equals("0")){
onNextSuccess(t.getData());
}else {
Expand Down Expand Up @@ -103,7 +101,7 @@ protected void onStart() {
mDialogView.showHUD(msg);
}

Activity currentActivity = ActivityUtil.getInstance().currentActivity();
Activity currentActivity = ActivityUtils.getInstance().currentActivity();
if (currentActivity != null && !NetUtils.isNetConnected(currentActivity)) {
Toast.makeText(currentActivity, "当前无网络", Toast.LENGTH_SHORT).show();
onComplete();
Expand Down
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();

}
Loading

0 comments on commit 4e01d18

Please sign in to comment.