├── car_hmi ├── .gitignore ├── libs │ └── sdk.jar ├── src │ └── main │ │ ├── res │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ └── themes.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.webp │ │ │ └── ic_launcher_round.webp │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── values-night │ │ │ └── themes.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── layout │ │ │ └── activity_hvac.xml │ │ └── drawable │ │ │ └── ic_launcher_background.xml │ │ ├── java │ │ └── com │ │ │ └── mvvm │ │ │ └── hmi │ │ │ └── ipc │ │ │ ├── model │ │ │ ├── HvacCallback.java │ │ │ └── HvacRepository.java │ │ │ ├── CarApp.java │ │ │ ├── ui │ │ │ ├── HvacActivity.java │ │ │ └── HvacViewModel.java │ │ │ └── factory │ │ │ ├── AppInjection.java │ │ │ └── AppViewModelFactory.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── lib_mvvm_fwk ├── .gitignore ├── src │ └── main │ │ ├── java │ │ └── com │ │ │ └── mvvm │ │ │ └── fwk │ │ │ ├── model │ │ │ └── BaseRepository.java │ │ │ ├── viewmodel │ │ │ ├── BaseViewModel.java │ │ │ └── BaseAndroidViewModel.java │ │ │ ├── ui │ │ │ ├── BaseBindingActivity.java │ │ │ ├── BaseBindingFragment.java │ │ │ ├── BaseActivity.java │ │ │ ├── BaseMvvmActivity.java │ │ │ ├── BaseMvvmFragment.java │ │ │ └── BaseFragment.java │ │ │ ├── utils │ │ │ ├── eventbus │ │ │ │ ├── LiveDataBus.java │ │ │ │ └── StickyLiveData.java │ │ │ ├── LogUtils.java │ │ │ └── AppExecutors.java │ │ │ └── AppGlobal.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── settings.gradle ├── gradle.properties ├── gradlew.bat ├── gradlew ├── LICENSE └── README.md /car_hmi/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /lib_mvvm_fwk/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /car_hmi/libs/sdk.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/libs/sdk.jar -------------------------------------------------------------------------------- /car_hmi/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | app_simple 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /lib_mvvm_fwk/src/main/java/com/mvvm/fwk/model/BaseRepository.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.fwk.model; 2 | 3 | public abstract class BaseRepository { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | .idea 5 | app 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linxu-link/CarMvvmArch/HEAD/car_hmi/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /lib_mvvm_fwk/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /car_hmi/src/main/java/com/mvvm/hmi/ipc/model/HvacCallback.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.hmi.ipc.model; 2 | 3 | public interface HvacCallback { 4 | 5 | default void onTemperatureChanged(String temp){ 6 | 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Oct 30 20:59:15 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip 4 | distributionPath=wrapper/dists 5 | zipStorePath=wrapper/dists 6 | zipStoreBase=GRADLE_USER_HOME 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | 3 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 4 | repositories { 5 | google() 6 | mavenCentral() 7 | } 8 | } 9 | rootProject.name = "ARCH_MVVM" 10 | include ':lib_mvvm_fwk' 11 | //include ':app' 12 | include ':car_hmi' 13 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /car_hmi/src/main/java/com/mvvm/hmi/ipc/CarApp.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.hmi.ipc; 2 | 3 | import android.app.Application; 4 | 5 | public class CarApp extends Application { 6 | 7 | public static final String TAG_HVAC = "HVAC_"; 8 | 9 | @Override 10 | public void onCreate() { 11 | super.onCreate(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /lib_mvvm_fwk/src/main/java/com/mvvm/fwk/viewmodel/BaseViewModel.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.fwk.viewmodel; 2 | 3 | import static com.mvvm.fwk.utils.LogUtils.TAG_FWK; 4 | 5 | import androidx.lifecycle.ViewModel; 6 | 7 | import com.mvvm.fwk.model.BaseRepository; 8 | import com.mvvm.fwk.utils.LogUtils; 9 | 10 | public abstract class BaseViewModel extends ViewModel { 11 | 12 | private final String TAG = TAG_FWK + getClass().getSimpleName(); 13 | 14 | protected M mRepository; 15 | 16 | public BaseViewModel(M repository) { 17 | mRepository = repository; 18 | } 19 | 20 | public M getRepository() { 21 | return mRepository; 22 | } 23 | 24 | @Override 25 | protected void onCleared() { 26 | super.onCleared(); 27 | LogUtils.logV(TAG, "[onCleared]"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /car_hmi/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 -------------------------------------------------------------------------------- /lib_mvvm_fwk/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 -------------------------------------------------------------------------------- /car_hmi/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /car_hmi/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /lib_mvvm_fwk/src/main/java/com/mvvm/fwk/viewmodel/BaseAndroidViewModel.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.fwk.viewmodel; 2 | 3 | import static com.mvvm.fwk.utils.LogUtils.TAG_FWK; 4 | 5 | import android.app.Application; 6 | 7 | import androidx.annotation.Nullable; 8 | import androidx.lifecycle.AndroidViewModel; 9 | 10 | import com.mvvm.fwk.model.BaseRepository; 11 | import com.mvvm.fwk.utils.LogUtils; 12 | 13 | public abstract class BaseAndroidViewModel extends AndroidViewModel { 14 | 15 | private final String TAG = TAG_FWK + getClass().getSimpleName(); 16 | 17 | protected M mRepository; 18 | 19 | public BaseAndroidViewModel(Application application, @Nullable M repository) { 20 | super(application); 21 | mRepository = repository; 22 | } 23 | 24 | public M getRepository() { 25 | return mRepository; 26 | } 27 | 28 | @Override 29 | protected void onCleared() { 30 | super.onCleared(); 31 | LogUtils.logV(TAG, "[onCleared]"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib_mvvm_fwk/src/main/java/com/mvvm/fwk/ui/BaseBindingActivity.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.fwk.ui; 2 | 3 | import android.os.Bundle; 4 | 5 | import androidx.annotation.LayoutRes; 6 | import androidx.annotation.Nullable; 7 | import androidx.databinding.DataBindingUtil; 8 | import androidx.databinding.ViewDataBinding; 9 | 10 | public abstract class BaseBindingActivity extends BaseActivity { 11 | 12 | protected V mBinding; 13 | 14 | @Override 15 | protected void onCreate(@Nullable Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | if (getLayoutId() == 0) { 18 | throw new RuntimeException("getLayout() must be not null"); 19 | } 20 | mBinding = DataBindingUtil.setContentView(this, getLayoutId()); 21 | mBinding.setLifecycleOwner(this); 22 | mBinding.executePendingBindings(); 23 | initView(); 24 | } 25 | 26 | @LayoutRes 27 | protected abstract int getLayoutId(); 28 | 29 | public V getBinding() { 30 | return mBinding; 31 | } 32 | 33 | protected abstract void initView(); 34 | } 35 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app"s APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true -------------------------------------------------------------------------------- /car_hmi/src/main/java/com/mvvm/hmi/ipc/ui/HvacActivity.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.hmi.ipc.ui; 2 | 3 | import android.content.Intent; 4 | 5 | import androidx.lifecycle.Observer; 6 | 7 | import com.mvvm.fwk.ui.BaseMvvmActivity; 8 | import com.mvvm.fwk.utils.LogUtils; 9 | import com.mvvm.fwk.utils.eventbus.LiveDataBus; 10 | import com.mvvm.hmi.ipc.BR; 11 | import com.mvvm.hmi.ipc.CarApp; 12 | import com.mvvm.hmi.ipc.R; 13 | import com.mvvm.hmi.ipc.databinding.ActivityHvacBinding; 14 | import com.mvvm.hmi.ipc.factory.AppInjection; 15 | 16 | public class HvacActivity extends BaseMvvmActivity{ 17 | 18 | @Override 19 | protected int getLayoutId() { 20 | return R.layout.activity_hvac; 21 | } 22 | 23 | @Override 24 | protected void initView() { 25 | 26 | } 27 | 28 | @Override 29 | protected Object getViewModelOrFactory() { 30 | return AppInjection.getViewModelFactory(); 31 | } 32 | 33 | @Override 34 | protected int getViewModelVariable() { 35 | return 0; 36 | } 37 | 38 | @Override 39 | protected void initObservable(HvacViewModel viewModel) { 40 | 41 | } 42 | 43 | @Override 44 | protected void loadData(HvacViewModel viewModel) { 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /car_hmi/src/main/java/com/mvvm/hmi/ipc/factory/AppInjection.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.hmi.ipc.factory; 2 | 3 | import androidx.lifecycle.ViewModel; 4 | import androidx.lifecycle.ViewModelProvider; 5 | import androidx.lifecycle.ViewModelStoreOwner; 6 | 7 | import com.fwk.sdk.hvac.HvacManager; 8 | import com.mvvm.hmi.ipc.model.HvacRepository; 9 | 10 | /** 11 | * 统一生成APP中 ViewModel & Repository. 12 | * 统一管理APP中的所有单例类. 13 | * 14 | * @author WuJia 15 | * @version 1.0 16 | * @date 2021/11/14 17 | */ 18 | public class AppInjection { 19 | 20 | // ViewModel 工厂 21 | private final static AppViewModelFactory mViewModelFactory = new AppViewModelFactory(); 22 | 23 | public static T getViewModel(ViewModelStoreOwner store, Class clazz) { 24 | return new ViewModelProvider(store, mViewModelFactory).get(clazz); 25 | } 26 | 27 | public static AppViewModelFactory getViewModelFactory() { 28 | return mViewModelFactory; 29 | } 30 | 31 | /** 32 | * 受保护的权限,除了ViewModel,其它模块不应该需要Model层的实例 33 | * 34 | * @return {@link HvacRepository} 35 | */ 36 | protected static HvacRepository getHvacRepository() { 37 | return new HvacRepository(getHvacManager()); 38 | } 39 | 40 | public static HvacManager getHvacManager() { 41 | return HvacManager.getInstance(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /car_hmi/src/main/java/com/mvvm/hmi/ipc/factory/AppViewModelFactory.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.hmi.ipc.factory; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.lifecycle.ViewModel; 5 | import androidx.lifecycle.ViewModelProvider; 6 | 7 | import com.mvvm.fwk.utils.AppExecutors; 8 | import com.mvvm.hmi.ipc.model.HvacRepository; 9 | import com.mvvm.hmi.ipc.ui.HvacViewModel; 10 | 11 | import java.lang.reflect.InvocationTargetException; 12 | 13 | // default 权限,不对外部公开此类 14 | class AppViewModelFactory implements ViewModelProvider.Factory { 15 | 16 | // 创建 viewModel 实例 17 | @NonNull 18 | @Override 19 | public T create(@NonNull Class modelClass) { 20 | try { 21 | if (modelClass == HvacViewModel.class) { 22 | return modelClass.getConstructor(HvacRepository.class, AppExecutors.class) 23 | .newInstance(AppInjection.getHvacRepository(), AppExecutors.get()); 24 | } else { 25 | throw new RuntimeException(modelClass.getSimpleName() + "create failed"); 26 | } 27 | } catch (NoSuchMethodException | IllegalAccessException 28 | | InstantiationException | InvocationTargetException exception) { 29 | exception.printStackTrace(); 30 | throw new RuntimeException(exception); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib_mvvm_fwk/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | compileSdk 31 7 | 8 | defaultConfig { 9 | minSdk 21 10 | targetSdk 31 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | 15 | compileOptions { 16 | sourceCompatibility JavaVersion.VERSION_1_8 17 | targetCompatibility JavaVersion.VERSION_1_8 18 | } 19 | 20 | buildFeatures { 21 | dataBinding true 22 | } 23 | } 24 | 25 | dependencies { 26 | compileOnly 'androidx.appcompat:appcompat:1.2.0' 27 | compileOnly 'com.google.android.material:material:1.3.0' 28 | } 29 | 30 | //makeJar 31 | def zipFile = file('build/intermediates/aar_main_jar/release/classes.jar') 32 | task makeJar(type: Jar) { 33 | from zipTree(zipFile) 34 | archiveBaseName = "fwk_mvvm" 35 | destinationDirectory = file("build/outputs/") 36 | manifest { 37 | attributes( 38 | 'Implementation-Title': "${project.name}", 39 | 'Built-Date': new Date().getDateTimeString(), 40 | 'Built-With': 41 | "gradle-${project.getGradle().getGradleVersion()},groovy-${GroovySystem.getVersion()}", 42 | 'Created-By': 43 | 'Java ' + System.getProperty('java.version') + ' (' + System.getProperty('java.vendor') + ')') 44 | } 45 | } 46 | makeJar.dependsOn(build) -------------------------------------------------------------------------------- /car_hmi/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdk 31 7 | 8 | defaultConfig { 9 | applicationId "com.mvvm.hmi.ipc" 10 | minSdk 21 11 | targetSdk 31 12 | versionCode 1 13 | versionName "1.0" 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | compileOptions { 25 | sourceCompatibility JavaVersion.VERSION_1_8 26 | targetCompatibility JavaVersion.VERSION_1_8 27 | } 28 | buildFeatures { 29 | dataBinding true 30 | } 31 | } 32 | 33 | dependencies { 34 | implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) 35 | implementation "androidx.lifecycle:lifecycle-livedata:2.3.0" 36 | implementation "androidx.lifecycle:lifecycle-viewmodel:2.3.0" 37 | implementation 'androidx.appcompat:appcompat:1.2.0' 38 | implementation 'com.google.android.material:material:1.3.0' 39 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 40 | implementation "com.google.code.gson:gson:2.8.6" 41 | implementation 'com.squareup.retrofit2:retrofit:2.9.0' 42 | implementation 'com.squareup.retrofit2:converter-gson:2.9.0' 43 | implementation'com.squareup.okhttp3:logging-interceptor:3.4.1' 44 | implementation project(":lib_mvvm_fwk") 45 | } -------------------------------------------------------------------------------- /lib_mvvm_fwk/src/main/java/com/mvvm/fwk/ui/BaseBindingFragment.java: -------------------------------------------------------------------------------- 1 | package com.mvvm.fwk.ui; 2 | 3 | import static com.mvvm.fwk.utils.LogUtils.TAG_FWK; 4 | 5 | import android.os.Bundle; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import androidx.annotation.LayoutRes; 11 | import androidx.annotation.NonNull; 12 | import androidx.annotation.Nullable; 13 | import androidx.databinding.DataBindingUtil; 14 | import androidx.databinding.ViewDataBinding; 15 | 16 | import com.mvvm.fwk.utils.LogUtils; 17 | 18 | public abstract class BaseBindingFragment extends BaseFragment { 19 | 20 | private static final String TAG = TAG_FWK + BaseBindingFragment.class.getSimpleName(); 21 | 22 | protected V mBinding; 23 | 24 | @Nullable 25 | @Override 26 | public View onCreateView(@NonNull LayoutInflater inflater, 27 | @Nullable ViewGroup container, 28 | @Nullable Bundle savedInstanceState) { 29 | LogUtils.logV(TAG, "[onCreateView]"); 30 | if (getLayoutId() == 0) { 31 | throw new RuntimeException("getLayout() must be not null"); 32 | } 33 | mBinding = DataBindingUtil.inflate(inflater, getLayoutId(), container, false); 34 | mBinding.setLifecycleOwner(this); 35 | mBinding.executePendingBindings(); 36 | initView(); 37 | return mBinding.getRoot(); 38 | } 39 | 40 | protected abstract void initView(); 41 | 42 | @LayoutRes 43 | protected abstract int getLayoutId(); 44 | 45 | public V getBinding() { 46 | return mBinding; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /car_hmi/src/main/res/layout/activity_hvac.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 11 | 12 | 13 | 16 | 17 |