├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── yang
│ │ │ │ └── cehome
│ │ │ │ └── com
│ │ │ │ └── mvvmdemo
│ │ │ │ ├── model
│ │ │ │ ├── data
│ │ │ │ │ └── Onclick.kt
│ │ │ │ ├── local
│ │ │ │ │ ├── dao
│ │ │ │ │ │ ├── PostEntity.kt
│ │ │ │ │ │ └── PostDao.kt
│ │ │ │ │ └── AppDatabase.kt
│ │ │ │ ├── repository
│ │ │ │ │ └── PostRepo.kt
│ │ │ │ └── remote
│ │ │ │ │ └── PostService.kt
│ │ │ │ ├── MyApplication.kt
│ │ │ │ ├── viewmodel
│ │ │ │ ├── OnclikViewModel.kt
│ │ │ │ ├── WeatherViewModel.kt
│ │ │ │ └── PostViewModel.kt
│ │ │ │ ├── network
│ │ │ │ ├── ApiClient.kt
│ │ │ │ └── InternalOkHttpClient.kt
│ │ │ │ └── view
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── yang
│ │ │ └── cehome
│ │ │ └── com
│ │ │ └── mvvmdemo
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── yang
│ │ └── cehome
│ │ └── com
│ │ └── mvvmdemo
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── caches
│ └── build_file_checksums.ser
├── encodings.xml
├── vcs.xml
├── kotlinc.xml
├── modules.xml
├── compiler.xml
├── runConfigurations.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── codeStyles
│ └── Project.xml
└── misc.xml
├── local.properties
├── README.md
├── gradle.properties
├── MVVM.iml
├── .gitignore
├── gradlew.bat
├── config.gradle
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MVVMDemo
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/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/yang0range/MVVM/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yang0range/MVVM/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/yang0range/MVVM/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | ;#Sat Apr 14 19:00:57 CST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/model/data/Onclick.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.model.data
2 |
3 | /**
4 | * @author yangzc
5 | * @data 2018/9/6 13:58
6 | * @desc 数据源Model(MVVM 中的V),负责提供ViewModel中需要处理的数据
7 | *
8 | */
9 | class Onclick(val who: String, var count: Int)
10 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/yang/cehome/com/mvvmdemo/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/MyApplication.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo
2 |
3 | import android.app.Application
4 | import com.facebook.stetho.Stetho
5 |
6 | /**
7 | * @author yangzc
8 | * @data 2018/11/2 11:59
9 | * @desc
10 | *
11 | */
12 | class MyApplication : Application() {
13 | override fun onCreate() {
14 | super.onCreate()
15 | if (BuildConfig.DEBUG) {
16 | Stetho.initializeWithDefaults(this);
17 | }
18 |
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Tue Sep 04 15:37:03 CST 2018
11 | ndk.dir=F\:\\studiosdk\\ndk-bundle
12 | sdk.dir=F\:\\studiosdk
13 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/model/local/dao/PostEntity.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.model.local.dao
2 |
3 | import android.arch.persistence.room.Entity
4 | import android.arch.persistence.room.PrimaryKey
5 |
6 | /**
7 | * @author yangzc
8 | * @data 2018/11/7 10:23
9 | * @desc 创建Post的Entity
10 | *
11 | */
12 | @Entity
13 | data class PostEntity(
14 | val message: String,
15 | @PrimaryKey
16 | val nu: String,
17 | val ischeck: String,
18 | val condition: String,
19 | val com: String,
20 | val status: String,
21 | val state: String
22 | )
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/viewmodel/OnclikViewModel.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.viewmodel
2 |
3 | import android.databinding.ObservableField
4 | import yang.cehome.com.mvvmdemo.model.data.Onclick
5 |
6 | /**
7 | * @author yangzc
8 | * @data 2018/9/6 16:59
9 | * @desc 处理数据V(MVVM 中的V),负责提供View中需要处理的数据
10 | *
11 | */
12 | class OnclikViewModel(val onlick: Onclick) {
13 | /******data******/
14 | val info = ObservableField("\"${onlick.who}点击了${onlick.count}次\"")
15 |
16 | /******binding******/
17 | fun click() {
18 | onlick.count++
19 | info.set("\"${onlick.who}点击了${onlick.count}次\"")
20 | }
21 |
22 | }
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/model/repository/PostRepo.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.model.repository
2 |
3 | import yang.cehome.com.mvvmdemo.model.local.dao.PostDao
4 | import yang.cehome.com.mvvmdemo.model.remote.PostService
5 |
6 | /**
7 | * @author yangzc
8 | * @data 2018/11/6 11:55
9 | * @desc PostRepo
10 | *
11 | */
12 | class PostRepo constructor(private val remote: PostService, private val local: PostDao){
13 | //首先查看本地数据库是否有数据
14 | fun getPostInfo() = local.getPostInfo()
15 | .onErrorResumeNext {
16 | //本地数据库不存在,会抛出会抛出EmptyResultSetException
17 | //转而进行获取网络数据,成功后保存在数据库
18 | remote.getPostInfo().doOnSuccess { local.inserttPost(it) }
19 | }
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/model/remote/PostService.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.model.remote
2 |
3 | import io.reactivex.Single
4 | import retrofit2.http.GET
5 | import yang.cehome.com.mvvmdemo.model.local.dao.PostEntity
6 |
7 | /**
8 | * @author yangzc
9 | * @data 2018/9/11 18:13
10 | * @desc PostService
11 | *
12 | */
13 | interface PostService {
14 | //获取天气
15 | // @GET("/data/sk/101190408.html")
16 | // fun getWeatherInfo(): Single>
17 |
18 |
19 | //获取天气
20 | // @GET("/data/sk/101190408.html")
21 | // fun getWeatherInfos(): Single
22 |
23 |
24 | //获取快递
25 | @GET("/query?type=yuantong&postid=112323")
26 | fun getPostInfo(): Single
27 |
28 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # MVVM
2 |
3 | #### 项目介绍
4 | mvvm架构的学习
5 |
6 | #### 博客地址
7 | [MVVM框架的搭建(一)——背景](https://www.jianshu.com/p/60dc39a8553a)
8 |
9 | [MVVM框架的搭建(二)——项目搭建](https://www.jianshu.com/p/6a5a9803d03b)
10 |
11 | [MVVM框架的搭建(三)——网络请求](https://www.jianshu.com/p/df2bde94c0bd)
12 |
13 | [MVVM的数据持久化(一)——ROOM的集成](https://www.jianshu.com/p/0159a5f1c557)
14 |
15 | [MVVM的数据持久化(二)——ROOM的使用](https://www.jianshu.com/p/9e0129c4fbd4)
16 |
17 | ### 欢迎关注公共号
18 | #### 关注公共号会有更多收获!
19 | 
20 |
21 | #### 扫一扫,据说年轻、优秀、颜值高的互联网人都在这个群里
22 | 
23 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/model/local/dao/PostDao.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.model.local.dao
2 |
3 | import android.arch.persistence.room.Dao
4 | import android.arch.persistence.room.Insert
5 | import android.arch.persistence.room.OnConflictStrategy
6 | import android.arch.persistence.room.Query
7 | import io.reactivex.Single
8 |
9 | /**
10 | * @author yangzc
11 | * @data 2018/11/5 17:40
12 | * @desc PostDao
13 | *
14 | */
15 | @Dao
16 | interface PostDao {
17 | @Insert(onConflict = OnConflictStrategy.REPLACE)
18 | fun insetAll(postinfo: List)
19 |
20 |
21 | @Insert(onConflict = OnConflictStrategy.REPLACE)
22 | fun inserttPost(postinfo: PostEntity)
23 |
24 | @Query("SELECT * FROM postentity")
25 | fun getPostInfo(): Single
26 |
27 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/yang/cehome/com/mvvmdemo/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("yang.cehome.com.mvvmdemo", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/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/main/java/yang/cehome/com/mvvmdemo/viewmodel/WeatherViewModel.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.viewmodel
2 |
3 | /**
4 | * @author yangzc
5 | * @data 2018/9/12 14:20
6 | * @desc WeatherViewModel
7 | *
8 | */
9 | //@Deprecated
10 | //class WeatherViewModel(private val repo: PostRepo) {
11 | // /******data******/
12 | // val weatherinfo = ObservableField()
13 | //
14 | // /******binding******/
15 | // fun loadWeather() {
16 | // repo.getWeatherInfo()
17 | // .subscribeOn(Schedulers.io())
18 | // .observeOn(AndroidSchedulers.mainThread())
19 | // .subscribe({ t: WeatherInfo? ->
20 | // weatherinfo.set(t?.let { it.toString() })
21 | // }, { t: Throwable? ->
22 | // weatherinfo.set(t?.message ?: "error")
23 | // })
24 | // }
25 | //}
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/network/ApiClient.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.network
2 |
3 | import retrofit2.Retrofit
4 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
5 | import retrofit2.converter.gson.GsonConverterFactory
6 |
7 | /**
8 | * @author yangzc
9 | * @data 2018/11/9 14:32
10 | * @desc ApiClient 这样就保证了全局只有一个retrofit对象
11 | *
12 | */
13 | class ApiClient {
14 | //这里我们可以控制URL 改变URL为测试/线上环境URL
15 | private val BASE_URL = "https://api.douban.com/v2/movie/"
16 | private var retrofit: Retrofit? = null
17 |
18 | init {
19 | retrofit = Retrofit.Builder()
20 | .addConverterFactory(GsonConverterFactory.create())
21 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
22 | .baseUrl(BASE_URL)
23 | .client(InternalOkHttpClient.getOkhttpClient())
24 | .build()
25 | }
26 |
27 |
28 | }
--------------------------------------------------------------------------------
/MVVM.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/viewmodel/PostViewModel.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.viewmodel
2 |
3 | import android.databinding.ObservableField
4 | import io.reactivex.android.schedulers.AndroidSchedulers
5 | import io.reactivex.schedulers.Schedulers
6 | import yang.cehome.com.mvvmdemo.model.local.dao.PostEntity
7 | import yang.cehome.com.mvvmdemo.model.repository.PostRepo
8 |
9 | /**
10 | * @author yangzc
11 | * @data 2018/11/7 10:26
12 | * @desc PostViewModel
13 | *
14 | */
15 | class PostViewModel(private val repo: PostRepo) {
16 | /******data******/
17 | val postinfo = ObservableField()
18 |
19 | /******binding******/
20 | fun loadpost() {
21 | repo.getPostInfo()
22 | .subscribeOn(Schedulers.io())
23 | .observeOn(AndroidSchedulers.mainThread())
24 | .subscribe({ t: PostEntity? ->
25 | postinfo.set(t?.let { it.toString() })
26 | }, { t: Throwable? ->
27 | postinfo.set(t?.message ?: "error")
28 | })
29 | }
30 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # IntelliJ
36 | *.iml
37 | .idea/workspace.xml
38 | .idea/tasks.xml
39 | .idea/gradle.xml
40 | .idea/dictionaries
41 | .idea/libraries
42 |
43 | # Keystore files
44 | # Uncomment the following line if you do not want to check your keystore files in.
45 | #*.jks
46 |
47 | # External native build folder generated in Android Studio 2.2 and later
48 | .externalNativeBuild
49 |
50 | # Google Services (e.g. APIs or Firebase)
51 | google-services.json
52 |
53 | # Freeline
54 | freeline.py
55 | freeline/
56 | freeline_project_description.json
57 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/model/local/AppDatabase.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.model.local
2 |
3 | import android.arch.persistence.room.Database
4 | import android.arch.persistence.room.Room
5 | import android.arch.persistence.room.RoomDatabase
6 | import android.content.Context
7 | import yang.cehome.com.mvvmdemo.model.local.dao.PostDao
8 | import yang.cehome.com.mvvmdemo.model.local.dao.PostEntity
9 |
10 | /**
11 | * @author yangzc
12 | * @data 2018/11/5 18:21
13 | * @desc 包含所有Entity以及操作它们的 DAO
14 | *
15 | */
16 | @Database(entities = arrayOf(PostEntity::class), version = 1)
17 | abstract class AppDatabase : RoomDatabase() {
18 | abstract fun PostDao(): PostDao
19 |
20 | companion object {
21 | @Volatile
22 | private var INSTANCE: AppDatabase? = null
23 |
24 | fun getInstance(context: Context): AppDatabase =
25 | INSTANCE ?: synchronized(this) {
26 | INSTANCE ?: buildDatabase(context).also { INSTANCE = it }
27 | }
28 |
29 | private fun buildDatabase(context: Context) =
30 | Room.databaseBuilder(context.applicationContext,
31 | AppDatabase::class.java, "app.db")
32 | .build()
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/yang/cehome/com/mvvmdemo/network/InternalOkHttpClient.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.network
2 |
3 | import com.facebook.stetho.okhttp3.StethoInterceptor
4 | import okhttp3.OkHttpClient
5 | import okhttp3.logging.HttpLoggingInterceptor
6 | import yang.cehome.com.mvvmdemo.BuildConfig
7 | import java.util.concurrent.TimeUnit
8 |
9 | class InternalOkHttpClient {
10 | companion object {
11 |
12 | fun getOkhttpClient(): OkHttpClient {
13 | var okHttpClient: OkHttpClient? = null
14 |
15 | if (okHttpClient == null) {
16 | okHttpClient = OkHttpClient.Builder()
17 | .retryOnConnectionFailure(true)
18 | .connectTimeout(60, TimeUnit.SECONDS)
19 | .readTimeout(60, TimeUnit.SECONDS)
20 | .writeTimeout(60, TimeUnit.SECONDS)
21 | .build()
22 |
23 | if (BuildConfig.DEBUG) {//printf logs while debug
24 | okHttpClient = okHttpClient?.newBuilder()?.addNetworkInterceptor(StethoInterceptor())?.addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC))?.build()
25 | }
26 | }
27 | return okHttpClient!!
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 | apply plugin: 'kotlin-android-extensions'
5 | apply from: "${rootProject.rootDir}/config.gradle"
6 |
7 | android {
8 | compileSdkVersion 27
9 | buildToolsVersion '27.0.3'
10 |
11 | defaultConfig {
12 | minSdkVersion project.ext.minSdkVersion
13 | targetSdkVersion project.ext.targetSdkVersion
14 | versionCode project.ext.module_appVersionCode
15 | versionName project.ext.module_appVersionName
16 | applicationId project.ext.module_appApplicationId
17 | multiDexEnabled true
18 |
19 | manifestPlaceholders = [
20 | app_name: project.ext.module_appName
21 |
22 | ]
23 | }
24 | buildTypes {
25 | release {
26 | minifyEnabled false
27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
28 | }
29 | }
30 |
31 | dataBinding {
32 | enabled = true
33 | }
34 |
35 | kapt {
36 | generateStubs = true
37 | }
38 |
39 | android {
40 | compileOptions {
41 | sourceCompatibility 1.8
42 | targetCompatibility 1.8
43 | }
44 | }
45 |
46 | }
47 |
48 | dependencies {
49 | implementation fileTree(include: ['*.jar'], dir: 'libs')
50 | implementation project.ext.kotlinDeps
51 | implementation project.ext.supportDeps
52 | implementation project.ext.networkDeps
53 | implementation project.ext.rxDeps
54 | implementation project.ext.stethoDeps
55 | implementation project.ext.roomDeps
56 | implementation project.ext.okhttpDep
57 | kapt project.ext.roomDep
58 | kapt project.ext.databindingDeps
59 | testImplementation 'junit:junit:4.12'
60 | }
61 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/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/java/yang/cehome/com/mvvmdemo/view/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package yang.cehome.com.mvvmdemo.view
2 |
3 | import android.databinding.DataBindingUtil
4 | import android.os.Bundle
5 | import android.support.v7.app.AppCompatActivity
6 | import com.facebook.stetho.okhttp3.StethoInterceptor
7 | import okhttp3.OkHttpClient
8 | import retrofit2.Retrofit
9 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
10 | import retrofit2.converter.gson.GsonConverterFactory
11 | import yang.cehome.com.mvvmdemo.R
12 | import yang.cehome.com.mvvmdemo.databinding.ActivityMainBinding
13 | import yang.cehome.com.mvvmdemo.model.data.Onclick
14 | import yang.cehome.com.mvvmdemo.model.local.AppDatabase
15 | import yang.cehome.com.mvvmdemo.model.remote.PostService
16 | import yang.cehome.com.mvvmdemo.model.repository.PostRepo
17 | import yang.cehome.com.mvvmdemo.viewmodel.OnclikViewModel
18 | import yang.cehome.com.mvvmdemo.viewmodel.PostViewModel
19 |
20 |
21 |
22 |
23 | /**
24 | * MVVM 当中的一个V层 将三者联系起来
25 | */
26 | class MainActivity : AppCompatActivity() {
27 | private lateinit var mBinding: ActivityMainBinding
28 | private lateinit var mViewMode: OnclikViewModel
29 | private lateinit var mViewMode2: PostViewModel
30 |
31 |
32 | override fun onCreate(savedInstanceState: Bundle?) {
33 | super.onCreate(savedInstanceState)
34 |
35 | mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main)
36 | /////model
37 | val onclick = Onclick("me", 0)
38 | ///ViewModel
39 | mViewMode = OnclikViewModel(onclick)
40 | ///binding
41 |
42 | val client = OkHttpClient.Builder()
43 | .addNetworkInterceptor(StethoInterceptor())
44 | .build()
45 |
46 | val remote = Retrofit.Builder()
47 | .baseUrl("http://www.kuaidi100.com")
48 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
49 | .addConverterFactory(GsonConverterFactory.create())
50 | .client(client)
51 | .build().create(PostService::class.java)
52 | val local= AppDatabase.getInstance(applicationContext).PostDao()
53 | val repo = PostRepo(remote, local)
54 |
55 | ////ViewModel2
56 | mViewMode2 = PostViewModel(repo)
57 | mBinding.vm = mViewMode
58 | ////binding
59 | mBinding.post = mViewMode2
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
15 |
16 |
17 |
18 |
19 |
24 |
25 |
29 |
30 |
36 |
37 |
46 |
47 |
48 |
53 |
54 |
55 |
61 |
62 |
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | Android Lint
36 |
37 |
38 |
39 |
40 | Abstraction issues
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 1.8
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | /**
2 | * config.gradle用于配置项目中各种lib引用和版本号控制
3 | *
4 | * [module_*] 各module版本号及applicationId控制
5 | * 如需在各个module中升级更新版本号,请使用 module_[modulename]*的命名规则
6 | *
7 | * [project.ext.dependVersion] 中创建各个依赖库的版本号控制,需在类库名称后增加‘_version’
8 | *
9 | * [类库maven地址] 中创建各个类库的maven地址,同一类库需要引用多个类时,可以使用数组,要确保类库引用不重复
10 | *
11 | * [项目依赖列表] 中创建可以直接让module引用的依赖列表,以Deps结尾,原则上以类库功能分类,比如网络库,图片处理库
12 | * 尽量不要以类库本身的名字命名依赖列表
13 | *
14 | * 各个module中引用类库时尽量使用项目依赖列表中的项目,不要直接使用类库地址中的项目
15 | *
16 | * 需要添加新的类库时,先查询本列表和项目中是否已引用类似功能的类库,尽量不要添加重复功能的类库
17 | */
18 | project.ext {
19 | compileSdkVersion = 27
20 | buildToolsVersion = '27.0.3'
21 | minSdkVersion = 16
22 | targetSdkVersion = 27
23 |
24 | //主app
25 | module_appApplicationId = 'yang.cehome.com.mvvmdemo'
26 | module_appVersionCode = 0001
27 | module_appVersionName = '1.0.0'
28 | module_appName = 'MVVM'
29 |
30 | //引用类库的版本号
31 | dependVersion = [
32 | kotlin_version : '1.2.51',
33 | support_version : '27.1.1',
34 | databinding_version: '3.1.4',
35 | retrofit2_version : '2.3.0',
36 | gson_version : '2.8.5',
37 | rxandroid_version : '2.1.0',
38 | rxjava_version : '2.2.2',
39 | stetho_version : '1.5.0',
40 | room_version : '1.1.1',
41 | okhttp_version : '3.11.0'
42 | ]
43 |
44 | //*************************类库maven地址**************************
45 | kotlin_base = [kotlin_stdlib_jdk8: "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$dependVersion.kotlin_version"
46 | ]
47 | supportLibs = [
48 | design : "com.android.support:design:$dependVersion.support_version",
49 | appcompat_v7: "com.android.support:appcompat-v7:$dependVersion.support_version",
50 | constraint : 'com.android.support.constraint:constraint-layout:1.1.3']
51 |
52 | databindingLibs = [databinding: "com.android.databinding:compiler:$dependVersion.databinding_version"]
53 |
54 | network = [
55 | retrofit : "com.squareup.retrofit2:retrofit:$dependVersion.retrofit2_version",
56 | retrofit_converters: "com.squareup.retrofit2:converter-gson:$dependVersion.retrofit2_version",
57 | retrofit_adapters : "com.squareup.retrofit2:adapter-rxjava2:$dependVersion.retrofit2_version"]
58 |
59 | gson = [gson: "com.google.code.gson:gson:$dependVersion.gson_version"]
60 |
61 | rxandroid = [rxandroid: "io.reactivex.rxjava2:rxandroid:$dependVersion.rxandroid_version"]
62 |
63 | rxjava = [rxjava: "io.reactivex.rxjava2:rxjava:$dependVersion.rxjava_version"]
64 |
65 | stetho = [stetho : "com.facebook.stetho:stetho:$dependVersion.stetho_version",
66 | okhttp_stetho: "com.facebook.stetho:stetho-okhttp3:$dependVersion.stetho_version"]
67 |
68 |
69 | roomLib = [room_runtime: "android.arch.persistence.room:runtime:$dependVersion.room_version",
70 | room_rxjave2: "android.arch.persistence.room:rxjava2:$dependVersion.room_version",
71 |
72 | ]
73 | room = [room: "android.arch.persistence.room:compiler:$dependVersion.room_version"]
74 |
75 | okhttpLibs = [okhttp : "com.squareup.okhttp3:okhttp:$dependVersion.okhttp_version",
76 | okhttplog: "com.squareup.okhttp3:logging-interceptor:$dependVersion.okhttp_version"]
77 |
78 | //********************项目依赖列表**********************
79 | kotlinDeps = [kotlin_base.values()]
80 | supportDeps = [supportLibs.values()]
81 | databindingDeps = [databindingLibs.values()]
82 | networkDeps = [network.values(), gson.values()]
83 | rxDeps = [rxandroid.values(), rxjava.values()]
84 | stethoDeps = [stetho.values()]
85 | roomDeps = [roomLib.values()]
86 | roomDep = [room.values()]
87 | okhttpDep = [okhttpLibs.values()]
88 | }
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------