├── .gitignore ├── .idea ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── meis │ │ └── basemodule │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── meis │ │ │ └── basemodule │ │ │ ├── MainActivity.java │ │ │ ├── activity │ │ │ ├── MainActivity.java │ │ │ └── ui │ │ │ │ ├── CustomEmptyActivity.java │ │ │ │ ├── MultiListActivity.java │ │ │ │ ├── PullRefreshActivity.java │ │ │ │ ├── SingleListActivity.java │ │ │ │ ├── StatusActivity.java │ │ │ │ └── TranslucentActivity.java │ │ │ ├── adapter │ │ │ ├── ChatAdapter.java │ │ │ ├── ChatRightAdapter.java │ │ │ ├── FirstHomeAdapter.java │ │ │ ├── MeiSimpleAdapter.java │ │ │ ├── MultiAdapter.java │ │ │ ├── MultiAdapter1.java │ │ │ ├── MultiAdapter2.java │ │ │ ├── MultiAdapter3.java │ │ │ └── ZhihuPagerFragmentAdapter.java │ │ │ ├── base │ │ │ ├── BaseActivity.java │ │ │ ├── BaseDialog.java │ │ │ ├── BaseFragment.java │ │ │ ├── BaseListActivity.java │ │ │ └── BaseListFragment.java │ │ │ ├── constant │ │ │ └── DataConstants.java │ │ │ ├── dialog │ │ │ ├── BottomCommentDialog.java │ │ │ ├── CreateLiveDialog.java │ │ │ └── MainActivity.java │ │ │ ├── entity │ │ │ ├── Article.java │ │ │ ├── Chat.java │ │ │ ├── MultiBean.java │ │ │ ├── MultiBean1.java │ │ │ ├── MultiBean2.java │ │ │ ├── MultiBean3.java │ │ │ └── Result.java │ │ │ ├── fragment │ │ │ ├── MainActivity.java │ │ │ ├── MainFragment.java │ │ │ └── ui │ │ │ │ ├── first │ │ │ │ ├── FirstDetailFragment.java │ │ │ │ ├── FirstHomeFragment.java │ │ │ │ └── ZhihuFirstFragment.java │ │ │ │ ├── fourth │ │ │ │ └── ZhihuFourthFragment.java │ │ │ │ ├── second │ │ │ │ ├── OtherPagerFragment.java │ │ │ │ └── ZhihuSecondFragment.java │ │ │ │ └── third │ │ │ │ ├── MsgFragment.java │ │ │ │ └── ZhihuThirdFragment.java │ │ │ ├── utils │ │ │ └── ListUtils.java │ │ │ └── widget │ │ │ ├── BottomBar.java │ │ │ └── BottomBarTab.java │ └── res │ │ ├── anim │ │ ├── comm_bottom_in.xml │ │ ├── comm_bottom_out.xml │ │ └── live_btn_bottom_in.xml │ │ ├── drawable-hdpi │ │ ├── chatfrom_bg_normal.9.png │ │ └── chatto_bg_normal.9.png │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable-xxhdpi │ │ ├── actionbar_shadow_up.9.png │ │ ├── bg_second.png │ │ ├── ic_account_circle_white_24dp.png │ │ ├── ic_avatar.png │ │ ├── ic_discover_white_24dp.png │ │ ├── ic_home_white_24dp.png │ │ └── ic_message_white_24dp.png │ │ ├── drawable │ │ ├── bg_chat_input.xml │ │ ├── bg_chat_right.9.png │ │ ├── comm_btn_close_gray.xml │ │ ├── ic_create_live.xml │ │ ├── ic_create_shortvideo.xml │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_custom_base_empty.xml │ │ ├── activity_dialog.xml │ │ ├── activity_fragment.xml │ │ ├── activity_main.xml │ │ ├── activity_module.xml │ │ ├── activity_translucent.xml │ │ ├── comm_bottom_comment.xml │ │ ├── comm_recycler.xml │ │ ├── dialog_bottom_live.xml │ │ ├── item_comm.xml │ │ ├── item_image_view.xml │ │ ├── item_section_content.xml │ │ ├── item_text_view.xml │ │ ├── item_zhihu_chat.xml │ │ ├── item_zhihu_home_first.xml │ │ ├── item_zhihu_msg.xml │ │ ├── zhihu_activity_main.xml │ │ ├── zhihu_fragment_first.xml │ │ ├── zhihu_fragment_first_detail.xml │ │ ├── zhihu_fragment_second.xml │ │ ├── zhihu_fragment_tab_first_msg.xml │ │ └── zhihu_fragment_tab_second_pager.xml │ │ ├── menu │ │ ├── custime_type.xml │ │ ├── refresh_type.xml │ │ └── type.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_arrow_back_white_24dp.png │ │ ├── ic_btn_close_gray_normal.png │ │ ├── ic_btn_close_gray_pressed.png │ │ ├── ic_create_live_normal.png │ │ ├── ic_create_live_pressed.png │ │ ├── ic_create_shortvideo_normal.png │ │ ├── ic_create_shortvideo_pressed.png │ │ ├── ic_empty_page.png │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── bg_fifth.png │ │ ├── bg_first.webp │ │ ├── bg_fourth.webp │ │ ├── bg_second.webp │ │ ├── bg_third.webp │ │ ├── ic_arrow_back_white_24dp.png │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── meis │ └── basemodule │ └── ExampleUnitTest.java ├── base ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── meis │ │ └── base │ │ └── mei │ │ ├── IMeiCompatActivity.java │ │ ├── MeiCompatActivity.java │ │ ├── MeiCompatActivityDelegate.java │ │ ├── adapter │ │ ├── IUpdatable.java │ │ ├── ItemPresenter.java │ │ ├── MeiBaseAdapter.java │ │ ├── MeiBaseMixAdapter.java │ │ └── MultiItemPresenter.java │ │ ├── annotation │ │ ├── PullToLoadMore.java │ │ └── PullToRefresh.java │ │ ├── dialog │ │ ├── IMeiCompatDialog.java │ │ ├── MeiCompatDialog.java │ │ └── MeiCompatDialogDelegate.java │ │ ├── fragment │ │ ├── IMeiCompatFragment.java │ │ ├── MeiCompatFragment.java │ │ └── MeiCompatFragmentDelegate.java │ │ ├── header │ │ └── DingDangHeader.java │ │ ├── status │ │ ├── IStatusHelper.java │ │ ├── StatusHelper.java │ │ └── ViewState.java │ │ └── utils │ │ ├── Eyes.java │ │ ├── EyesKitKat.java │ │ ├── EyesLollipop.java │ │ └── SoftKeyboardUtils.java │ └── res │ ├── anim │ └── mei_fade_out.xml │ ├── drawable │ └── mei_dingdang_refresh_loading_list.xml │ ├── layout │ ├── mei_base.xml │ ├── mei_base_empty_stub.xml │ ├── mei_base_error_stub.xml │ ├── mei_base_loading_stub.xml │ ├── mei_base_with_refresh.xml │ ├── mei_dingdang_refresh_header.xml │ ├── mei_empty_item.xml │ └── mei_toolbar.xml │ ├── mipmap-xhdpi │ ├── mei_comm_ic_empty.png │ ├── mei_comm_ic_error.png │ ├── mei_refresh_loading_01.png │ ├── mei_refresh_loading_02.png │ ├── mei_refresh_loading_03.png │ ├── mei_refresh_loading_04.png │ ├── mei_refresh_loading_05.png │ ├── mei_refresh_loading_06.png │ ├── mei_refresh_loading_07.png │ ├── mei_refresh_loading_08.png │ ├── mei_refresh_loading_09.png │ ├── mei_refresh_loading_10.png │ ├── mei_refresh_loading_11.png │ ├── mei_refresh_loading_12.png │ ├── mei_refresh_loading_13.png │ ├── mei_refresh_loading_14.png │ ├── mei_refresh_loading_15.png │ ├── mei_refresh_loading_16.png │ ├── mei_refresh_loading_17.png │ ├── mei_refresh_loading_18.png │ ├── mei_refresh_loading_19.png │ ├── mei_refresh_loading_20.png │ ├── mei_refresh_loading_21.png │ ├── mei_refresh_loading_22.png │ ├── mei_refresh_loading_23.png │ ├── mei_refresh_loading_24.png │ ├── mei_refresh_loading_25.png │ ├── mei_refresh_loading_26.png │ ├── mei_refresh_loading_27.png │ ├── mei_refresh_loading_28.png │ ├── mei_refresh_loading_29.png │ ├── mei_refresh_loading_30.png │ ├── mei_refresh_loading_31.png │ ├── mei_refresh_loading_32.png │ ├── mei_refresh_loading_33.png │ ├── mei_refresh_loading_34.png │ └── mei_refresh_loading_35.png │ ├── values-zh │ └── strings.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── mei_attrs.xml │ ├── mei_style.xml │ ├── strings.xml │ └── themes.xml ├── build.gradle ├── gif ├── demo1.gif ├── demo2.gif ├── demo3.gif ├── demo4.gif └── demo5.gif ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | ### Android template 3 | # Built application files 4 | *.apk 5 | *.ap_ 6 | .idea 7 | 8 | # Files for the ART/Dalvik VM 9 | *.dex 10 | 11 | # Java class files 12 | *.class 13 | 14 | # Generated files 15 | bin/ 16 | gen/ 17 | out/ 18 | 19 | # Gradle files 20 | .gradle/ 21 | build/ 22 | 23 | # Local configuration file (sdk path, etc) 24 | local.properties 25 | 26 | # Proguard folder generated by Eclipse 27 | proguard/ 28 | 29 | # Log Files 30 | *.log 31 | 32 | # Android Studio Navigation editor temp files 33 | .navigation/ 34 | 35 | # Android Studio captures folder 36 | captures/ 37 | 38 | # IntelliJ 39 | *.iml 40 | .idea/workspace.xml 41 | .idea/tasks.xml 42 | .idea/gradle.xml 43 | .idea/dictionaries 44 | .idea/libraries 45 | 46 | # Keystore files 47 | # Uncomment the following line if you do not want to check your keystore files in. 48 | #*.jks 49 | 50 | # External native build folder generated in Android Studio 2.2 and later 51 | .externalNativeBuild 52 | 53 | # Google Services (e.g. APIs or Firebase) 54 | google-services.json 55 | 56 | # Freeline 57 | freeline.py 58 | freeline/ 59 | freeline_project_description.json 60 | 61 | build 62 | 63 | 64 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 41 | 42 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 62 | 63 | 64 | 65 | 66 | 1.8 67 | 68 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![](https://jitpack.io/v/HpWens/MeiBaseModule.svg)](https://jitpack.io/#HpWens/MeiBaseModule) 2 | [![](https://img.shields.io/scrutinizer/build/g/filp/whoops.svg)](https://blog.csdn.net/u012551350/) 3 | [![Hex.pm](https://img.shields.io/hexpm/l/plug.svg)](https://www.apache.org/licenses/LICENSE-2.0) 4 | [![Hex.pm](https://img.shields.io/github/stars/HpWens/MeiBaseModule.svg)](https://github.com/HpWens/MeiBaseModule) 5 | 6 | # MeiBaseModule 7 | A powerful multi-function library that extended base activity for Android! 8 | 9 | ## 引入 10 | 11 | ### Step 1. Add the JitPack repository to your build file 12 | 13 | root gradle 14 | 15 | ```` 16 | allprojects { 17 | repositories { 18 | ... 19 | maven { url "https://jitpack.io" } 20 | } 21 | } 22 | 23 | ```` 24 | 25 | ### Step 2. Add the dependency 26 | 27 | app gradle 28 | 29 | ```` 30 | dependencies { 31 | compile 'com.github.HpWens:MeiBaseModule:1.0.5' 32 | } 33 | ```` 34 | 35 | ### Step 3. extends MeiBase_ 36 | 37 | Activity extends MeiBaseActivity , Fragment extends MeiBaseFragment , Dialog extends MeiBaseDialog 38 | 39 | ## Preview 40 | 41 | 42 | 43 | 44 | 45 | ## Feature 46 | 47 | **1. 支持网络错误,空数据,正在加载,自定义等状态界面(一行代码切换状态)** 48 | 49 | **2. 注入的方式实现下拉刷新,上拉加载(一行代码)且支持自定义下拉刷新样式** 50 | 51 | **3. 支持单类型,多类型列表** 52 | 53 | **4. 支持"单Activity + 多Fragment","多模块Activity + 多Fragment"** 54 | 55 | **5. 支持透明状态栏** 56 | 57 | **6. 支持软键盘的状态监听** 58 | 59 | **7. 支持软键盘触摸非输入区域自动隐藏** 60 | 61 | **8. 实现可拖动的底部提示框** 62 | 63 | ## Example 64 | 65 | ```` 66 | //效果见图2 67 | @PullToRefresh // 一行代码 注入下拉刷新功能 68 | @PullToLoadMore // 注入上拉加载 69 | public class PullRefreshActivity extends BaseActivity { 70 | // 需要继承 BaseActivity ; 同理 Fragment 继承 BaseFragment ; Dialog 继承 BaseDialog 71 | 72 | @Override 73 | protected void initView() { 74 |    //抽象方法,必须被重写 初始化控件 调用的先后顺序 initView -> initData 75 |    } 76 | 77 | @Override 78 | protected void initData() { 79 |    //抽象方法,必须被重写 初始化数据 80 |        getToolbarView().setTitle(getResources().getString(R.string.refresh)); 81 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 82 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View v) { 85 | finish(); 86 | } 87 | }); 88 | 89 |        //初始显示空界面(可以配置空界面的图标和文本) 90 |        setState(ViewState.EMPTY, new Object[]{getString(R.string.drag_refresh)}); 91 | } 92 | 93 | @Override 94 | protected int layoutResId() { 95 | //抽象方法 96 | return 0; 97 | } 98 | 99 | @Override 100 |    protected void onRefreshing() { //正在刷新 101 |        super.onRefreshing(); 102 |        //rx方式(移除订阅防止泄露) 103 |        postUiThread(2000, new UiSubscriber() { 104 | @Override 105 | public void onCompleted() { 106 | Toast.makeText(PullRefreshActivity.this, getResources().getString(R.string 107 | .mei_refresh_success), Toast.LENGTH_SHORT).show(); 108 | PullRefreshActivity.this.setRefreshing(false); 109 | } 110 | }); 111 | } 112 | 113 | @Override 114 |    protected void onLoadingMore() { //正在加载更多 115 |        super.onLoadingMore(); 116 | postUiThread(2000, new UiSubscriber() { 117 | @Override 118 | public void onCompleted() { 119 | Toast.makeText(PullRefreshActivity.this, getResources().getString(R.string 120 | .mei_refresh_success), Toast.LENGTH_SHORT).show(); 121 | PullRefreshActivity.this.setLoadingMore(false); 122 | } 123 | }); 124 | } 125 | } 126 | 127 | ```` 128 | 129 | 130 | ## LICENSE 131 | ```` 132 | Copyright 2018 文淑 133 | 134 | Licensed under the Apache License, Version 2.0 (the "License"); 135 | you may not use this file except in compliance with the License. 136 | You may obtain a copy of the License at 137 | 138 | http://www.apache.org/licenses/LICENSE-2.0 139 | 140 | Unless required by applicable law or agreed to in writing, software 141 | distributed under the License is distributed on an "AS IS" BASIS, 142 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 143 | See the License for the specific language governing permissions and 144 | limitations under the License. 145 | ```` 146 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | ### Android template 3 | # Built application files 4 | *.apk 5 | *.ap_ 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # IntelliJ 38 | *.iml 39 | .idea/workspace.xml 40 | .idea/tasks.xml 41 | .idea/gradle.xml 42 | .idea/dictionaries 43 | .idea/libraries 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 26 5 | defaultConfig { 6 | applicationId "com.meis.basemodule" 7 | minSdkVersion 18 8 | targetSdkVersion 26 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(include: ['*.jar'], dir: 'libs') 23 | implementation 'com.android.support:appcompat-v7:26.1.0' 24 | implementation 'com.android.support.constraint:constraint-layout:1.0.2' 25 | implementation project(':base') 26 | //RxPermissions 27 | compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.5@aar' 28 | implementation 'com.android.support:recyclerview-v7:26.1.0' 29 | compile "com.android.support:design:26.1.0" 30 | compile "com.android.support:cardview-v7:26.1.0" 31 | 32 | //compile 'com.github.HpWens:MeiBaseModule:1.0.1' 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/meis/basemodule/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.meis.basemodule", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule; 2 | 3 | import android.content.Intent; 4 | import android.view.View; 5 | 6 | import com.meis.basemodule.base.BaseActivity; 7 | 8 | public class MainActivity extends BaseActivity { 9 | 10 | @Override 11 | protected int layoutResId() { 12 | return R.layout.activity_main; 13 | } 14 | 15 | @Override 16 | protected void initView() { 17 | } 18 | 19 | @Override 20 | protected void initData() { 21 | getToolbarView().setTitle("BaseModule"); 22 | } 23 | 24 | public void clickActivity(View view) { 25 | startActivity(new Intent(this, com.meis.basemodule.activity.MainActivity.class)); 26 | } 27 | 28 | public void clickFragment(View view) { 29 | startActivity(new Intent(this, com.meis.basemodule.fragment.MainActivity.class)); 30 | } 31 | 32 | public void clickDialog(View view) { 33 | startActivity(new Intent(this, com.meis.basemodule.dialog.MainActivity.class)); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity; 2 | 3 | import android.content.Intent; 4 | import android.view.View; 5 | 6 | import com.meis.basemodule.R; 7 | import com.meis.basemodule.activity.ui.CustomEmptyActivity; 8 | import com.meis.basemodule.activity.ui.MultiListActivity; 9 | import com.meis.basemodule.activity.ui.PullRefreshActivity; 10 | import com.meis.basemodule.activity.ui.SingleListActivity; 11 | import com.meis.basemodule.activity.ui.StatusActivity; 12 | import com.meis.basemodule.activity.ui.TranslucentActivity; 13 | import com.meis.basemodule.base.BaseActivity; 14 | 15 | /** 16 | * author: ws4 17 | * created on: 2018/4/11 15:04 18 | * description: 19 | */ 20 | public class MainActivity extends BaseActivity { 21 | @Override 22 | protected void initView() { 23 | 24 | } 25 | 26 | @Override 27 | protected void initData() { 28 | getToolbarView().setTitle(getResources().getString(R.string.activity_module)); 29 | } 30 | 31 | @Override 32 | protected int layoutResId() { 33 | return R.layout.activity_module; 34 | } 35 | 36 | public void clickStatus(View view) { 37 | startActivity(new Intent(this, StatusActivity.class)); 38 | } 39 | 40 | public void clickCusStatus(View view) { 41 | startActivity(new Intent(this, CustomEmptyActivity.class)); 42 | } 43 | 44 | public void clickPullRefresh(View view) { 45 | startActivity(new Intent(this, PullRefreshActivity.class)); 46 | } 47 | 48 | public void clickSingleList(View view) { 49 | startActivity(new Intent(this, SingleListActivity.class)); 50 | } 51 | 52 | public void clickMultiList(View view) { 53 | startActivity(new Intent(this, MultiListActivity.class)); 54 | } 55 | 56 | public void clickTranslucent(View view) { 57 | startActivity(new Intent(this, TranslucentActivity.class)); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/ui/CustomEmptyActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity.ui; 2 | 3 | import android.view.View; 4 | 5 | import com.meis.base.mei.status.ViewState; 6 | import com.meis.basemodule.R; 7 | import com.meis.basemodule.base.BaseActivity; 8 | 9 | /** 10 | * author: ws4 11 | * created on: 2018/4/11 15:31 12 | * description: 13 | */ 14 | public class CustomEmptyActivity extends BaseActivity { 15 | @Override 16 | protected void initView() { 17 | 18 | } 19 | 20 | @Override 21 | protected void initData() { 22 | getToolbarView().setTitle(getResources().getString(R.string.cus_status_type)); 23 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 24 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 25 | @Override 26 | public void onClick(View v) { 27 | finish(); 28 | } 29 | }); 30 | // setEmptyLayout 在 setState 方法之前调用 31 | setEmptyLayout(R.layout.activity_custom_base_empty); 32 | setState(ViewState.EMPTY); 33 | } 34 | 35 | @Override 36 | protected int layoutResId() { 37 | return 0; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/ui/MultiListActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity.ui; 2 | 3 | import android.support.v7.widget.GridLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | import com.chad.library.adapter.base.BaseQuickAdapter; 8 | import com.meis.base.mei.adapter.MeiBaseAdapter; 9 | import com.meis.base.mei.adapter.MeiBaseMixAdapter; 10 | import com.meis.basemodule.R; 11 | import com.meis.basemodule.adapter.MultiAdapter; 12 | import com.meis.basemodule.adapter.MultiAdapter1; 13 | import com.meis.basemodule.adapter.MultiAdapter2; 14 | import com.meis.basemodule.adapter.MultiAdapter3; 15 | import com.meis.basemodule.base.BaseListActivity; 16 | import com.meis.basemodule.entity.MultiBean; 17 | import com.meis.basemodule.entity.MultiBean1; 18 | import com.meis.basemodule.entity.MultiBean2; 19 | import com.meis.basemodule.entity.MultiBean3; 20 | import com.meis.basemodule.entity.Result; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | import io.reactivex.Observable; 26 | 27 | /** 28 | * author: ws4 29 | * created on: 2018/4/11 15:33 30 | * description: 31 | */ 32 | public class MultiListActivity extends BaseListActivity { 33 | 34 | RecyclerView mRecyclerView; 35 | MeiBaseMixAdapter mAdapter; 36 | 37 | @Override 38 | protected void initData() { 39 | getToolbarView().setTitle(getResources().getString(R.string.mul_type)); 40 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 41 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 42 | @Override 43 | public void onClick(View v) { 44 | finish(); 45 | } 46 | }); 47 | } 48 | 49 | @Override 50 | protected RecyclerView getRecyclerView() { 51 | mRecyclerView = findViewById(R.id.recycler); 52 | mRecyclerView.setLayoutManager(new GridLayoutManager(this, 4)); 53 | mAdapter.setSpanSizeLookup(new BaseQuickAdapter.SpanSizeLookup() { 54 | @Override 55 | public int getSpanSize(GridLayoutManager gridLayoutManager, int position) { 56 | Object o = mAdapter.getItem(position); 57 | if (o instanceof MultiBean1) { 58 | return 1; 59 | } else if (o instanceof MultiBean2) { 60 | return 4; 61 | } else if (o instanceof MultiBean) { 62 | return 2; 63 | } 64 | return 3; 65 | } 66 | }); 67 | return mRecyclerView; 68 | } 69 | 70 | @Override 71 | protected MeiBaseAdapter getAdapter() { 72 | mAdapter = new MeiBaseMixAdapter(); 73 | mAdapter.addItemPresenter(new MultiAdapter1()); 74 | mAdapter.addItemPresenter(new MultiAdapter2()); 75 | mAdapter.addItemPresenter(new MultiAdapter3()); 76 | mAdapter.addItemPresenter(new MultiAdapter()); 77 | return mAdapter; 78 | } 79 | 80 | @Override 81 | protected Observable>> getListObservable(int pageNo) { 82 | return getData(pageNo); 83 | } 84 | 85 | public Observable>> getData(int pageNo) { 86 | Result> result = new Result<>(); 87 | List objectList = new ArrayList<>(); 88 | for (int i = 0; i < 4; i++) { 89 | objectList.add(new MultiBean1()); 90 | objectList.add(new MultiBean3()); 91 | objectList.add(new MultiBean2()); 92 | objectList.add(new MultiBean()); 93 | objectList.add(new MultiBean()); 94 | } 95 | result.data = objectList; 96 | result.resultCode = 0; 97 | result.message = ""; 98 | return Observable.just(result); 99 | } 100 | 101 | @Override 102 | public boolean canLoadMore() { 103 | return true; 104 | } 105 | 106 | @Override 107 | public boolean canPullToRefresh() { 108 | return true; 109 | } 110 | 111 | @Override 112 | protected int layoutResId() { 113 | return R.layout.comm_recycler; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/ui/PullRefreshActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity.ui; 2 | 3 | import android.support.v4.view.GravityCompat; 4 | import android.support.v7.widget.PopupMenu; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.meis.base.mei.annotation.PullToLoadMore; 11 | import com.meis.base.mei.annotation.PullToRefresh; 12 | import com.meis.base.mei.header.DingDangHeader; 13 | import com.meis.base.mei.status.ViewState; 14 | import com.meis.basemodule.R; 15 | import com.meis.basemodule.base.BaseActivity; 16 | import com.scwang.smartrefresh.layout.header.BezierRadarHeader; 17 | import com.scwang.smartrefresh.layout.header.ClassicsHeader; 18 | 19 | /** 20 | * author: ws4 21 | * created on: 2018/4/11 15:32 22 | * description: 23 | */ 24 | @PullToRefresh 25 | @PullToLoadMore 26 | public class PullRefreshActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener { 27 | 28 | @Override 29 | protected void initView() { 30 | 31 | } 32 | 33 | @Override 34 | protected void initData() { 35 | getToolbarView().setTitle(getResources().getString(R.string.refresh)); 36 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 37 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 38 | @Override 39 | public void onClick(View v) { 40 | finish(); 41 | } 42 | }); 43 | 44 | setState(ViewState.EMPTY, new Object[]{getString(R.string.drag_refresh)}); 45 | 46 | getToolbarView().inflateMenu(R.menu.type); 47 | getToolbarView().setOnMenuItemClickListener(this); 48 | } 49 | 50 | @Override 51 | protected int layoutResId() { 52 | return 0; 53 | } 54 | 55 | @Override 56 | public void onRefreshing() { 57 | super.onRefreshing(); 58 | postUiThread(new Runnable() { 59 | @Override 60 | public void run() { 61 | Toast.makeText(PullRefreshActivity.this, getResources().getString(R.string 62 | .mei_refresh_success), Toast.LENGTH_SHORT).show(); 63 | PullRefreshActivity.this.setRefreshing(false); 64 | } 65 | }, 2000); 66 | } 67 | 68 | @Override 69 | public void onLoadingMore() { 70 | super.onLoadingMore(); 71 | postUiThread(new Runnable() { 72 | @Override 73 | public void run() { 74 | Toast.makeText(PullRefreshActivity.this, getResources().getString(R.string 75 | .mei_refresh_success), Toast.LENGTH_SHORT).show(); 76 | PullRefreshActivity.this.setLoadingMore(false); 77 | } 78 | }, 2000); 79 | } 80 | 81 | @Override 82 | public boolean onMenuItemClick(MenuItem item) { 83 | switch (item.getItemId()) { 84 | case R.id.action_anim: 85 | final PopupMenu popupMenu = new PopupMenu(this, getToolbarView(), GravityCompat 86 | .END); 87 | popupMenu.inflate(R.menu.refresh_type); 88 | popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 89 | @Override 90 | public boolean onMenuItemClick(MenuItem item) { 91 | switch (item.getItemId()) { 92 | case R.id.dingdang_type: 93 | setRefreshHeader(new DingDangHeader(PullRefreshActivity.this)); 94 | break; 95 | case R.id.bezier_type: 96 | setRefreshHeader(new BezierRadarHeader(PullRefreshActivity.this)); 97 | break; 98 | case R.id.classics_type: 99 | setRefreshHeader(new ClassicsHeader(PullRefreshActivity.this)); 100 | break; 101 | } 102 | autoRefresh(); 103 | popupMenu.dismiss(); 104 | return true; 105 | } 106 | }); 107 | popupMenu.show(); 108 | break; 109 | } 110 | return true; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/ui/SingleListActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity.ui; 2 | 3 | import android.support.v7.widget.LinearLayoutManager; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.view.View; 6 | 7 | import com.meis.base.mei.adapter.MeiBaseAdapter; 8 | import com.meis.base.mei.status.ViewState; 9 | import com.meis.basemodule.R; 10 | import com.meis.basemodule.adapter.MeiSimpleAdapter; 11 | import com.meis.basemodule.base.BaseListActivity; 12 | import com.meis.basemodule.entity.Article; 13 | import com.meis.basemodule.entity.Result; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import io.reactivex.Observable; 19 | 20 | /** 21 | * author: ws4 22 | * created on: 2018/4/11 15:32 23 | * description: 24 | */ 25 | public class SingleListActivity extends BaseListActivity
{ 26 | 27 | RecyclerView mRecyclerView; 28 | MeiSimpleAdapter mAdapter; 29 | 30 | @Override 31 | protected void initData() { 32 | getToolbarView().setTitle(getResources().getString(R.string.simple_type)); 33 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 34 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 35 | @Override 36 | public void onClick(View v) { 37 | finish(); 38 | } 39 | }); 40 | 41 | setState(ViewState.LOADING); 42 | } 43 | 44 | @Override 45 | protected RecyclerView getRecyclerView() { 46 | mRecyclerView = findViewById(R.id.recycler); 47 | mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 48 | return mRecyclerView; 49 | } 50 | 51 | @Override 52 | protected MeiBaseAdapter
getAdapter() { 53 | return mAdapter = new MeiSimpleAdapter(); 54 | } 55 | 56 | 57 | @Override 58 | protected Observable>> getListObservable(int pageNo) { 59 | return getData(pageNo); 60 | } 61 | 62 | public Observable>> getData(int pageNo) { 63 | Result> result = new Result<>(); 64 | List
articleList = new ArrayList<>(); 65 | for (int i = 0; i < 20; i++) { 66 | int index = (int) (Math.random() * 3); 67 | Article article = new Article(getResources().getStringArray(R.array.array_title) 68 | [index], getResources().getStringArray(R.array.array_content)[index]); 69 | articleList.add(article); 70 | } 71 | result.data = articleList; 72 | result.resultCode = 0; 73 | result.message = ""; 74 | return Observable.just(result); 75 | } 76 | 77 | @Override 78 | protected void loadPage(final int pageNo) { 79 | postUiThread(new Runnable() { 80 | @Override 81 | public void run() { 82 | SingleListActivity.super.loadPage(pageNo); 83 | } 84 | }, 2000); 85 | } 86 | 87 | @Override 88 | public boolean canLoadMore() { 89 | return true; 90 | } 91 | 92 | @Override 93 | public boolean canPullToRefresh() { 94 | return true; 95 | } 96 | 97 | @Override 98 | protected int layoutResId() { 99 | return R.layout.comm_recycler; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/ui/StatusActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity.ui; 2 | 3 | import android.support.v4.view.GravityCompat; 4 | import android.support.v7.widget.PopupMenu; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.MenuItem; 7 | import android.view.View; 8 | import android.widget.Toast; 9 | 10 | import com.meis.base.mei.status.ViewState; 11 | import com.meis.basemodule.R; 12 | import com.meis.basemodule.base.BaseActivity; 13 | /** 14 | * author: ws4 15 | * created on: 2018/4/11 15:31 16 | * description: 17 | */ 18 | public class StatusActivity extends BaseActivity implements Toolbar.OnMenuItemClickListener { 19 | @Override 20 | protected void initView() { 21 | 22 | } 23 | 24 | @Override 25 | protected void initData() { 26 | getToolbarView().setTitle(getResources().getString(R.string.status_type)); 27 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 28 | getToolbarView().inflateMenu(R.menu.type); 29 | getToolbarView().setOnMenuItemClickListener(this); 30 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 31 | @Override 32 | public void onClick(View v) { 33 | finish(); 34 | } 35 | }); 36 | 37 | setState(ViewState.EMPTY); 38 | } 39 | 40 | @Override 41 | protected int layoutResId() { 42 | return 0; 43 | } 44 | 45 | @Override 46 | public boolean onMenuItemClick(MenuItem item) { 47 | switch (item.getItemId()) { 48 | case R.id.action_anim: 49 | final PopupMenu popupMenu = new PopupMenu(this, getToolbarView(), GravityCompat 50 | .END); 51 | popupMenu.inflate(R.menu.custime_type); 52 | popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { 53 | @Override 54 | public boolean onMenuItemClick(MenuItem item) { 55 | switch (item.getItemId()) { 56 | case R.id.empty_type: 57 | setState(ViewState.EMPTY, new Object[]{R.mipmap.ic_empty_page, 58 | getResources().getString(R.string.empty_type_1)}); 59 | break; 60 | case R.id.error_type: 61 | setState(ViewState.ERROR); 62 | break; 63 | case R.id.loading_type: 64 | setState(ViewState.LOADING); 65 | break; 66 | } 67 | popupMenu.dismiss(); 68 | return true; 69 | } 70 | }); 71 | popupMenu.show(); 72 | break; 73 | } 74 | return true; 75 | } 76 | 77 | @Override 78 | public void onErrorRetry() { 79 | super.onErrorRetry(); 80 | Toast.makeText(this, getResources().getString(R.string.reload_data), Toast.LENGTH_SHORT) 81 | .show(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/activity/ui/TranslucentActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.activity.ui; 2 | 3 | import android.support.v7.widget.Toolbar; 4 | import android.view.View; 5 | 6 | import com.meis.base.mei.utils.Eyes; 7 | import com.meis.basemodule.R; 8 | import com.meis.basemodule.base.BaseActivity; 9 | 10 | /** 11 | * desc: 12 | * author: ws 13 | * date: 2018/4/14. 14 | */ 15 | 16 | public class TranslucentActivity extends BaseActivity { 17 | 18 | Toolbar mToolbar; 19 | 20 | @Override 21 | protected void initView() { 22 | //调用Eyes设置各种透明状态 23 | Eyes.translucentStatusBar(this, true); 24 | mToolbar = findViewById(R.id.toolbar); 25 | } 26 | 27 | @Override 28 | protected void initData() { 29 | mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 30 | mToolbar.setNavigationOnClickListener(new View.OnClickListener() { 31 | @Override 32 | public void onClick(View v) { 33 | finish(); 34 | } 35 | }); 36 | } 37 | 38 | @Override 39 | protected int layoutResId() { 40 | return R.layout.activity_translucent; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/ChatAdapter.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.MeiBaseAdapter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.Chat; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/12 18:00 11 | * description: 12 | */ 13 | public class ChatAdapter extends MeiBaseAdapter { 14 | 15 | public ChatAdapter() { 16 | super(R.layout.item_zhihu_chat); 17 | } 18 | 19 | @Override 20 | protected void convert(BaseViewHolder helper, Chat item) { 21 | helper.setText(R.id.tv_name, item.name) 22 | .setText(R.id.tv_msg, item.message); 23 | 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/ChatRightAdapter.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.MeiBaseAdapter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.Chat; 7 | 8 | /** 9 | * desc: 10 | * author: ws 11 | * date: 2018/4/13. 12 | */ 13 | 14 | public class ChatRightAdapter extends MeiBaseAdapter { 15 | 16 | public ChatRightAdapter() { 17 | super(R.layout.item_zhihu_msg); 18 | } 19 | 20 | @Override 21 | protected void convert(BaseViewHolder helper, Chat item) { 22 | helper.setText(R.id.tv_msg, item.message) 23 | .addOnClickListener(R.id.img_avatar); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/FirstHomeAdapter.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import android.support.v4.view.ViewCompat; 4 | 5 | import com.chad.library.adapter.base.BaseViewHolder; 6 | import com.meis.base.mei.adapter.MeiBaseAdapter; 7 | import com.meis.basemodule.R; 8 | import com.meis.basemodule.entity.Article; 9 | 10 | /** 11 | * author: ws4 12 | * created on: 2018/4/12 16:31 13 | * description: 14 | */ 15 | public class FirstHomeAdapter extends MeiBaseAdapter
{ 16 | 17 | public FirstHomeAdapter() { 18 | super(R.layout.item_zhihu_home_first); 19 | } 20 | 21 | @Override 22 | protected void convert(BaseViewHolder helper, Article item) { 23 | // 把每个图片视图设置不同的Transition名称, 防止在一个视图内有多个相同的名称, 在变换的时候造成混乱 24 | // Fragment支持多个View进行变换, 使用适配器时, 需要加以区分 25 | ViewCompat.setTransitionName(helper.getView(R.id.img), String.valueOf(helper 26 | .getAdapterPosition()) + "_image"); 27 | ViewCompat.setTransitionName(helper.getView(R.id.tv_title), String.valueOf(helper 28 | .getAdapterPosition()) + "_tv"); 29 | 30 | helper.setImageResource(R.id.img, item.getImgRes()); 31 | helper.setText(R.id.tv_title, item.getTitle()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/MeiSimpleAdapter.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.MeiBaseAdapter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.Article; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/11 17:40 11 | * description: 12 | */ 13 | public class MeiSimpleAdapter extends MeiBaseAdapter
{ 14 | 15 | public MeiSimpleAdapter() { 16 | super(R.layout.item_comm); 17 | } 18 | 19 | @Override 20 | protected void convert(BaseViewHolder helper, Article item) { 21 | helper.setText(R.id.tv_title, item.getTitle()); 22 | helper.setText(R.id.tv_content, item.getContent()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/MultiAdapter.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.ItemPresenter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.MultiBean; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/12 15:38 11 | * description: 12 | */ 13 | public class MultiAdapter extends ItemPresenter { 14 | @Override 15 | public int getLayoutRes() { 16 | return R.layout.item_section_content; 17 | } 18 | 19 | @Override 20 | public void convert(BaseViewHolder holder, MultiBean item) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/MultiAdapter1.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.ItemPresenter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.MultiBean1; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/12 15:18 11 | * description: 12 | */ 13 | public class MultiAdapter1 extends ItemPresenter { 14 | @Override 15 | public int getLayoutRes() { 16 | return R.layout.item_image_view; 17 | } 18 | 19 | @Override 20 | public void convert(BaseViewHolder holder, MultiBean1 item) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/MultiAdapter2.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.ItemPresenter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.MultiBean2; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/12 15:19 11 | * description: 12 | */ 13 | public class MultiAdapter2 extends ItemPresenter { 14 | @Override 15 | public int getLayoutRes() { 16 | return R.layout.item_section_content; 17 | } 18 | 19 | @Override 20 | public void convert(BaseViewHolder holder, MultiBean2 item) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/MultiAdapter3.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import com.chad.library.adapter.base.BaseViewHolder; 4 | import com.meis.base.mei.adapter.ItemPresenter; 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.entity.MultiBean3; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/12 15:20 11 | * description: 12 | */ 13 | public class MultiAdapter3 extends ItemPresenter { 14 | @Override 15 | public int getLayoutRes() { 16 | return R.layout.item_text_view; 17 | } 18 | 19 | @Override 20 | public void convert(BaseViewHolder holder, MultiBean3 item) { 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/adapter/ZhihuPagerFragmentAdapter.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.adapter; 2 | 3 | import android.support.v4.app.Fragment; 4 | import android.support.v4.app.FragmentManager; 5 | import android.support.v4.app.FragmentPagerAdapter; 6 | 7 | import com.meis.basemodule.fragment.ui.second.OtherPagerFragment; 8 | 9 | /** 10 | * Created by YoKeyword on 16/6/5. 11 | */ 12 | public class ZhihuPagerFragmentAdapter extends FragmentPagerAdapter { 13 | private String[] mTitles; 14 | 15 | public ZhihuPagerFragmentAdapter(FragmentManager fm, String... titles) { 16 | super(fm); 17 | mTitles = titles; 18 | } 19 | 20 | @Override 21 | public Fragment getItem(int position) { 22 | return OtherPagerFragment.newInstance(mTitles[position]); 23 | } 24 | 25 | @Override 26 | public int getCount() { 27 | return mTitles.length; 28 | } 29 | 30 | @Override 31 | public CharSequence getPageTitle(int position) { 32 | return mTitles[position]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/base/BaseDialog.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.base; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | 9 | import com.meis.base.mei.dialog.MeiCompatDialog; 10 | 11 | 12 | /** 13 | * desc: 14 | * author: ws 15 | * date: 2018/4/19. 16 | */ 17 | 18 | public abstract class BaseDialog extends MeiCompatDialog { 19 | 20 | @Override 21 | public void onCreate(@Nullable Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | } 24 | 25 | @Nullable 26 | @Override 27 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle 28 | savedInstanceState) { 29 | return inflater.inflate(getLayoutId(), container, false); 30 | } 31 | 32 | @Override 33 | public void onActivityCreated(Bundle savedInstanceState) { 34 | super.onActivityCreated(savedInstanceState); 35 | //初始化控件 36 | initView(); 37 | //初始化数据 38 | initData(); 39 | } 40 | 41 | protected abstract int getLayoutId(); 42 | 43 | protected abstract void initView(); 44 | 45 | protected abstract void initData(); 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/base/BaseListFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.base; 2 | 3 | import android.support.v7.widget.RecyclerView; 4 | 5 | import com.chad.library.adapter.base.BaseQuickAdapter; 6 | import com.meis.base.mei.adapter.MeiBaseAdapter; 7 | import com.meis.base.mei.status.ViewState; 8 | import com.meis.basemodule.constant.DataConstants; 9 | import com.meis.basemodule.entity.Result; 10 | import com.meis.basemodule.utils.ListUtils; 11 | 12 | import java.util.List; 13 | 14 | import io.reactivex.Observable; 15 | import io.reactivex.Observer; 16 | import io.reactivex.android.schedulers.AndroidSchedulers; 17 | import io.reactivex.disposables.Disposable; 18 | import io.reactivex.functions.Predicate; 19 | 20 | /** 21 | * desc: 22 | * author: ws 23 | * date: 2018/4/19. 24 | */ 25 | 26 | public abstract class BaseListFragment extends BaseFragment { 27 | protected MeiBaseAdapter mAdapter; 28 | 29 | private int mPageNo; 30 | 31 | @Override 32 | protected void initView() { 33 | mAdapter = getAdapter(); 34 | RecyclerView recyclerView = getRecyclerView(); 35 | if (mAdapter == null || recyclerView == null) { 36 | return; 37 | } 38 | recyclerView.setAdapter(mAdapter); 39 | if (canLoadMore()) { 40 | mAdapter.setEnableLoadMore(true); 41 | mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() { 42 | @Override 43 | public void onLoadMoreRequested() { 44 | loadPage(mAdapter.getPageCount() + 1); 45 | } 46 | }, recyclerView); 47 | } 48 | //是否首次加载 是否每次显示加载 49 | if (loadOnInit() || !loadOnShow()) { 50 | loadPage(DataConstants.FIRST_PAGE); 51 | } 52 | } 53 | 54 | @Override 55 | protected void initData() { 56 | 57 | } 58 | 59 | @Override 60 | public void onSupportVisible() { 61 | super.onSupportVisible(); 62 | if (loadOnShow()) { 63 | loadPage(DataConstants.FIRST_PAGE); 64 | } 65 | } 66 | 67 | @Override 68 | public void onRefreshing() { 69 | loadPage(DataConstants.FIRST_PAGE); 70 | } 71 | 72 | public void setPageNo(int pageNo) { 73 | this.mPageNo = pageNo; 74 | } 75 | 76 | protected void reload() { 77 | loadPage(DataConstants.FIRST_PAGE); 78 | } 79 | 80 | /** 81 | * 当前页数加载数据 82 | * 83 | * @param pageNo 84 | */ 85 | protected void loadPage(final int pageNo) { 86 | if (mAdapter == null) { 87 | return; 88 | } 89 | mPageNo = pageNo; 90 | getListObservable(pageNo) 91 | .filter(new Predicate>>() { 92 | @Override 93 | public boolean test(Result> listResult) throws Exception { 94 | return pageNo == mPageNo; 95 | } 96 | }).observeOn(AndroidSchedulers.mainThread()) 97 | .subscribe(new Observer>>() { 98 | @Override 99 | public void onSubscribe(Disposable d) { 100 | 101 | } 102 | 103 | @Override 104 | public void onNext(Result> listResult) { 105 | setRefreshing(false); 106 | onDataLoaded(pageNo, listResult); 107 | } 108 | 109 | @Override 110 | public void onError(Throwable e) { 111 | setRefreshing(false); 112 | if (pageNo == DataConstants.FIRST_PAGE) { 113 | if (keepEmptyOnFail() && mAdapter.getDataCount() > 0) { 114 | return; 115 | } 116 | setState(ViewState.EMPTY); 117 | } else { 118 | mAdapter.loadMoreFail(); 119 | } 120 | } 121 | 122 | @Override 123 | public void onComplete() { 124 | 125 | } 126 | }); 127 | } 128 | 129 | /** 130 | * @param pageNo 131 | * @param result 132 | */ 133 | protected void onDataLoaded(int pageNo, Result> result) { 134 | List data = result.data; 135 | if (pageNo == DataConstants.FIRST_PAGE) { 136 | if (ListUtils.isEmpty(data)) { 137 | setState(ViewState.EMPTY); 138 | } else { 139 | mAdapter.setNewData(data); 140 | if (data.size() < getPageSize()) { 141 | mAdapter.setEnableLoadMore(false); 142 | } else { 143 | mAdapter.setEnableLoadMore(true); 144 | } 145 | setState(ViewState.COMPLETED); 146 | } 147 | } else { 148 | if (ListUtils.isEmpty(data)) { 149 | mAdapter.loadMoreEnd(mAdapter.getData().size() < getPageSize() / 2); 150 | } else { 151 | mAdapter.addData(data); 152 | if (data.size() < getPageSize()) { 153 | mAdapter.loadMoreEnd(); 154 | } else { 155 | mAdapter.loadMoreComplete(); 156 | } 157 | } 158 | } 159 | } 160 | 161 | protected boolean loadOnInit() { 162 | return false; 163 | } 164 | 165 | /** 166 | * 每次界面重新显示的时候 是否加载数据 167 | * true 加载 168 | * false 不加载 169 | * 170 | * @return 171 | */ 172 | protected boolean loadOnShow() { 173 | return true; 174 | } 175 | 176 | /** 177 | * false 默认第一页数据为空或加载失败 显示空界面 178 | * true 不显示空界面 179 | * 180 | * @return false 181 | */ 182 | protected boolean keepEmptyOnFail() { 183 | return false; 184 | } 185 | 186 | /** 187 | * 可以重写该方法 返回每页大小 默认返回20 188 | * 189 | * @return 190 | */ 191 | protected int getPageSize() { 192 | return DataConstants.DEFAULT_PAGE_SIZE; 193 | } 194 | 195 | protected abstract RecyclerView getRecyclerView(); 196 | 197 | protected abstract MeiBaseAdapter getAdapter(); 198 | 199 | protected abstract Observable>> getListObservable(int pageNo); 200 | 201 | public abstract boolean canLoadMore(); 202 | 203 | @Override 204 | public abstract boolean canPullToRefresh(); 205 | } 206 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/constant/DataConstants.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.constant; 2 | 3 | public interface DataConstants { 4 | 5 | /** 6 | * 默认每页数量 7 | */ 8 | int DEFAULT_PAGE_SIZE = 20; 9 | 10 | /** 11 | * 接口的第一页索引 12 | */ 13 | int FIRST_PAGE = 1; 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/dialog/BottomCommentDialog.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.dialog; 2 | 3 | import android.graphics.drawable.ColorDrawable; 4 | import android.support.v4.content.ContextCompat; 5 | import android.view.Gravity; 6 | import android.view.Window; 7 | import android.view.WindowManager; 8 | 9 | import com.meis.basemodule.R; 10 | import com.meis.basemodule.base.BaseDialog; 11 | 12 | /** 13 | * desc: 以底部弹出评论提示框 可以解决很多软键盘与滚动界面冲突问题 14 | * author: ws 15 | * date: 2018/4/14. 16 | */ 17 | 18 | public class BottomCommentDialog extends BaseDialog { 19 | 20 | @Override 21 | protected int getLayoutId() { 22 | return R.layout.comm_bottom_comment; 23 | } 24 | 25 | @Override 26 | protected void initView() { 27 | 28 | } 29 | 30 | @Override 31 | protected void initData() { 32 | 33 | } 34 | 35 | @Override 36 | public void onStart() { 37 | super.onStart(); 38 | 39 | Window window = getDialog().getWindow(); 40 | WindowManager.LayoutParams params = window.getAttributes(); 41 | // 显示在底部 42 | params.gravity = Gravity.BOTTOM; 43 | // 宽度填充满屏 44 | params.width = WindowManager.LayoutParams.MATCH_PARENT; 45 | //显示dialog的时候,就显示软键盘 46 | params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE; 47 | window.setAttributes(params); 48 | 49 | // 这里用透明颜色替换掉系统自带背景 50 | int color = ContextCompat.getColor(getActivity(), android.R.color.transparent); 51 | window.setBackgroundDrawable(new ColorDrawable(color)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/dialog/CreateLiveDialog.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.dialog; 2 | 3 | import android.app.Dialog; 4 | import android.os.Bundle; 5 | import android.support.annotation.NonNull; 6 | import android.support.design.widget.BottomSheetDialog; 7 | import android.view.View; 8 | import android.view.animation.Animation; 9 | import android.view.animation.AnimationUtils; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | 13 | import com.meis.basemodule.R; 14 | import com.meis.basemodule.base.BaseDialog; 15 | 16 | /** 17 | * desc: 18 | * author: ws 19 | * date: 2018/4/14. 20 | */ 21 | 22 | public class CreateLiveDialog extends BaseDialog { 23 | 24 | TextView mTvLive; 25 | TextView mTvVideo; 26 | ImageView mIvClose; 27 | 28 | @NonNull 29 | @Override 30 | public Dialog onCreateDialog(Bundle savedInstanceState) { 31 | return new BottomSheetDialog(getContext(), R.style.CreateLiveDialog); 32 | } 33 | 34 | 35 | @Override 36 | protected int getLayoutId() { 37 | return R.layout.dialog_bottom_live; 38 | } 39 | 40 | @Override 41 | protected void initView() { 42 | mTvLive = findViewById(R.id.create_live_tv); 43 | mTvVideo = findViewById(R.id.create_shortvideo_tv); 44 | mIvClose = findViewById(R.id.close_iv); 45 | } 46 | 47 | @Override 48 | protected void initData() { 49 | Animation animation = AnimationUtils.loadAnimation(getActivity(), R.anim.live_btn_bottom_in); 50 | animation.setStartOffset(80); 51 | mTvLive.startAnimation(animation); 52 | animation = AnimationUtils.loadAnimation(getActivity(), R.anim.live_btn_bottom_in); 53 | animation.setStartOffset(160); 54 | mTvVideo.startAnimation(animation); 55 | animation = AnimationUtils.loadAnimation(getActivity(), R.anim.live_btn_bottom_in); 56 | animation.setStartOffset(200); 57 | mIvClose.startAnimation(animation); 58 | 59 | mIvClose.setOnClickListener(new View.OnClickListener() { 60 | @Override 61 | public void onClick(View view) { 62 | dismiss(); 63 | } 64 | }); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/dialog/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.dialog; 2 | 3 | import android.view.View; 4 | 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.base.BaseActivity; 7 | 8 | /** 9 | * author: ws4 10 | * created on: 2018/4/11 15:06 11 | * description: 12 | */ 13 | public class MainActivity extends BaseActivity { 14 | @Override 15 | protected void initView() { 16 | 17 | } 18 | 19 | @Override 20 | protected void initData() { 21 | getToolbarView().setTitle(getString(R.string.dialog_module)); 22 | showDialog(new CreateLiveDialog()); 23 | } 24 | 25 | public void clickLive(View view) { 26 | showDialog(new CreateLiveDialog()); 27 | } 28 | 29 | public void clickComment(View view) { 30 | showDialog(new BottomCommentDialog()); 31 | } 32 | 33 | @Override 34 | protected int layoutResId() { 35 | return R.layout.activity_dialog; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/Article.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by YoKeyword on 16/2/1. 8 | */ 9 | public class Article implements Parcelable { 10 | private String title; 11 | private String content; 12 | private int imgRes; 13 | 14 | public Article(String title, String content) { 15 | this.title = title; 16 | this.content = content; 17 | } 18 | 19 | public Article(String title, int imgRes) { 20 | this.title = title; 21 | this.imgRes = imgRes; 22 | } 23 | 24 | protected Article(Parcel in) { 25 | title = in.readString(); 26 | content = in.readString(); 27 | imgRes = in.readInt(); 28 | } 29 | 30 | public static final Creator
CREATOR = new Creator
() { 31 | @Override 32 | public Article createFromParcel(Parcel in) { 33 | return new Article(in); 34 | } 35 | 36 | @Override 37 | public Article[] newArray(int size) { 38 | return new Article[size]; 39 | } 40 | }; 41 | 42 | public String getTitle() { 43 | return title; 44 | } 45 | 46 | public void setTitle(String title) { 47 | this.title = title; 48 | } 49 | 50 | public String getContent() { 51 | return content; 52 | } 53 | 54 | public void setContent(String content) { 55 | this.content = content; 56 | } 57 | 58 | public int getImgRes() { 59 | return imgRes; 60 | } 61 | 62 | public void setImgRes(int imgRes) { 63 | this.imgRes = imgRes; 64 | } 65 | 66 | @Override 67 | public int describeContents() { 68 | return 0; 69 | } 70 | 71 | @Override 72 | public void writeToParcel(Parcel dest, int flags) { 73 | dest.writeString(title); 74 | dest.writeString(content); 75 | dest.writeInt(imgRes); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/Chat.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * Created by YoKeyword on 16/6/30. 8 | */ 9 | public class Chat implements Parcelable { 10 | 11 | public int id; 12 | public String name; 13 | public String message; 14 | public long time; 15 | public int avatar; 16 | 17 | @Override 18 | public boolean equals(Object o) { 19 | if (this == o) return true; 20 | if (o == null || getClass() != o.getClass()) return false; 21 | 22 | Chat chat = (Chat) o; 23 | 24 | return id == chat.id; 25 | } 26 | 27 | @Override 28 | public int hashCode() { 29 | return id; 30 | } 31 | 32 | @Override 33 | public int describeContents() { 34 | return 0; 35 | } 36 | 37 | @Override 38 | public void writeToParcel(Parcel dest, int flags) { 39 | dest.writeInt(this.id); 40 | dest.writeString(this.name); 41 | dest.writeString(this.message); 42 | dest.writeLong(this.time); 43 | dest.writeInt(this.avatar); 44 | } 45 | 46 | public Chat() { 47 | } 48 | 49 | protected Chat(Parcel in) { 50 | this.id = in.readInt(); 51 | this.name = in.readString(); 52 | this.message = in.readString(); 53 | this.time = in.readLong(); 54 | this.avatar = in.readInt(); 55 | } 56 | 57 | public static final Creator CREATOR = new Creator() { 58 | @Override 59 | public Chat createFromParcel(Parcel source) { 60 | return new Chat(source); 61 | } 62 | 63 | @Override 64 | public Chat[] newArray(int size) { 65 | return new Chat[size]; 66 | } 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/MultiBean.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | /** 4 | * author: ws4 5 | * created on: 2018/4/12 15:38 6 | * description: 7 | */ 8 | public class MultiBean { 9 | 10 | public String count; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/MultiBean1.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | /** 4 | * author: ws4 5 | * created on: 2018/4/12 15:14 6 | * description: 7 | */ 8 | public class MultiBean1 { 9 | 10 | public String name; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/MultiBean2.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | /** 4 | * author: ws4 5 | * created on: 2018/4/12 15:14 6 | * description: 7 | */ 8 | public class MultiBean2 { 9 | 10 | public int age; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/MultiBean3.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | /** 4 | * author: ws4 5 | * created on: 2018/4/12 15:14 6 | * description: 7 | */ 8 | public class MultiBean3 { 9 | 10 | public String info; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/entity/Result.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.entity; 2 | 3 | /** 4 | * author: ws4 5 | * created on: 2018/4/11 14:34 6 | * description:下个版本会进行扩展 7 | */ 8 | public class Result { 9 | 10 | public int resultCode; 11 | public String message; 12 | public T data; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment; 2 | 3 | import com.meis.basemodule.R; 4 | import com.meis.basemodule.base.BaseActivity; 5 | 6 | /** 7 | * author: ws4 8 | * created on: 2018/4/11 15:06 9 | * description: 10 | */ 11 | public class MainActivity extends BaseActivity { 12 | 13 | @Override 14 | protected void initView() { 15 | 16 | } 17 | 18 | @Override 19 | protected void initData() { 20 | if (findFragment(MainFragment.class) == null) { 21 | loadRootFragment(R.id.fl_container, MainFragment.newInstance()); 22 | } 23 | enableKeyboardVisibilityListener(); 24 | } 25 | 26 | @Override 27 | protected int layoutResId() { 28 | return R.layout.zhihu_activity_main; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/MainFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.base.BaseFragment; 7 | import com.meis.basemodule.fragment.ui.first.ZhihuFirstFragment; 8 | import com.meis.basemodule.fragment.ui.fourth.ZhihuFourthFragment; 9 | import com.meis.basemodule.fragment.ui.second.ZhihuSecondFragment; 10 | import com.meis.basemodule.fragment.ui.third.ZhihuThirdFragment; 11 | import com.meis.basemodule.widget.BottomBar; 12 | import com.meis.basemodule.widget.BottomBarTab; 13 | 14 | /** 15 | * author: ws4 16 | * created on: 2018/4/13 11:13 17 | * description: 18 | */ 19 | public class MainFragment extends BaseFragment { 20 | 21 | public static final int FIRST = 0; 22 | public static final int SECOND = 1; 23 | public static final int THIRD = 2; 24 | public static final int FOURTH = 3; 25 | 26 | private BaseFragment[] mFragments = new BaseFragment[4]; 27 | private BottomBar mBottomBar; 28 | 29 | public static MainFragment newInstance() { 30 | 31 | Bundle args = new Bundle(); 32 | 33 | MainFragment fragment = new MainFragment(); 34 | fragment.setArguments(args); 35 | return fragment; 36 | } 37 | 38 | 39 | @Override 40 | protected void initView() { 41 | mBottomBar = (BottomBar) findViewById(R.id.bottomBar); 42 | } 43 | 44 | @Override 45 | protected void initData() { 46 | BaseFragment firstFragment = findChildFragment(ZhihuFirstFragment.class); 47 | if (firstFragment == null) { 48 | mFragments[FIRST] = ZhihuFirstFragment.newInstance(); 49 | mFragments[SECOND] = ZhihuSecondFragment.newInstance(); 50 | mFragments[THIRD] = ZhihuThirdFragment.newInstance(); 51 | mFragments[FOURTH] = ZhihuFourthFragment.newInstance(); 52 | 53 | loadMultipleRootFragment(R.id.fl_container, FIRST, 54 | mFragments[FIRST], 55 | mFragments[SECOND], 56 | mFragments[THIRD], 57 | mFragments[FOURTH]); 58 | } else { 59 | // 这里库已经做了Fragment恢复,所有不需要额外的处理了, 不会出现重叠问题 60 | 61 | // 这里我们需要拿到mFragments的引用 62 | mFragments[FIRST] = firstFragment; 63 | mFragments[SECOND] = findChildFragment(ZhihuSecondFragment.class); 64 | mFragments[THIRD] = findChildFragment(ZhihuThirdFragment.class); 65 | mFragments[FOURTH] = findChildFragment(ZhihuFourthFragment.class); 66 | } 67 | 68 | mBottomBar.addItem(new BottomBarTab(mActivity, R.drawable.ic_home_white_24dp)) 69 | .addItem(new BottomBarTab(mActivity, R.drawable.ic_discover_white_24dp)) 70 | .addItem(new BottomBarTab(mActivity, R.drawable.ic_message_white_24dp)) 71 | .addItem(new BottomBarTab(mActivity, R.drawable.ic_account_circle_white_24dp)); 72 | 73 | mBottomBar.setOnTabSelectedListener(new BottomBar.OnTabSelectedListener() { 74 | @Override 75 | public void onTabSelected(int position, int prePosition) { 76 | showHideFragment(mFragments[position], mFragments[prePosition]); 77 | } 78 | 79 | @Override 80 | public void onTabUnselected(int position) { 81 | 82 | } 83 | 84 | @Override 85 | public void onTabReselected(int position) { 86 | 87 | } 88 | }); 89 | } 90 | 91 | @Override 92 | protected int getLayoutId() { 93 | return R.layout.activity_fragment; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/first/FirstDetailFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.first; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.widget.Toolbar; 6 | import android.view.View; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | 10 | import com.meis.basemodule.R; 11 | import com.meis.basemodule.base.BaseFragment; 12 | import com.meis.basemodule.entity.Article; 13 | 14 | /** 15 | * Created by YoKeyword on 16/6/5. 16 | */ 17 | public class FirstDetailFragment extends BaseFragment { 18 | 19 | private static final String ARG_ITEM = "arg_item"; 20 | 21 | private Article mArticle; 22 | 23 | private ImageView mImgDetail; 24 | private TextView mTvTitle; 25 | private Toolbar mToolbar; 26 | 27 | public static FirstDetailFragment newInstance(Article article) { 28 | 29 | Bundle args = new Bundle(); 30 | args.putParcelable(ARG_ITEM, article); 31 | FirstDetailFragment fragment = new FirstDetailFragment(); 32 | fragment.setArguments(args); 33 | return fragment; 34 | } 35 | 36 | @Override 37 | public void onCreate(@Nullable Bundle savedInstanceState) { 38 | super.onCreate(savedInstanceState); 39 | mArticle = getArguments().getParcelable(ARG_ITEM); 40 | } 41 | 42 | @Override 43 | protected void initView() { 44 | mImgDetail = (ImageView) findViewById(R.id.img_detail); 45 | mTvTitle = (TextView) findViewById(R.id.tv_content); 46 | mToolbar = findViewById(R.id.toolbar); 47 | } 48 | 49 | @Override 50 | protected void initData() { 51 | mImgDetail.setImageResource(mArticle.getImgRes()); 52 | mTvTitle.setText(mArticle.getTitle()); 53 | mToolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 54 | mToolbar.setNavigationOnClickListener(new View.OnClickListener() { 55 | @Override 56 | public void onClick(View v) { 57 | pop(); 58 | } 59 | }); 60 | } 61 | 62 | @Override 63 | protected int getLayoutId() { 64 | return R.layout.zhihu_fragment_first_detail; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/first/FirstHomeFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.first; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | 8 | import com.chad.library.adapter.base.BaseQuickAdapter; 9 | import com.meis.base.mei.adapter.MeiBaseAdapter; 10 | import com.meis.basemodule.R; 11 | import com.meis.basemodule.adapter.FirstHomeAdapter; 12 | import com.meis.basemodule.base.BaseListFragment; 13 | import com.meis.basemodule.entity.Article; 14 | import com.meis.basemodule.entity.Result; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import io.reactivex.Observable; 20 | 21 | /** 22 | * Created by YoKeyword on 16/6/5. 23 | */ 24 | public class FirstHomeFragment extends BaseListFragment
{ 25 | 26 | private String[] mTitles = new String[]{ 27 | "Use imagery to express a distinctive voice and exemplify creative excellence.", 28 | "An image that tells a story is infinitely more interesting and informative.", 29 | "The most powerful iconic images consist of a few meaningful elements, with minimal " + 30 | "distractions.", 31 | "Properly contextualized concepts convey your message and brand more effectively.", 32 | "Have an iconic point of focus in your imagery. Focus ranges from a single entity to " + 33 | "an overarching composition." 34 | }; 35 | 36 | @Override 37 | protected void initData() { 38 | super.initData(); 39 | getToolbarView().setTitle(getResources().getString(R.string.home)); 40 | } 41 | 42 | private int[] mImgRes = new int[]{ 43 | R.mipmap.bg_first, R.mipmap.bg_second, R.mipmap.bg_third, R.mipmap.bg_fourth, R 44 | .mipmap.bg_fifth 45 | }; 46 | 47 | 48 | public static FirstHomeFragment newInstance() { 49 | 50 | Bundle args = new Bundle(); 51 | 52 | FirstHomeFragment fragment = new FirstHomeFragment(); 53 | fragment.setArguments(args); 54 | return fragment; 55 | } 56 | 57 | @Override 58 | protected RecyclerView getRecyclerView() { 59 | RecyclerView recyclerView = findViewById(R.id.recycler); 60 | recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); 61 | return recyclerView; 62 | } 63 | 64 | @Override 65 | protected MeiBaseAdapter
getAdapter() { 66 | FirstHomeAdapter adapter = new FirstHomeAdapter(); 67 | adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { 68 | @Override 69 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) { 70 | FirstDetailFragment fragment = FirstDetailFragment.newInstance(mAdapter.getItem 71 | (position)); 72 | start(fragment); 73 | } 74 | }); 75 | return adapter; 76 | } 77 | 78 | @Override 79 | protected Observable>> getListObservable(int pageNo) { 80 | return getData(pageNo); 81 | } 82 | 83 | public Observable>> getData(int pageNo) { 84 | Result> result = new Result<>(); 85 | List
articleList = new ArrayList<>(); 86 | for (int i = 0; i < 20; i++) { 87 | int index = (int) (Math.random() * 3); 88 | Article article = new Article(mTitles[index], mImgRes[index]); 89 | articleList.add(article); 90 | } 91 | result.data = articleList; 92 | result.resultCode = 0; 93 | result.message = ""; 94 | return Observable.just(result); 95 | } 96 | 97 | @Override 98 | public boolean canLoadMore() { 99 | return true; 100 | } 101 | 102 | @Override 103 | public boolean canPullToRefresh() { 104 | return true; 105 | } 106 | 107 | @Override 108 | protected int getLayoutId() { 109 | return R.layout.comm_recycler; 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/first/ZhihuFirstFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.first; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.meis.basemodule.R; 6 | import com.meis.basemodule.base.BaseFragment; 7 | 8 | /** 9 | * Created by YoKeyword on 16/6/5. 10 | */ 11 | public class ZhihuFirstFragment extends BaseFragment { 12 | 13 | public static ZhihuFirstFragment newInstance() { 14 | 15 | Bundle args = new Bundle(); 16 | 17 | ZhihuFirstFragment fragment = new ZhihuFirstFragment(); 18 | fragment.setArguments(args); 19 | return fragment; 20 | } 21 | 22 | @Override 23 | protected void initView() { 24 | 25 | } 26 | 27 | @Override 28 | protected void initData() { 29 | if (findChildFragment(FirstHomeFragment.class) == null) { 30 | loadRootFragment(R.id.fl_first_container, FirstHomeFragment.newInstance()); 31 | } 32 | } 33 | 34 | 35 | @Override 36 | protected int getLayoutId() { 37 | return R.layout.zhihu_fragment_first; 38 | } 39 | 40 | 41 | /** 42 | * 处理回退事件 43 | * 44 | * @return 45 | */ 46 | @Override 47 | public boolean onBackPressedSupport() { 48 | if (getChildFragmentManager().getBackStackEntryCount() > 1) { 49 | popChild(); 50 | } else { 51 | if (this instanceof ZhihuFirstFragment) { // 如果是 第一个Fragment 则退出app 52 | mActivity.finish(); 53 | } 54 | } 55 | return true; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/fourth/ZhihuFourthFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.fourth; 2 | 3 | import android.os.Bundle; 4 | 5 | import com.meis.base.mei.status.ViewState; 6 | import com.meis.basemodule.R; 7 | import com.meis.basemodule.base.BaseFragment; 8 | 9 | /** 10 | * Created by YoKeyword on 16/6/3. 11 | */ 12 | public class ZhihuFourthFragment extends BaseFragment { 13 | 14 | public static ZhihuFourthFragment newInstance() { 15 | 16 | Bundle args = new Bundle(); 17 | 18 | ZhihuFourthFragment fragment = new ZhihuFourthFragment(); 19 | fragment.setArguments(args); 20 | return fragment; 21 | } 22 | 23 | @Override 24 | protected void initView() { 25 | 26 | } 27 | 28 | @Override 29 | protected void initData() { 30 | getToolbarView().setTitle(getResources().getString(R.string.user_center)); 31 | 32 | setState(ViewState.EMPTY); 33 | } 34 | 35 | @Override 36 | protected int getLayoutId() { 37 | return 0; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/second/OtherPagerFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.second; 2 | 3 | import android.os.Bundle; 4 | import android.widget.TextView; 5 | 6 | import com.meis.basemodule.R; 7 | import com.meis.basemodule.base.BaseFragment; 8 | 9 | 10 | /** 11 | * Created by YoKeyword on 16/6/30. 12 | */ 13 | public class OtherPagerFragment extends BaseFragment { 14 | 15 | private static final String ARG_MSG = "arg_msg"; 16 | 17 | private String mTitle = ""; 18 | 19 | public static OtherPagerFragment newInstance(String title) { 20 | 21 | Bundle args = new Bundle(); 22 | args.putString(ARG_MSG, title); 23 | OtherPagerFragment fragment = new OtherPagerFragment(); 24 | fragment.setArguments(args); 25 | return fragment; 26 | } 27 | 28 | @Override 29 | protected void initView() { 30 | Bundle args = getArguments(); 31 | if (args != null) { 32 | if (args.containsKey(ARG_MSG)) { 33 | this.mTitle = args.getString(ARG_MSG); 34 | } 35 | } 36 | ((TextView) findViewById(R.id.tv_title)).setText(mTitle); 37 | } 38 | 39 | @Override 40 | protected void initData() { 41 | 42 | } 43 | 44 | @Override 45 | protected int getLayoutId() { 46 | return R.layout.zhihu_fragment_tab_second_pager; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/second/ZhihuSecondFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.second; 2 | 3 | import android.os.Bundle; 4 | import android.support.design.widget.TabLayout; 5 | import android.support.v4.view.ViewPager; 6 | 7 | import com.meis.basemodule.R; 8 | import com.meis.basemodule.adapter.ZhihuPagerFragmentAdapter; 9 | import com.meis.basemodule.base.BaseFragment; 10 | 11 | /** 12 | * Created by YoKeyword on 16/6/3. 13 | */ 14 | public class ZhihuSecondFragment extends BaseFragment { 15 | 16 | TabLayout mTabLayout; 17 | ViewPager mViewPager; 18 | 19 | public static ZhihuSecondFragment newInstance() { 20 | 21 | Bundle args = new Bundle(); 22 | 23 | ZhihuSecondFragment fragment = new ZhihuSecondFragment(); 24 | fragment.setArguments(args); 25 | return fragment; 26 | } 27 | 28 | @Override 29 | protected void initView() { 30 | mTabLayout = findViewById(R.id.tab); 31 | mViewPager = findViewById(R.id.pager); 32 | } 33 | 34 | @Override 35 | protected void initData() { 36 | mTabLayout.addTab(mTabLayout.newTab()); 37 | mTabLayout.addTab(mTabLayout.newTab()); 38 | mTabLayout.addTab(mTabLayout.newTab()); 39 | 40 | mViewPager.setAdapter(new ZhihuPagerFragmentAdapter(getChildFragmentManager(), 41 | getString(R.string.recommend), getString(R.string.hot), getString(R.string.favorite), 42 | getString(R.string.more))); 43 | mTabLayout.setupWithViewPager(mViewPager); 44 | } 45 | 46 | @Override 47 | protected int getLayoutId() { 48 | return R.layout.zhihu_fragment_second; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/third/MsgFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.third; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | import android.widget.EditText; 8 | import android.widget.Toast; 9 | 10 | import com.chad.library.adapter.base.BaseQuickAdapter; 11 | import com.meis.basemodule.R; 12 | import com.meis.basemodule.adapter.ChatRightAdapter; 13 | import com.meis.basemodule.base.BaseFragment; 14 | import com.meis.basemodule.entity.Chat; 15 | 16 | /** 17 | * author: ws4 18 | * created on: 2018/4/13 11:18 19 | * description: 20 | */ 21 | public class MsgFragment extends BaseFragment { 22 | 23 | private static final String ARG_MSG = "arg_msg"; 24 | 25 | private Chat mChat; 26 | 27 | private RecyclerView mRecyclerView; 28 | 29 | private ChatRightAdapter mAdapter; 30 | 31 | private EditText mEditText; 32 | 33 | public static MsgFragment newInstance(Chat msg) { 34 | 35 | Bundle args = new Bundle(); 36 | args.putParcelable(ARG_MSG, msg); 37 | MsgFragment fragment = new MsgFragment(); 38 | fragment.setArguments(args); 39 | return fragment; 40 | } 41 | 42 | @Override 43 | protected void initView() { 44 | Bundle args = getArguments(); 45 | if (args != null) { 46 | if (args.containsKey(ARG_MSG)) { 47 | this.mChat = args.getParcelable(ARG_MSG); 48 | } 49 | } 50 | 51 | mRecyclerView = findViewById(R.id.recycler); 52 | } 53 | 54 | @Override 55 | protected void initData() { 56 | getToolbarView().setTitle(mChat.name); 57 | getToolbarView().setNavigationIcon(R.mipmap.ic_arrow_back_white_24dp); 58 | getToolbarView().setNavigationOnClickListener(new View.OnClickListener() { 59 | @Override 60 | public void onClick(View v) { 61 | pop(); 62 | } 63 | }); 64 | 65 | mRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity)); 66 | mRecyclerView.setAdapter(mAdapter = new ChatRightAdapter()); 67 | 68 | mAdapter.addData(mChat); 69 | 70 | mEditText = findViewById(R.id.et_send); 71 | 72 | findViewById(R.id.btn_send).setOnClickListener(new View.OnClickListener() { 73 | @Override 74 | public void onClick(View view) { 75 | String content = mEditText.getText().toString().trim(); 76 | if (!content.equals("")) { 77 | Chat chat = new Chat(); 78 | chat.id = content.hashCode(); 79 | chat.message = content; 80 | mAdapter.addData(chat); 81 | mEditText.setText(""); 82 | } 83 | } 84 | }); 85 | 86 | mAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() { 87 | @Override 88 | public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) { 89 | Toast.makeText(mActivity, getString(R.string.chat_header_click), Toast.LENGTH_SHORT).show(); 90 | } 91 | }); 92 | } 93 | 94 | @Override 95 | protected int getLayoutId() { 96 | return R.layout.zhihu_fragment_tab_first_msg; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/fragment/ui/third/ZhihuThirdFragment.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.fragment.ui.third; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.LinearLayoutManager; 5 | import android.support.v7.widget.RecyclerView; 6 | import android.view.View; 7 | 8 | import com.chad.library.adapter.base.BaseQuickAdapter; 9 | import com.meis.base.mei.adapter.MeiBaseAdapter; 10 | import com.meis.base.mei.header.DingDangHeader; 11 | import com.meis.basemodule.R; 12 | import com.meis.basemodule.adapter.ChatAdapter; 13 | import com.meis.basemodule.base.BaseListFragment; 14 | import com.meis.basemodule.entity.Chat; 15 | import com.meis.basemodule.entity.Result; 16 | import com.meis.basemodule.fragment.MainFragment; 17 | import com.scwang.smartrefresh.layout.api.RefreshHeader; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | 22 | import io.reactivex.Observable; 23 | 24 | /** 25 | * Created by YoKeyword on 16/6/3. 26 | */ 27 | public class ZhihuThirdFragment extends BaseListFragment { 28 | 29 | public static ZhihuThirdFragment newInstance() { 30 | 31 | Bundle args = new Bundle(); 32 | 33 | ZhihuThirdFragment fragment = new ZhihuThirdFragment(); 34 | fragment.setArguments(args); 35 | return fragment; 36 | } 37 | 38 | @Override 39 | protected void initView() { 40 | super.initView(); 41 | } 42 | 43 | @Override 44 | protected void initData() { 45 | getToolbarView().setTitle(getResources().getString(R.string.message)); 46 | } 47 | 48 | @Override 49 | protected RecyclerView getRecyclerView() { 50 | RecyclerView recyclerView = findViewById(R.id.recycler); 51 | recyclerView.setLayoutManager(new LinearLayoutManager(mActivity)); 52 | return recyclerView; 53 | } 54 | 55 | @Override 56 | protected MeiBaseAdapter getAdapter() { 57 | ChatAdapter chatAdapter = new ChatAdapter(); 58 | chatAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() { 59 | @Override 60 | public void onItemClick(BaseQuickAdapter adapter, View view, int position) { 61 | // 因为启动的MsgFragment是MainFragment的兄弟Fragment,所以需要MainFragment.start() 62 | 63 | // 也可以像使用getParentFragment()的方式,拿到父Fragment来操作 或者使用 EventBusActivityScope 64 | ((MainFragment) getParentFragment()).start(MsgFragment.newInstance(mAdapter 65 | .getItem(position))); 66 | } 67 | }); 68 | return chatAdapter; 69 | } 70 | 71 | @Override 72 | protected Observable>> getListObservable(int pageNo) { 73 | return getData(pageNo); 74 | } 75 | 76 | public Observable>> getData(int pageNo) { 77 | Result> result = new Result<>(); 78 | List chatList = new ArrayList<>(); 79 | for (int i = 0; i < 20; i++) { 80 | Chat chat = new Chat(); 81 | chat.id = i; 82 | String[] name = new String[]{"Jake", "Eric", "Kenny", "Helen", "Carr"}; 83 | String[] chats = new String[]{"message1", "message2", "message3", "message4", 84 | "message5"}; 85 | chat.name = name[i % name.length]; 86 | chat.message = chats[i % name.length]; 87 | chatList.add(chat); 88 | } 89 | result.data = chatList; 90 | result.resultCode = 0; 91 | result.message = ""; 92 | return Observable.just(result); 93 | } 94 | 95 | @Override 96 | public boolean canLoadMore() { 97 | return false; 98 | } 99 | 100 | @Override 101 | public boolean canPullToRefresh() { 102 | return true; 103 | } 104 | 105 | @Override 106 | protected int getLayoutId() { 107 | return R.layout.comm_recycler; 108 | } 109 | 110 | @Override 111 | public RefreshHeader getRefreshHeader() { 112 | return new DingDangHeader(mActivity); 113 | } 114 | 115 | @Override 116 | protected boolean loadOnShow() { 117 | return false; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/utils/ListUtils.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.utils; 2 | 3 | import java.util.Collection; 4 | 5 | /** 6 | * author: ws4 7 | * created on: 2018/4/11 18:19 8 | * description:集合工具 9 | */ 10 | public class ListUtils { 11 | public static boolean isEmpty(Collection collection) { 12 | return collection == null || collection.size() == 0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/com/meis/basemodule/widget/BottomBarTab.java: -------------------------------------------------------------------------------- 1 | package com.meis.basemodule.widget; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.annotation.DrawableRes; 7 | import android.support.v4.content.ContextCompat; 8 | import android.util.AttributeSet; 9 | import android.util.TypedValue; 10 | import android.view.Gravity; 11 | import android.widget.FrameLayout; 12 | import android.widget.ImageView; 13 | 14 | import com.meis.basemodule.R; 15 | 16 | /** 17 | * Created by YoKeyword on 16/6/3. 18 | */ 19 | public class BottomBarTab extends FrameLayout { 20 | private ImageView mIcon; 21 | private Context mContext; 22 | private int mTabPosition = -1; 23 | 24 | public BottomBarTab(Context context, @DrawableRes int icon) { 25 | this(context, null, icon); 26 | } 27 | 28 | public BottomBarTab(Context context, AttributeSet attrs, int icon) { 29 | this(context, attrs, 0, icon); 30 | } 31 | 32 | public BottomBarTab(Context context, AttributeSet attrs, int defStyleAttr, int icon) { 33 | super(context, attrs, defStyleAttr); 34 | init(context, icon); 35 | } 36 | 37 | private void init(Context context, int icon) { 38 | mContext = context; 39 | TypedArray typedArray = context.obtainStyledAttributes(new int[]{R.attr 40 | .selectableItemBackgroundBorderless}); 41 | Drawable drawable = typedArray.getDrawable(0); 42 | setBackgroundDrawable(drawable); 43 | typedArray.recycle(); 44 | 45 | mIcon = new ImageView(context); 46 | int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 27, getResources 47 | ().getDisplayMetrics()); 48 | LayoutParams params = new LayoutParams(size, size); 49 | params.gravity = Gravity.CENTER; 50 | mIcon.setImageResource(icon); 51 | mIcon.setLayoutParams(params); 52 | mIcon.setColorFilter(ContextCompat.getColor(context, R.color.tab_unselect)); 53 | addView(mIcon); 54 | } 55 | 56 | @Override 57 | public void setSelected(boolean selected) { 58 | super.setSelected(selected); 59 | if (selected) { 60 | mIcon.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary)); 61 | } else { 62 | mIcon.setColorFilter(ContextCompat.getColor(mContext, R.color.tab_unselect)); 63 | } 64 | } 65 | 66 | public void setTabPosition(int position) { 67 | mTabPosition = position; 68 | if (position == 0) { 69 | setSelected(true); 70 | } 71 | } 72 | 73 | public int getTabPosition() { 74 | return mTabPosition; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/res/anim/comm_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/anim/comm_bottom_out.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/anim/live_btn_bottom_in.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 7 | 8 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/chatfrom_bg_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-hdpi/chatfrom_bg_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/chatto_bg_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-hdpi/chatto_bg_normal.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/actionbar_shadow_up.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/actionbar_shadow_up.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/bg_second.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/bg_second.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_account_circle_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/ic_account_circle_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/ic_avatar.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_discover_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/ic_discover_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_home_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/ic_home_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_message_white_24dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable-xxhdpi/ic_message_white_24dp.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_chat_input.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_chat_right.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HpWens/MeiBaseModule/5e1e38f91bba1b8e6dedd7ae1a84d064a5d4c9d6/app/src/main/res/drawable/bg_chat_right.9.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/comm_btn_close_gray.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_create_live.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_create_shortvideo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_custom_base_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |