Commit f6d23f56ef04a7adc4a63e3712bcf1faaf5395c2

Authored by YangShuai
1 parent de2d04c9

优化基类

app/strike/src/main/java/com/cnlive/strike/MyActivityTest1.java
... ... @@ -7,7 +7,7 @@ public class MyActivityTest1 extends BaseActivity {
7 7  
8 8 @Override
9 9 protected int initLayout() {
10   - return R.layout.activity_my;
  10 + return R.layout.activity_my1;
11 11 }
12 12  
13 13 @Override
... ...
app/strike/src/main/java/com/cnlive/strike/MyFragment1.java
... ... @@ -26,7 +26,7 @@ public class MyFragment1 extends BaseFragment<MyFragment1View, MyPresenter1> {
26 26  
27 27 @Override
28 28 protected void initView() {
29   - setStatusBarColor(R.color.green, 0);
  29 + setStatusBarColor(R.color.qmui_config_color_red, 0);
30 30 setStatusBarTextColor(StatusBarConfig.BLACK);
31 31  
32 32  
... ...
app/strike/src/main/res/layout/activity_my1.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + tools:context="com.cnlive.strike.MyActivity">
  8 + <RelativeLayout
  9 + android:id="@+id/fragment_container"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent">
  12 +
  13 + </RelativeLayout>
  14 +</RelativeLayout>
... ...
core/base/src/main/java/com/cnlive/libs/base/frame/fragment/BaseFragment.java
... ... @@ -35,7 +35,10 @@ public abstract class BaseFragment&lt;V extends BaseView, P extends BasePresenter&lt;V
35 35 }
36 36 }
37 37  
38   -
  38 + @NonNull
  39 + public V createView() {
  40 + return ReflectUtil.instanceView(0, this.getClass(), this, BaseView.class);
  41 + }
39 42 @Override
40 43 public P createPresenter() {
41 44 return ReflectUtil.instancePresenter(1, this.getClass(), BasePresenter.class);
... ... @@ -44,7 +47,10 @@ public abstract class BaseFragment&lt;V extends BaseView, P extends BasePresenter&lt;V
44 47 @NonNull
45 48 @Override
46 49 public V getMvpView() {
47   - return ReflectUtil.instanceView(0, this.getClass(), this, BaseView.class);
  50 + if (null == view) {
  51 + view = createView();
  52 + }
  53 + return view;
48 54 }
49 55  
50 56 // protected abstract int getLayoutId();
... ...