GithubHelp home page GithubHelp logo

hpwens / meibasemodule Goto Github PK

View Code? Open in Web Editor NEW
77.0 4.0 15.0 25.95 MB

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

License: Apache License 2.0

Java 100.00%
baseactivity basefragment basedialog baseadapter refreshlayout android android-library

meibasemodule's Introduction

Hex.pm Hex.pm

MeiBaseModule

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

引入

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

Feature

1. 支持网络错误,空数据,正在加载,自定义等状态界面(一行代码切换状态)

2. 注入的方式实现下拉刷新,上拉加载(一行代码)且支持自定义下拉刷新样式

3. 支持单类型,多类型列表

4. 支持"单Activity + 多Fragment","多模块Activity + 多Fragment"

5. 支持透明状态栏

6. 支持软键盘的状态监听

7. 支持软键盘触摸非输入区域自动隐藏

8. 实现可拖动的底部提示框

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);
            }
        });
    }
}

LICENSE

Copyright 2018 文淑

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

meibasemodule's People

Contributors

hpwens avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

meibasemodule's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.