keys = headers.keySet();
26 | // for (String headerKey : keys) {
27 | // builder.addHeader(headerKey, headers.get(headerKey)).build();
28 | // }
29 | // }
30 | //请求信息
31 | return chain.proceed(builder.build());
32 | }
33 | }
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/http/interceptor/CacheInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.http.interceptor;
2 |
3 | import android.content.Context;
4 |
5 | import com.rui.mvvmlazy.http.NetworkUtil;
6 |
7 | import java.io.IOException;
8 |
9 | import okhttp3.CacheControl;
10 | import okhttp3.Interceptor;
11 | import okhttp3.Request;
12 | import okhttp3.Response;
13 |
14 | /**
15 | * Created by zjr on 2020/5/10.
16 | * 无网络状态下智能读取缓存的拦截器
17 | */
18 | public class CacheInterceptor implements Interceptor {
19 |
20 | private Context context;
21 |
22 | public CacheInterceptor(Context context) {
23 | this.context = context;
24 | }
25 |
26 | @Override
27 | public Response intercept(Chain chain) throws IOException {
28 | Request request = chain.request();
29 | if (NetworkUtil.isNetworkAvailable(context)) {
30 | Response response = chain.proceed(request);
31 | // read from cache for 60 s
32 | int maxAge = 60;
33 | return response.newBuilder()
34 | .removeHeader("Pragma")
35 | .removeHeader("Cache-Control")
36 | .header("Cache-Control", "public, max-age=" + maxAge)
37 | .build();
38 | } else {
39 | //读取缓存信息
40 | request = request.newBuilder()
41 | .cacheControl(CacheControl.FORCE_CACHE)
42 | .build();
43 | Response response = chain.proceed(request);
44 | //set cache times is 3 days
45 | int maxStale = 60 * 60 * 24 * 3;
46 | return response.newBuilder()
47 | .removeHeader("Pragma")
48 | .removeHeader("Cache-Control")
49 | .header("Cache-Control", "public, only-if-cached, max-stale=" + maxStale)
50 | .build();
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/http/interceptor/logging/I.java:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.http.interceptor.logging;
2 |
3 |
4 | import java.util.logging.Level;
5 |
6 | import okhttp3.internal.platform.Platform;
7 |
8 | /**
9 | * @author ihsan on 10/02/2020.
10 | */
11 | class I {
12 |
13 | protected I() {
14 | throw new UnsupportedOperationException();
15 | }
16 |
17 | static void log(int type, String tag, String msg) {
18 | java.util.logging.Logger logger = java.util.logging.Logger.getLogger(tag);
19 | switch (type) {
20 | case Platform.INFO:
21 | logger.log(Level.INFO, msg);
22 | break;
23 | default:
24 | logger.log(Level.WARNING, msg);
25 | break;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/http/interceptor/logging/Level.java:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.http.interceptor.logging;
2 |
3 | /**
4 | * @author ihsan on 21/02/2020.
5 | */
6 |
7 | public enum Level {
8 | /**
9 | * No logs.
10 | */
11 | NONE,
12 | /**
13 | * Example:
14 | *
{@code
15 | * - URL
16 | * - Method
17 | * - Headers
18 | * - Body
19 | * }
20 | */
21 | BASIC,
22 | /**
23 | * Example:
24 | *
{@code
25 | * - URL
26 | * - Method
27 | * - Headers
28 | * }
29 | */
30 | HEADERS,
31 | /**
32 | * Example:
33 | *
{@code
34 | * - URL
35 | * - Method
36 | * - Body
37 | * }
38 | */
39 | BODY
40 | }
41 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/http/interceptor/logging/Logger.java:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.http.interceptor.logging;
2 |
3 | import okhttp3.internal.platform.Platform;
4 |
5 | /**
6 | * @author ihsan on 11/07/2020.
7 | */
8 | @SuppressWarnings({"WeakerAccess", "unused"})
9 | public interface Logger {
10 | void log(int level, String tag, String msg);
11 |
12 | Logger DEFAULT = new Logger() {
13 | @Override
14 | public void log(int level, String tag, String message) {
15 | Platform.get().log( message, level,null);
16 | }
17 | };
18 | }
19 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/state/ResultState.kt:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.state
2 | import androidx.lifecycle.MutableLiveData
3 | import com.rui.mvvmlazy.http.AppException
4 | import com.rui.mvvmlazy.http.BaseResponse
5 | import com.rui.mvvmlazy.http.ExceptionHandle
6 |
7 | /**
8 | * 作者 : zjr
9 | * 时间 : 2020/4/9
10 | * 描述 : 自定义结果集封装类
11 | */
12 | sealed class ResultState {
13 | companion object {
14 | fun onAppSuccess(data: T): ResultState = Success(data)
15 | fun onAppLoading(loadingMessage: String): ResultState = Loading(loadingMessage)
16 | fun onAppError(error: AppException): ResultState = Error(error)
17 | }
18 |
19 | data class Loading(val loadingMessage: String) : ResultState()
20 | data class Success(val data: T) : ResultState()
21 | data class Error(val error: AppException) : ResultState()
22 | }
23 |
24 | /**
25 | * 处理返回值
26 | * @param result 请求结果
27 | */
28 | fun MutableLiveData>.paresResult(result: BaseResponse) {
29 | value = when {
30 | result.isSuccess() -> {
31 | ResultState.onAppSuccess(result.getResponseData())
32 | }
33 | else -> {
34 | ResultState.onAppError(AppException(result.getResponseCode(), result.getResponseMsg()))
35 | }
36 | }
37 | }
38 |
39 | /**
40 | * 不处理返回值 直接返回请求结果
41 | * @param result 请求结果
42 | */
43 | fun MutableLiveData>.paresResult(result: T) {
44 | value = ResultState.onAppSuccess(result)
45 | }
46 |
47 | /**
48 | * 异常转换异常处理
49 | */
50 | fun MutableLiveData>.paresException(e: Throwable) {
51 | this.value = ResultState.onAppError(ExceptionHandle.handleException(e))
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/utils/constant/DateFormatConstants.kt:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2018 jirui_zhao(jirui_zhao@163.com)
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package com.rui.mvvmlazy.utils.constant
17 |
18 | /**
19 | * 日期格式
20 | *
21 | * @author zjr
22 | * @date 2018/2/16 下午10:23
23 | */
24 | object DateFormatConstants {
25 | /**
26 | * yyyy-MM-dd
27 | */
28 | const val yyyyMMdd = "yyyy-MM-dd"
29 |
30 | /**
31 | * yyyyMMdd
32 | */
33 | const val yyyyMMddNoSep = "yyyyMMdd"
34 |
35 | /**
36 | * HH:mm:ss
37 | */
38 | const val HHmmss = "HH:mm:ss"
39 |
40 | /**
41 | * HH:mm
42 | */
43 | const val HHmm = "HH:mm"
44 |
45 | /**
46 | * yyyy-MM-dd HH:mm:ss
47 | */
48 | const val yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss"
49 |
50 | /**
51 | * yyyyMMddHHmmss
52 | */
53 | const val yyyyMMddHHmmssNoSep = "yyyyMMddHHmmss"
54 |
55 | /**
56 | * yyyy-MM-dd HH:mm
57 | */
58 | const val yyyyMMddHHmm = "yyyy-MM-dd HH:mm"
59 |
60 | /**
61 | * yyyy-MM-dd HH:mm:ss:SSS
62 | */
63 | const val yyyyMMddHHmmssSSS = "yyyy-MM-dd HH:mm:ss:SSS"
64 | }
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/utils/constant/MemoryConstants.kt:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.utils.constant
2 |
3 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtStoragePath
4 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtDownloadsPath
5 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtPicturesPath
6 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtDCIMPath
7 | import androidx.annotation.IntDef
8 | import com.rui.mvvmlazy.utils.constant.MemoryConstants
9 | import com.rui.mvvmlazy.utils.constant.PathConstants
10 | import android.annotation.SuppressLint
11 | import android.Manifest.permission
12 | import androidx.annotation.StringDef
13 | import com.rui.mvvmlazy.utils.constant.TimeConstants
14 | import java.lang.annotation.Retention
15 | import java.lang.annotation.RetentionPolicy
16 |
17 | /**
18 | * Created by zjr on 2020/5/14.
19 | * 存储相关常量
20 | */
21 | object MemoryConstants {
22 | /**
23 | * Byte与Byte的倍数
24 | */
25 | const val BYTE = 1
26 |
27 | /**
28 | * KB与Byte的倍数
29 | */
30 | const val KB = 1024
31 |
32 | /**
33 | * MB与Byte的倍数
34 | */
35 | const val MB = 1048576
36 |
37 | /**
38 | * GB与Byte的倍数
39 | */
40 | const val GB = 1073741824
41 |
42 | @IntDef(BYTE, KB, MB, GB)
43 | @Retention(RetentionPolicy.SOURCE)
44 | annotation class Unit
45 | }
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/utils/constant/TimeConstants.kt:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.utils.constant
2 |
3 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtStoragePath
4 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtDownloadsPath
5 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtPicturesPath
6 | import com.rui.mvvmlazy.utils.app.PathUtils.Companion.getExtDCIMPath
7 | import androidx.annotation.IntDef
8 | import com.rui.mvvmlazy.utils.constant.MemoryConstants
9 | import com.rui.mvvmlazy.utils.constant.PathConstants
10 | import android.annotation.SuppressLint
11 | import android.Manifest.permission
12 | import androidx.annotation.StringDef
13 | import com.rui.mvvmlazy.utils.constant.TimeConstants
14 | import java.lang.annotation.Retention
15 | import java.lang.annotation.RetentionPolicy
16 |
17 | /**
18 | * Created by zjr on 2020/5/14.
19 | * 时间相关常量
20 | */
21 | object TimeConstants {
22 | /**
23 | * 毫秒与毫秒的倍数
24 | */
25 | const val MSEC = 1
26 |
27 | /**
28 | * 秒与毫秒的倍数
29 | */
30 | const val SEC = 1000
31 |
32 | /**
33 | * 分与毫秒的倍数
34 | */
35 | const val MIN = 60000
36 |
37 | /**
38 | * 时与毫秒的倍数
39 | */
40 | const val HOUR = 3600000
41 |
42 | /**
43 | * 天与毫秒的倍数
44 | */
45 | const val DAY = 86400000
46 |
47 | @IntDef(MSEC, SEC, MIN, HOUR, DAY)
48 | @Retention(RetentionPolicy.SOURCE)
49 | annotation class Unit
50 | }
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/utils/file/CloseUtils.kt:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.utils.file
2 |
3 | import java.io.Closeable
4 | import java.io.IOException
5 |
6 | /**
7 | * Created by zjr on 2020/5/14.
8 | * 关闭相关工具类
9 | */
10 | class CloseUtils private constructor() {
11 | companion object {
12 | /**
13 | * 关闭IO
14 | *
15 | * @param closeables closeables
16 | */
17 | fun closeIO(vararg closeables: Closeable?) {
18 | if (closeables == null) return
19 | for (closeable in closeables) {
20 | if (closeable != null) {
21 | try {
22 | closeable.close()
23 | } catch (e: IOException) {
24 | e.printStackTrace()
25 | }
26 | }
27 | }
28 | }
29 |
30 | /**
31 | * 安静关闭IO
32 | *
33 | * @param closeables closeables
34 | */
35 | fun closeIOQuietly(vararg closeables: Closeable?) {
36 | if (closeables == null) return
37 | for (closeable in closeables) {
38 | if (closeable != null) {
39 | try {
40 | closeable.close()
41 | } catch (ignored: IOException) {
42 | }
43 | }
44 | }
45 | }
46 | }
47 |
48 | init {
49 | throw UnsupportedOperationException("u can't instantiate me...")
50 | }
51 | }
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/java/com/rui/mvvmlazy/widget/ControlDistributeLinearLayout.kt:
--------------------------------------------------------------------------------
1 | package com.rui.mvvmlazy.widget
2 |
3 | import android.content.Context
4 | import kotlin.jvm.JvmOverloads
5 | import android.widget.LinearLayout
6 | import android.view.MotionEvent
7 | import android.content.res.TypedArray
8 | import android.util.AttributeSet
9 | import com.rui.mvvmlazy.R
10 |
11 | /**
12 | * Created by zjr on 2020/3/16.
13 | * 控制事件分发的LinearLayout
14 | */
15 | class ControlDistributeLinearLayout(
16 | context: Context?,
17 | attrs: AttributeSet? = null,
18 | defStyleAttr: Int = 0
19 | ) : LinearLayout(context, attrs, defStyleAttr) {
20 | //默认是不拦截事件,分发事件给子View
21 | var isDistributeEvent = false
22 |
23 | /**
24 | * 重写事件分发方法,false 为分发 , true 为父控件自己消耗, 由外面传进来的参数决定
25 | */
26 | override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
27 | return isDistributeEvent
28 | }
29 |
30 | init {
31 | val typedArray =
32 | getContext().obtainStyledAttributes(attrs, R.styleable.ControlDistributeLinearLayout)
33 | isDistributeEvent =
34 | typedArray.getBoolean(R.styleable.ControlDistributeLinearLayout_distribute_event, false)
35 | }
36 | }
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-hdpi/customactivityoncrash_error_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-hdpi/customactivityoncrash_error_image.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-mdpi/customactivityoncrash_error_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-mdpi/customactivityoncrash_error_image.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-xhdpi/customactivityoncrash_error_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-xhdpi/customactivityoncrash_error_image.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-xxhdpi/back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-xxhdpi/back.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-xxhdpi/base_view_empty_cache.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-xxhdpi/base_view_empty_cache.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-xxhdpi/customactivityoncrash_error_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-xxhdpi/customactivityoncrash_error_image.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-xxhdpi/icon_net_error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-xxhdpi/icon_net_error.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/drawable-xxxhdpi/customactivityoncrash_error_image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jirywell/MvvmLazy-kotlin/b37dcb02d8b93699299aada9ec98a1c3ae10e346/library-mvvmlazy/src/main/res/drawable-xxxhdpi/customactivityoncrash_error_image.png
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/layout/activity_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/layout/view_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/layout/view_error.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
24 |
25 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/layout/view_loading.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
14 |
15 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFFFFF
4 | #000000
5 | #808080
6 | #FFFF00
7 | #008000
8 | #0000FF
9 | #FFA500
10 | #55E6E6E6
11 | #aaE6E6E6
12 |
13 | - #4B03A9F4
14 | - #3303A9F4
15 | - #1903A9F4
16 |
17 |
18 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 | 12sp
8 |
9 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | mvvmhabit
3 | 发生意外错误。\n抱歉,给您带来不便。
4 | 重新启动
5 | 关闭程序
6 | 错误日志
7 | 错误详情
8 | 关闭
9 | 复制日志
10 | 复制日志
11 | 错误信息
12 |
13 | 数据不见了
14 | 请检查您的网络\n重新加载吧
15 | 暂无数据
16 |
17 |
18 |
--------------------------------------------------------------------------------
/library-mvvmlazy/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/module-demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module-demo/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'kotlin-android'
3 | id 'kotlin-kapt'
4 | }
5 | apply from: "../module.build.gradle"
6 | android {
7 |
8 | buildFeatures {
9 | viewBinding true
10 | }
11 | defaultConfig {
12 | //如果是独立模块,则使用当前组件的包名
13 | if (isBuildModule.toBoolean()) {
14 | applicationId "com.rui.demo"
15 | }
16 | }
17 | //统一资源前缀,规范资源引用
18 | resourcePrefix "test_"
19 | namespace 'com.rui.demo'
20 | sourceSets {
21 | main {
22 | jniLibs.srcDirs = ['libs']
23 | }
24 | }
25 | }
26 | kapt {
27 | arguments {
28 | arg("AROUTER_MODULE_NAME", project.getName())
29 | }
30 | }
31 |
32 | dependencies {
33 | implementation fileTree(dir: 'libs', include: ['*.?ar'])
34 | api project(':library-base')
35 | //组件中依赖阿里路由编译框架
36 | kapt rootProject.ext.dependencies["arouter-compiler"]
37 | kapt rootProject.ext.android_x["room-compiler"]
38 | }
39 |
--------------------------------------------------------------------------------
/module-demo/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 |
--------------------------------------------------------------------------------
/module-demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/module-demo/src/main/java/com/rui/demo/DemoModuleInit.kt:
--------------------------------------------------------------------------------
1 | package com.rui.demo
2 |
3 | import android.content.Context
4 | import androidx.startup.Initializer
5 | import com.rui.mvvmlazy.utils.common.KLog
6 |
7 | /**
8 | * Created by zjr on 2018/6/21 0021.
9 | */
10 | class DemoModuleInit : Initializer {
11 |
12 | override fun create(context: Context) {
13 | KLog.d("demo组件初始化")
14 | }
15 |
16 | override fun dependencies(): MutableList>> {
17 | return mutableListOf()
18 | }
19 | }
--------------------------------------------------------------------------------
/module-demo/src/main/java/com/rui/demo/data/bean/CityInfo.kt:
--------------------------------------------------------------------------------
1 | package com.rui.demo.data.bean
2 |
3 | import com.rui.mvvmlazy.binding.viewadapter.spinner.IKeyAndValue
4 |
5 | /**
6 |
7 | */
8 |
9 | class CityInfo : IKeyAndValue {
10 | var name: String? = null
11 | var code: String? = null
12 |
13 | constructor(name: String?, code: String?) {
14 | this.name = name
15 | this.code = code
16 | }
17 |
18 | override fun loadKey(): String {
19 | return name ?: "";
20 | }
21 |
22 | override fun loadValue(): String {
23 | return code ?: "";
24 | }
25 | }
--------------------------------------------------------------------------------
/module-demo/src/main/java/com/rui/demo/data/bean/JokeInfo.kt:
--------------------------------------------------------------------------------
1 | package com.rui.demo.data.bean
2 |
3 | /**
4 | * author :zjr
5 | * date: 2020/07/24 19:06
6 | * description:
7 |
8 | */
9 |
10 | class JokeInfo(var title: String?, var url: String?) {
11 |
12 | }
--------------------------------------------------------------------------------
/module-demo/src/main/java/com/rui/demo/data/bean/MsgInfo.kt:
--------------------------------------------------------------------------------
1 | package com.rui.demo.data.bean
2 |
3 | /**
4 | * author :zjr
5 | * date: 2020/07/24 19:06
6 | * description:
7 |
8 | */
9 |
10 | class MsgInfo(var title: String?, var type: Int?) {
11 |
12 | }
--------------------------------------------------------------------------------
/module-demo/src/main/java/com/rui/demo/data/source/HttpDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.rui.demo.data.source
2 |
3 | import com.rui.base.entity.ApiResponse
4 | import com.rui.base.entity.ApiResponseTest
5 | import com.rui.demo.data.bean.JokeInfo
6 | import com.rui.mvvmlazy.http.PagingData
7 | import retrofit2.http.Query
8 |
9 | /**
10 | * Created by zjr on 2019/3/26.
11 | */
12 | interface HttpDataSource {
13 | suspend fun getJoke(
14 | @Query("page") page: Int,
15 | @Query("size") size: Int
16 | ): ApiResponse>
17 | suspend fun testApi(
18 | @Query("q") page: String
19 | ):ApiResponseTest