├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── compiler.xml
├── gradle.xml
├── jarRepositories.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── mvvmframe
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ └── ic_launcher_background.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.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
│ │ └── values
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── mvvmframe
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library-base
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── base
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── base
│ │ │ └── network
│ │ │ ├── application
│ │ │ ├── ApplicationDelegate.kt
│ │ │ ├── ApplicationManager.kt
│ │ │ └── BaseApplication.kt
│ │ │ ├── base
│ │ │ ├── activity
│ │ │ │ ├── BaseActivity.kt
│ │ │ │ └── BaseMvvmActivity.kt
│ │ │ ├── fragment
│ │ │ │ ├── BaseLazyloadFragment.kt
│ │ │ │ └── BaseMvvmFragment.kt
│ │ │ ├── livedata
│ │ │ │ └── BaseLiveData.kt
│ │ │ ├── response
│ │ │ │ └── BaseResponse.kt
│ │ │ ├── view
│ │ │ │ └── IBaseView.kt
│ │ │ └── viewmodel
│ │ │ │ ├── BasePageViewModel.kt
│ │ │ │ ├── BaseViewModel.kt
│ │ │ │ └── commonviewmodel
│ │ │ │ └── ScrollBannerViewModel.kt
│ │ │ ├── bean
│ │ │ ├── Author.kt
│ │ │ ├── CommomItemResponse.kt
│ │ │ ├── CommonItemBean.kt
│ │ │ ├── DataX.kt
│ │ │ ├── Detail.kt
│ │ │ ├── Header.kt
│ │ │ ├── ItemListItem.kt
│ │ │ ├── Owner.kt
│ │ │ ├── PushBean.kt
│ │ │ ├── Tag.kt
│ │ │ └── UserInfoCache.kt
│ │ │ ├── config
│ │ │ ├── AppConfig.kt
│ │ │ ├── DirConfig.kt
│ │ │ └── ItemTypeConfig.kt
│ │ │ ├── databinding
│ │ │ └── BindingAdapterUtil.kt
│ │ │ ├── route
│ │ │ └── RoutePath.kt
│ │ │ ├── utils
│ │ │ ├── ActivityManager.kt
│ │ │ ├── AnimUtils.kt
│ │ │ ├── ItemDecortionGridLayout.kt
│ │ │ ├── LogUtils.kt
│ │ │ ├── NetStateUtils.kt
│ │ │ ├── OnItemClickListener.kt
│ │ │ ├── ScreenUtils.kt
│ │ │ ├── TimeUtils.kt
│ │ │ └── ToastUtil.kt
│ │ │ └── widget
│ │ │ ├── CircleImageView.java
│ │ │ └── FmPagerAdapter.kt
│ └── res
│ │ ├── layout
│ │ ├── customview_toast.xml
│ │ ├── item_banner2.xml
│ │ ├── item_empty.xml
│ │ ├── item_leftright_title.xml
│ │ ├── item_only_pic.xml
│ │ ├── item_scroll_banner.xml
│ │ ├── item_scroll_banner_item.xml
│ │ ├── item_small_card.xml
│ │ ├── item_title.xml
│ │ ├── item_videoad.xml
│ │ ├── layout.xml
│ │ └── view_empty.xml
│ │ └── values
│ │ └── attrs.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── base
│ └── ExampleUnitTest.java
├── library-network
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── network
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── java
│ │ └── com
│ │ └── example
│ │ └── network
│ │ └── interceptor
│ │ ├── interceptor
│ │ ├── HeaderInterceptor.kt
│ │ ├── LoggingInterceptor.kt
│ │ ├── LoginInterceptor.kt
│ │ └── NetCacheInterceptor.kt
│ │ └── service
│ │ ├── Api.kt
│ │ ├── ApiCallBack.kt
│ │ └── ApiManager.kt
│ └── test
│ └── java
│ └── com
│ └── example
│ └── network
│ └── ExampleUnitTest.kt
├── library-res
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── library_res
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ └── res
│ │ ├── color
│ │ └── selector_tv_hometab.xml
│ │ ├── drawable
│ │ ├── ic_cache_black.xml
│ │ ├── ic_calendar.xml
│ │ ├── ic_close_white.xml
│ │ ├── ic_eye.xml
│ │ ├── ic_favorite_border_black.xml
│ │ ├── ic_reply.xml
│ │ ├── ic_search_black.xml
│ │ ├── ic_star_white.xml
│ │ ├── selecor_btn_community.xml
│ │ ├── selecor_btn_home.xml
│ │ ├── selecor_btn_mine.xml
│ │ ├── selecor_btn_notification.xml
│ │ ├── shape_black_roundsmall.xml
│ │ ├── shape_black_roundsmall_borderlight.xml
│ │ ├── shape_white_circle.xml
│ │ ├── shape_white_roundsmall_border.xml
│ │ └── shape_white_roundsmall_borderlight.xml
│ │ ├── mipmap-xxhdpi
│ │ ├── bg_splash.png
│ │ ├── card_more_action_icon.png
│ │ ├── daily_label.png
│ │ ├── default_cover.jpg
│ │ ├── goto_icon.png
│ │ ├── ic_account_login_header.png
│ │ ├── ic_account_login_password.png
│ │ ├── ic_account_login_user_name.png
│ │ ├── ic_action_collect.png
│ │ ├── ic_action_download.png
│ │ ├── ic_action_like.png
│ │ ├── ic_action_more_black.png
│ │ ├── ic_action_reply_more.png
│ │ ├── ic_action_share.png
│ │ ├── ic_action_share_qq_grey.png
│ │ ├── ic_action_share_wechat_grey.png
│ │ ├── ic_action_share_weibo_grey.png
│ │ ├── ic_action_sumb.png
│ │ ├── ic_app.png
│ │ ├── ic_collection_grey.png
│ │ ├── ic_comment_grey.png
│ │ ├── ic_empty.png
│ │ ├── ic_like_grey.png
│ │ ├── ic_menu_more.png
│ │ ├── ic_right_arrow.png
│ │ ├── ic_share_grey.png
│ │ ├── ic_tab_strip_icon_category.png
│ │ ├── ic_tab_strip_icon_category_selected.png
│ │ ├── ic_tab_strip_icon_feed.png
│ │ ├── ic_tab_strip_icon_feed_selected.png
│ │ ├── ic_tab_strip_icon_follow.png
│ │ ├── ic_tab_strip_icon_follow_selected.png
│ │ ├── ic_tab_strip_icon_profile.png
│ │ ├── ic_tab_strip_icon_profile_selected.png
│ │ ├── icon_user.png
│ │ ├── login_bg.png
│ │ ├── no_account_tip.png
│ │ ├── publish_add.png
│ │ └── wordmark_white.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── string.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── library_res
│ └── ExampleUnitTest.kt
├── module-community
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── module_community
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── module_community
│ │ │ ├── CommunityFragment.kt
│ │ │ ├── FocusFragment.kt
│ │ │ ├── FocusViewModel.kt
│ │ │ ├── RecomendFragment.kt
│ │ │ ├── RecommendHeaderViewModel.kt
│ │ │ ├── RecommendViewModel.kt
│ │ │ └── net
│ │ │ └── ICommunityService.kt
│ └── res
│ │ ├── layout
│ │ ├── fragment_community.xml
│ │ ├── fragment_focus.xml
│ │ ├── fragment_recomend.xml
│ │ ├── include_focus_header.xml
│ │ ├── item_focus.xml
│ │ ├── item_recommend.xml
│ │ ├── item_recommend_horiscroll.xml
│ │ └── item_recommend_scroll.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── module_community
│ └── ExampleUnitTest.kt
├── module-entrance
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── module_entrance
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── module_entrance
│ │ │ ├── SplashActivity.kt
│ │ │ └── SplashViewModel.kt
│ └── res
│ │ ├── layout
│ │ └── activity_splash.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── module_entrance
│ └── ExampleUnitTest.kt
├── module-home
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── module_home
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── module_home
│ │ │ ├── module
│ │ │ └── home
│ │ │ │ ├── DailyFragment.kt
│ │ │ │ ├── FindFragment.kt
│ │ │ │ ├── HomeFragment.kt
│ │ │ │ ├── MainActivity.kt
│ │ │ │ └── RecommendFragment.kt
│ │ │ ├── net
│ │ │ └── IHomeService.kt
│ │ │ ├── viewmodel
│ │ │ ├── DailyViewModel.kt
│ │ │ ├── FindViewModel.kt
│ │ │ ├── HomeViewModel.kt
│ │ │ └── RecommendViewModel.kt
│ │ │ └── widget
│ │ │ └── HomeNavigationBarView.kt
│ └── res
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── fragment_daily.xml
│ │ ├── fragment_find.xml
│ │ ├── fragment_home.xml
│ │ ├── fragment_recommend.xml
│ │ ├── item_big_card.xml
│ │ ├── item_big_card2.xml
│ │ ├── item_header.xml
│ │ ├── item_theme.xml
│ │ └── view_home_navigationbar.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── module_home
│ └── ExampleUnitTest.kt
├── module-login
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── module_login
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── module_login
│ │ │ ├── LoginActivity.kt
│ │ │ └── LoginViewModel.kt
│ └── res
│ │ ├── layout
│ │ └── activity_login.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── module_login
│ └── ExampleUnitTest.kt
├── module-notice
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── module_notice
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── module_notice
│ │ │ ├── InteractionFragment.kt
│ │ │ ├── NoticeFragment.kt
│ │ │ ├── PushFragment.kt
│ │ │ ├── PushViewModel.kt
│ │ │ ├── net
│ │ │ └── INoticeService.kt
│ │ │ └── response
│ │ │ └── PushResponse.kt
│ └── res
│ │ ├── layout
│ │ ├── fragment_interaction.xml
│ │ ├── fragment_notice.xml
│ │ ├── fragment_push.xml
│ │ └── item_notice.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── module_notice
│ └── ExampleUnitTest.kt
├── module-play
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── playactivity
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── playactivity
│ │ │ ├── module
│ │ │ ├── CommentFragment.kt
│ │ │ ├── CommentViewModel.kt
│ │ │ ├── PlayDetailActivity.kt
│ │ │ ├── PlayDetailViewModel.kt
│ │ │ ├── RelateVideoFragment.kt
│ │ │ └── RelateVideoViewModel.kt
│ │ │ └── net
│ │ │ ├── CommentResponse.kt
│ │ │ ├── IPlayService.kt
│ │ │ ├── PlayDetailResponse.kt
│ │ │ └── RelateVideoResponse.kt
│ └── res
│ │ ├── layout
│ │ ├── activity_play_detail.xml
│ │ ├── fragment_comment.xml
│ │ ├── fragment_relate_video.xml
│ │ ├── include_video_introduce.xml
│ │ ├── item_comment.xml
│ │ ├── item_comment_title.xml
│ │ └── item_relate.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── playactivity
│ └── ExampleUnitTest.kt
├── module-user
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── maven.properties
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── example
│ │ └── module_user
│ │ └── ExampleInstrumentedTest.kt
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── example
│ │ │ └── module_user
│ │ │ └── MineFragment.kt
│ └── res
│ │ ├── layout
│ │ └── fragment_mine.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── example
│ └── module_user
│ └── ExampleUnitTest.kt
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
31 |
32 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.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 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | def ext = rootProject.ext.commonConfit
6 | android {
7 | compileSdkVersion ext.compileSdkVersion
8 | buildToolsVersion "30.0.0"
9 |
10 | defaultConfig {
11 | applicationId "com.example.mvvmframe"
12 | minSdkVersion ext.minSdkVersion
13 | targetSdkVersion ext.targetSdkVersion
14 | versionCode ext.versionCode
15 | versionName ext.versionName
16 |
17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18 |
19 | if (curEnv == isDev) {
20 | manifestPlaceholders.put('APP_NAME', "开眼-开发")
21 | } else if (curEnv == isBeta) {
22 | manifestPlaceholders.put('APP_NAME', "开眼-测试")
23 | } else if (curEnv == isRelease){
24 | manifestPlaceholders.put('APP_NAME', "开眼-正式")
25 | }
26 |
27 | }
28 |
29 | buildTypes {
30 | release {
31 | minifyEnabled false
32 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
33 | }
34 | }
35 |
36 | dataBinding {
37 | enabled = true
38 | }
39 | }
40 |
41 | dependencies {
42 | implementation fileTree(dir: "libs", include: ["*.jar"])
43 | implementation 'androidx.appcompat:appcompat:1.1.0'
44 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
45 | implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha05'
46 | testImplementation 'junit:junit:4.12'
47 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
48 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
49 | implementation "androidx.core:core-ktx:+"
50 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0"
51 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
52 |
53 | implementation projectCompat(":library-res")
54 | implementation projectCompat(":library-base")
55 | implementation projectCompat(":library-network")
56 | implementation projectCompat(":module-entrance")
57 | implementation projectCompat(":module-home")
58 | implementation projectCompat(":module-community")
59 | implementation projectCompat(":module-notice")
60 | implementation projectCompat(":module-user")
61 | implementation projectCompat(":module-login")
62 | implementation projectCompat(":module-play")
63 |
64 | }
65 | repositories {
66 | mavenCentral()
67 | }
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/mvvmframe/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.mvvmframe;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.example.mvvmframe", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 开眼
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/mvvmframe/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.mvvmframe;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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
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
20 |
21 | DEMO=false
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Aug 03 16:41:29 CST 2020
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-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/library-base/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/library-base/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-base/consumer-rules.pro
--------------------------------------------------------------------------------
/library-base/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.1.0
--------------------------------------------------------------------------------
/library-base/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
--------------------------------------------------------------------------------
/library-base/src/androidTest/java/com/example/base/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.example.base;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.platform.app.InstrumentationRegistry;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | import static org.junit.Assert.*;
12 |
13 | /**
14 | * Instrumented test, which will execute on an Android device.
15 | *
16 | * @see Testing documentation
17 | */
18 | @RunWith(AndroidJUnit4.class)
19 | public class ExampleInstrumentedTest {
20 | @Test
21 | public void useAppContext() {
22 | // Context of the app under test.
23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
24 | assertEquals("com.example.base.test", appContext.getPackageName());
25 | }
26 | }
--------------------------------------------------------------------------------
/library-base/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/application/ApplicationDelegate.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.application
2 |
3 | /**
4 | * create by libo
5 | * create on 2018/11/15
6 | * description Application生命周期回调
7 | */
8 | interface ApplicationDelegate {
9 |
10 | fun onCreate()
11 |
12 | fun onTerminate()
13 |
14 | fun onLowMemory()
15 |
16 | fun onTrimMemory(level: Int)
17 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/application/ApplicationManager.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.application
2 |
3 | /**
4 | * create by libo
5 | * create on 2020/8/7
6 | * description application管理器
7 | */
8 | class ApplicationManager {
9 |
10 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/application/BaseApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.application
2 |
3 | import android.app.Application
4 | import android.content.Context
5 | import com.alibaba.android.arouter.launcher.ARouter
6 | import com.example.base.BuildConfig
7 | import com.example.base.R
8 | import com.orhanobut.logger.AndroidLogAdapter
9 | import com.orhanobut.logger.Logger
10 | import com.scwang.smartrefresh.header.MaterialHeader
11 | import com.scwang.smartrefresh.layout.SmartRefreshLayout
12 | import com.scwang.smartrefresh.layout.api.RefreshHeader
13 | import com.scwang.smartrefresh.layout.api.RefreshLayout
14 | import com.scwang.smartrefresh.layout.footer.ClassicsFooter
15 |
16 | /**
17 | * create by libo
18 | * create on 2020/8/4
19 | * description Application
20 | */
21 | class BaseApplication : Application() {
22 |
23 | companion object {
24 | var instance: Application? = null
25 | }
26 |
27 | override fun onCreate() {
28 | super.onCreate()
29 |
30 | instance = this
31 |
32 | initARouter()
33 |
34 | initSmartRefreshLayout()
35 |
36 | Logger.addLogAdapter(AndroidLogAdapter())
37 | }
38 |
39 | /**
40 | * 初始化路由
41 | */
42 | fun initARouter() {
43 | if (BuildConfig.DEBUG) {
44 | ARouter.openLog()
45 | ARouter.openDebug()
46 | }
47 | ARouter.init(this)
48 | }
49 |
50 | /**
51 | * 初始化刷新加载
52 | */
53 | fun initSmartRefreshLayout() {
54 | SmartRefreshLayout.setDefaultRefreshHeaderCreator(fun(
55 | context: Context,
56 | layout: RefreshLayout
57 | ): RefreshHeader {
58 | layout.setEnableHeaderTranslationContent(true)
59 | return MaterialHeader(context).setColorSchemeResources(
60 | R.color.blue,
61 | R.color.blue,
62 | R.color.blue
63 | )
64 | })
65 |
66 | SmartRefreshLayout.setDefaultRefreshFooterCreator { context, layout ->
67 | return@setDefaultRefreshFooterCreator ClassicsFooter(context)
68 | }
69 | }
70 |
71 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/activity/BaseActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.activity
2 |
3 | import android.content.pm.ActivityInfo
4 | import android.os.Bundle
5 | import androidx.appcompat.app.AppCompatActivity
6 | import androidx.lifecycle.Lifecycle
7 | import androidx.lifecycle.LifecycleObserver
8 | import androidx.lifecycle.OnLifecycleEvent
9 | import com.example.base.R
10 | import com.example.base.network.base.view.IBaseView
11 | import com.example.base.network.utils.ActivityManager
12 | import com.gyf.immersionbar.ImmersionBar
13 |
14 | /**
15 | * create by libo
16 | * create on 2020/8/7
17 | * description BaseActivity
18 | */
19 | open abstract class BaseActivity : AppCompatActivity(), IBaseView {
20 |
21 | override fun onCreate(savedInstanceState: Bundle?) {
22 | //统一设置activity竖屏
23 | requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
24 | super.onCreate(savedInstanceState)
25 |
26 | setContentView(setLayoutId())
27 |
28 | ActivityManager.addActivity(this) //创建Activity入栈管理
29 |
30 | statusBaySetting()
31 | }
32 |
33 | /**
34 | * activity系统状态栏封装,并设置默认样式
35 | */
36 | open fun statusBaySetting() {
37 | lifecycle.addObserver(object: LifecycleObserver {
38 | @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
39 | fun onCreate() {
40 | ImmersionBar.with(this@BaseActivity)
41 | .statusBarColor(statusBarColor())
42 | .statusBarDarkFont(isDarkFont())
43 | .fitsSystemWindows(true)
44 | .init()
45 | }
46 | })
47 | }
48 |
49 | protected abstract fun setLayoutId(): Int
50 |
51 | /**
52 | * 设置系统状态栏颜色
53 | */
54 | open fun statusBarColor(): Int = R.color.colorPrimary
55 |
56 | /**
57 | * 设置状态栏颜色,默认黑色
58 | */
59 | open fun isDarkFont(): Boolean = true
60 |
61 | override fun showToast() {}
62 |
63 | override fun showLoading() {}
64 |
65 | override fun showEmpty() {}
66 |
67 | override fun onDestroy() {
68 | super.onDestroy()
69 | ActivityManager.removeActivity(this) //销毁Activity移出栈
70 | }
71 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/activity/BaseMvvmActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.activity
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import androidx.databinding.ViewDataBinding
6 | import androidx.lifecycle.ViewModelProviders
7 | import com.example.base.BR
8 | import com.example.base.network.base.viewmodel.BaseViewModel
9 | import java.lang.reflect.ParameterizedType
10 |
11 | /**
12 | * create by libo
13 | * create on 2020/8/4
14 | * description
15 | */
16 | abstract class BaseMvvmActivity : BaseActivity() {
17 | lateinit var viewModel: VM
18 | lateinit var binding: V
19 |
20 | override fun onCreate(savedInstanceState: Bundle?) {
21 | super.onCreate(savedInstanceState)
22 | initDataBinding()
23 | initViewModel()
24 |
25 | init()
26 | }
27 |
28 | /**
29 | * 创建dataBingding,并自动设置布局
30 | */
31 | private fun initDataBinding() {
32 | var dbClass = genericTypeBinding()
33 | var method = dbClass.getMethod("inflate", LayoutInflater::class.java)
34 | binding = method.invoke(null, layoutInflater) as V
35 | setContentView(binding.root)
36 | }
37 |
38 | private fun initViewModel() {
39 | viewModel = createViewModel()
40 | binding!!.setVariable(getBindingVariable(), viewModel)
41 | binding.lifecycleOwner = this
42 | }
43 |
44 | /**
45 | * 创建viewModel
46 | */
47 | protected fun createViewModel(): VM {
48 | return ViewModelProviders.of(this).get(genericTypeViewModel())
49 | }
50 |
51 | /**
52 | * 获取参数Variable
53 | */
54 | private fun getBindingVariable() = BR.viewModel
55 |
56 | /**
57 | * 获取当前类泛型viewmodel的Class类型
58 | * @return
59 | */
60 | fun genericTypeViewModel(): Class {
61 | return (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[1] as Class
62 | }
63 |
64 | fun genericTypeBinding(): Class {
65 | return (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0] as Class
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/fragment/BaseLazyloadFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.fragment
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.fragment.app.Fragment
8 | import com.example.base.network.base.view.IBaseView
9 |
10 | /**
11 | * create by libo
12 | * create on 2018/11/16
13 | * description 懒加载Fragment,默认所有fragment都是懒加载
14 | */
15 | abstract class BaseLazyloadFragment : Fragment() {
16 | protected var rootView: View? = null
17 | private var canVisible = false
18 | /** 是否是第一次加载布局 */
19 | private var isInitView = false
20 |
21 | override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
22 | initLoadMoreViews()
23 | isInitView = true
24 | isCanLoadData
25 |
26 | isVisible()
27 | return getContentView(layoutInflater, container)
28 | }
29 |
30 | override fun onActivityCreated(savedInstanceState: Bundle?) {
31 | super.onActivityCreated(savedInstanceState)
32 | initView()
33 | initData()
34 | }
35 |
36 | override fun setUserVisibleHint(isVisibleToUser: Boolean) {
37 | super.setUserVisibleHint(isVisibleToUser)
38 |
39 | //isVisibleToUser值表示:该Fragment的UI用户是否可见,获取该标志记录下来
40 | if (isVisibleToUser) {
41 | canVisible = true
42 | isCanLoadData
43 | } else {
44 | canVisible = false
45 | }
46 | }
47 |
48 | //所以能加载数据条件是view初始化完成并且对用户可见
49 | private val isCanLoadData: Unit
50 | private get() {
51 | //所以能加载数据条件是view初始化完成并且对用户可见
52 | if (canVisible && isInitView) {
53 | loadData()
54 | canVisible = false
55 | isInitView = false
56 | }
57 | }
58 |
59 | protected abstract fun initView()
60 |
61 | protected fun initData() {}
62 |
63 | protected fun initLoadMoreViews() {}
64 |
65 | /**
66 | * 懒加载方法
67 | */
68 | protected fun loadData() {}
69 |
70 | abstract fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View
71 |
72 | // override fun showToast() {}
73 | //
74 | // override fun showLoading() {}
75 | //
76 | // override fun showEmpty() {}
77 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/fragment/BaseMvvmFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.fragment
2 |
3 | import android.os.Bundle
4 | import android.view.LayoutInflater
5 | import android.view.View
6 | import android.view.ViewGroup
7 | import androidx.databinding.ViewDataBinding
8 | import androidx.lifecycle.ViewModelProviders
9 | import com.example.base.BR
10 | import com.example.base.network.base.viewmodel.BaseViewModel
11 | import java.lang.reflect.ParameterizedType
12 |
13 | /**
14 | * create by libo
15 | * create on 2020/8/4
16 | * description
17 | */
18 | abstract class BaseMvvmFragment : BaseLazyloadFragment() {
19 | lateinit var viewModel: VM
20 | lateinit var binding: V
21 |
22 | override fun onCreate(savedInstanceState: Bundle?) {
23 | super.onCreate(savedInstanceState)
24 | initDataBinding()
25 | initViewModel()
26 | }
27 |
28 | private fun initViewModel() {
29 | viewModel = createViewModel()
30 | binding.setVariable(getBindingVariable(), viewModel)
31 | binding.lifecycleOwner = this
32 | }
33 |
34 | /**
35 | * 创建dataBingding,并自动设置布局
36 | */
37 | private fun initDataBinding() {
38 | var dbClass = genericTypeBinding()
39 | var method = dbClass.getMethod("inflate", LayoutInflater::class.java)
40 | binding = method.invoke(null, layoutInflater) as V
41 | }
42 |
43 | override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
44 | return binding.root
45 | }
46 |
47 | protected fun createViewModel(): VM {
48 | return ViewModelProviders.of(this).get(genericTypeViewModel())
49 | }
50 |
51 | /**
52 | * 获取参数Variable
53 | */
54 | fun getBindingVariable() = BR.viewModel
55 |
56 | /**
57 | * 获取当前类泛型viewmodel的Class类型
58 | * @return
59 | */
60 | fun genericTypeViewModel(): Class {
61 | return (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[1] as Class
62 | }
63 |
64 | fun genericTypeBinding(): Class {
65 | return (javaClass.genericSuperclass as ParameterizedType).actualTypeArguments[0] as Class
66 | }
67 |
68 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/livedata/BaseLiveData.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.livedata
2 |
3 | import androidx.lifecycle.MutableLiveData
4 |
5 | /**
6 | * create by libo
7 | * create on 2020/8/7
8 | * description 项目事件通知基类
9 | */
10 | class BaseLiveData {
11 |
12 | /** 请求成功通知 */
13 | val loadSuccess by lazy { MutableLiveData() }
14 |
15 | /** 请求失败通知 */
16 | val loadFail by lazy { MutableLiveData() }
17 |
18 | /** 刷新 */
19 | val refresh by lazy { MutableLiveData() }
20 |
21 | /** 加载更多 */
22 | val loadMore by lazy { MutableLiveData() }
23 |
24 | /** 切换到空布局 */
25 | val switchToEmpty by lazy { MutableLiveData() }
26 |
27 | /** 切换到列表布局 */
28 | val switchToList by lazy { MutableLiveData() }
29 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/response/BaseResponse.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.response
2 |
3 | import java.io.Serializable
4 |
5 | /**
6 | * create by libo
7 | * create on 2018/11/13
8 | * description 请求数据实体类基类
9 | */
10 | open class BaseResponse : Serializable {
11 |
12 | var count: Int = 0
13 |
14 | var total: Int = 0
15 |
16 | var nextPageUrl: String? = null
17 |
18 | var adExist: Boolean? = false
19 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/view/IBaseView.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.view
2 |
3 | /**
4 | * create by libo
5 | * create on 2020/8/4
6 | * description 设定页面主要方法
7 | */
8 | interface IBaseView {
9 | fun init()
10 |
11 | fun showToast()
12 |
13 | fun showLoading()
14 |
15 | fun showEmpty()
16 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/viewmodel/BasePageViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.viewmodel
2 |
3 | import android.app.Application
4 | import androidx.databinding.ObservableArrayList
5 | import androidx.lifecycle.MutableLiveData
6 | import com.example.base.BR
7 | import me.tatarka.bindingcollectionadapter2.ItemBinding
8 |
9 | /**
10 | * create by libo
11 | * create on 2020/8/4
12 | * description 列表页面viewModel基类
13 | */
14 | open abstract class BasePageViewModel(application: Application) : BaseViewModel(application) {
15 | val items = ObservableArrayList()
16 |
17 | val itemBinding by lazy {
18 | ItemBinding.of(BR.item, getItemLayoutId()).bindExtra(BR.viewModel, this)
19 | }
20 |
21 | var curPage = MutableLiveData()
22 |
23 | /**
24 | * 获取item的布局ID
25 | */
26 | open fun getItemLayoutId(): Int = 0
27 |
28 | open fun requestData(page: Int) {}
29 |
30 | fun getStartPageNum(): Int = 0
31 |
32 | fun refresh() {
33 | curPage.value = getStartPageNum()
34 |
35 | requestData(getStartPageNum())
36 | }
37 |
38 | fun loadMore() {
39 | curPage.value = curPage.value?.plus(1)
40 | requestData(curPage.value!!)
41 | }
42 |
43 | /**
44 | * 请求数据成功处理
45 | */
46 | fun handleItemData(page: Int, datas: List) {
47 | if (page == getStartPageNum()) {
48 | //刷新完成
49 | items.clear()
50 | baseLiveData.refresh.postValue(1)
51 | } else {
52 | //加载更多完成
53 | baseLiveData.loadMore.postValue(1)
54 | }
55 |
56 | items.addAll(datas)
57 |
58 | if (items.size == 0) {
59 | baseLiveData.switchToEmpty.value = 1
60 | } else {
61 | //请求到数据且当前为空布局,需切换到列表状态
62 | if (baseLiveData.switchToEmpty.value == 1) {
63 | baseLiveData.switchToList.value = 1
64 | }
65 | }
66 | }
67 |
68 | /**
69 | * 请求数据失败处理
70 | */
71 | fun handleFail() {
72 | baseLiveData.loadFail.value = 1
73 |
74 | if (items.size == 0) {
75 | baseLiveData.switchToEmpty.value = 1
76 | }
77 | }
78 |
79 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/viewmodel/BaseViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.viewmodel
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.AndroidViewModel
5 | import com.example.base.network.base.livedata.BaseLiveData
6 |
7 | /**
8 | * create by apple
9 | * create on 2020/8/9
10 | * description 项目所有viewModel基类
11 | */
12 | open class BaseViewModel(application: Application) : AndroidViewModel(application) {
13 | var baseLiveData = BaseLiveData()
14 |
15 |
16 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/base/viewmodel/commonviewmodel/ScrollBannerViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.base.viewmodel.commonviewmodel
2 |
3 | import android.app.Application
4 | import com.example.base.R
5 | import com.example.base.network.base.viewmodel.BasePageViewModel
6 | import com.example.base.network.bean.ItemListItem
7 |
8 | /**
9 | * create by apple
10 | * create on 2020/8/24
11 | * description
12 | */
13 | class ScrollBannerViewModel(application: Application) : BasePageViewModel(application) {
14 |
15 | fun setDatas(itemList : ArrayList) {
16 | items.addAll(itemList)
17 | }
18 |
19 | override fun getItemLayoutId(): Int = R.layout.item_scroll_banner_item
20 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/Author.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class Author(
9 | val adTrack: Any,
10 | val approvedNotReadyVideoCount: Int,
11 | val description: String,
12 | val expert: Boolean,
13 | val follow: Follow,
14 | val icon: String,
15 | val id: Int,
16 | val ifPgc: Boolean,
17 | val latestReleaseTime: Long,
18 | val link: String,
19 | val name: String,
20 | val recSort: Int,
21 | val shield: Shield,
22 | val videoNum: Int
23 | )
24 |
25 | data class Follow(
26 | val followed: Boolean,
27 | val itemId: Int,
28 | val itemType: String
29 | )
30 |
31 | data class Shield(
32 | val itemId: Int,
33 | val itemType: String,
34 | val shielded: Boolean
35 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/CommomItemResponse.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | import com.example.base.network.base.response.BaseResponse
4 |
5 | /**
6 | * create by apple
7 | * create on 2020/8/10
8 | * description
9 | */
10 | data class CommomItemResponse(var itemList: ArrayList) : BaseResponse()
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/CommonItemBean.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class CommonItemBean(
9 | var adIndex: Int,
10 | var data: Data,
11 | var id: Int,
12 | var tag: Any,
13 | var type: String
14 | )
15 |
16 | data class Data(
17 | var adTrack: Any,
18 | var content: Content,
19 | var dataType: String,
20 | var header: Header,
21 | var itemList : ArrayList,
22 | var text: String,
23 | var detail: Detail,
24 | var cover: Cover,
25 | var icon: String,
26 | var title: String,
27 | var description: String,
28 | var category: String,
29 | var image: String,
30 | var rightText: String
31 | )
32 |
33 | data class Content(
34 | var adIndex: Int,
35 | var `data`: DataX,
36 | var id: Int,
37 | var tag: Any,
38 | var type: String,
39 | var author: Author
40 | )
41 |
42 | data class Consumption(
43 | var collectionCount: Int,
44 | var realCollectionCount: Int,
45 | var replyCount: Int,
46 | var shareCount: Int
47 | )
48 |
49 | data class Cover(
50 | var blurred: String,
51 | var detail: String,
52 | var feed: String,
53 | var homepage: String,
54 | var sharing: Any
55 | )
56 |
57 | data class RecentOnceReply(
58 | var actionUrl: String,
59 | var contentType: Any,
60 | var dataType: String,
61 | var message: String,
62 | var nickname: String
63 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/DataX.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class DataX(
9 | var addWatermark: Boolean,
10 | var area: String,
11 | var checkStatus: String,
12 | var city: String,
13 | var collected: Boolean,
14 | var consumption: Consumption,
15 | var cover: Cover,
16 | var createTime: Long,
17 | var dataType: String,
18 | var description: String,
19 | var height: Int,
20 | var id: Int,
21 | var author: Author,
22 | var ifMock: Boolean,
23 | var latitude: Double,
24 | var library: String,
25 | var longitude: Double,
26 | var owner: Owner,
27 | var playUrl: String,
28 | var duration: Int,
29 | var privateMessageActionUrl: Any,
30 | var reallyCollected: Boolean,
31 | var recentOnceReply: RecentOnceReply,
32 | var releaseTime: Long,
33 | var resourceType: String,
34 | var selectedTime: Long,
35 | var tags: List,
36 | var title: String,
37 | var uid: Int,
38 | var updateTime: Long,
39 | var url: String,
40 | var urls: List,
41 | var urlsWithWatermark: List,
42 | var varidateResult: String,
43 | var varidateStatus: String,
44 | var width: Int
45 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/Detail.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class Detail(
9 | val actionUrl: String,
10 | val adTrack: List,
11 | val adaptiveImageUrls: String,
12 | val adaptiveUrls: String,
13 | val canSkip: Boolean,
14 | val categoryId: Int,
15 | val countdown: Boolean,
16 | val cycleCount: Int,
17 | val description: String,
18 | val displayCount: Int,
19 | val displayTimeDuration: Int,
20 | val icon: String,
21 | val id: Int,
22 | val ifLinkage: Boolean,
23 | val imageUrl: String,
24 | val iosActionUrl: String,
25 | val linkageAdId: Int,
26 | val loadingMode: Int,
27 | val openSound: Boolean,
28 | val position: Int,
29 | val showActionButton: Boolean,
30 | val showImage: Boolean,
31 | val showImageTime: Int,
32 | val timeBeforeSkip: Int,
33 | val title: String,
34 | val url: String,
35 | val videoAdType: String,
36 | val videoType: String
37 | )
38 |
39 | data class AdTrack(
40 | val clickUrl: String,
41 | val monitorPositions: String,
42 | val needExtraParams: List,
43 | val organization: String,
44 | val playUrl: String,
45 | val viewUrl: String
46 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/Header.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class Header(
9 | val actionUrl: String,
10 | val cover: Any,
11 | val description: String,
12 | val font: Any,
13 | val icon: String,
14 | val iconType: String,
15 | val id: Int,
16 | val label: Any,
17 | val labelList: Any,
18 | val rightText: String,
19 | val showHateVideo: Boolean,
20 | val subTitle: Any,
21 | val subTitleFont: Any,
22 | val textAlign: String,
23 | val time: Long,
24 | val title: String
25 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/ItemListItem.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/24
6 | * description 社区-推荐顶部滑动item
7 | */
8 | data class ItemListItem(
9 | val adIndex: Int,
10 | val `data`: DataItem,
11 | val id: Int,
12 | val tag: Any,
13 | val type: String
14 | )
15 |
16 | data class DataItem(
17 | val actionUrl: String,
18 | val image: String,
19 | val bgPicture: String,
20 | val dataType: String,
21 | val subTitle: String,
22 | val title: String
23 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/Owner.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class Owner(
9 | var actionUrl: String,
10 | var area: Any,
11 | var avatar: String,
12 | var birthday: Long,
13 | var city: String,
14 | var country: String,
15 | var cover: String,
16 | var description: String,
17 | var expert: Boolean,
18 | var followed: Boolean,
19 | var gender: String,
20 | var ifPgc: Boolean,
21 | var job: String,
22 | var library: String,
23 | var limitVideoOpen: Boolean,
24 | var nickname: String,
25 | var registDate: Long,
26 | var releaseDate: Long,
27 | var uid: Int,
28 | var university: String,
29 | var userType: String
30 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/PushBean.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/23
6 | * description
7 | */
8 | data class PushBean(
9 | val actionUrl: String,
10 | val content: String,
11 | val date: Long,
12 | val icon: String,
13 | val id: Int,
14 | val ifPush: Boolean,
15 | val pushStatus: Int,
16 | val title: String,
17 | val uid: Any,
18 | val viewed: Boolean
19 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/Tag.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description
7 | */
8 | data class Tag(
9 | var actionUrl: String,
10 | var adTrack: Any,
11 | var bgPicture: String,
12 | var childTagIdList: Any,
13 | var childTagList: Any,
14 | var communityIndex: Int,
15 | var desc: String,
16 | var haveReward: Boolean,
17 | var headerImage: String,
18 | var id: Int,
19 | var ifNewest: Boolean,
20 | var name: String,
21 | var newestEndTime: Any,
22 | var tagRecType: String
23 | )
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/bean/UserInfoCache.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.bean
2 |
3 | import android.text.TextUtils
4 |
5 | /**
6 | * create by libo
7 | * create on 2018/12/18
8 | * description 缓存的用户信息
9 | */
10 | object UserInfoCache {
11 | var USERID: String? = null
12 | var TOKEN = ""
13 | var NIKENAME: String? = null
14 |
15 | /**
16 | * 当前是否为登录状态
17 | */
18 | fun isLogin(): Boolean {
19 | return !TextUtils.isEmpty(TOKEN)
20 | }
21 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/config/AppConfig.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.config
2 |
3 | object AppConfig {
4 | /**
5 | * 是否是测试模式
6 | */
7 | var isDebug = true
8 |
9 | /**
10 | * 业务状态码成功标识
11 | */
12 | const val BIZCODE_OK = "OK"
13 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/config/DirConfig.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.config
2 |
3 | import android.os.Environment
4 |
5 | /**
6 | * create by libo
7 | * create on 2018/11/13
8 | * description 存储路径配置
9 | */
10 | object DirConfig {
11 | /**
12 | * 请求数据缓存
13 | */
14 | val HTTP_CACHE = Environment.getExternalStorageDirectory().absolutePath + "/httpCache"
15 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/config/ItemTypeConfig.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.config
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/13
6 | * description 多布局各个item类型声明
7 | */
8 | object ItemTypeConfig {
9 |
10 | /**
11 | *文字频标题类型
12 | */
13 | const val ITEM_TYPE_TEXTCARD = "TextCard"
14 |
15 | /**
16 | * 视频大item类型
17 | */
18 | const val ITEM_TYPE_FOLLOWCARD = "followCard"
19 |
20 | /**
21 | * 自动播放视频item类
22 | */
23 | const val ITEM_TYPE_AUTOPLAY_FOLLOWCARD = "autoPlayFollowCard"
24 |
25 | /**
26 | * 图片item类型
27 | */
28 | const val ITEM_TYPE_PICTURE_FOLLOWCARD = "pictureFollowCard"
29 |
30 | /**
31 | * 视频小item类型
32 | */
33 | const val ITEM_TYPE_VIDEO_SAMLLCARD = "videoSmallCard"
34 |
35 | /**
36 | * 评论标题item类型
37 | */
38 | const val ITEM_TYPE_COMMENT_TITLE = "leftAlignTextHeader"
39 |
40 | /**
41 | * 评论item类型
42 | */
43 | const val ITEM_TYPE_COMMENT = "reply"
44 |
45 | val ITEM_TYPE_SQUARECARD = "squareCardCollection"
46 |
47 | /**
48 | * 广告类型
49 | */
50 | const val ITEM_TYPE_VIDEOAD = "autoPlayVideoAd"
51 |
52 | /**
53 | * 主题item类型
54 | */
55 | const val ITEM_TYPE_TAGBRIEFCARD = "TagBriefCard"
56 |
57 | /**
58 | * 简单卡片
59 | */
60 | const val ITEM_TYPE_BRIEFCARD = "BriefCard"
61 |
62 | /**
63 | * 左右文字标题
64 | */
65 | const val ITEM_TYPE_LEFTRIGHT_TITLE = "TextCardWithRightAndLeftTitle"
66 |
67 | /**
68 | * banner2广告类型
69 | */
70 | const val ITEM_TYPE_BANNER2 = "banner2"
71 |
72 | const val ITEM_TYPE_COLLECTION = "ItemCollection"
73 |
74 | const val ITEM_TYPE_FOLLOWCARD_UPPER = "FollowCard"
75 |
76 | /**
77 | * 仅一张图banner
78 | */
79 | const val ITEM_TYPE_BANNER = "Banner"
80 |
81 | /**
82 | * 水平滑动banner
83 | */
84 | const val ITEM_TYPE_HORIZONTALSCROLLCARD = "HorizontalScrollCard"
85 |
86 | const val ITEM_TYPE_VIDEOBEANFORCLIENT = "VideoBeanForClient"
87 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/databinding/BindingAdapterUtil.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.databinding
2 |
3 | import android.text.TextUtils
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import android.widget.ImageView
7 | import android.widget.TextView
8 | import androidx.databinding.BindingAdapter
9 | import com.alibaba.android.arouter.launcher.ARouter
10 | import com.bumptech.glide.Glide
11 | import com.example.base.network.utils.ScreenUtils
12 | import java.text.SimpleDateFormat
13 | import java.util.*
14 |
15 | /**
16 | * create by apple
17 | * create on 2020/8/24
18 | * description
19 | */
20 | object BindingAdapterUtil {
21 |
22 | @JvmStatic
23 | @BindingAdapter(value = ["imgUrl"], requireAll = true)
24 | fun setImgUrl(imageView: ImageView, url: String?) {
25 |
26 | if (!TextUtils.isEmpty(url)) {
27 | Glide.with(imageView.context).load(url).into(imageView)
28 | }
29 | }
30 |
31 | /**
32 | * 由时间戳转日期格式
33 | */
34 | @JvmStatic
35 | @BindingAdapter(value = ["timestamp"], requireAll = false)
36 | fun timeStamp2Date(textView: TextView, timestamp: Long) {
37 | var sdf = SimpleDateFormat("YYYY/mm/dd")
38 | val date = Date(timestamp)
39 | textView.setText(sdf.format(date) + " 发布:")
40 | }
41 |
42 | /**
43 | * 由宽高值算Imageview实际高度
44 | */
45 | @JvmStatic
46 | @BindingAdapter(value = ["widthHeight"], requireAll = false)
47 | fun resize(imageView: ImageView, widthHeight: Array?) {
48 |
49 | var realWidth = (ScreenUtils.getScreenWidth(imageView.context)-ScreenUtils.dp2px(imageView.context, 32.0f))/2
50 | var layoutParams: ViewGroup.LayoutParams = imageView.layoutParams
51 | layoutParams.width = realWidth
52 | layoutParams.height = (realWidth.toFloat()/ (widthHeight?.get(0) ?: 100) * (widthHeight?.get(1) ?: 100)).toInt()
53 | imageView.layoutParams = layoutParams
54 | }
55 |
56 | /**
57 | * 给view设置点击跳转页面
58 | */
59 | @JvmStatic
60 | @BindingAdapter(value = ["jumpPage"], requireAll = false)
61 | fun jumpPage(view: View, routePath: String) {
62 | view.setOnClickListener {
63 | ARouter.getInstance().build(routePath).navigation()
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/route/RoutePath.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.route
2 |
3 |
4 | /**
5 | * create by libo
6 | * create on 2020/8/7
7 | * description 路由路径
8 | */
9 | object RoutePath {
10 |
11 | /**
12 | * 首页模块
13 | */
14 | object Home {
15 | private const val MAIN = "/home"
16 |
17 | const val HOME_ACTIVITY = "${MAIN}/homeActivity"
18 | }
19 |
20 | /**
21 | * 社区模块
22 | */
23 | object Community {
24 | private const val MAIN = "/communication"
25 |
26 | const val COMMUNICATION_FRAGMENT = "${MAIN}/communication"
27 | }
28 |
29 | /**
30 | * 通知模块
31 | */
32 | object Notification {
33 | private const val MAIN = "/notification"
34 |
35 | const val NOTIFICATION_FRAGMENT = "${MAIN}/notificationFragment"
36 | }
37 |
38 | /**
39 | * 我的模块
40 | */
41 | object Mine {
42 | private const val MAIN = "/mine"
43 |
44 | const val MINE_FRAGMENT = "${MAIN}/mineFragment"
45 | }
46 |
47 | /**
48 | * 登录模块
49 | */
50 | object Login {
51 | private const val MAIN = "/login"
52 |
53 | const val LOGIN_ACTIVITY = "${MAIN}/loginActivity"
54 | }
55 |
56 | /**
57 | * 播放详情页
58 | */
59 | object Play {
60 | private const val MAIN = "/play"
61 |
62 | const val PLAY_DETAIL_ACTIVITY = "${MAIN}/playDetailActivity"
63 | }
64 |
65 |
66 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/ActivityManager.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | import android.app.Activity
4 | import android.content.Context
5 | import android.os.Process
6 | import java.util.*
7 |
8 | /**
9 | * create by libo
10 | * create on 2018/11/15
11 | * description Activity出入栈管理类
12 | */
13 | object ActivityManager {
14 | /**
15 | * 用于存储和统一销毁一套操作的Activities
16 | */
17 | private var activities: Stack? = null
18 |
19 | /**
20 | * 将创建的activity入栈管理
21 | *
22 | * @param activity
23 | */
24 | fun addActivity(activity: Activity) {
25 | if (activities == null) {
26 | activities = Stack()
27 | }
28 | activities!!.add(activity)
29 | }
30 |
31 | /**
32 | * 将该activity出栈
33 | *
34 | * @param activity
35 | */
36 | fun removeActivity(activity: Activity?) {
37 | if (activity != null) {
38 | activities!!.remove(activity)
39 | activity.finish()
40 | }
41 | }
42 |
43 | /**
44 | * 结束所有activity
45 | */
46 | fun finishAll() {
47 | for (activity in activities!!) {
48 | if (!activity.isFinishing) {
49 | activity.finish()
50 | }
51 | }
52 | activities!!.clear()
53 | Process.killProcess(Process.myPid())
54 | }
55 |
56 | /**
57 | * 退出程序并杀死任务栈
58 | * @param context
59 | */
60 | fun exitApp(context: Context?) {
61 | // 结束进程
62 | System.exit(0)
63 | }
64 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/AnimUtils.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | import android.animation.ObjectAnimator
4 | import android.view.View
5 | import android.view.animation.AlphaAnimation
6 | import android.view.animation.DecelerateInterpolator
7 | import android.view.animation.TranslateAnimation
8 |
9 | /**
10 | * create by libo
11 | * create on 2020/8/7
12 | * description
13 | */
14 | class AnimUtils {
15 |
16 | companion object {
17 | /**
18 | * 以中心缩放属性动画
19 | * @param view
20 | * @param from
21 | * @param to
22 | */
23 | fun startScaleAnim(view: View?, time: Long, from: Float, to: Float) {
24 | val animX = ObjectAnimator.ofFloat(view, "scaleX", from, to)
25 | val animY = ObjectAnimator.ofFloat(view, "scaleY", from, to)
26 | animX.duration = time
27 | animY.duration = time
28 | animX.start()
29 | animY.start()
30 | }
31 |
32 | /**
33 | * 旋转属性动画
34 | * @param view
35 | * @param time
36 | * @param fromAngle
37 | * @param toAngle
38 | */
39 | fun startRotateAnim(view: View?, time: Long, fromAngle: Int, toAngle: Float) {
40 | val animRotate = ObjectAnimator.ofFloat(view, "rotation", fromAngle.toFloat(), toAngle)
41 | animRotate.duration = time
42 | animRotate.start()
43 | }
44 |
45 | /**
46 | * 移动动画
47 | * @param view
48 | * @param fromX
49 | * @param toX
50 | * @param fromY
51 | * @param toY
52 | */
53 | fun translationAnim(view: View, duration: Long, fromX: Float, toX: Float, fromY: Float, toY: Float) {
54 | val anim = TranslateAnimation(fromX, toX, fromY, toY)
55 | anim.duration = duration
56 | anim.fillAfter = true
57 | anim.interpolator = DecelerateInterpolator()
58 | view.startAnimation(anim)
59 | }
60 |
61 | /**
62 | * 透明度改变动画
63 | * @param view
64 | * @param fromAlpha
65 | * @param toAlpha
66 | * @param duration
67 | */
68 | fun alphaAnim(view: View, fromAlpha: Float, toAlpha: Float, duration: Long) {
69 | val anim = AlphaAnimation(fromAlpha, toAlpha)
70 | anim.duration = duration
71 | view.startAnimation(anim)
72 | }
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/ItemDecortionGridLayout.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | import android.content.Context
4 | import android.graphics.Canvas
5 | import androidx.recyclerview.widget.RecyclerView
6 |
7 | /**
8 | * create by libo
9 | * create on 2018/11/29
10 | * description recyclerview gridlayoutManager或者staggeredLayoutManager设置间距类
11 | */
12 | class ItemDecortionGridLayout : RecyclerView.ItemDecoration {
13 | private var mContext: Context
14 | private var paddingSpace = 10
15 |
16 | constructor(context: Context) {
17 | mContext = context
18 | }
19 |
20 | constructor(context: Context, paddingSpace: Int) {
21 | mContext = context
22 | this.paddingSpace = paddingSpace
23 | }
24 |
25 | override fun onDraw(c: Canvas, parent: RecyclerView, state: RecyclerView.State) {
26 | drawVertical(c, parent)
27 | }
28 |
29 | fun drawVertical(c: Canvas?, parent: RecyclerView) {
30 | val childCount = parent.childCount
31 |
32 | // 在每一个子控件的右侧画线
33 | for (i in 0 until childCount) {
34 | val child = parent.getChildAt(i)
35 | val tag = child.tag as String
36 | if (tag == null) {
37 | val right = child.right
38 | val layoutParams = child.layoutParams as RecyclerView.LayoutParams
39 | val M = ScreenUtils.dp2px(mContext, paddingSpace.toFloat())
40 | layoutParams.topMargin = M
41 | layoutParams.bottomMargin = M
42 | if (right > ScreenUtils.getScreenWidth(mContext) / 2) {
43 | layoutParams.rightMargin = M
44 | layoutParams.leftMargin = M / 2
45 | } else {
46 | layoutParams.rightMargin = M / 2
47 | layoutParams.leftMargin = M
48 | }
49 | child.layoutParams = layoutParams
50 | }
51 | }
52 | }
53 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/LogUtils.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | import android.util.Log
4 |
5 | /**
6 | * create by libo
7 | * create on 2018/11/13
8 | * description 日志打印工具类
9 | */
10 | object LogUtils {
11 | var isOpenLog = true
12 | const val TAG = "debugTag"
13 | fun isOpenLog(isDebug: Boolean) {
14 | isOpenLog = isDebug
15 | }
16 |
17 | fun d(content: String?) {
18 | if (!isOpenLog) return
19 | Log.d(TAG, content)
20 | }
21 |
22 | fun d(content: String?, tr: Throwable?) {
23 | if (!isOpenLog) return
24 | Log.d(TAG, content, tr)
25 | }
26 |
27 | fun e(content: String?) {
28 | if (!isOpenLog) return
29 | Log.e(TAG, content)
30 | }
31 |
32 | fun e(content: String?, tr: Throwable?) {
33 | if (!isOpenLog) return
34 | Log.e(TAG, content, tr)
35 | }
36 |
37 | fun i(content: String?) {
38 | if (!isOpenLog) return
39 | Log.i(TAG, content)
40 | }
41 |
42 | fun i(content: String?, tr: Throwable?) {
43 | if (!isOpenLog) return
44 | Log.i(TAG, content, tr)
45 | }
46 |
47 | fun v(content: String?) {
48 | if (!isOpenLog) return
49 | Log.v(TAG, content)
50 | }
51 |
52 | fun v(content: String?, tr: Throwable?) {
53 | if (!isOpenLog) return
54 | Log.v(TAG, content, tr)
55 | }
56 |
57 | fun w(content: String?) {
58 | if (!isOpenLog) return
59 | Log.w(TAG, content)
60 | }
61 |
62 | fun w(content: String?, tr: Throwable?) {
63 | if (!isOpenLog) return
64 | Log.w(TAG, content, tr)
65 | }
66 |
67 | fun w(tr: Throwable?) {
68 | if (!isOpenLog) return
69 | Log.w(TAG, tr)
70 | }
71 |
72 | fun wtf(content: String?) {
73 | if (!isOpenLog) return
74 | Log.wtf(TAG, content)
75 | }
76 |
77 | fun wtf(content: String?, tr: Throwable?) {
78 | if (!isOpenLog) return
79 | Log.wtf(TAG, content, tr)
80 | }
81 |
82 | fun wtf(tr: Throwable?) {
83 | if (!isOpenLog) return
84 | Log.wtf(TAG, tr)
85 | }
86 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/NetStateUtils.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | import android.content.Context
4 | import android.net.ConnectivityManager
5 |
6 | /**
7 | * create by libo
8 | * create on 2020/8/7
9 | * description
10 | */
11 | class NetStateUtils {
12 | /**
13 | * 获取当前网络类型
14 | *
15 | * @param context
16 | * @return
17 | */
18 | fun getNetworkState(context: Context): NetStateEnum {
19 | val manager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
20 | if (manager.activeNetworkInfo == null) {
21 | return NetStateEnum.NONE
22 | }
23 | val netType = manager.activeNetworkInfo.type
24 | return when (netType) {
25 | ConnectivityManager.TYPE_WIFI -> NetStateEnum.WIFI
26 | ConnectivityManager.TYPE_MOBILE -> NetStateEnum.MOBILE
27 | else -> NetStateEnum.NONE
28 | }
29 | }
30 |
31 | /**
32 | * 检测是否有网络
33 | *
34 | * @param context
35 | * @return
36 | */
37 | fun isHasNet(context: Context): Boolean {
38 | return if (getNetworkState(context) == NetStateEnum.NONE) false else true
39 | }
40 |
41 | enum class NetStateEnum {
42 | NONE, WIFI, MOBILE
43 | }
44 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/OnItemClickListener.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/11
6 | * description
7 | */
8 | interface OnItemClickListener {
9 |
10 | fun onItemClick(m: T)
11 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/utils/TimeUtils.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.utils
2 |
3 | /**
4 | * create by apple
5 | * create on 2020/8/10
6 | * description 时间转化工具类
7 | */
8 | object TimeUtils {
9 |
10 | /**
11 | * 秒转为 00:00 ,单位为秒
12 | * @param duration
13 | */
14 | fun duration2Time(duration: Long): String? {
15 | val m = duration / 60
16 | val s = duration % 60
17 | val builder = StringBuilder()
18 | builder.append(m / 10).append(m % 10).append(":").append(s / 10).append(s % 10)
19 | return builder.toString()
20 | }
21 | }
--------------------------------------------------------------------------------
/library-base/src/main/java/com/example/base/network/widget/FmPagerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.example.base.network.widget
2 |
3 | import androidx.fragment.app.Fragment
4 | import androidx.fragment.app.FragmentManager
5 | import androidx.fragment.app.FragmentPagerAdapter
6 | import java.util.*
7 |
8 | /**
9 | * create by libo
10 | * create on 2018/11/16
11 | * description 通用fragmentadapter
12 | */
13 | class FmPagerAdapter(fm: FragmentManager?, private val tabFragments: ArrayList, private val titles: Array) : FragmentPagerAdapter(fm!!) {
14 |
15 | override fun getItem(position: Int): Fragment {
16 | return tabFragments[position]
17 | }
18 |
19 | override fun getCount(): Int {
20 | return tabFragments.size
21 | }
22 |
23 | override fun getPageTitle(position: Int): CharSequence? {
24 | return titles[position]
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/customview_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/item_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/item_leftright_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
17 |
18 |
29 |
30 |
40 |
41 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/item_only_pic.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
11 |
15 |
16 |
24 |
25 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/item_scroll_banner.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
14 |
15 |
16 |
19 |
20 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/item_scroll_banner_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
17 |
18 |
27 |
28 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/item_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
15 |
16 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
12 |
13 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/library-base/src/main/res/layout/view_empty.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
26 |
--------------------------------------------------------------------------------
/library-base/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/library-base/src/test/java/com/example/base/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.example.base;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/library-network/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/library-network/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "30.0.0"
8 |
9 | defaultConfig {
10 | minSdkVersion 21
11 | targetSdkVersion 29
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles "consumer-rules.pro"
17 |
18 | //将环境变量注入到buildConfig中
19 | buildConfigField 'int', 'CUR_ENV', "$curEnv"
20 | buildConfigField 'int', 'IS_DEV', "0"
21 | buildConfigField 'int', 'IS_BETA', "1"
22 | buildConfigField 'int', 'IS_RELEASE', "2"
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | implementation fileTree(dir: "libs", include: ["*.jar"])
35 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
36 | implementation 'androidx.core:core-ktx:1.3.1'
37 | implementation 'androidx.appcompat:appcompat:1.1.0'
38 | testImplementation 'junit:junit:4.12'
39 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
40 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
41 |
42 | implementation 'com.libo:library-base:1.1.0'
43 |
44 | }
45 |
46 | apply plugin: 'maven'
47 | uploadArchives {
48 | repositories {
49 | mavenDeployer {
50 | repository(url: 'https://packages.aliyun.com/maven/repository/2088958-release-NjyZEe/') {
51 | authentication(
52 | userName: '605c8c634639bfa6ebf357c5',
53 | password: '0j)7TdpkQy6B'
54 | )
55 | }
56 | snapshotRepository(url: 'https://packages.aliyun.com/maven/repository/2088958-snapshot-Svd6Nt/') {
57 | authentication(
58 | userName: '605c8c634639bfa6ebf357c5',
59 | password: '0j)7TdpkQy6B'
60 | )
61 | }
62 | pom.version = '1.1.0'
63 | pom.artifactId = 'library-network'
64 | pom.groupId = 'com.libo'
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/library-network/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-network/consumer-rules.pro
--------------------------------------------------------------------------------
/library-network/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.1.0
--------------------------------------------------------------------------------
/library-network/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
--------------------------------------------------------------------------------
/library-network/src/androidTest/java/com/example/network/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.network
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.network.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/library-network/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | /
5 |
--------------------------------------------------------------------------------
/library-network/src/main/java/com/example/network/interceptor/interceptor/HeaderInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.example.network.interceptor.interceptor
2 |
3 | import com.example.base.network.bean.UserInfoCache
4 | import okhttp3.Interceptor
5 | import okhttp3.Response
6 | import java.io.IOException
7 |
8 | /**
9 | * create by libo
10 | * create on 2018/11/13
11 | * description 统一添加header的拦截器
12 | */
13 | class HeaderInterceptor : Interceptor {
14 | @Throws(IOException::class)
15 | override fun intercept(chain: Interceptor.Chain): Response {
16 | val builder = chain.request().newBuilder()
17 | builder.addHeader("token", UserInfoCache.TOKEN)
18 | return chain.proceed(builder.build())
19 | }
20 | }
--------------------------------------------------------------------------------
/library-network/src/main/java/com/example/network/interceptor/interceptor/LoggingInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.example.network.interceptor.interceptor
2 |
3 | import com.example.base.network.utils.LogUtils
4 | import com.orhanobut.logger.Logger
5 | import okhttp3.Interceptor
6 | import okhttp3.Response
7 | import java.io.IOException
8 |
9 | /**
10 | * create by libo
11 | * create on 2018/11/13
12 | * description Okhttp返回数据日志拦截器
13 | */
14 | class LoggingInterceptor : Interceptor {
15 | private val byteCount = 1024 * 1024
16 |
17 | @Throws(IOException::class)
18 | override fun intercept(chain: Interceptor.Chain): Response {
19 | //chain里面包含了request和response,按需获取
20 | val request = chain.request()
21 | val response = chain.proceed(request)
22 | LogUtils.d(String.format("发送请求 %s", request.url()))
23 | val responseBody = response.peekBody(byteCount.toLong())
24 |
25 | Logger.d(responseBody.string())
26 | LogUtils.d(String.format("接收响应 %s", responseBody.string()))
27 | return response
28 | }
29 | }
--------------------------------------------------------------------------------
/library-network/src/main/java/com/example/network/interceptor/interceptor/LoginInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.example.network.interceptor.interceptor
2 |
3 | import android.content.Context
4 | import com.alibaba.android.arouter.facade.Postcard
5 | import com.alibaba.android.arouter.facade.annotation.Interceptor
6 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback
7 | import com.alibaba.android.arouter.facade.template.IInterceptor
8 | import com.alibaba.android.arouter.launcher.ARouter
9 | import com.example.base.network.bean.UserInfoCache
10 | import com.example.base.network.route.RoutePath
11 |
12 | /**
13 | * create by apple
14 | * create on 2020/8/11
15 | * description 登录拦截器
16 | */
17 | @Interceptor(priority = 3)
18 | class LoginInterceptor : IInterceptor {
19 |
20 | override fun process(postcard: Postcard?, callback: InterceptorCallback?) {
21 | if (!UserInfoCache.isLogin()) {
22 | ARouter.getInstance().build(RoutePath.Login.LOGIN_ACTIVITY).navigation()
23 | callback!!.onInterrupt(null)
24 | } else {
25 | callback!!.onContinue(postcard)
26 | }
27 | }
28 |
29 | override fun init(context: Context?) {
30 |
31 | }
32 |
33 | }
--------------------------------------------------------------------------------
/library-network/src/main/java/com/example/network/interceptor/interceptor/NetCacheInterceptor.kt:
--------------------------------------------------------------------------------
1 | package com.example.network.interceptor.interceptor
2 |
3 | import okhttp3.Interceptor
4 | import okhttp3.Response
5 | import java.io.IOException
6 |
7 | /**
8 | * create by libo
9 | * create on 2018/11/13
10 | * description 网络拦截器进行网络缓存
11 | */
12 | class NetCacheInterceptor : Interceptor {
13 | @Throws(IOException::class)
14 | override fun intercept(chain: Interceptor.Chain): Response {
15 | val request = chain.request()
16 | val response = chain.proceed(request)
17 | val onlineCacheTime = 60
18 | return response.newBuilder()
19 | .header("Cache-Control", "public, max-age=$onlineCacheTime")
20 | .removeHeader("Pragma")
21 | .build()
22 | }
23 | }
--------------------------------------------------------------------------------
/library-network/src/main/java/com/example/network/interceptor/service/ApiCallBack.kt:
--------------------------------------------------------------------------------
1 | package com.example.network.interceptor.service
2 |
3 | import com.example.base.network.utils.LogUtils
4 | import org.jetbrains.annotations.NotNull
5 | import retrofit2.adapter.rxjava.HttpException
6 | import rx.Subscriber
7 |
8 | /**
9 | * create by libo
10 | * create on 2018/11/13
11 | * description 自定义请求数据回调和过滤
12 | */
13 | abstract class ApiCallBack : Subscriber() {
14 |
15 | override fun onCompleted() {}
16 |
17 | override fun onError(e: Throwable) {
18 | e.printStackTrace()
19 | if (e is HttpException) {
20 | val code = e.code()
21 |
22 | //Http状态码提示
23 | if (code >= 400 && code < 500) {
24 | LogUtils.e("请求错误")
25 | onFail("请求错误")
26 | } else if (code >= 500) {
27 | LogUtils.e("服务器错误")
28 | onFail("服务器错误")
29 | }
30 | } else {
31 | onFail("请求错误")
32 | }
33 | }
34 |
35 | override fun onNext(baseModel: M) {
36 | onSuccess(baseModel)
37 | }
38 |
39 | /**
40 | * onSuccess回调的数据为程序具体需要的业务状态码,具体数据等
41 | */
42 | abstract fun onSuccess(@NotNull m: M)
43 |
44 | abstract fun onFail(msg: String)
45 | }
--------------------------------------------------------------------------------
/library-network/src/main/java/com/example/network/interceptor/service/ApiManager.kt:
--------------------------------------------------------------------------------
1 | package com.example.network.interceptor.service
2 |
3 | import com.example.base.network.config.AppConfig
4 | import com.example.base.network.config.DirConfig
5 | import okhttp3.Cache
6 | import okhttp3.OkHttpClient
7 | import retrofit2.Retrofit
8 | import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
9 | import retrofit2.converter.gson.GsonConverterFactory
10 | import java.io.File
11 | import java.util.concurrent.TimeUnit
12 |
13 | /**
14 | * create by libo
15 | * create on 2018/11/13
16 | * description 单例的Retrofit和Okhttp管理类
17 | */
18 | object ApiManager {
19 |
20 | private val TIMEOUT = 10
21 |
22 | private val mOkHttpClient: OkHttpClient by lazy {
23 | val builder = OkHttpClient.Builder()
24 | .connectTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) //连接超时设置
25 | .readTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) //写入缓存超时10s
26 | .writeTimeout(TIMEOUT.toLong(), TimeUnit.SECONDS) //读取缓存超时10s
27 | .retryOnConnectionFailure(true) //失败重连
28 | .addInterceptor(com.example.network.interceptor.interceptor.HeaderInterceptor()) //添加header
29 | .addInterceptor(com.example.network.interceptor.interceptor.NetCacheInterceptor()) //添加网络缓存
30 | addLogIntercepter(builder) //日志拦截器
31 | setCacheFile(builder) //网络缓存
32 | builder.build()
33 | }
34 |
35 | val retrofit: Retrofit by lazy {
36 | Retrofit.Builder()
37 | .baseUrl(Api.getBaseUrl())
38 | .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
39 | .addConverterFactory(GsonConverterFactory.create())
40 | .client(mOkHttpClient)
41 | .build()
42 | }
43 |
44 | /**
45 | * 设置缓存文件路径
46 | */
47 | private fun setCacheFile(builder: OkHttpClient.Builder) {
48 | //设置缓存文件
49 | val cacheFile = File(DirConfig.HTTP_CACHE)
50 | //缓存大小为10M
51 | val cacheSize = 10 * 1024 * 1024
52 | val cache = Cache(cacheFile, cacheSize.toLong())
53 | builder.cache(cache)
54 | }
55 |
56 | /**
57 | * 调试模式下加入日志拦截器
58 | * @param builder
59 | */
60 | private fun addLogIntercepter(builder: OkHttpClient.Builder) {
61 | if (AppConfig.isDebug) {
62 | builder.addInterceptor(com.example.network.interceptor.interceptor.LoggingInterceptor())
63 | }
64 | }
65 |
66 | }
--------------------------------------------------------------------------------
/library-network/src/test/java/com/example/network/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.network
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 | }
--------------------------------------------------------------------------------
/library-res/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/library-res/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "30.0.0"
8 |
9 | defaultConfig {
10 | minSdkVersion 21
11 | targetSdkVersion 29
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles "consumer-rules.pro"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | }
26 |
27 | dependencies {
28 | implementation fileTree(dir: "libs", include: ["*.jar"])
29 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
30 | implementation 'androidx.core:core-ktx:1.3.1'
31 | implementation 'androidx.appcompat:appcompat:1.1.0'
32 | testImplementation 'junit:junit:4.12'
33 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
34 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
35 |
36 | }
37 |
38 | apply plugin: 'maven'
39 | uploadArchives {
40 | repositories {
41 | mavenDeployer {
42 | repository(url: 'https://packages.aliyun.com/maven/repository/2088958-release-NjyZEe/') {
43 | authentication(
44 | userName: '605c8c634639bfa6ebf357c5',
45 | password: '0j)7TdpkQy6B'
46 | )
47 | }
48 | snapshotRepository(url: 'https://packages.aliyun.com/maven/repository/2088958-snapshot-Svd6Nt/') {
49 | authentication(
50 | userName: '605c8c634639bfa6ebf357c5',
51 | password: '0j)7TdpkQy6B'
52 | )
53 | }
54 | pom.version = '1.1.0'
55 | pom.artifactId = 'library-res'
56 | pom.groupId = 'com.libo'
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/library-res/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/consumer-rules.pro
--------------------------------------------------------------------------------
/library-res/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.1.0
--------------------------------------------------------------------------------
/library-res/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
--------------------------------------------------------------------------------
/library-res/src/androidTest/java/com/example/library_res/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.library_res
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.library_res.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/library-res/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | /
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/color/selector_tv_hometab.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_cache_black.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_calendar.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_close_white.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_eye.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_favorite_border_black.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_reply.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_search_black.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/ic_star_white.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/selecor_btn_community.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/selecor_btn_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/selecor_btn_mine.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/selecor_btn_notification.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/shape_black_roundsmall.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/shape_black_roundsmall_borderlight.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/shape_white_circle.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/shape_white_roundsmall_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/library-res/src/main/res/drawable/shape_white_roundsmall_borderlight.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/bg_splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/bg_splash.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/card_more_action_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/card_more_action_icon.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/daily_label.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/daily_label.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/default_cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/default_cover.jpg
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/goto_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/goto_icon.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_account_login_header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_account_login_header.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_account_login_password.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_account_login_password.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_account_login_user_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_account_login_user_name.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_collect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_collect.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_download.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_like.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_like.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_more_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_more_black.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_reply_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_reply_more.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_share.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_share_qq_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_share_qq_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_share_wechat_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_share_wechat_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_share_weibo_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_share_weibo_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_action_sumb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_action_sumb.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_app.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_app.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_collection_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_collection_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_comment_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_comment_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_empty.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_empty.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_like_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_like_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_menu_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_menu_more.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_right_arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_right_arrow.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_share_grey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_share_grey.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_category.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_category_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_category_selected.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_feed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_feed.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_feed_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_feed_selected.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_follow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_follow.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_follow_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_follow_selected.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_profile.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_profile_selected.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/ic_tab_strip_icon_profile_selected.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/icon_user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/icon_user.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/login_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/login_bg.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/no_account_tip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/no_account_tip.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/publish_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/publish_add.png
--------------------------------------------------------------------------------
/library-res/src/main/res/mipmap-xxhdpi/wordmark_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/library-res/src/main/res/mipmap-xxhdpi/wordmark_white.png
--------------------------------------------------------------------------------
/library-res/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #fafafa
4 | #3700B3
5 | #03DAC5
6 |
7 | #fff
8 | #9fff
9 | #3fff
10 | #403b47
11 |
12 | #000
13 | #1d1e1f
14 | #5000
15 | #2000
16 |
17 | #ededed
18 | #adadad
19 |
20 | #888888
21 | #444444
22 |
23 | #4687d7
24 |
25 |
--------------------------------------------------------------------------------
/library-res/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 8sp
6 | 9sp
7 | 10sp
8 | 12sp
9 | 13sp
10 | 14sp
11 | 16sp
12 | 18sp
13 | 20sp
14 | 24sp
15 |
16 |
17 | 0.5dp
18 | 1dp
19 | 2dp
20 | 3dp
21 | 4dp
22 | 5dp
23 | 8dp
24 | 10dp
25 | 12dp
26 | 13dp
27 | 14dp
28 | 15dp
29 | 16dp
30 | 20dp
31 | 27dp
32 | 30dp
33 | 40dp
34 | 42dp
35 | 45dp
36 | 48dp
37 | 50dp
38 | 60dp
39 | 70dp
40 | 80dp
41 | 150dp
42 | 200dp
43 |
44 |
--------------------------------------------------------------------------------
/library-res/src/main/res/values/string.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 每日精选视频推介,让你打开眼界
5 | Daily applizer for your eyes. Bon eyepetit.
6 | 再按一次退出
7 | 首页
8 | 社区
9 | 通知
10 | 我的
11 | 发现
12 | 推荐
13 | 日报
14 | 查看个人主页
15 | 收藏
16 | 缓存
17 | +关注
18 | 我的关注
19 | 观看记录
20 | 通知开关
21 | 我的徽章
22 | 意见反馈
23 | 我要投稿
24 | 找回密码
25 | 登录后即可关注作者、 \n 发表评论、同步收藏视频和播放记录
26 | 请输入手机号/邮箱地址
27 | 请输入密码
28 | 登录
29 | 用户注册
30 | 作者登录
31 | 登录或注册即同意开眼
32 | 用户服务协议
33 | 点击发表你的评论
34 | 回复
35 | 广告
36 | WIFI预载
37 | 推送
38 | 互动
39 | 私信
40 | 别错过重要信息
41 | 登录后即可查看评论回复、点赞及关注等通知信息
42 | 点击登录后可关注主题和作者
43 | 关注
44 |
--------------------------------------------------------------------------------
/library-res/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/library-res/src/test/java/com/example/library_res/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.library_res
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 | }
--------------------------------------------------------------------------------
/module-community/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-community/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-community/consumer-rules.pro
--------------------------------------------------------------------------------
/module-community/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-community/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
--------------------------------------------------------------------------------
/module-community/src/androidTest/java/com/example/module_community/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.module_community.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-community/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | /
5 |
--------------------------------------------------------------------------------
/module-community/src/main/java/com/example/module_community/CommunityFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.fragment.app.Fragment
7 | import com.alibaba.android.arouter.facade.annotation.Route
8 | import com.example.base.network.base.fragment.BaseLazyloadFragment
9 | import com.example.base.network.route.RoutePath
10 | import com.example.base.network.widget.FmPagerAdapter
11 | import kotlinx.android.synthetic.main.fragment_community.*
12 | import java.util.ArrayList
13 |
14 | @Route(path = RoutePath.Community.COMMUNICATION_FRAGMENT)
15 | class CommunityFragment : BaseLazyloadFragment() {
16 | lateinit var recomendFragment: RecomendFragment
17 | lateinit var focusFragment: FocusFragment
18 | private val fragments = ArrayList()
19 |
20 | private val titleStr by lazy {
21 | arrayOf(getString(R.string.recommend), getString(R.string.focus))
22 | }
23 |
24 | override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
25 | return LayoutInflater.from(context).inflate(R.layout.fragment_community, container, false)
26 | }
27 |
28 | override fun initView() {
29 | setTabLayout()
30 | }
31 |
32 | /**
33 | * 设置tablayout子fragment
34 | */
35 | private fun setTabLayout() {
36 | for (i in titleStr.indices) {
37 | tablayout.addTab(tablayout.newTab().setText(titleStr[i]))
38 | }
39 | recomendFragment = RecomendFragment()
40 | focusFragment = FocusFragment()
41 |
42 | fragments.add(recomendFragment)
43 | fragments.add(focusFragment)
44 |
45 | viewPager.adapter = FmPagerAdapter(childFragmentManager, fragments, titleStr)
46 | tablayout.setupWithViewPager(viewPager)
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/module-community/src/main/java/com/example/module_community/FocusFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
2 |
3 | import com.example.base.network.base.fragment.BaseMvvmFragment
4 | import com.example.module_community.databinding.FragmentFocusBinding
5 |
6 | class FocusFragment : BaseMvvmFragment() {
7 |
8 | override fun initView() {
9 |
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/module-community/src/main/java/com/example/module_community/FocusViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BasePageViewModel
5 | import com.example.base.network.bean.CommomItemResponse
6 | import com.example.base.network.bean.CommonItemBean
7 | import com.example.module_community.net.ICommunityService
8 | import com.example.network.interceptor.service.ApiCallBack
9 | import me.tatarka.bindingcollectionadapter2.ItemBinding
10 | import me.tatarka.bindingcollectionadapter2.OnItemBind
11 | import rx.android.schedulers.AndroidSchedulers
12 | import rx.schedulers.Schedulers
13 |
14 | /**
15 | * create by apple
16 | * create on 2020/8/23
17 | * description
18 | */
19 | class FocusViewModel(application: Application) : BasePageViewModel(application) {
20 |
21 | init {
22 | refresh()
23 | }
24 |
25 | val onItemBind: OnItemBind = OnItemBind { itemBinding, position, item ->
26 | itemBinding.set(BR.item, getItemType(position))
27 | }
28 |
29 | fun getItemType(position: Int): Int {
30 | if (position == 0) {
31 | return R.layout.include_focus_header
32 | } else {
33 | return R.layout.item_focus
34 | }
35 | }
36 |
37 | var multiItemBinding = ItemBinding.of(onItemBind)
38 |
39 | override fun requestData(page: Int) {
40 |
41 | ICommunityService.instance.getFocusList()
42 | .observeOn(AndroidSchedulers.mainThread())
43 | .subscribeOn(Schedulers.io())
44 | .subscribe(object: ApiCallBack() {
45 | override fun onSuccess(m: CommomItemResponse) {
46 | m.itemList.add(m.itemList.get(0))
47 | handleItemData(page, m.itemList)
48 | }
49 |
50 | override fun onFail(msg: String) {
51 | handleFail()
52 | }
53 |
54 | })
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/module-community/src/main/java/com/example/module_community/RecomendFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
2 |
3 | import com.example.base.network.base.fragment.BaseMvvmFragment
4 | import com.example.module_community.databinding.FragmentRecomendBinding
5 |
6 | class RecomendFragment : BaseMvvmFragment() {
7 |
8 | override fun initView() {
9 |
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/module-community/src/main/java/com/example/module_community/RecommendHeaderViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BasePageViewModel
5 | import com.example.base.network.bean.ItemListItem
6 |
7 | /**
8 | * create by apple
9 | * create on 2020/8/24
10 | * description
11 | */
12 | class RecommendHeaderViewModel(application: Application) : BasePageViewModel(application) {
13 |
14 | fun setDatas(itemList : ArrayList) {
15 | items.addAll(itemList)
16 | }
17 |
18 | override fun getItemLayoutId(): Int = R.layout.item_recommend_horiscroll
19 | }
--------------------------------------------------------------------------------
/module-community/src/main/java/com/example/module_community/net/ICommunityService.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community.net
2 |
3 | import com.example.base.network.bean.CommomItemResponse
4 | import com.example.network.interceptor.service.Api
5 | import com.example.network.interceptor.service.ApiManager
6 | import retrofit2.http.GET
7 | import rx.Observable
8 |
9 | /**
10 | * create by apple
11 | * create on 2020/8/24
12 | * description
13 | */
14 | interface ICommunityService {
15 |
16 | companion object {
17 | val instance = ApiManager.retrofit.create(ICommunityService::class.java)
18 |
19 | fun invoke(): ICommunityService {
20 | return instance
21 | }
22 | }
23 |
24 | /**
25 | * 关注
26 | */
27 | @GET(Api.FOCUS)
28 | fun getFocusList(): Observable
29 |
30 | /**
31 | * 推荐
32 | */
33 | @GET(Api.COMMUNITY_RECOMMEND)
34 | fun getRecommendData(): Observable
35 | }
--------------------------------------------------------------------------------
/module-community/src/main/res/layout/fragment_focus.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/module-community/src/main/res/layout/fragment_recomend.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/module-community/src/main/res/layout/include_focus_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
23 |
24 |
35 |
36 |
42 |
43 |
--------------------------------------------------------------------------------
/module-community/src/main/res/layout/item_recommend_scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
13 |
14 |
15 |
18 |
19 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/module-community/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/module-community/src/test/java/com/example/module_community/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_community
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 | }
--------------------------------------------------------------------------------
/module-entrance/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-entrance/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-entrance/consumer-rules.pro
--------------------------------------------------------------------------------
/module-entrance/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-entrance/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
--------------------------------------------------------------------------------
/module-entrance/src/androidTest/java/com/example/module_entrance/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_entrance
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.module_entrance.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-entrance/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/module-entrance/src/main/java/com/example/module_entrance/SplashActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_entrance
2 |
3 | import android.os.Handler
4 | import com.alibaba.android.arouter.launcher.ARouter
5 | import com.example.base.network.base.activity.BaseMvvmActivity
6 | import com.example.base.network.route.RoutePath
7 | import com.example.base.network.utils.AnimUtils
8 | import com.example.module_entrance.databinding.ActivitySplashBinding
9 | import com.gyf.immersionbar.ImmersionBar
10 | import kotlinx.android.synthetic.main.activity_splash.*
11 |
12 | /**
13 | * create by libo
14 | * create on 2020/08/07
15 | * description 欢迎页面
16 | */
17 | class SplashActivity : BaseMvvmActivity() {
18 | var handler = Handler()
19 | val animDuration: Long = 2000
20 |
21 | override fun init() {
22 | countDown()
23 |
24 | scaleAnim()
25 | }
26 |
27 | override fun statusBaySetting() {
28 | ImmersionBar.with(this).init() //设置全屏效果
29 | }
30 |
31 | /**
32 | * 进入主页倒计时
33 | */
34 | fun countDown() {
35 | handler.postDelayed({
36 | ARouter.getInstance().build(RoutePath.Home.HOME_ACTIVITY).navigation()
37 | finish()
38 | }, animDuration)
39 | }
40 |
41 | override fun setLayoutId(): Int = R.layout.activity_splash
42 |
43 | /**
44 | * 背景图放大动画
45 | */
46 | fun scaleAnim() {
47 | AnimUtils.startScaleAnim(ivSplashBg, animDuration, 1.0f, 1.05f)
48 | }
49 | }
--------------------------------------------------------------------------------
/module-entrance/src/main/java/com/example/module_entrance/SplashViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_entrance
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BaseViewModel
5 |
6 | /**
7 | * create by libo
8 | * create on 2020/8/7
9 | * description
10 | */
11 | class SplashViewModel(application: Application) : BaseViewModel(application) {
12 |
13 | }
--------------------------------------------------------------------------------
/module-entrance/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
14 |
15 |
21 |
22 |
31 |
32 |
42 |
43 |
54 |
55 |
56 |
--------------------------------------------------------------------------------
/module-entrance/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module-entrance/src/test/java/com/example/module_entrance/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_entrance
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 | }
--------------------------------------------------------------------------------
/module-home/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-home/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-home/consumer-rules.pro
--------------------------------------------------------------------------------
/module-home/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-home/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
--------------------------------------------------------------------------------
/module-home/src/androidTest/java/com/example/module_home/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.module_home.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-home/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/module-home/src/main/java/com/example/module_home/module/home/DailyFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home.module.home
2 |
3 | import android.view.View
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.Observer
6 | import com.example.base.network.base.fragment.BaseMvvmFragment
7 | import com.example.module_home.databinding.FragmentDailyBinding
8 | import com.example.module_home.viewmodel.DailyViewModel
9 | import kotlinx.android.synthetic.main.fragment_daily.*
10 |
11 | class DailyFragment : BaseMvvmFragment() {
12 |
13 | override fun initView() {
14 |
15 | var myLiveData = MutableLiveData()
16 |
17 | myLiveData.observe(this, Observer {
18 |
19 | })
20 |
21 | smartRefreshLayout.setOnRefreshListener {
22 | viewModel.refresh()
23 | }
24 |
25 | smartRefreshLayout.setOnLoadMoreListener {
26 | viewModel.loadMore()
27 | }
28 |
29 | viewModel.baseLiveData.refresh.observe(this, Observer {
30 | smartRefreshLayout.finishRefresh()
31 | })
32 |
33 | viewModel.baseLiveData.loadMore.observe(this, Observer {
34 | smartRefreshLayout.finishLoadMore()
35 | })
36 |
37 | viewModel.baseLiveData.loadFail.observe(this, Observer {
38 | smartRefreshLayout.finishRefresh()
39 | smartRefreshLayout.finishLoadMore()
40 | })
41 |
42 | viewModel.baseLiveData.switchToEmpty.observe(this, Observer {
43 | viewEmpty.visibility = View.VISIBLE
44 | })
45 |
46 | viewModel.baseLiveData.switchToList.observe(this, Observer {
47 | viewEmpty.visibility = View.GONE
48 | })
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/module-home/src/main/java/com/example/module_home/module/home/FindFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home.module.home
2 |
3 | import com.example.base.network.base.fragment.BaseMvvmFragment
4 | import com.example.module_home.databinding.FragmentFindBinding
5 | import com.example.module_home.viewmodel.FindViewModel
6 |
7 | class FindFragment : BaseMvvmFragment() {
8 |
9 | override fun initView() {
10 |
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/module-home/src/main/java/com/example/module_home/module/home/HomeFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home.module.home
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.fragment.app.Fragment
7 | import com.example.base.network.base.fragment.BaseLazyloadFragment
8 | import com.example.base.network.widget.FmPagerAdapter
9 | import com.example.module_home.R
10 | import kotlinx.android.synthetic.main.fragment_home.*
11 | import java.util.*
12 |
13 | class HomeFragment : BaseLazyloadFragment() {
14 |
15 | private val titleStr by lazy {
16 | arrayOf(getString(R.string.find), getString(R.string.recommend), getString(R.string.daily))
17 | }
18 | private val fragments = ArrayList()
19 | var findFragment: FindFragment? = null
20 | var recommendFragment: RecommendFragment? = null
21 | var dailyFragment: DailyFragment? = null
22 |
23 | override fun initView() {
24 | setTabLayout()
25 | }
26 |
27 | override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
28 | return LayoutInflater.from(context).inflate(R.layout.fragment_home, container, false)
29 | }
30 |
31 | /**
32 | * 设置tablayout子fragment
33 | */
34 | private fun setTabLayout() {
35 | for (i in titleStr.indices) {
36 | tablayout.addTab(tablayout.newTab().setText(titleStr[i]))
37 | }
38 | findFragment = FindFragment()
39 | recommendFragment = RecommendFragment()
40 | dailyFragment = DailyFragment()
41 |
42 | fragments.add(findFragment!!)
43 | fragments.add(recommendFragment!!)
44 | fragments.add(dailyFragment!!)
45 |
46 | vpHome.adapter = FmPagerAdapter(childFragmentManager, fragments, titleStr)
47 | tablayout.setupWithViewPager(vpHome)
48 | }
49 |
50 | }
--------------------------------------------------------------------------------
/module-home/src/main/java/com/example/module_home/module/home/RecommendFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home.module.home
2 |
3 | import android.view.View
4 | import androidx.lifecycle.Observer
5 | import com.example.base.network.base.fragment.BaseMvvmFragment
6 | import com.example.module_home.databinding.FragmentRecommendBinding
7 | import com.example.module_home.viewmodel.RecommendViewModel
8 | import kotlinx.android.synthetic.main.fragment_daily.*
9 |
10 | /**
11 | * create by apple
12 | * create on 2020/8/13
13 | * description
14 | */
15 | class RecommendFragment : BaseMvvmFragment() {
16 |
17 | override fun initView() {
18 | smartRefreshLayout.setOnRefreshListener {
19 | viewModel.refresh()
20 | }
21 |
22 | smartRefreshLayout.setOnLoadMoreListener {
23 | viewModel.loadMore()
24 | }
25 |
26 | viewModel.baseLiveData.refresh.observe(this, Observer {
27 | smartRefreshLayout.finishRefresh()
28 | })
29 |
30 | viewModel.baseLiveData.loadMore.observe(this, Observer {
31 | smartRefreshLayout.finishLoadMore()
32 | })
33 |
34 | viewModel.baseLiveData.loadFail.observe(this, Observer {
35 | smartRefreshLayout.finishRefresh()
36 | smartRefreshLayout.finishLoadMore()
37 | })
38 |
39 | viewModel.baseLiveData.switchToEmpty.observe(this, Observer {
40 | viewEmpty.visibility = View.VISIBLE
41 | })
42 |
43 | viewModel.baseLiveData.switchToList.observe(this, Observer {
44 | viewEmpty.visibility = View.GONE
45 | })
46 |
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/module-home/src/main/java/com/example/module_home/net/IHomeService.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home.net
2 |
3 | import com.example.base.network.bean.CommomItemResponse
4 | import com.example.network.interceptor.service.Api
5 | import com.example.network.interceptor.service.ApiManager
6 | import retrofit2.http.GET
7 | import retrofit2.http.Query
8 | import rx.Observable
9 |
10 | /**
11 | * create by libo
12 | * create on 2020/8/7
13 | * description
14 | */
15 | interface IHomeService {
16 |
17 | companion object {
18 | val instance = ApiManager.retrofit.create(IHomeService::class.java)
19 |
20 | fun invoke(): IHomeService {
21 | return instance
22 | }
23 | }
24 |
25 | /**
26 | * 首页-发现
27 | */
28 | @GET(Api.FIND)
29 | fun getFindData(): Observable
30 |
31 | /**
32 | * 首页-日报
33 | */
34 | @GET(Api.DAILY)
35 | fun getDailyData(@Query("num") num: Int): Observable
36 |
37 | /**
38 | * 首页-推荐
39 | */
40 | @GET(Api.HOME_RECOMMEND)
41 | fun getRecommend(@Query("page") page: Int): Observable
42 |
43 | }
--------------------------------------------------------------------------------
/module-home/src/main/java/com/example/module_home/viewmodel/HomeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home.viewmodel
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BaseViewModel
5 |
6 | /**
7 | * create by libo
8 | * create on 2020/8/4
9 | * description
10 | */
11 | class HomeViewModel(application: Application) : BaseViewModel(application) {
12 |
13 |
14 | }
--------------------------------------------------------------------------------
/module-home/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
23 |
24 |
29 |
30 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/module-home/src/main/res/layout/fragment_daily.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
17 |
18 |
22 |
23 |
35 |
36 |
37 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/module-home/src/main/res/layout/fragment_find.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
11 |
12 |
13 |
17 |
18 |
22 |
23 |
35 |
36 |
37 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/module-home/src/main/res/layout/fragment_recommend.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
15 |
16 |
20 |
21 |
33 |
34 |
35 |
38 |
39 |
--------------------------------------------------------------------------------
/module-home/src/main/res/layout/item_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
15 |
16 |
27 |
28 |
40 |
41 |
--------------------------------------------------------------------------------
/module-home/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/module-home/src/test/java/com/example/module_home/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_home
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 | }
--------------------------------------------------------------------------------
/module-login/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-login/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-login/consumer-rules.pro
--------------------------------------------------------------------------------
/module-login/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-login/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
--------------------------------------------------------------------------------
/module-login/src/androidTest/java/com/example/module_login/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_login
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.module_login.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-login/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/module-login/src/main/java/com/example/module_login/LoginActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_login
2 |
3 | import com.alibaba.android.arouter.facade.annotation.Route
4 | import com.example.base.network.base.activity.BaseMvvmActivity
5 | import com.example.base.network.route.RoutePath
6 | import com.example.module_login.databinding.ActivityLoginBinding
7 | import kotlinx.android.synthetic.main.activity_login.*
8 |
9 | @Route(path = RoutePath.Login.LOGIN_ACTIVITY)
10 | class LoginActivity : BaseMvvmActivity() {
11 |
12 | override fun setLayoutId(): Int = R.layout.activity_login
13 |
14 | override fun statusBarColor(): Int = R.color.black
15 |
16 | override fun isDarkFont(): Boolean = false
17 |
18 | override fun init() {
19 | ivClose.setOnClickListener { finish() }
20 | }
21 | }
--------------------------------------------------------------------------------
/module-login/src/main/java/com/example/module_login/LoginViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_login
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BaseViewModel
5 |
6 | /**
7 | * create by apple
8 | * create on 2020/8/9
9 | * description
10 | */
11 | class LoginViewModel(application: Application) : BaseViewModel(application) {
12 |
13 |
14 | }
--------------------------------------------------------------------------------
/module-login/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module-login/src/test/java/com/example/module_login/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_login
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 | }
--------------------------------------------------------------------------------
/module-notice/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-notice/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 | android {
7 | compileSdkVersion 29
8 | buildToolsVersion "30.0.0"
9 |
10 | defaultConfig {
11 | minSdkVersion 21
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | consumerProguardFiles "consumer-rules.pro"
18 |
19 | javaCompileOptions {
20 | annotationProcessorOptions {
21 | arguments = [moduleName: project.getName()]
22 | includeCompileClasspath true
23 | }
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | minifyEnabled false
30 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
31 | }
32 | }
33 |
34 | dataBinding {
35 | enabled = true
36 | }
37 | }
38 |
39 | dependencies {
40 | implementation fileTree(dir: "libs", include: ["*.jar"])
41 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
42 | implementation 'androidx.core:core-ktx:1.3.1'
43 | implementation 'androidx.appcompat:appcompat:1.1.0'
44 | implementation 'androidx.legacy:legacy-support-v4:1.0.0'
45 | testImplementation 'junit:junit:4.12'
46 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
47 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
48 |
49 | implementation 'com.libo:library-network:1.1.0'
50 |
51 | kapt 'com.alibaba:arouter-compiler:1.1.2'
52 | }
53 |
54 | apply plugin: 'maven'
55 | uploadArchives {
56 | repositories {
57 | mavenDeployer {
58 | repository(url: 'https://packages.aliyun.com/maven/repository/2088958-release-NjyZEe/') {
59 | authentication(
60 | userName: '605c8c634639bfa6ebf357c5',
61 | password: '0j)7TdpkQy6B'
62 | )
63 | }
64 | snapshotRepository(url: 'https://packages.aliyun.com/maven/repository/2088958-snapshot-Svd6Nt/') {
65 | authentication(
66 | userName: '605c8c634639bfa6ebf357c5',
67 | password: '0j)7TdpkQy6B'
68 | )
69 | }
70 | pom.version = '1.2.0'
71 | pom.artifactId = 'module-notice'
72 | pom.groupId = 'com.libo'
73 | }
74 | }
75 | }
--------------------------------------------------------------------------------
/module-notice/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-notice/consumer-rules.pro
--------------------------------------------------------------------------------
/module-notice/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-notice/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
--------------------------------------------------------------------------------
/module-notice/src/androidTest/java/com/example/module_notice/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.module_notice.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-notice/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/module-notice/src/main/java/com/example/module_notice/InteractionFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import com.alibaba.android.arouter.launcher.ARouter
7 | import com.example.base.network.base.fragment.BaseLazyloadFragment
8 | import com.example.base.network.route.RoutePath
9 | import kotlinx.android.synthetic.main.fragment_interaction.*
10 |
11 | class InteractionFragment : BaseLazyloadFragment() {
12 |
13 | override fun initView() {
14 | }
15 |
16 | override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
17 | return LayoutInflater.from(context).inflate(R.layout.fragment_interaction, container, false)
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/module-notice/src/main/java/com/example/module_notice/NoticeFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import androidx.fragment.app.Fragment
7 | import com.alibaba.android.arouter.facade.annotation.Route
8 | import com.example.base.network.base.fragment.BaseLazyloadFragment
9 | import com.example.base.network.route.RoutePath
10 | import com.example.base.network.widget.FmPagerAdapter
11 | import kotlinx.android.synthetic.main.fragment_notice.*
12 | import java.util.ArrayList
13 |
14 | @Route(path = RoutePath.Notification.NOTIFICATION_FRAGMENT)
15 | class NoticeFragment : BaseLazyloadFragment() {
16 | lateinit var pushFragment: PushFragment
17 | lateinit var interactionFragment: InteractionFragment
18 | lateinit var privateLetterFragment: InteractionFragment
19 | private val fragments = ArrayList()
20 |
21 | private val titleStr by lazy {
22 | arrayOf(getString(R.string.push), getString(R.string.interaction), getString(R.string.private_letter))
23 | }
24 |
25 | override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
26 | return LayoutInflater.from(context).inflate(R.layout.fragment_notice, container, false)
27 | }
28 |
29 | override fun initView() {
30 | setTabLayout()
31 | }
32 |
33 | /**
34 | * 设置tablayout子fragment
35 | */
36 | private fun setTabLayout() {
37 | for (i in titleStr.indices) {
38 | tablayout.addTab(tablayout.newTab().setText(titleStr[i]))
39 | }
40 | pushFragment = PushFragment()
41 | interactionFragment = InteractionFragment()
42 | privateLetterFragment = InteractionFragment()
43 |
44 | fragments.add(pushFragment)
45 | fragments.add(interactionFragment)
46 | fragments.add(privateLetterFragment)
47 |
48 | viewPager.adapter = FmPagerAdapter(childFragmentManager, fragments, titleStr)
49 | tablayout.setupWithViewPager(viewPager)
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/module-notice/src/main/java/com/example/module_notice/PushFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice
2 |
3 | import com.example.base.network.base.fragment.BaseMvvmFragment
4 | import com.example.module_notice.databinding.FragmentPushBinding
5 |
6 | class PushFragment : BaseMvvmFragment() {
7 |
8 | override fun initView() {
9 |
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/module-notice/src/main/java/com/example/module_notice/PushViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BasePageViewModel
5 | import com.example.base.network.bean.PushBean
6 | import com.example.module_notice.net.INoticeService
7 | import com.example.module_notice.response.PushResponse
8 | import com.example.network.interceptor.service.ApiCallBack
9 | import rx.android.schedulers.AndroidSchedulers
10 | import rx.schedulers.Schedulers
11 |
12 | /**
13 | * create by apple
14 | * create on 2020/8/23
15 | * description
16 | */
17 | class PushViewModel(application: Application) : BasePageViewModel(application) {
18 |
19 | init {
20 | refresh()
21 | }
22 |
23 | override fun requestData(page: Int) {
24 |
25 | INoticeService.instance.getPushData()
26 | .observeOn(AndroidSchedulers.mainThread())
27 | .subscribeOn(Schedulers.io())
28 | .subscribe(object: ApiCallBack() {
29 | override fun onSuccess(m: PushResponse) {
30 | handleItemData(page, m.messageList)
31 | }
32 |
33 | override fun onFail(msg: String) {
34 | handleFail()
35 | }
36 |
37 | })
38 |
39 | }
40 |
41 | override fun getItemLayoutId(): Int = R.layout.item_notice
42 |
43 | }
--------------------------------------------------------------------------------
/module-notice/src/main/java/com/example/module_notice/net/INoticeService.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice.net
2 |
3 | import com.example.module_notice.response.PushResponse
4 | import com.example.network.interceptor.service.Api
5 | import com.example.network.interceptor.service.ApiManager
6 | import retrofit2.http.GET
7 | import rx.Observable
8 |
9 | /**
10 | * create by apple
11 | * create on 2020/8/23
12 | * description
13 | */
14 | interface INoticeService {
15 |
16 | companion object {
17 | val instance = ApiManager.retrofit.create(INoticeService::class.java)
18 |
19 | fun invoke(): INoticeService {
20 | return instance
21 | }
22 | }
23 |
24 | /**
25 | * 推送
26 | */
27 | @GET(Api.PUSH)
28 | fun getPushData(): Observable
29 |
30 | }
--------------------------------------------------------------------------------
/module-notice/src/main/java/com/example/module_notice/response/PushResponse.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice.response
2 |
3 | import com.example.base.network.base.response.BaseResponse
4 | import com.example.base.network.bean.PushBean
5 |
6 | /**
7 | * create by apple
8 | * create on 2020/8/23
9 | * description
10 | */
11 | data class PushResponse(var messageList: ArrayList) : BaseResponse()
--------------------------------------------------------------------------------
/module-notice/src/main/res/layout/fragment_push.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/module-notice/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/module-notice/src/test/java/com/example/module_notice/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_notice
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 | }
--------------------------------------------------------------------------------
/module-play/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-play/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-play/consumer-rules.pro
--------------------------------------------------------------------------------
/module-play/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-play/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
--------------------------------------------------------------------------------
/module-play/src/androidTest/java/com/example/playactivity/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.playactivity.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-play/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/module/CommentFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.module
2 |
3 | import com.example.base.network.base.fragment.BaseMvvmFragment
4 | import com.example.playactivity.databinding.FragmentCommentBinding
5 |
6 |
7 | class CommentFragment : BaseMvvmFragment() {
8 |
9 | override fun initView() {
10 | viewModel.getComments(arguments!!.get("videoId") as Int)
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/module/CommentViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.module
2 |
3 | import android.app.Application
4 | import com.example.base.network.base.viewmodel.BasePageViewModel
5 | import com.example.base.network.config.ItemTypeConfig
6 | import com.example.network.interceptor.service.ApiCallBack
7 | import com.example.playactivity.BR
8 | import com.example.playactivity.R
9 | import com.example.playactivity.net.CommentResponse
10 | import com.example.playactivity.net.IPlayService
11 | import me.tatarka.bindingcollectionadapter2.ItemBinding
12 | import me.tatarka.bindingcollectionadapter2.OnItemBind
13 | import rx.android.schedulers.AndroidSchedulers
14 | import rx.schedulers.Schedulers
15 |
16 | /**
17 | * create by apple
18 | * create on 2020/8/12
19 | * description
20 | */
21 | class CommentViewModel(application: Application) : BasePageViewModel(application) {
22 |
23 | val onItemBind: OnItemBind = OnItemBind { itemBinding, position, item ->
24 | itemBinding.set(BR.item, getItemType(item))
25 | .bindExtra(BR.viewModel, this)
26 | }
27 |
28 | fun getItemType(item: CommentResponse.CommentData): Int {
29 | when(item.type) {
30 | ItemTypeConfig.ITEM_TYPE_COMMENT_TITLE ->
31 | return R.layout.item_comment_title
32 | ItemTypeConfig.ITEM_TYPE_COMMENT ->
33 | return R.layout.item_comment
34 | }
35 |
36 | return R.layout.item_comment_title
37 | }
38 |
39 | var multiItemBinding = ItemBinding.of(onItemBind)
40 |
41 | fun getComments(videoId: Int) {
42 | IPlayService.instance.getCommentList(videoId)
43 | .observeOn(AndroidSchedulers.mainThread())
44 | .subscribeOn(Schedulers.io())
45 | .subscribe(object: ApiCallBack() {
46 | override fun onSuccess(m: CommentResponse) {
47 | handleItemData(0, m.itemList)
48 | }
49 |
50 | override fun onFail(msg: String) {
51 | handleFail()
52 | }
53 |
54 | })
55 | }
56 |
57 | }
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/module/PlayDetailViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.module
2 |
3 | import android.app.Application
4 | import androidx.lifecycle.MutableLiveData
5 | import com.example.base.network.base.viewmodel.BaseViewModel
6 | import com.example.network.interceptor.service.ApiCallBack
7 | import com.example.playactivity.net.IPlayService
8 | import com.example.playactivity.net.PlayDetailResponse
9 | import rx.android.schedulers.AndroidSchedulers
10 | import rx.schedulers.Schedulers
11 |
12 | /**
13 | * create by apple
14 | * create on 2020/8/11
15 | * description
16 | */
17 | class PlayDetailViewModel(application: Application) : BaseViewModel(application) {
18 | var detailData = MutableLiveData()
19 |
20 | fun getPlayDetailData(videoId: Int) {
21 | IPlayService.instance.getPlayDetailData(videoId)
22 | .observeOn(AndroidSchedulers.mainThread())
23 | .subscribeOn(Schedulers.io())
24 | .subscribe(object: ApiCallBack() {
25 | override fun onSuccess(m: PlayDetailResponse) {
26 | detailData.value = m
27 | }
28 |
29 | override fun onFail(msg: String) {
30 | baseLiveData.loadFail.value = 1
31 | }
32 |
33 | })
34 | }
35 |
36 | }
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/module/RelateVideoFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.module
2 |
3 | import com.example.base.network.base.fragment.BaseMvvmFragment
4 | import com.example.playactivity.databinding.FragmentRelateVideoBinding
5 |
6 | class RelateVideoFragment : BaseMvvmFragment() {
7 |
8 | override fun initView() {
9 | viewModel.getRelateVideos(arguments!!.get("videoId") as Int)
10 | }
11 |
12 | }
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/net/CommentResponse.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.net
2 |
3 | import com.example.base.network.base.response.BaseResponse
4 |
5 | /**
6 | * create by apple
7 | * create on 2020/8/12
8 | * description
9 | */
10 | data class CommentResponse(var itemList: List) : BaseResponse() {
11 |
12 | data class CommentData(
13 | val adIndex: Int,
14 | val `data`: Data,
15 | val id: Int,
16 | val tag: Any,
17 | val type: String
18 | )
19 |
20 | data class Data(
21 | val actionUrl: Any,
22 | val cover: Any,
23 | val createTime: Long,
24 | val dataType: String,
25 | val hot: Boolean,
26 | val text: String,
27 | val id: Long,
28 | val imageUrl: String,
29 | val likeCount: Int,
30 | val liked: Boolean,
31 | val message: String,
32 | val parentReply: Any,
33 | val parentReplyId: Long,
34 | val replyStatus: String,
35 | val rootReplyId: Long,
36 | val sequence: Int,
37 | val showConversationButton: Boolean,
38 | val showParentReply: Boolean,
39 | val sid: String,
40 | val type: String,
41 | val ugcVideoId: Any,
42 | val ugcVideoUrl: Any,
43 | val user: User,
44 | val userBlocked: Boolean,
45 | val userType: Any,
46 | val videoId: Int,
47 | val videoTitle: String
48 | )
49 |
50 | data class User(
51 | val actionUrl: String,
52 | val area: Any,
53 | val avatar: String,
54 | val birthday: Any,
55 | val city: Any,
56 | val country: Any,
57 | val cover: Any,
58 | val description: Any,
59 | val expert: Boolean,
60 | val followed: Boolean,
61 | val gender: Any,
62 | val ifPgc: Boolean,
63 | val job: Any,
64 | val library: String,
65 | val limitVideoOpen: Boolean,
66 | val nickname: String,
67 | val registDate: Long,
68 | val releaseDate: Any,
69 | val uid: Int,
70 | val university: Any,
71 | val userType: String
72 | )
73 | }
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/net/IPlayService.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.net
2 |
3 | import com.example.network.interceptor.service.Api
4 | import com.example.network.interceptor.service.ApiManager
5 | import retrofit2.http.*
6 | import rx.Observable
7 |
8 | /**
9 | * create by apple
10 | * create on 2020/8/12
11 | * description
12 | */
13 | interface IPlayService {
14 |
15 | companion object {
16 | val instance = ApiManager.retrofit.create(IPlayService::class.java)
17 |
18 | fun invoke(): IPlayService {
19 | return instance
20 | }
21 | }
22 |
23 | /**
24 | * 视频播放详情页
25 | */
26 | @GET(Api.PLAY_DETAIL)
27 | fun getPlayDetailData(@Path("id") videoId: Int): Observable
28 |
29 | /**
30 | * 相关视频列表
31 | */
32 | @GET(Api.RELATE_VIDEO)
33 | fun getRelateVideos(@Query("id") videoId: Int): Observable
34 |
35 | /**
36 | * 评论列表
37 | */
38 | @GET(Api.COMMENT_LIST)
39 | fun getCommentList(@Query("videoId") videoId: Int): Observable
40 | }
--------------------------------------------------------------------------------
/module-play/src/main/java/com/example/playactivity/net/RelateVideoResponse.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity.net
2 |
3 | import com.example.base.network.base.response.BaseResponse
4 |
5 | /**
6 | * create by apple
7 | * create on 2020/8/12
8 | * description
9 | */
10 | data class RelateVideoResponse(var itemList: ArrayList) : BaseResponse() {
11 |
12 | data class RelateVideoItemBean(val type: String, val data: PlayDetailResponse)
13 | }
--------------------------------------------------------------------------------
/module-play/src/main/res/layout/fragment_comment.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
16 |
17 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/module-play/src/main/res/layout/fragment_relate_video.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
21 |
--------------------------------------------------------------------------------
/module-play/src/main/res/layout/item_comment_title.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
10 |
11 |
12 |
15 |
16 |
28 |
29 |
--------------------------------------------------------------------------------
/module-play/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/module-play/src/test/java/com/example/playactivity/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.playactivity
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 | }
--------------------------------------------------------------------------------
/module-user/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module-user/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/running-libo/Eyepetizer/445c9b666397381e33a75a4c2087e5d0f1d494f5/module-user/consumer-rules.pro
--------------------------------------------------------------------------------
/module-user/maven.properties:
--------------------------------------------------------------------------------
1 | MAVEN=false
2 | VERSION=1.2.0
--------------------------------------------------------------------------------
/module-user/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
--------------------------------------------------------------------------------
/module-user/src/androidTest/java/com/example/module_user/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_user
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext
22 | assertEquals("com.example.module_user.test", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/module-user/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 | /
5 |
--------------------------------------------------------------------------------
/module-user/src/main/java/com/example/module_user/MineFragment.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_user
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 | import com.alibaba.android.arouter.facade.annotation.Route
7 | import com.example.base.network.base.fragment.BaseLazyloadFragment
8 | import com.example.base.network.route.RoutePath
9 |
10 | @Route(path = RoutePath.Mine.MINE_FRAGMENT)
11 | class MineFragment : BaseLazyloadFragment() {
12 |
13 | override fun initView() {
14 |
15 | }
16 |
17 | override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
18 | return LayoutInflater.from(context).inflate(R.layout.fragment_mine, container, false)
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/module-user/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Hello blank fragment
4 |
--------------------------------------------------------------------------------
/module-user/src/test/java/com/example/module_user/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.module_user
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 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | includeCompat ':module-play'
2 | includeCompat ':module-notice'
3 | includeCompat ':module-community'
4 | includeCompat ':module-user'
5 | includeCompat ':module-login'
6 | includeCompat ':module-home'
7 | includeCompat ':module-entrance'
8 | includeCompat ':library-res'
9 | includeCompat ':library-network'
10 | includeCompat ':library-base'
11 | includeCompat ':app'
12 | rootProject.name = "MvvmFrame"
13 |
14 | def includeCompat(String name) {
15 | if (!isMaven(name)) {
16 | include(name)
17 | }
18 | }
19 |
20 | def isMaven(String name) {
21 | println("isMaven" + name)
22 | Properties properties = new Properties()
23 | def file = new File("${name.replace(":", "")}/maven.properties")
24 | if (file.exists()) {
25 | InputStream inputStream = file.newDataInputStream()
26 | properties.load(inputStream)
27 | def str = properties.getProperty('MAVEN')
28 | if (str == null) {
29 | return false
30 | } else {
31 | return Boolean.parseBoolean(str)
32 | }
33 | }
34 | return false
35 | }
--------------------------------------------------------------------------------