Modify: 基类调整,不再使用构造方法,采用反射进行初始化

This commit is contained in:
Quyunshuo
2020-09-26 17:17:04 +08:00
parent f14f5e9b32
commit bc9772a828
12 changed files with 37 additions and 108 deletions

View File

@ -65,9 +65,6 @@ android {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
buildFeatures {
viewBinding = true
}
}
dependencies {

View File

@ -21,15 +21,7 @@
android:supportsRtl="true"
android:theme="@style/base_AppTheme"
tools:ignore="UnusedAttribute">
<activity
android:name=".MyActivity"
android:screenOrientation="portrait"
android:theme="@style/base_AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 屏幕适配基准DP -->
<meta-data
android:name="design_width_in_dp"

View File

@ -1,27 +0,0 @@
package com.quyunshuo.androidbaseframemvvm;
import com.quyunshuo.androidbaseframemvvm.databinding.MyActivityLayoutBinding;
import com.quyunshuo.base.mvvm.v.BaseFrameActivity;
import org.jetbrains.annotations.NotNull;
/**
* @author DBoy
* @date 2020/9/26
* Class 描述 :
*/
public class MyActivity extends BaseFrameActivity<MyActivityLayoutBinding, MyViewModel> {
@Override
protected void initView() {
getMViewModel().test();
getMBinding().testTv.setText("反射初始化 ViewBinding");
}
@Override
protected void initViewObserve() {
}
}

View File

@ -1,17 +0,0 @@
package com.quyunshuo.androidbaseframemvvm;
import android.util.Log;
import androidx.lifecycle.ViewModel;
/**
* @author DBoy
* @date 2020/9/26
* Class 描述 :
*/
public class MyViewModel extends ViewModel {
public void test(){
Log.e("DJC", "AAA");
}
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<TextView
android:id="@+id/test_Tv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textColor="#000"
android:textSize="20sp" />
</androidx.constraintlayout.widget.ConstraintLayout>