├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── mipmap-xxhdpi
│ │ │ ├── splash.png
│ │ │ ├── ic_launcher.png
│ │ │ ├── arrow_right_black.png
│ │ │ ├── arrow_right_white.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.png
│ │ │ ├── tab_fist_no.png
│ │ │ ├── tab_fist_yes.png
│ │ │ ├── tab_fourth_no.png
│ │ │ ├── tab_second_no.png
│ │ │ ├── tab_third_no.png
│ │ │ ├── tab_third_yes.png
│ │ │ ├── tab_fourth_yes.png
│ │ │ ├── tab_second_yes.png
│ │ │ ├── title_back_gray.png
│ │ │ ├── title_back_white.png
│ │ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.png
│ │ │ └── ic_launcher_round.png
│ │ ├── drawable
│ │ │ ├── shape_text_cursor_drawable.xml
│ │ │ ├── shape_square_dark_blue.xml
│ │ │ ├── shape_circle_gray.xml
│ │ │ ├── shape_circle_dark_blue.xml
│ │ │ ├── bg_round_white.xml
│ │ │ ├── shape_toast_bg.xml
│ │ │ ├── selector_main_bottom_navigation_icon_first.xml
│ │ │ ├── selector_main_bottom_navigation_icon_fourth.xml
│ │ │ ├── selector_main_bottom_navigation_icon_secoud.xml
│ │ │ ├── selector_main_bottom_navigation_icon_third.xml
│ │ │ ├── shape_border_btn_blue_circle.xml
│ │ │ ├── shape_border_btn_gray_rectangle.xml
│ │ │ ├── shape_border_btn_blue_rectangle.xml
│ │ │ ├── shape_btn_blue_circle.xml
│ │ │ └── ic_launcher_background.xml
│ │ ├── xml
│ │ │ └── network_security_config.xml
│ │ ├── values
│ │ │ ├── dimens.xml
│ │ │ ├── ids.xml
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ ├── attr.xml
│ │ │ └── styles.xml
│ │ ├── anim
│ │ │ ├── left_push_out.xml
│ │ │ └── right_push_in.xml
│ │ ├── values-zh
│ │ │ └── strings.xml
│ │ ├── layout
│ │ │ ├── fragment_fourth.xml
│ │ │ ├── fragment_second.xml
│ │ │ ├── fragment_third.xml
│ │ │ ├── toast_view.xml
│ │ │ ├── fragment_first.xml
│ │ │ ├── activity_splash.xml
│ │ │ ├── view_edit_input.xml
│ │ │ ├── layout_company_person.xml
│ │ │ ├── activity_main.xml
│ │ │ ├── view_comm_title_bar.xml
│ │ │ ├── dialog_common_round.xml
│ │ │ ├── activity_login.xml
│ │ │ └── activity_settings.xml
│ │ └── values-en
│ │ │ └── strings.xml
│ │ ├── java
│ │ └── com
│ │ │ └── lxb
│ │ │ └── freeAndroid
│ │ │ ├── frame
│ │ │ ├── mvp
│ │ │ │ ├── IModel.java
│ │ │ │ ├── IPresenter.java
│ │ │ │ ├── IView.java
│ │ │ │ ├── BasePresenter.java
│ │ │ │ └── BaseModel.java
│ │ │ ├── base
│ │ │ │ ├── Constants.java
│ │ │ │ ├── OnFragmentInteractionListener.java
│ │ │ │ ├── BaseViewHolder.java
│ │ │ │ ├── AppConfig.java
│ │ │ │ ├── BaseResponseBean.java
│ │ │ │ ├── BasesActivity.java
│ │ │ │ ├── OrdinaryBaseActivity.java
│ │ │ │ ├── BaseFragment.java
│ │ │ │ └── AppApplication.java
│ │ │ └── http
│ │ │ │ ├── ApiUrl.java
│ │ │ │ ├── interceptor
│ │ │ │ ├── TestLogInterceptor.java
│ │ │ │ ├── DefaultInterceptor.java
│ │ │ │ └── HttpLogInterceptor.java
│ │ │ │ ├── Service.java
│ │ │ │ ├── gsonConverterFactory
│ │ │ │ ├── GsonRequestBodyConverter.java
│ │ │ │ ├── CustomGsonConverterFactory.java
│ │ │ │ └── GsonResponseBodyConverter.java
│ │ │ │ ├── RetrofitManager.java
│ │ │ │ └── ResponseObserver.java
│ │ │ └── project
│ │ │ ├── mainDemo
│ │ │ ├── MainBean.java
│ │ │ ├── fragment
│ │ │ │ ├── thirdFragment
│ │ │ │ │ ├── ThirdPresenter.java
│ │ │ │ │ ├── ThirdContract.java
│ │ │ │ │ ├── ThirdModelImpl.java
│ │ │ │ │ └── ThirdFragment.java
│ │ │ │ ├── fourthFragment
│ │ │ │ │ ├── FourthPresenter.java
│ │ │ │ │ ├── FourthContract.java
│ │ │ │ │ ├── FourthModelImpl.java
│ │ │ │ │ └── FourthFragment.java
│ │ │ │ ├── secondFragment
│ │ │ │ │ ├── SecondPresenter.java
│ │ │ │ │ ├── SecondContract.java
│ │ │ │ │ ├── SecondModelImpl.java
│ │ │ │ │ └── SecondFragment.java
│ │ │ │ └── firstFragment
│ │ │ │ │ ├── FirstContract.java
│ │ │ │ │ ├── FirstModelImpl.java
│ │ │ │ │ ├── FirstPresenter.java
│ │ │ │ │ └── FirstFragment.java
│ │ │ ├── presenter
│ │ │ │ └── MainPresenter.java
│ │ │ ├── MainContract.java
│ │ │ ├── MainModelImpl.java
│ │ │ └── SplashActivity.java
│ │ │ ├── modulesDemo
│ │ │ └── mineModule
│ │ │ │ ├── login
│ │ │ │ ├── LoginBean.java
│ │ │ │ ├── LoginContract.java
│ │ │ │ ├── LoginModelImpl.java
│ │ │ │ ├── LoginPresenter.java
│ │ │ │ └── LoginActivity.java
│ │ │ │ └── SettingsActivity.java
│ │ │ ├── utils
│ │ │ ├── GlideUtils
│ │ │ │ ├── GlideCatchConfig.java
│ │ │ │ ├── GlideCacheModule.java
│ │ │ │ └── GlideCatchUtil.java
│ │ │ ├── StringFilterUtils.java
│ │ │ ├── ToastUtils
│ │ │ │ ├── ToastUtil.java
│ │ │ │ └── ToastView.java
│ │ │ ├── SizeUtils.java
│ │ │ ├── FileIOUtils.java
│ │ │ ├── GsonUtils.java
│ │ │ ├── AppUtils.java
│ │ │ ├── FeatureUtils.java
│ │ │ ├── SoftInputUtils.java
│ │ │ ├── EditTextUtils.java
│ │ │ ├── GPSUtils.java
│ │ │ └── LanguageUtils.java
│ │ │ └── views
│ │ │ └── EditInputView.java
│ │ └── AndroidManifest.xml
├── build.gradle
└── proguard-rules.pro
├── settings.gradle
├── 附件
├── 目录.jpg
├── splash.png
└── titleLogo.jpg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── 项目目录结构说明.txt
├── gradle.properties
├── README.md
└── gradlew.bat
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/附件/目录.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/附件/目录.jpg
--------------------------------------------------------------------------------
/附件/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/附件/splash.png
--------------------------------------------------------------------------------
/附件/titleLogo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/附件/titleLogo.jpg
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/splash.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_fist_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_fist_no.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_fist_yes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_fist_yes.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_fourth_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_fourth_no.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_second_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_second_no.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_third_no.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_third_no.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_third_yes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_third_yes.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_fourth_yes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_fourth_yes.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/tab_second_yes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/tab_second_yes.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/title_back_gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/title_back_gray.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/title_back_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/title_back_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/arrow_right_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/arrow_right_black.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/arrow_right_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/arrow_right_white.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lixiangbin/FreeAndroid/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_text_cursor_drawable.xml:
--------------------------------------------------------------------------------
1 |
2 |
extends OrdinaryBaseActivity { 18 | 19 | //Presenter实例 20 | protected P presenter; 21 | 22 | @Override 23 | void mvpPresenterInit() { 24 | super.mvpPresenterInit(); 25 | //实例化Presenter 26 | presenter = initPresenter(); 27 | //绑定presenter 28 | if (presenter != null) { 29 | presenter.bind(); 30 | } 31 | } 32 | 33 | /** 34 | * 作者:李相斌 35 | * 创建时期:xxxx-08-23 36 | * 方法说明:初始化Presenter 37 | */ 38 | protected abstract P initPresenter(); 39 | 40 | 41 | @Override 42 | protected void onDestroy() { 43 | super.onDestroy(); 44 | //解除presenter绑定 45 | if (presenter != null) { 46 | presenter.onDestroy(); 47 | presenter = null; 48 | } 49 | System.gc(); 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/lxb/freeAndroid/frame/mvp/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.lxb.freeAndroid.frame.mvp; 2 | 3 | import java.util.HashMap; 4 | import java.util.LinkedHashMap; 5 | 6 | /** 7 | * 业务名:BasePresenter 8 | * 功能说明:Presenter基类 9 | * 编写日期: xxxx/8/25 0025. 10 | * 作者: 李相斌 11 | *
12 | * 历史记录 13 | * 1、修改日期: 14 | * 修改人: 15 | * 修改内容: 16 | */ 17 | public abstract class BasePresenter这是一个能让你快速开始新项目而不必重新搭建框架的开源mvp项目,旨在为了让更多的开发者在开发初期,或者开发周期要求较短的情况下,只需关注业务层开发,不用再去设计搭建繁琐的框架层;同时也为尝试学习设计框架的Android开发人员提供一个示范学习项目;当然,如果您发现项目中有需要改进或优化的地方,欢迎联系作者(联系方式在结尾处)指出或提交 "Pull Requests"。
6 | 7 | **【项目中用到的技术或开源库】** 8 | 架构模式:MVP 9 | 网络框架:Retrofit+okHttp 10 | 注入框架:ButterKnife 11 | 异步处理/线程切换:RxJava/RxAndroid 12 | 图片加载:Glide 13 | 事件总线:EventBus (这里未使用RxBus,有两点原因:1.RxBus无法发送粘性事件;2.RxBus效率会随订阅者增多而成比例下降等;若你的项 14 | 目中不介意这些,可在gradle文件中删除EventBus引用,并将RxBus文件添加到项目中;有关RxBus使用这里暂不讲解) 15 | 动态权限库:RxPermissions2 16 | 17 | 18 | **【项目目录结构说明】** 19 | 20 |  21 | 22 | **【如何使用】** 23 | 24 |1.MVP模式的Activity使用可参考 project/modulesDemo/login 目录下LoginActivity; 26 | 2.MVP模式的Fragment使用可参考 project/mainDemo/fragment 目录下FirstFragment; 27 | 3.相关M层、V层、P层的继承写法以及使用可参考此目录下相关类文件; 28 | 4.无网络请求的Activity可继承OrdinaryBaseActivity作为基类,具体请参考SettingsActivity。 29 |
30 | 31 |【必】1.ApiUrl.java类 (app/src/main/java/com/lxb/freeAndroid/frame/http/ApiUrl.java):服务器域名、api地址等url可在此文件中配置、添加; 40 | 【必】2.BaseModel.java类 (app/src/main/java/com/lxb/freeAndroid/frame/mvp/BaseModel.java):公共请求参数可在此类的“setParams()”方法中配置; 41 | 【选】3.ResponseObserver.java类 (app/src/main/java/com/lxb/freeAndroid/frame/http/ResponseObserver.java):此文件中可根据实际需要对你请求到的网络数据进行预处理、业务预封装等; 42 | 【选】4.OkHttpClientManager.java类 (app/src/main/java/com/lxb/freeAndroid/frame/http/OkHttpClientManager.java):可在此文件中配置SSL相关,默认信任所有主机; 43 | 【选】5.Service.java类 (app/src/main/java/com/lxb/freeAndroid/frame/http/Service.java):api接口封装,此处只封装了一个常用POST请求,可根据需求添加GET请求、文件上传下载等api等。 44 | 另:其它配置(如:签名、包名等)这里不再详述;
45 | 46 | 47 |1.项目中所提供的工具类、自定义View、属性样式、资源文件等,可自行修改或增删; 49 |
50 | 51 | 作者QQ:1276655894 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/lxb/freeAndroid/project/utils/ToastUtils/ToastView.java: -------------------------------------------------------------------------------- 1 | package com.lxb.freeAndroid.project.utils.ToastUtils; 2 | 3 | import android.content.Context; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.widget.TextView; 7 | import android.widget.Toast; 8 | 9 | 10 | import com.lxb.freeAndroid.R; 11 | 12 | import java.util.Timer; 13 | import java.util.TimerTask; 14 | /** 15 | * 业务名: 自定义Toast 16 | * 功能说明: 17 | * 编写日期: xxxx-08-29 18 | * 作者: 19 | * 20 | * 历史记录 21 | * 1、修改日期: 22 | * 修改人: 23 | * 修改内容: 24 | */ 25 | 26 | public class ToastView { 27 | 28 | public static Toast toast; 29 | private int time; 30 | private Timer timer; 31 | 32 | public ToastView(Context context, String text) { 33 | LayoutInflater inflater = LayoutInflater.from(context); 34 | View view = inflater.inflate(R.layout.toast_view, null); 35 | TextView t = (TextView) view.findViewById(R.id.toast_text); 36 | t.setText(text); 37 | if(toast != null) { 38 | toast.cancel(); 39 | } 40 | toast = new Toast(context); 41 | toast.setDuration(Toast.LENGTH_SHORT); 42 | toast.setView(view); 43 | } 44 | 45 | public ToastView(Context context, int text) { 46 | LayoutInflater inflater = LayoutInflater.from(context); 47 | View view = inflater.inflate(R.layout.toast_view, null); 48 | TextView t = (TextView) view.findViewById(R.id.toast_text); 49 | t.setText(text); 50 | if(toast != null) { 51 | toast.cancel(); 52 | } 53 | toast = new Toast(context); 54 | toast.setDuration(Toast.LENGTH_SHORT); 55 | toast.setView(view); 56 | } 57 | 58 | //设置toast显示位置 59 | public void setGravity(int gravity, int xOffset, int yOffset) { 60 | //toast.setGravity(Gravity.CENTER, 0, 0); //居中显示 61 | toast.setGravity(gravity, xOffset, yOffset); 62 | } 63 | 64 | //设置toast显示时间 65 | public void setDuration(int duration) { 66 | toast.setDuration(duration); 67 | } 68 | //设置toast显示时间(自定义时间) 69 | public void setLongTime(final int duration) { 70 | time = duration; 71 | timer = new Timer(); 72 | timer.schedule(new TimerTask(){ 73 | @Override 74 | public void run() { 75 | if(time-1000 >= 0) { 76 | show(); 77 | time= time - 1000; 78 | } else { 79 | timer.cancel(); 80 | cancel(); 81 | } 82 | } 83 | }, 0,1000); 84 | } 85 | 86 | public void show() { 87 | toast.show(); 88 | } 89 | 90 | public static void cancel() { 91 | if(toast != null) { 92 | toast.cancel(); 93 | } 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_company_person.xml: -------------------------------------------------------------------------------- 1 | 2 | extends Fragment {
35 |
36 | //Presenter
37 | protected P presenter;
38 | //View
39 | private View view;
40 | //ButterKnife注解
41 | private Unbinder unbinder;
42 | //Context
43 | protected Context context;
44 | //封装activity与fragment数据交互
45 | private OnFragmentInteractionListener onFragmentInteractionListener;
46 |
47 | private boolean tag;
48 |
49 | public void setTag(boolean tag) {
50 | this.tag = tag;
51 | }
52 |
53 | public boolean findTag() {
54 | return tag;
55 | }
56 |
57 | //来自宿主activity的Bundle
58 | protected Bundle actBundle;
59 |
60 | @Override
61 | public void onAttach(Context context) {
62 | super.onAttach(context);
63 | this.context = context;
64 |
65 | }
66 |
67 | @Override
68 | public void onCreate(@Nullable Bundle savedInstanceState) {
69 | super.onCreate(savedInstanceState);
70 |
71 | if (getArguments() != null) {
72 | actBundle = getArguments();
73 | }
74 | //注册EventBus
75 | //EventBus.getDefault().register(this);
76 | //初始化 presenter
77 | presenter = initPresenter();
78 | //presenter绑定
79 | if (presenter != null) {
80 | presenter.bind();
81 | }
82 | }
83 |
84 |
85 | @Nullable
86 | @Override
87 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
88 | view = inflater.inflate(getLayoutId(), container, false);
89 | //绑定 ButterKnife
90 | unbinder = ButterKnife.bind(this, view);
91 | return view;
92 | }
93 |
94 | @Override
95 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
96 | super.onViewCreated(view, savedInstanceState);
97 | initViewData(view, savedInstanceState);
98 | }
99 |
100 | @Override
101 | public void onDestroy() {
102 | super.onDestroy();
103 | //解除EventBus
104 | //EventBus.getDefault().unregister(this);
105 | //解除presenter绑定
106 | if (presenter != null) {
107 | presenter.onDestroy();
108 | presenter = null;
109 | }
110 | //解除ButterKnife注入绑定
111 | if (unbinder != null) {
112 | unbinder.unbind();
113 | unbinder = null;
114 | }
115 | System.gc();
116 | }
117 |
118 | @Override
119 | public void onDetach() {
120 | super.onDetach();
121 | onFragmentInteractionListener = null;
122 | }
123 |
124 | /**
125 | * 作者:李相斌
126 | * 创建时期:xxxx-09-04
127 | * 方法说明:统一跳转
128 | */
129 | protected void startActivity(Class extends Activity> activityCls) {
130 | startActivity(activityCls, null);
131 | }
132 |
133 | protected void startActivity(Class extends Activity> activityCls, Bundle bundle) {
134 | Intent intent = new Intent(context, activityCls);
135 | if (bundle != null) {
136 | intent.putExtras(bundle);
137 | }
138 | startActivity(intent);
139 | }
140 |
141 | /**
142 | * 作者:李相斌
143 | * 创建时期:xxxx-08-28
144 | * 方法说明:初始化presenter
145 | */
146 | protected abstract P initPresenter();
147 |
148 | /**
149 | * 作者:李相斌
150 | * 创建时期:xxxx-08-28
151 | * 方法说明:初始化View
152 | */
153 | protected abstract void initViewData(View view, Bundle savedInstanceState);
154 |
155 | /**
156 | * 作者:李相斌
157 | * 创建时期:xxxx-08-28
158 | * 方法说明:获取界面布局id
159 | */
160 | protected abstract int getLayoutId();
161 |
162 |
163 | /**
164 | * 作者:李相斌
165 | * 创建时期:xxxx-08-28
166 | * 方法说明:简化findViewById
167 | */
168 | protected