/ UI

A powerful multi-function library that extended base activity for Android

A powerful multi-function library that extended base activity for Android

MeiBaseModule

A powerful multi-function library that extended base activity for Android!

Usage

Step 1. Add the JitPack repository to your build file

root gradle

    allprojects {
        repositories {
            ...
            maven { url "https://jitpack.io" }
        }
    }

Step 2. Add the dependency

app gradle

	dependencies {
	        compile 'com.github.HpWens:MeiBaseModule:1.0.5'
	}

Step 3. extends MeiBase_

Activity extends MeiBaseActivity , Fragment extends MeiBaseFragment , Dialog extends MeiBaseDialog

Preview

demo4

demo5

demo3

demo2

demo1

Example

//效果见图2
@PullToRefresh  // 一行代码 注入下拉刷新功能
@PullToLoadMore // 注入上拉加载
public class PullRefreshActivity extends BaseActivity {
// 需要继承 BaseActivity ; 同理 Fragment 继承 BaseFragment ; Dialog 继承 BaseDialog 

    @Override
    protected void initView() {
    //抽象方法,必须被重写 初始化控件 调用的先后顺序 initView  ->  initData
    }

    @Override
    protected void initData() {
    //抽象方法,必须被重写 初始化数据
        getToolbarView().setTitle(getResources().getString(R.string.refresh));
        getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp);
        getToolbarView().setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        
        //初始显示空界面(可以配置空界面的图标和文本)
        setState(ViewState.EMPTY, new Object[]{getString(R.string.drag_refresh)});
    }

    @Override
    protected int layoutResId() {
    //抽象方法
        return 0;
    }

    @Override
    protected void onRefreshing() { //正在刷新
        super.onRefreshing();
        //rx方式(移除订阅防止泄露)
        postUiThread(2000, new UiSubscriber<Long>() {
            @Override
            public void onCompleted() {
                Toast.makeText(PullRefreshActivity.this, getResources().getString(R.string
                        .mei_refresh_success), Toast.LENGTH_SHORT).show();
                PullRefreshActivity.this.setRefreshing(false);
            }
        });
    }

    @Override
    protected void onLoadingMore() { //正在加载更多
        super.onLoadingMore();
        postUiThread(2000, new UiSubscriber<Long>() {
            @Override
            public void onCompleted() {
                Toast.makeText(PullRefreshActivity.this, getResources().getString(R.string
                        .mei_refresh_success), Toast.LENGTH_SHORT).show();
                PullRefreshActivity.this.setLoadingMore(false);
            }
        });
    }
}

GitHub