├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── compiler.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── jarRepositories.xml
├── markdown-navigator-enh.xml
├── misc.xml
├── runConfigurations.xml
└── vcs.xml
├── README-LIBRARY.md
├── README-UPDATE.md
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── library
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── library
│ │ │ ├── MainActivity.java
│ │ │ ├── filedownload
│ │ │ └── FileDownloadActivity.java
│ │ │ ├── glide
│ │ │ └── GlideUseActivity.java
│ │ │ ├── http
│ │ │ └── HttpSampleActivity.java
│ │ │ ├── lazyload
│ │ │ ├── LazyFragment.java
│ │ │ └── LazyLoadActivity.java
│ │ │ ├── list
│ │ │ ├── multiplechoice
│ │ │ │ ├── MultipleChoiceListActivity.java
│ │ │ │ └── MultipleChoiceListAdapter.java
│ │ │ ├── refreshload
│ │ │ │ ├── RefreshLoadListActivity.java
│ │ │ │ └── RefreshLoadListAdapter.java
│ │ │ └── singlechoice
│ │ │ │ ├── SingleChoiceListActivity.java
│ │ │ │ └── SingleChoiceListAdapter.java
│ │ │ ├── login
│ │ │ ├── LoginActivity.java
│ │ │ └── mvp
│ │ │ │ ├── LoginContract.java
│ │ │ │ ├── LoginModel.java
│ │ │ │ └── LoginPresenter.java
│ │ │ ├── mainpage
│ │ │ ├── MainPageActivity.java
│ │ │ └── fragment
│ │ │ │ ├── HomeFragment.java
│ │ │ │ ├── MineFragment.java
│ │ │ │ └── NewsFragment.java
│ │ │ ├── question
│ │ │ ├── AnswerAdapter.java
│ │ │ ├── QuestionActivity.java
│ │ │ ├── QuestionAdapter.java
│ │ │ └── QuestionBean.java
│ │ │ └── toolbar
│ │ │ └── CommonToolbarActivity.java
│ └── res
│ │ ├── drawable-xhdpi
│ │ ├── ic_home_select.png
│ │ ├── ic_home_unselect.png
│ │ ├── ic_list_item_select.png
│ │ ├── ic_list_item_unselect.png
│ │ ├── ic_mine_select.png
│ │ ├── ic_mine_unselect.png
│ │ ├── ic_news_select.png
│ │ └── ic_news_unselect.png
│ │ ├── drawable
│ │ ├── bg_circle_float_button.xml
│ │ ├── border_black_corner_10.xml
│ │ ├── item_answer_select.xml
│ │ ├── item_answer_unselect.xml
│ │ ├── select_home_icon.xml
│ │ ├── select_list_item.xml
│ │ ├── select_main_bottom_text_color.xml
│ │ ├── select_mine_icon.xml
│ │ ├── select_news_icon.xml
│ │ └── selected_item_answer.xml
│ │ ├── layout
│ │ ├── activity_common_toolbar.xml
│ │ ├── activity_file_download.xml
│ │ ├── activity_glide_use.xml
│ │ ├── activity_http_sample.xml
│ │ ├── activity_lazy_load.xml
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_main_page.xml
│ │ ├── activity_multiple_choice_list.xml
│ │ ├── activity_question.xml
│ │ ├── activity_refresh_load_list.xml
│ │ ├── activity_single_choice_list.xml
│ │ ├── fragment_lazy.xml
│ │ ├── fragment_main.xml
│ │ ├── include_main_bottom.xml
│ │ ├── item_question_answer.xml
│ │ ├── item_question_type_1.xml
│ │ ├── item_question_type_2.xml
│ │ ├── item_question_type_3.xml
│ │ ├── item_refresh_layout.xml
│ │ ├── item_single_choice.xml
│ │ ├── toolbar_my_left_view.xml
│ │ ├── toolbar_my_right_view.xml
│ │ └── toolbar_my_title_view.xml
│ │ └── values
│ │ └── strings.xml
│ └── test
│ └── java
│ └── com
│ └── library
│ └── ExampleUnitTest.java
├── basecommon
├── .gitignore
├── build.gradle
├── consumer-rules.pro
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── common
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── question.json
│ ├── java
│ │ └── com
│ │ │ └── common
│ │ │ ├── base
│ │ │ ├── BaseActivity.java
│ │ │ ├── BaseApplication.java
│ │ │ ├── BaseFragment.java
│ │ │ └── mvp
│ │ │ │ ├── BaseMvpActivity.java
│ │ │ │ ├── BaseMvpFragment.java
│ │ │ │ ├── BasePresenter.java
│ │ │ │ └── BaseView.java
│ │ │ ├── constants
│ │ │ ├── Constants.java
│ │ │ └── HttpConstants.java
│ │ │ ├── http
│ │ │ ├── XRetrofit.java
│ │ │ ├── api
│ │ │ │ └── ApiService.java
│ │ │ ├── base
│ │ │ │ ├── BaseObserver.java
│ │ │ │ ├── BaseResponse.java
│ │ │ │ └── RxJavaHelper.java
│ │ │ ├── bean
│ │ │ │ ├── ExampleBean.java
│ │ │ │ ├── ExampleFileBean.java
│ │ │ │ └── ExampleListBean.java
│ │ │ ├── helper
│ │ │ │ ├── CompressHelper.java
│ │ │ │ ├── Mobile.java
│ │ │ │ ├── RequestBodyHelper.java
│ │ │ │ └── upload
│ │ │ │ │ ├── OnUploadFileListener.java
│ │ │ │ │ └── UploadFileHelper.java
│ │ │ └── intercept
│ │ │ │ └── HttpIntercept.java
│ │ │ ├── library
│ │ │ └── bravh_rvadapter
│ │ │ │ ├── BaseItemDraggableAdapter.java
│ │ │ │ ├── BaseMultiItemRecyclerAdapter.java
│ │ │ │ ├── BaseRecyclerAdapter.java
│ │ │ │ ├── BaseSectionMultiItemRecyclerAdapter.java
│ │ │ │ ├── BaseSectionRecyclerAdapter.java
│ │ │ │ ├── MultipleItemRvAdapter.java
│ │ │ │ ├── RecyclerViewHolder.java
│ │ │ │ ├── animation
│ │ │ │ ├── AlphaInAnimation.java
│ │ │ │ ├── BaseAnimation.java
│ │ │ │ ├── ScaleInAnimation.java
│ │ │ │ ├── SlideInBottomAnimation.java
│ │ │ │ ├── SlideInLeftAnimation.java
│ │ │ │ └── SlideInRightAnimation.java
│ │ │ │ ├── callback
│ │ │ │ └── ItemDragAndSwipeCallback.java
│ │ │ │ ├── entity
│ │ │ │ ├── AbstractExpandableItem.java
│ │ │ │ ├── IExpandable.java
│ │ │ │ ├── MultiItemEntity.java
│ │ │ │ ├── SectionEntity.java
│ │ │ │ └── SectionMultiEntity.java
│ │ │ │ ├── listener
│ │ │ │ ├── OnItemDragListener.java
│ │ │ │ └── OnItemSwipeListener.java
│ │ │ │ ├── loadmore
│ │ │ │ ├── LoadMoreView.java
│ │ │ │ └── SimpleLoadMoreView.java
│ │ │ │ ├── provider
│ │ │ │ └── BaseItemProvider.java
│ │ │ │ └── util
│ │ │ │ ├── ItemProviderException.java
│ │ │ │ ├── MultiTypeDelegate.java
│ │ │ │ ├── ProviderDelegate.java
│ │ │ │ └── TouchEventUtil.java
│ │ │ ├── util
│ │ │ ├── BitmapUtil.java
│ │ │ ├── FileUtil.java
│ │ │ ├── GetPathFromUri.java
│ │ │ ├── ParamUtil.java
│ │ │ ├── SpUtil.java
│ │ │ ├── filedownload
│ │ │ │ ├── FileDownloadHelper.java
│ │ │ │ └── OnDownloadListener.java
│ │ │ └── glide
│ │ │ │ ├── GlideUtil.java
│ │ │ │ └── MyGlideModule.java
│ │ │ └── weight
│ │ │ ├── CommonRecyclerView.java
│ │ │ ├── CommonSmartRefreshLayout.java
│ │ │ ├── CommonToolbar.java
│ │ │ └── CommonViewPager.java
│ └── res
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable-xhdpi
│ │ ├── ic_back.png
│ │ ├── ic_placeholder.png
│ │ ├── ic_release.png
│ │ └── ic_title.png
│ │ ├── drawable
│ │ ├── bg_f5f5_corner_8.xml
│ │ └── ic_launcher_background.xml
│ │ ├── layout
│ │ ├── brvah_quick_view_load_more.xml
│ │ └── layout_toolbar.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
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── ids.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── common
│ └── ExampleUnitTest.java
├── build.gradle
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── 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/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | xmlns:android
17 |
18 | ^$
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | xmlns:.*
28 |
29 | ^$
30 |
31 |
32 | BY_NAME
33 |
34 |
35 |
36 |
37 |
38 |
39 | .*:id
40 |
41 | http://schemas.android.com/apk/res/android
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 | .*:name
51 |
52 | http://schemas.android.com/apk/res/android
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | name
62 |
63 | ^$
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | style
73 |
74 | ^$
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | .*
84 |
85 | ^$
86 |
87 |
88 | BY_NAME
89 |
90 |
91 |
92 |
93 |
94 |
95 | .*
96 |
97 | http://schemas.android.com/apk/res/android
98 |
99 |
100 | ANDROID_ATTRIBUTE_ORDER
101 |
102 |
103 |
104 |
105 |
106 |
107 | .*
108 |
109 | .*
110 |
111 |
112 | BY_NAME
113 |
114 |
115 |
116 |
117 |
118 |
119 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/.idea/markdown-navigator-enh.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/README-LIBRARY.md:
--------------------------------------------------------------------------------
1 | # 项目所用开源库
2 | + #### [屏幕适配 AutoSize](https://github.com/JessYanCoding/AndroidAutoSize)
3 |
4 | + #### [图片加载 Glide](https://github.com/bumptech/glide)
5 |
6 | + #### [RecyclerView 适配器 BaseRecyclerViewAdapterHelper](https://github.com/CymChad/BaseRecyclerViewAdapterHelper)
7 |
8 | + #### [事件通知 EventBus](https://github.com/greenrobot/EventBus)
9 |
10 | + #### [Android工具类 AndroidUtilCode](https://github.com/Blankj/AndroidUtilCode)
11 |
12 | + #### [网络请求 Retrofit2](https://github.com/square/retrofit)
13 |
14 | + #### [网络请求 OkHttp](https://github.com/square/okhttp)
15 |
16 | + #### [Json 数据解析](https://github.com/google/gson)
17 |
18 | + #### [列表刷新加载 SmartRefreshLayout](https://github.com/scwang90/SmartRefreshLayout)
19 |
20 | + #### [文件下载 FileDownloader](https://github.com/lingochamp/FileDownloader)
21 |
22 | + #### [线程异步处理 Rxjava RxAndroid](https://github.com/amitshekhariitbhu/RxJava2-Android-Samples)
23 |
24 |
--------------------------------------------------------------------------------
/README-UPDATE.md:
--------------------------------------------------------------------------------
1 | # 更新日志
2 |
3 | ## 2022/03/10
4 | + 新增答题页面(单选,多选,填空) [Java版本](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/question/QuestionActivity.java)
5 |
6 | ## 2020/11/19
7 | + 新增Mvp示例使用 [Kotlin版本](https://github.com/manitozhang/QuickAndroid/blob/kotlin/app/src/main/java/com/library/login/LoginActivity.kt) [Java版本](https://github.com/manitozhang/QuickAndroid/blob/java/app/src/main/java/com/library/login/LoginActivity.java)
8 | + 新增Kotlin版本 [点击查看](https://github.com/manitozhang/QuickAndroid/tree/kotlin)
9 |
10 | ## 2020/11/18
11 | + 优化README模板布局,方便预览项目介绍与功能
12 | + 新增列表刷新加载
13 | + 新增列表单选示例
14 | + 新增列表多选,反选示例
15 |
16 | ## 2020/11/17
17 | + 新增文件下载示例
18 | + 新增CommonToolbar属性,字体大小,图片宽高
19 | + 新增CommonToolbar功能.issus提交的需求 [Toobar把Title标题改为图文一起的](https://github.com/manitozhang/QuickAndroid/issues/2) 可以自己将标题改为自定义布局: [使用示例](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/toolbar/CommonToolbarActivity.java)
20 |
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # QuickAndroid Android快速开发框(持续更新中)
2 |
3 | ## [更新日志](https://github.com/manitozhang/QuickAndroid/blob/master/README-UPDATE.md)
4 |
5 | ## [Java版本](https://github.com/manitozhang/QuickAndroid/tree/java) [Kotlin版本](https://github.com/manitozhang/QuickAndroid/tree/kotlin)
6 |
7 | ## [项目用到的开源库以及地址](https://github.com/manitozhang/QuickAndroid/blob/master/README-LIBRARY.md)
8 |
9 | ## 各位小伙伴如果想到有什么常用到的可以联系我添加
10 | 1. 可以提交issus
11 | 2. 加我联系方式: 1271396448 (QQ,Vx 同步)
12 |
13 | ## 项目介绍
14 | + 针对用于一些外包或者其他快速开发的app,项目中包含了一些常用的框架,还有集成一些常用的第三方库以及使用,以及常用的组合控件(标题栏,按钮,菜单条目...),每个第三方使用方法和项目的架构均可直接复制到项目中使用,没有很多关联,继承实现之类,基本上每个东西单独封装,可直接引入basecommon包使用,也可按需cv
15 | ---
16 | ## 项目中所包含的功能
17 | + 安卓快速开发框架
18 | + 网络请求全示例
19 | + 常用第三方库合集
20 | + 常用的一些组件封装
21 | + 常用第三方组件的继承处理属性
22 | ---
23 | ## 快速引导
24 |
25 | | [首页框架-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/mainpage/MainPageActivity.java) | [网络请求示例-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/http/HttpSampleActivity.java) | [Fragment懒加载-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/lazyload/LazyFragment.java) | [公共标题栏-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/toolbar/CommonToolbarActivity.java) |
26 | | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: | :----------------------------------------------------------: |
27 | |
|
|
|
|
28 | | [文件下载安装-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/filedownload/FileDownloadActivity.java) | [列表刷新加载-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/list/refreshload/RefreshLoadListActivity.java) | [列表单选-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/list/singlechoice/SingleChoiceListActivity.java) | [列表多选-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/list/multiplechoice/MultipleChoiceListActivity.java) |
29 | |
|
|
|
|
30 | | [Glide图片加载-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/glide/GlideUseActivity.java) | [答题页面列表-使用](https://github.com/manitozhang/QuickAndroid/blob/master/app/src/main/java/com/library/question/QuestionActivity.java) | | |
31 | |
|
| | |
32 |
33 |
34 |
35 | ------
36 |
37 |
38 |
39 | ## 免责声明
40 |
41 | + 项目旨在为更多的Android初学者与开发者提供便利,项目内使用到一些第三方开源库,如有违规或侵权,请联系删除
42 | + 项目使用的大部分开源库均可商用,不排除没有看到的或作者刚声明的,如出现法律纠纷与本人无关
43 | + 项目本着互相交流学习的目的,禁止用于非法用途,如出现法律纠纷与本人无关
44 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.android.compileSdkVersion
5 | buildToolsVersion rootProject.ext.android.buildToolsVersion
6 | defaultConfig {
7 | applicationId rootProject.ext.android.applicationId
8 | minSdkVersion rootProject.ext.android.minSdkVersion
9 | targetSdkVersion rootProject.ext.android.targetSdkVersion
10 | versionCode rootProject.ext.android.versionCode
11 | versionName rootProject.ext.android.versionName
12 |
13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | compileOptions {
23 | sourceCompatibility JavaVersion.VERSION_1_8
24 | targetCompatibility JavaVersion.VERSION_1_8
25 | }
26 |
27 | }
28 |
29 | dependencies {
30 | implementation fileTree(dir: 'libs', include: ['*.jar'])
31 | implementation project(path: ':basecommon')
32 | implementation 'androidx.appcompat:appcompat:1.2.0'
33 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
34 | }
35 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/library/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.library;
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 |
25 | assertEquals("com.library", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.library;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.common.base.BaseActivity;
10 | import com.library.filedownload.FileDownloadActivity;
11 | import com.library.glide.GlideUseActivity;
12 | import com.library.http.HttpSampleActivity;
13 | import com.library.lazyload.LazyLoadActivity;
14 | import com.library.list.multiplechoice.MultipleChoiceListActivity;
15 | import com.library.list.refreshload.RefreshLoadListActivity;
16 | import com.library.list.singlechoice.SingleChoiceListActivity;
17 | import com.library.login.LoginActivity;
18 | import com.library.mainpage.MainPageActivity;
19 | import com.library.question.QuestionActivity;
20 | import com.library.toolbar.CommonToolbarActivity;
21 |
22 | public class MainActivity extends BaseActivity {
23 |
24 | @Override
25 | public int getLayout() {
26 | return R.layout.activity_main;
27 | }
28 |
29 | @Override
30 | public void initViewIds() {
31 | }
32 |
33 | @Override
34 | public void initView() {
35 |
36 | }
37 |
38 | @Override
39 | public void initData(@Nullable Bundle savedInstanceState) {
40 |
41 | }
42 |
43 | /**
44 | * 首页框架
45 | * @param view
46 | */
47 | public void btnMainPage(View view){
48 | startActivity(new Intent(this, MainPageActivity.class));
49 | }
50 |
51 | /**
52 | * 网络请求相关
53 | *
54 | * @param view
55 | */
56 | public void btnHttp(View view) {
57 | startActivity(new Intent(this, HttpSampleActivity.class));
58 | }
59 |
60 | /**
61 | * 懒加载
62 | * @param view
63 | */
64 | public void btnLazyLoad(View view) {
65 | startActivity(new Intent(this, LazyLoadActivity.class));
66 | }
67 |
68 | /**
69 | * 封装的标题栏
70 | * @param view
71 | */
72 | public void btnCommonToolbar(View view) {
73 | startActivity(new Intent(this, CommonToolbarActivity.class));
74 | }
75 |
76 | /**
77 | * Glide操作
78 | * @param view
79 | */
80 | public void btnGlideClip(View view) {
81 | startActivity(new Intent(this, GlideUseActivity.class));
82 | }
83 |
84 | /**
85 | * 文件下载
86 | * @param view
87 | */
88 | public void btnDownload(View view) {
89 | startActivity(new Intent(this, FileDownloadActivity.class));
90 | }
91 |
92 | /**
93 | * 列表刷新加载
94 | * @param view
95 | */
96 | public void btnListRefresh(View view) {
97 | startActivity(new Intent(this , RefreshLoadListActivity.class));
98 | }
99 |
100 | /**
101 | * 列表单选
102 | * @param view
103 | */
104 | public void btnListSingleChoice(View view) {
105 | startActivity(new Intent(this , SingleChoiceListActivity.class));
106 | }
107 |
108 | /**
109 | * 列表多选
110 | * @param view
111 | */
112 | public void btnListMultipleChoice(View view) {
113 | startActivity(new Intent(this , MultipleChoiceListActivity.class));
114 | }
115 |
116 | /**
117 | * Mvp示例
118 | * @param view
119 | */
120 | public void btnMvp(View view) {
121 | startActivity(new Intent(this , LoginActivity.class));
122 | }
123 |
124 | /**
125 | * 答题页面
126 | * @param view
127 | */
128 | public void btnQuestion(View view) {
129 | startActivity(new Intent(this , QuestionActivity.class));
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/filedownload/FileDownloadActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.filedownload;
2 |
3 | import androidx.annotation.Nullable;
4 |
5 | import android.os.Bundle;
6 | import android.view.View;
7 | import android.widget.ProgressBar;
8 | import android.widget.TextView;
9 |
10 | import com.blankj.utilcode.util.AppUtils;
11 | import com.blankj.utilcode.util.ToastUtils;
12 | import com.common.base.BaseActivity;
13 | import com.common.util.BitmapUtil;
14 | import com.common.util.filedownload.FileDownloadHelper;
15 | import com.common.util.filedownload.OnDownloadListener;
16 | import com.library.R;
17 |
18 | /**
19 | * 文件下载页面
20 | */
21 | public class FileDownloadActivity extends BaseActivity {
22 |
23 | private static final String fileUrl = "https://library-collection.oss-cn-beijing.aliyuncs.com/file/file.apk";
24 | private int ids;
25 | private ProgressBar progressBar;
26 | private TextView tvProgress;
27 | private TextView tvSpeed;
28 | private FileDownloadHelper fileDownloadHelper;
29 |
30 | @Override
31 | public int getLayout() {
32 | return R.layout.activity_file_download;
33 | }
34 |
35 | @Override
36 | public void initViewIds() {
37 | progressBar = findViewById(R.id.progress_bar);
38 | tvProgress = findViewById(R.id.tv_progress);
39 | tvSpeed = findViewById(R.id.tv_speed);
40 | }
41 |
42 | @Override
43 | public void initView() {
44 |
45 | }
46 |
47 | @Override
48 | public void initData(@Nullable Bundle savedInstanceState) {
49 |
50 | }
51 |
52 | /**
53 | * 开始下载
54 | *
55 | * @param view
56 | */
57 | public void btnStart(View view) {
58 | startDownload();
59 | }
60 |
61 | /**
62 | * 开始下载
63 | */
64 | private void startDownload(){
65 | fileDownloadHelper = new FileDownloadHelper();
66 | fileDownloadHelper.downloadFile(fileUrl, BitmapUtil.getFileStoragePath(), false, new OnDownloadListener() {
67 |
68 | @Override
69 | public void onPending(int id, int soFarBytes, int totalBytes) {
70 | }
71 |
72 | @Override
73 | public void onProgress(int id, int speed, int soFarBytes, int totalBytes) {
74 | tvProgress.setText(soFarBytes + " / " + totalBytes);
75 | tvSpeed.setText(speed + " KB/s");
76 | progressBar.setMax(totalBytes);
77 | progressBar.setProgress(soFarBytes);
78 | }
79 |
80 | @Override
81 | public void onComplete(String path) {
82 | ToastUtils.showShort("下载完成");
83 | //安装App
84 | AppUtils.installApp(path);
85 | }
86 |
87 | @Override
88 | public void onError(Throwable e) {
89 | ToastUtils.showShort("下载异常" + e.getMessage());
90 | }
91 | });
92 | }
93 |
94 | /**
95 | * 暂停下载
96 | *
97 | * @param view
98 | */
99 | public void btnPause(View view) {
100 | fileDownloadHelper.pause();
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/glide/GlideUseActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.glide;
2 |
3 | import androidx.annotation.Nullable;
4 | import androidx.appcompat.app.AppCompatActivity;
5 |
6 | import android.os.Bundle;
7 | import android.view.View;
8 | import android.widget.ImageView;
9 |
10 | import com.common.base.BaseActivity;
11 | import com.common.util.glide.GlideUtil;
12 | import com.library.R;
13 |
14 | /**
15 | * Glide 使用
16 | */
17 | public class GlideUseActivity extends BaseActivity {
18 |
19 | private static final String imgUrl = "https://library-collection.oss-cn-beijing.aliyuncs.com/img/glideuse.png";
20 |
21 | private ImageView ivDefault;
22 | private ImageView ivCircle;
23 | private ImageView ivCorner;
24 |
25 | @Override
26 | public int getLayout() {
27 | return R.layout.activity_glide_use;
28 | }
29 |
30 | @Override
31 | public void initViewIds() {
32 | ivDefault = findViewById(R.id.iv_default);
33 | ivCircle = findViewById(R.id.iv_circle);
34 | ivCorner = findViewById(R.id.iv_corner);
35 | }
36 |
37 | @Override
38 | public void initView() {
39 | GlideUtil.loadImage(imgUrl, ivDefault, getResources().getDrawable(R.drawable.ic_placeholder));
40 | GlideUtil.loadCircleImage(imgUrl, ivCircle, getResources().getDrawable(R.drawable.ic_placeholder));
41 | GlideUtil.loadCornerImage(imgUrl, ivCorner, 20, getResources().getDrawable(R.drawable.ic_placeholder));
42 | }
43 |
44 | @Override
45 | public void initData(@Nullable Bundle savedInstanceState) {
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/lazyload/LazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.library.lazyload;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.common.base.BaseFragment;
8 | import com.library.R;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | * @Date: 2020/11/13
14 | *
15 | * @Desc:
16 | */
17 | public class LazyFragment extends BaseFragment {
18 |
19 | private TextView tvTabName;
20 | private String bundleTabName = "";
21 |
22 | @Override
23 | public int getLayout() {
24 | return R.layout.fragment_lazy;
25 | }
26 |
27 | @Override
28 | public void initViewIds(View view) {
29 | tvTabName = view.findViewById(R.id.tv_tab_name);
30 | }
31 |
32 | @Override
33 | public void initArguments() {
34 | if (getArguments() != null)
35 | bundleTabName = getArguments().getString("bundle_tab");
36 | super.initArguments();
37 | }
38 |
39 | @Override
40 | public void initView(View view) {
41 |
42 | }
43 |
44 | /**
45 | * 在initData方法写需要懒加载的业务代码即可
46 | * @param savedInstanceState
47 | */
48 | @Override
49 | public void initData(Bundle savedInstanceState) {
50 | tvTabName.setText(bundleTabName);
51 | }
52 |
53 | /**
54 | * 使用懒加载 必须实现 需要配合viewpager.setOffscreenPageLimit()方法,有多少个就写几
55 | *
56 | * @return
57 | */
58 | @Override
59 | public boolean useLazyFragment() {
60 | return true;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/lazyload/LazyLoadActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.lazyload;
2 |
3 | import androidx.annotation.NonNull;
4 | import androidx.annotation.Nullable;
5 | import androidx.appcompat.app.AppCompatActivity;
6 | import androidx.fragment.app.Fragment;
7 | import androidx.fragment.app.FragmentManager;
8 | import androidx.fragment.app.FragmentPagerAdapter;
9 |
10 | import android.os.Bundle;
11 | import android.view.View;
12 |
13 | import com.common.base.BaseActivity;
14 | import com.common.weight.CommonViewPager;
15 | import com.google.android.material.tabs.TabLayout;
16 | import com.library.R;
17 |
18 | import static androidx.fragment.app.FragmentStatePagerAdapter.BEHAVIOR_SET_USER_VISIBLE_HINT;
19 |
20 | /**
21 | * 懒加载的Activity
22 | */
23 | public class LazyLoadActivity extends BaseActivity {
24 |
25 |
26 | private String[] tabArray = new String[]{"推荐", "关注", "娱乐", "国内", "军事", "财经"};
27 | private TabLayout tabLayout;
28 | private CommonViewPager viewPager;
29 |
30 | @Override
31 | public int getLayout() {
32 | return R.layout.activity_lazy_load;
33 | }
34 |
35 | @Override
36 | public void initViewIds() {
37 | tabLayout = findViewById(R.id.tab_layout);
38 | viewPager = findViewById(R.id.view_pager);
39 | }
40 |
41 | @Override
42 | public void initView() {
43 | tabLayout.setupWithViewPager(viewPager);
44 | viewPager.setOffscreenPageLimit(tabArray.length);
45 | viewPager.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));
46 | }
47 |
48 | @Override
49 | public void initData(@Nullable Bundle savedInstanceState) {
50 |
51 | }
52 |
53 | class MyPagerAdapter extends FragmentPagerAdapter {
54 | public MyPagerAdapter(@NonNull FragmentManager fm) {
55 | super(fm);
56 | }
57 |
58 | @Nullable
59 | @Override
60 | public CharSequence getPageTitle(int position) {
61 | return tabArray[position];
62 | }
63 |
64 | @NonNull
65 | @Override
66 | public Fragment getItem(int position) {
67 | //传递数据
68 | LazyFragment lazyFragment = new LazyFragment();
69 | Bundle bundle = new Bundle();
70 | bundle.putString("bundle_tab", tabArray[position]);
71 | lazyFragment.setArguments(bundle);
72 | return lazyFragment;
73 | }
74 |
75 | @Override
76 | public int getCount() {
77 | return tabArray.length;
78 | }
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/list/multiplechoice/MultipleChoiceListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.library.list.multiplechoice;
2 |
3 | import android.widget.ImageView;
4 | import android.widget.TextView;
5 |
6 | import androidx.annotation.Nullable;
7 |
8 | import com.common.http.bean.ExampleListBean;
9 | import com.common.library.bravh_rvadapter.BaseRecyclerAdapter;
10 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
11 | import com.library.R;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * @Author: 张鹏飞
17 | * @Email: 1271396448@qq.com
18 | * @Date: 2020/11/18
19 | *
20 | * @Desc: 多选列表适配器
21 | */
22 | public class MultipleChoiceListAdapter extends BaseRecyclerAdapter {
23 |
24 | public MultipleChoiceListAdapter(@Nullable List data) {
25 | super(R.layout.item_single_choice, data);
26 | }
27 |
28 | @Override
29 | protected void convert(RecyclerViewHolder holder, ExampleListBean item) {
30 | //注册子View的点击事件,必须,否则在Act点击事件不生效
31 | holder.addOnClickListener(R.id.iv_select);
32 | ImageView ivSelect = holder.getImageView(R.id.iv_select);
33 | //因为在布局中定义了一个选中与非选中的drawable,select_list_item.xml
34 | //如果实体类里面的标识符为选中状态,就给他选中
35 | ivSelect.setSelected(item.isChecked());
36 | TextView tvTitle = holder.getTextView(R.id.tv_title);
37 | TextView tvContent = holder.getTextView(R.id.tv_content);
38 | TextView tvTime = holder.getTextView(R.id.tv_time);
39 | tvTitle.setText(item.getTitle());
40 | tvContent.setText(item.getContent());
41 | tvTime.setText(item.getTime());
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/list/refreshload/RefreshLoadListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.library.list.refreshload;
2 |
3 | import android.view.View;
4 | import android.widget.Button;
5 | import android.widget.TextView;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.common.http.bean.ExampleListBean;
10 | import com.common.library.bravh_rvadapter.BaseRecyclerAdapter;
11 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
12 | import com.library.R;
13 |
14 | import java.util.List;
15 |
16 | /**
17 | * @Author: 张鹏飞
18 | * @Email: 1271396448@qq.com
19 | * @Date: 2020/11/18
20 | *
21 | * @Desc:
22 | */
23 | public class RefreshLoadListAdapter extends BaseRecyclerAdapter {
24 | public RefreshLoadListAdapter(@Nullable List data) {
25 | super(R.layout.item_refresh_layout, data);
26 | }
27 |
28 | @Override
29 | protected void convert(RecyclerViewHolder holder, ExampleListBean item) {
30 | //注册子View的点击事件,必须,否则在Act点击事件不生效
31 | holder.addOnClickListener(R.id.btn_click_me);
32 | TextView tvTitle = holder.getTextView(R.id.tv_title);
33 | TextView tvContent = holder.getTextView(R.id.tv_content);
34 | TextView tvTime = holder.getTextView(R.id.tv_time);
35 | tvTitle.setText(item.getTitle());
36 | tvContent.setText(item.getContent());
37 | tvTime.setText(item.getTime());
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/list/singlechoice/SingleChoiceListActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.list.singlechoice;
2 |
3 | import androidx.annotation.Nullable;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import androidx.recyclerview.widget.LinearLayoutManager;
6 |
7 | import android.os.Bundle;
8 | import android.view.View;
9 |
10 | import com.blankj.utilcode.util.ToastUtils;
11 | import com.common.base.BaseActivity;
12 | import com.common.http.XRetrofit;
13 | import com.common.http.base.BaseObserver;
14 | import com.common.http.base.RxJavaHelper;
15 | import com.common.http.bean.ExampleListBean;
16 | import com.common.http.helper.Mobile;
17 | import com.common.library.bravh_rvadapter.BaseRecyclerAdapter;
18 | import com.common.weight.CommonRecyclerView;
19 | import com.library.R;
20 | import com.library.list.refreshload.RefreshLoadListAdapter;
21 |
22 | import java.util.Collections;
23 | import java.util.List;
24 |
25 | /**
26 | * 单选列表Activity
27 | */
28 | public class SingleChoiceListActivity extends BaseActivity {
29 |
30 | private CommonRecyclerView rvSingleChoice;
31 | private SingleChoiceListAdapter singleChoiceListAdapter;
32 | private final int page = 1;
33 | private final int pageNum = 20;
34 |
35 | @Override
36 | public int getLayout() {
37 | return R.layout.activity_single_choice_list;
38 | }
39 |
40 | @Override
41 | public void initViewIds() {
42 | rvSingleChoice = findViewById(R.id.rv_single_choice);
43 | }
44 |
45 | @Override
46 | public void initView() {
47 | initSingleChoiceRecycler();
48 | }
49 |
50 | private void initSingleChoiceRecycler() {
51 | LinearLayoutManager layoutManager = new LinearLayoutManager(this);
52 | rvSingleChoice.setLayoutManager(layoutManager);
53 | singleChoiceListAdapter = new SingleChoiceListAdapter(Collections.emptyList());
54 | rvSingleChoice.setAdapter(singleChoiceListAdapter);
55 | }
56 |
57 | @Override
58 | public void initData(@Nullable Bundle savedInstanceState) {
59 | getList(page, pageNum);
60 | }
61 |
62 | @Override
63 | public void initListener() {
64 | super.initListener();
65 | singleChoiceListAdapter.setOnItemChildClickListener((adapter, view, position) -> {
66 | if (view.getId() == R.id.iv_select) {
67 | //点击按钮,将当前点击的下标传进去,刷新适配器
68 | singleChoiceListAdapter.setSelPos(position);
69 | singleChoiceListAdapter.notifyDataSetChanged();
70 | }
71 | });
72 | }
73 |
74 | /**
75 | * 获取集合
76 | *
77 | * @param page: 页数
78 | * @param pageNum: 条目数
79 | */
80 | private void getList(int page, int pageNum) {
81 | XRetrofit.getApi()
82 | .getList(Mobile.getList(page, pageNum))
83 | .compose(RxJavaHelper.observeOnMainThread())
84 | .subscribe(new BaseObserver>() {
85 | @Override
86 | public void onSuccess(List response) {
87 | if (response == null)
88 | return;
89 | singleChoiceListAdapter.setNewData(response);
90 | }
91 | });
92 | }
93 |
94 | /**
95 | * 获取选中的下标
96 | *
97 | * @param view
98 | */
99 | public void btnGetSingleData(View view) {
100 | if (singleChoiceListAdapter.getSelPos() == -1) {
101 | ToastUtils.showShort("你还未选中数据");
102 | return;
103 | }
104 | ToastUtils.showShort("选中的标题是---"
105 | + singleChoiceListAdapter.getData()
106 | .get(singleChoiceListAdapter.getSelPos()).getTitle());
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/list/singlechoice/SingleChoiceListAdapter.java:
--------------------------------------------------------------------------------
1 | package com.library.list.singlechoice;
2 |
3 | import android.widget.ImageView;
4 | import android.widget.TextView;
5 |
6 | import androidx.annotation.Nullable;
7 |
8 | import com.common.http.bean.ExampleListBean;
9 | import com.common.library.bravh_rvadapter.BaseRecyclerAdapter;
10 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
11 | import com.library.R;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * @Author: 张鹏飞
17 | * @Email: 1271396448@qq.com
18 | * @Date: 2020/11/18
19 | *
20 | * @Desc:
21 | */
22 | public class SingleChoiceListAdapter extends BaseRecyclerAdapter {
23 | /**
24 | * 定义选中的下标, 默认-1
25 | */
26 | private int selPos = -1;
27 |
28 | public void setSelPos(int selPos) {
29 | this.selPos = selPos;
30 | }
31 |
32 | public int getSelPos() {
33 | return selPos;
34 | }
35 |
36 | public SingleChoiceListAdapter(@Nullable List data) {
37 | super(R.layout.item_single_choice, data);
38 | }
39 |
40 | @Override
41 | protected void convert(RecyclerViewHolder holder, ExampleListBean item) {
42 | //注册子View的点击事件,必须,否则在Act点击事件不生效
43 | holder.addOnClickListener(R.id.iv_select);
44 | ImageView ivSelect = holder.getImageView(R.id.iv_select);
45 | //因为在布局中定义了一个选中与非选中的drawable,select_list_item.xml
46 | //如果传进来的选中下标等于当前下标,就给设置选中状态
47 | ivSelect.setSelected(selPos == holder.getAdapterPosition());
48 | TextView tvTitle = holder.getTextView(R.id.tv_title);
49 | TextView tvContent = holder.getTextView(R.id.tv_content);
50 | TextView tvTime = holder.getTextView(R.id.tv_time);
51 | tvTitle.setText(item.getTitle());
52 | tvContent.setText(item.getContent());
53 | tvTime.setText(item.getTime());
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/login/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.login;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.EditText;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.blankj.utilcode.util.ToastUtils;
10 | import com.common.base.mvp.BaseMvpActivity;
11 | import com.common.http.bean.ExampleBean;
12 | import com.common.http.helper.Mobile;
13 | import com.common.util.ParamUtil;
14 | import com.library.R;
15 | import com.library.login.mvp.LoginContract;
16 | import com.library.login.mvp.LoginPresenter;
17 |
18 | public class LoginActivity extends BaseMvpActivity implements LoginContract.View {
19 |
20 |
21 | private EditText etPassword;
22 | private EditText etUsername;
23 |
24 | @Override
25 | public int getLayout() {
26 | return R.layout.activity_login;
27 | }
28 |
29 | @Override
30 | public void initViewIds() {
31 | etUsername = findViewById(R.id.et_username);
32 | etPassword = findViewById(R.id.et_password);
33 | }
34 |
35 | @Override
36 | public void initView() {
37 | mPresenter = new LoginPresenter();
38 | mPresenter.attachView(this);
39 | }
40 |
41 | @Override
42 | public void initData(@Nullable Bundle savedInstanceState) {
43 |
44 | }
45 |
46 | @Override
47 | public void loginSuccess(ExampleBean bean) {
48 | //登录请求成功
49 | ToastUtils.showShort("登录成功");
50 | }
51 |
52 | public void btnLogin(View view) {
53 | mPresenter.login(Mobile.userLogin(ParamUtil.getEditStr(etUsername), ParamUtil.getEditStr(etPassword)));
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/login/mvp/LoginContract.java:
--------------------------------------------------------------------------------
1 | package com.library.login.mvp;
2 |
3 | import com.common.base.mvp.BaseView;
4 | import com.common.http.base.BaseResponse;
5 | import com.common.http.bean.ExampleBean;
6 |
7 | import java.util.HashMap;
8 |
9 | import io.reactivex.Observable;
10 |
11 | /**
12 | * @Author: 张鹏飞
13 | * @Email: 1271396448@qq.com
14 | *
15 | * @Desc:
16 | */
17 |
18 | public interface LoginContract {
19 |
20 | interface Model {
21 | Observable> login(HashMap map);
22 | }
23 |
24 | interface View extends BaseView {
25 | void loginSuccess(ExampleBean bean);
26 | }
27 |
28 | interface Presenter {
29 | void login(HashMap map);
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/library/login/mvp/LoginModel.java:
--------------------------------------------------------------------------------
1 | package com.library.login.mvp;
2 |
3 |
4 | import com.common.http.XRetrofit;
5 | import com.common.http.base.BaseResponse;
6 | import com.common.http.bean.ExampleBean;
7 | import com.common.http.helper.RequestBodyHelper;
8 |
9 | import java.util.HashMap;
10 |
11 | import io.reactivex.Observable;
12 |
13 | /**
14 | * @Author: 张鹏飞
15 | * @Email: 1271396448@qq.com
16 | *
17 | * @Desc:
18 | */
19 |
20 | public class LoginModel implements LoginContract.Model {
21 |
22 | @Override
23 | public Observable> login(HashMap map) {
24 | return XRetrofit.getApi().testLogin(RequestBodyHelper.getRequestBody(map));
25 | }
26 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/library/login/mvp/LoginPresenter.java:
--------------------------------------------------------------------------------
1 | package com.library.login.mvp;
2 |
3 | import com.common.base.mvp.BasePresenter;
4 | import com.common.http.base.BaseObserver;
5 | import com.common.http.base.RxJavaHelper;
6 | import com.common.http.bean.ExampleBean;
7 |
8 | import java.util.HashMap;
9 |
10 |
11 | /**
12 | * @Author: 张鹏飞
13 | * @Email: 1271396448@qq.com
14 | *
15 | * @Desc:
16 | */
17 |
18 | public class LoginPresenter extends BasePresenter implements LoginContract.Presenter{
19 |
20 |
21 | private LoginModel model;
22 |
23 | public LoginPresenter() {
24 | model = new LoginModel();
25 | }
26 |
27 | @Override
28 | public void login(HashMap map) {
29 | model.login(map)
30 | .compose(RxJavaHelper.observeOnMainThread())
31 | .subscribe(new BaseObserver() {
32 | @Override
33 | public void onSuccess(ExampleBean response) {
34 | mView.loginSuccess(response);
35 | }
36 | });
37 | }
38 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/library/mainpage/MainPageActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.mainpage;
2 |
3 | import androidx.annotation.Nullable;
4 | import androidx.fragment.app.FragmentManager;
5 | import androidx.fragment.app.FragmentTransaction;
6 |
7 | import android.os.Bundle;
8 | import android.widget.TextView;
9 |
10 | import com.common.base.BaseActivity;
11 | import com.library.R;
12 | import com.library.mainpage.fragment.HomeFragment;
13 | import com.library.mainpage.fragment.MineFragment;
14 | import com.library.mainpage.fragment.NewsFragment;
15 |
16 | /**
17 | * 首页页面
18 | */
19 | public class MainPageActivity extends BaseActivity {
20 |
21 | private int[] idArrays = new int[]{R.id.tv_home, R.id.tv_news, R.id.tv_mine};
22 |
23 | private FragmentTransaction beginTransaction;
24 | private HomeFragment homeFragment;
25 | private NewsFragment newsFragment;
26 | private MineFragment mineFragment;
27 | private TextView tvHome;
28 | private TextView tvNews;
29 | private TextView tvMine;
30 |
31 | @Override
32 | public int getLayout() {
33 | return R.layout.activity_main_page;
34 | }
35 |
36 | @Override
37 | public void initViewIds() {
38 | tvHome = findViewById(R.id.tv_home);
39 | tvNews = findViewById(R.id.tv_news);
40 | tvMine = findViewById(R.id.tv_mine);
41 | }
42 |
43 | @Override
44 | public void initView() {
45 | setFragment(0);
46 | }
47 |
48 | @Override
49 | public void initData(@Nullable Bundle savedInstanceState) {
50 | }
51 |
52 | @Override
53 | public void initListener() {
54 | super.initListener();
55 | tvHome.setOnClickListener(v -> {
56 | setFragment(0);
57 | });
58 | tvNews.setOnClickListener(v -> {
59 | setFragment(1);
60 | });
61 | tvMine.setOnClickListener(v -> {
62 | setFragment(2);
63 | });
64 | }
65 |
66 | /**
67 | * 设置Fragment
68 | * 其他地方可发送通知来执行该方法改变tab选中
69 | * @param index: 下标
70 | */
71 | private void setFragment(int index) {
72 | FragmentManager fragmentManager = getSupportFragmentManager();
73 | beginTransaction = fragmentManager.beginTransaction();
74 | hideFragment();
75 | switch (index) {
76 | case 0:
77 | //首页
78 | if (homeFragment == null) {
79 | homeFragment = new HomeFragment();
80 | beginTransaction.add(R.id.fl_layout, homeFragment);
81 | } else {
82 | beginTransaction.show(homeFragment);
83 | }
84 | break;
85 | case 1:
86 | //发现
87 | if (newsFragment == null) {
88 | newsFragment = new NewsFragment();
89 | beginTransaction.add(R.id.fl_layout, newsFragment);
90 | } else {
91 | beginTransaction.show(newsFragment);
92 | }
93 | break;
94 | case 2:
95 | //我的
96 | if (mineFragment == null) {
97 | mineFragment = new MineFragment();
98 | beginTransaction.add(R.id.fl_layout, mineFragment);
99 | } else {
100 | beginTransaction.show(mineFragment);
101 | }
102 | break;
103 | }
104 | beginTransaction.commitAllowingStateLoss();
105 | refreshBottomStatus(index);
106 | }
107 |
108 | /**
109 | * 改变底部图片和文字的状态
110 | *
111 | * @param position: 下标
112 | */
113 | private void refreshBottomStatus(int position) {
114 | for (int i = 0; i < idArrays.length; i++) {
115 | findViewById(idArrays[i]).setSelected(position == i);
116 | }
117 | }
118 |
119 | /**
120 | * 隐藏所有Fragment
121 | */
122 | private void hideFragment() {
123 | if (homeFragment != null)
124 | beginTransaction.hide(homeFragment);
125 | if (newsFragment != null)
126 | beginTransaction.hide(newsFragment);
127 | if (mineFragment != null)
128 | beginTransaction.hide(mineFragment);
129 | }
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/mainpage/fragment/HomeFragment.java:
--------------------------------------------------------------------------------
1 | package com.library.mainpage.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.common.base.BaseFragment;
8 | import com.library.R;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | * @Date: 2020/11/13
14 | *
15 | * @Desc:
16 | */
17 | public class HomeFragment extends BaseFragment {
18 |
19 | private TextView tvDesc;
20 |
21 | @Override
22 | public int getLayout() {
23 | return R.layout.fragment_main ;
24 | }
25 |
26 | @Override
27 | public void initViewIds(View view) {
28 | tvDesc = view.findViewById(R.id.tv_desc);
29 | }
30 |
31 | @Override
32 | public void initView(View view) {
33 | tvDesc.setText("我是首页");
34 | }
35 |
36 | @Override
37 | public void initData(Bundle savedInstanceState) {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/mainpage/fragment/MineFragment.java:
--------------------------------------------------------------------------------
1 | package com.library.mainpage.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.common.base.BaseFragment;
8 | import com.library.R;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | * @Date: 2020/11/13
14 | *
15 | * @Desc:
16 | */
17 | public class MineFragment extends BaseFragment {
18 |
19 | private TextView tvDesc;
20 |
21 | @Override
22 | public int getLayout() {
23 | return R.layout.fragment_main ;
24 | }
25 |
26 | @Override
27 | public void initViewIds(View view) {
28 | tvDesc = view.findViewById(R.id.tv_desc);
29 | }
30 |
31 | @Override
32 | public void initView(View view) {
33 | tvDesc.setText("我是个人页");
34 | }
35 |
36 | @Override
37 | public void initData(Bundle savedInstanceState) {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/mainpage/fragment/NewsFragment.java:
--------------------------------------------------------------------------------
1 | package com.library.mainpage.fragment;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.TextView;
6 |
7 | import com.common.base.BaseFragment;
8 | import com.library.R;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | * @Date: 2020/11/13
14 | *
15 | * @Desc:
16 | */
17 | public class NewsFragment extends BaseFragment {
18 |
19 | private TextView tvDesc;
20 |
21 | @Override
22 | public int getLayout() {
23 | return R.layout.fragment_main ;
24 | }
25 |
26 | @Override
27 | public void initViewIds(View view) {
28 | tvDesc = view.findViewById(R.id.tv_desc);
29 | }
30 |
31 | @Override
32 | public void initView(View view) {
33 | tvDesc.setText("我是新闻页");
34 | }
35 |
36 | @Override
37 | public void initData(Bundle savedInstanceState) {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/question/AnswerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.library.question;
2 |
3 | import android.util.Log;
4 | import android.widget.ImageView;
5 | import android.widget.TextView;
6 |
7 | import androidx.annotation.Nullable;
8 |
9 | import com.common.library.bravh_rvadapter.BaseRecyclerAdapter;
10 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
11 | import com.library.R;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * @Author: Created by seven.zhang
17 | * @Date: 2022/3/10 15:43
18 | * @Desc:
19 | */
20 | public class AnswerAdapter extends BaseRecyclerAdapter {
21 | private OnItemClickListener onItemClickListener;
22 | /**
23 | * 类型
24 | * {@link QuestionBean }
25 | * 1: 单选
26 | * 2: 多选
27 | */
28 | private int type;
29 | /**
30 | * 单选的下标
31 | */
32 | private QuestionBean.QuestionData questionItem;
33 |
34 | public int getType() {
35 | return type;
36 | }
37 |
38 | public AnswerAdapter(QuestionBean.QuestionData questionItem, int type, @Nullable List data) {
39 | super(R.layout.item_question_answer, data);
40 | this.questionItem = questionItem;
41 | this.type = type;
42 | }
43 |
44 | @Override
45 | protected void convert(RecyclerViewHolder holder, QuestionBean.QuestionData.AnswerData item) {
46 | ImageView ivSelect = holder.getImageView(R.id.iv_select);
47 | TextView tvAnswer = holder.getTextView(R.id.tv_answer);
48 | tvAnswer.setText(item.getAnswer());
49 | ivSelect.setSelected(type == QuestionBean.TYPE_MULTI_CHOICE ? item.isChecked() : item.getId() == questionItem.getCheckedId());
50 | holder.itemView.setOnClickListener(v -> {
51 | if (type == QuestionBean.TYPE_SINGLE_CHOICE) {
52 | //单选
53 | onItemClickListener.onItemClick(type, item.getId());
54 | } else {
55 | //多选
56 | item.setChecked(!item.isChecked());
57 | ivSelect.setSelected(item.isChecked());
58 | }
59 | });
60 | }
61 |
62 | interface OnItemClickListener {
63 | void onItemClick(int type, int answerId);
64 | }
65 |
66 | public void setmOnItemClickListener(OnItemClickListener onItemClickListener) {
67 | this.onItemClickListener = onItemClickListener;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/question/QuestionActivity.java:
--------------------------------------------------------------------------------
1 | package com.library.question;
2 |
3 | import androidx.annotation.Nullable;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import androidx.recyclerview.widget.LinearLayoutManager;
6 |
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.TextView;
12 |
13 | import com.blankj.utilcode.util.GsonUtils;
14 | import com.blankj.utilcode.util.LogUtils;
15 | import com.blankj.utilcode.util.ResourceUtils;
16 | import com.common.base.BaseActivity;
17 | import com.common.weight.CommonRecyclerView;
18 | import com.library.R;
19 |
20 | import java.util.ArrayList;
21 |
22 | /**
23 | * 答题页面
24 | */
25 | public class QuestionActivity extends BaseActivity {
26 |
27 | private CommonRecyclerView rvQuestion;
28 | private String TAG = "QuestionActivity";
29 | private QuestionAdapter questionAdapter;
30 | private Button btnShowAnswer;
31 | private TextView tvAllAnswer;
32 |
33 | @Override
34 | public int getLayout() {
35 | return R.layout.activity_question;
36 | }
37 |
38 | @Override
39 | public void initViewIds() {
40 | rvQuestion = findViewById(R.id.rv_question);
41 | btnShowAnswer = findViewById(R.id.btn_show_answer);
42 | tvAllAnswer = findViewById(R.id.tv_all_answer);
43 | }
44 |
45 | @Override
46 | public void initView() {
47 | initQuestionRecycler();
48 | }
49 |
50 | /**
51 | * 初始化问题列表
52 | */
53 | private void initQuestionRecycler() {
54 | questionAdapter = new QuestionAdapter(new ArrayList<>());
55 | rvQuestion.setLayoutManager(new LinearLayoutManager(this));
56 | rvQuestion.setAdapter(questionAdapter);
57 | }
58 |
59 | @Override
60 | public void initData(@Nullable Bundle savedInstanceState) {
61 | formatQuestionJson();
62 | }
63 |
64 | @Override
65 | public void initListener() {
66 | super.initListener();
67 | btnShowAnswer.setOnClickListener(v -> {
68 | StringBuilder stringBuilder = new StringBuilder();
69 | //显示所有答案
70 | for (QuestionBean.QuestionData questionItem : questionAdapter.getData()) {
71 | if (questionItem.getType() == QuestionBean.TYPE_SINGLE_CHOICE) {
72 | //单选
73 | stringBuilder.append("问题id: " + questionItem.getId() + " 答案id: " + questionItem.getCheckedId() + "\n");
74 | } else if (questionItem.getType() == QuestionBean.TYPE_MULTI_CHOICE) {
75 | //多选
76 | ArrayList answerIdList = new ArrayList<>();
77 | for (QuestionBean.QuestionData.AnswerData answerItem : questionItem.getAnswer()) {
78 | if (answerItem.isChecked()) {
79 | answerIdList.add(answerItem.getId());
80 | }
81 | }
82 | stringBuilder.append("问题id: " + questionItem.getId() + " 答案id: " + answerIdList.toString() + "\n");
83 | } else if (questionItem.getType() == QuestionBean.TYPE_FILL_BLANKS) {
84 | //填空
85 | stringBuilder.append("问题id: " + questionItem.getId() + " 答案: " + questionItem.getInputAnswer() + "\n");
86 | }
87 | }
88 | tvAllAnswer.setText(stringBuilder);
89 | });
90 | }
91 |
92 | /**
93 | * 格式化问题的json
94 | */
95 | private void formatQuestionJson() {
96 | String questionJsonStr = ResourceUtils.readAssets2String("question.json");
97 | QuestionBean questionBean = GsonUtils.fromJson(questionJsonStr, QuestionBean.class);
98 | questionAdapter.setNewData(questionBean.getData());
99 | }
100 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/library/question/QuestionAdapter.java:
--------------------------------------------------------------------------------
1 | package com.library.question;
2 |
3 | import android.text.Editable;
4 | import android.text.TextWatcher;
5 | import android.util.Log;
6 | import android.view.View;
7 | import android.widget.EditText;
8 | import android.widget.TextView;
9 |
10 | import androidx.annotation.Nullable;
11 | import androidx.recyclerview.widget.GridLayoutManager;
12 |
13 | import com.blankj.utilcode.util.Utils;
14 | import com.common.library.bravh_rvadapter.BaseMultiItemRecyclerAdapter;
15 | import com.common.library.bravh_rvadapter.BaseRecyclerAdapter;
16 | import com.common.library.bravh_rvadapter.MultipleItemRvAdapter;
17 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
18 | import com.common.weight.CommonRecyclerView;
19 | import com.library.R;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * @Author: Created by seven.zhang
25 | * @Date: 2022/3/9 18:52
26 | * @Desc:
27 | */
28 | public class QuestionAdapter extends BaseMultiItemRecyclerAdapter {
29 |
30 | /**
31 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
32 | * some initialization data.
33 | *
34 | * @param data A new list is created out of this one to avoid mutable list
35 | */
36 | public QuestionAdapter(List data) {
37 | super(data);
38 | addItemType(QuestionBean.TYPE_SINGLE_CHOICE, R.layout.item_question_type_1);
39 | addItemType(QuestionBean.TYPE_MULTI_CHOICE, R.layout.item_question_type_2);
40 | addItemType(QuestionBean.TYPE_FILL_BLANKS, R.layout.item_question_type_3);
41 | }
42 |
43 | @Override
44 | protected void convert(RecyclerViewHolder holder, QuestionBean.QuestionData item) {
45 | TextView tvTitle = holder.getTextView(R.id.tv_title);
46 | tvTitle.setText(item.getTitle() + " (" + item.getTypeDesc() + ")");
47 | if (item.getItemType() == QuestionBean.TYPE_SINGLE_CHOICE || item.getItemType() == QuestionBean.TYPE_MULTI_CHOICE) {
48 | //单选或者多选
49 | CommonRecyclerView rvAnswer = holder.findViewById(R.id.rv_answer);
50 | initAnswerRecycler(rvAnswer, item, item.getItemType(), item.getAnswer());
51 | } else {
52 | //填空
53 | EditText etAnswer = holder.findViewById(R.id.et_answer);
54 | etAnswer.setText(item.getInputAnswer());
55 | etAnswer.addTextChangedListener(new TextWatcher() {
56 | @Override
57 | public void beforeTextChanged(CharSequence s, int start, int count, int after) {
58 |
59 | }
60 |
61 | @Override
62 | public void onTextChanged(CharSequence s, int start, int before, int count) {
63 | item.setInputAnswer(s.toString());
64 | }
65 |
66 | @Override
67 | public void afterTextChanged(Editable s) {
68 |
69 | }
70 | });
71 | }
72 | }
73 |
74 | /**
75 | * 初始化答案列表适配器
76 | *
77 | * @param rvAnswer
78 | * @param type
79 | * @param answerList
80 | */
81 | private void initAnswerRecycler(CommonRecyclerView rvAnswer,QuestionBean.QuestionData item, int type, List answerList) {
82 | rvAnswer.setLayoutManager(new GridLayoutManager(Utils.getApp(), 2));
83 | AnswerAdapter answerAdapter = new AnswerAdapter(item, type, answerList);
84 | rvAnswer.setAdapter(answerAdapter);
85 | answerAdapter.setmOnItemClickListener((type1, answerId) -> {
86 | if (type1 == QuestionBean.TYPE_SINGLE_CHOICE) {
87 | item.setCheckedId(answerId);
88 | answerAdapter.notifyDataSetChanged();
89 | }
90 | });
91 |
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/library/question/QuestionBean.java:
--------------------------------------------------------------------------------
1 | package com.library.question;
2 |
3 | import android.util.Log;
4 |
5 | import com.common.library.bravh_rvadapter.entity.MultiItemEntity;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * @Author: Created by seven.zhang
11 | * @Date: 2022/3/10 11:03
12 | * @Desc:
13 | */
14 | public class QuestionBean {
15 | /**
16 | * 单选
17 | */
18 | public static int TYPE_SINGLE_CHOICE = 1;
19 | /**
20 | * 多选
21 | */
22 | public static int TYPE_MULTI_CHOICE = 2;
23 | /**
24 | * 填空
25 | */
26 | public static int TYPE_FILL_BLANKS = 3;
27 |
28 | private List data;
29 |
30 | public List getData() {
31 | return data;
32 | }
33 |
34 | static class QuestionData implements MultiItemEntity{
35 | private int id;
36 | private String title;
37 | private String rightAnswer;
38 | private List answer;
39 | private String typeDesc;
40 | /**
41 | * 用于单选,单选的下标
42 | */
43 | private int checkedId = -1;
44 |
45 | public int getCheckedId() {
46 | return checkedId;
47 | }
48 |
49 | public void setCheckedId(int checkedId) {
50 | this.checkedId = checkedId;
51 | }
52 |
53 | /**
54 | * 用于填空,输入的填空内容
55 | */
56 | private String inputAnswer;
57 |
58 | public String getInputAnswer() {
59 | return inputAnswer;
60 | }
61 |
62 | public void setInputAnswer(String inputAnswer) {
63 | this.inputAnswer = inputAnswer;
64 | }
65 |
66 | /**
67 | * 问题类型
68 | * 1: 单选
69 | * 2: 多选
70 | * 3: 填空
71 | */
72 | private int type;
73 |
74 | public int getId() {
75 | return id;
76 | }
77 |
78 | public String getTitle() {
79 | return title;
80 | }
81 |
82 | public String getRightAnswer() {
83 | return rightAnswer;
84 | }
85 |
86 | public List getAnswer() {
87 | return answer;
88 | }
89 |
90 | public String getTypeDesc() {
91 | return typeDesc;
92 | }
93 |
94 | public int getType() {
95 | return type;
96 | }
97 |
98 | @Override
99 | public int getItemType() {
100 | return type;
101 | }
102 |
103 | static class AnswerData{
104 | /**
105 | * 用于多选,是否选择
106 | */
107 | private boolean isChecked = false;
108 | private int id;
109 | private String answer;
110 |
111 | public boolean isChecked() {
112 | return isChecked;
113 | }
114 |
115 | public void setChecked(boolean checked) {
116 | isChecked = checked;
117 | }
118 |
119 | public int getId() {
120 | return id;
121 | }
122 |
123 | public String getAnswer() {
124 | return answer;
125 | }
126 | }
127 | }
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_home_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_home_select.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_home_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_home_unselect.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_list_item_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_list_item_select.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_list_item_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_list_item_unselect.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_mine_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_mine_select.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_mine_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_mine_unselect.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_news_select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_news_select.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_news_unselect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/app/src/main/res/drawable-xhdpi/ic_news_unselect.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_circle_float_button.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/border_black_corner_10.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/item_answer_select.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 | -
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/item_answer_unselect.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_home_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_main_bottom_text_color.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_mine_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/select_news_icon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selected_item_answer.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_file_download.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
22 |
23 |
27 |
28 |
34 |
35 |
40 |
41 |
46 |
47 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_glide_use.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
23 |
24 |
25 |
31 |
32 |
37 |
38 |
39 |
45 |
46 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_http_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
24 |
25 |
34 |
35 |
41 |
42 |
47 |
48 |
53 |
54 |
59 |
60 |
65 |
66 |
71 |
72 |
81 |
82 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_lazy_load.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
17 |
18 |
25 |
26 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
27 |
28 |
33 |
34 |
39 |
40 |
45 |
46 |
51 |
52 |
56 |
57 |
63 |
64 |
70 |
71 |
77 |
78 |
79 |
84 |
85 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_multiple_choice_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
16 |
27 |
28 |
34 |
35 |
41 |
42 |
48 |
49 |
55 |
56 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_question.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
27 |
28 |
35 |
36 |
37 |
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_refresh_load_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_single_choice_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_lazy.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/include_main_bottom.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
21 |
22 |
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_question_answer.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_question_type_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
21 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_question_type_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_question_type_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
19 |
20 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_refresh_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
25 |
26 |
35 |
36 |
44 |
45 |
46 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_single_choice.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
18 |
19 |
25 |
26 |
34 |
35 |
44 |
45 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar_my_left_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar_my_right_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/toolbar_my_title_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/test/java/com/library/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.library;
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 | }
--------------------------------------------------------------------------------
/basecommon/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/basecommon/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.android.compileSdkVersion
5 | buildToolsVersion rootProject.ext.android.buildToolsVersion
6 | defaultConfig {
7 | minSdkVersion rootProject.ext.android.minSdkVersion
8 | targetSdkVersion rootProject.ext.android.targetSdkVersion
9 | versionCode rootProject.ext.android.versionCode
10 | versionName rootProject.ext.android.versionName
11 |
12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13 | consumerProguardFiles 'consumer-rules.pro'
14 | }
15 |
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 |
23 | compileOptions {
24 | sourceCompatibility JavaVersion.VERSION_1_8
25 | targetCompatibility JavaVersion.VERSION_1_8
26 | }
27 |
28 | }
29 |
30 | dependencies {
31 | api fileTree(dir: 'libs', include: ['*.jar'])
32 | api rootProject.ext.dependencies.appcompat
33 | api rootProject.ext.dependencies.constraintLayout
34 | api rootProject.ext.dependencies.junit
35 | androidTestApi rootProject.ext.dependencies.testJunit
36 | androidTestApi rootProject.ext.dependencies.testEspressoCore
37 | api rootProject.ext.dependencies.design
38 | api rootProject.ext.dependencies.androidUtilCode
39 | api rootProject.ext.dependencies.autoSize
40 | api rootProject.ext.dependencies.eventBus
41 | api rootProject.ext.dependencies.glide
42 | annotationProcessor rootProject.ext.dependencies.glideCompiler
43 | api rootProject.ext.dependencies.smartRefresh
44 | api rootProject.ext.dependencies.smartRefreshClassics
45 |
46 | api rootProject.ext.dependencies.fileDownloader
47 |
48 | //AutoDispose解决RxJava内存泄漏
49 | api rootProject.ext.dependencies.uberAutoDispose
50 | api rootProject.ext.dependencies.uberAutoDisposeAndroid
51 | api rootProject.ext.dependencies.uberAutoDisposeAndroidArchcomponents
52 |
53 | // 网络&数据相关
54 | api rootProject.ext.dependencies.retrofit2
55 | api rootProject.ext.dependencies.retrofitConverterGson
56 | api rootProject.ext.dependencies.rxjava2
57 | api rootProject.ext.dependencies.rxandroid
58 | api rootProject.ext.dependencies.retrofit2AdapterRxjava2
59 | api rootProject.ext.dependencies.okHttp
60 | api rootProject.ext.dependencies.okHttpLoggingInterceptorVersion
61 | api rootProject.ext.dependencies.gson
62 | }
63 |
--------------------------------------------------------------------------------
/basecommon/consumer-rules.pro:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/consumer-rules.pro
--------------------------------------------------------------------------------
/basecommon/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/basecommon/src/androidTest/java/com/common/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.common;
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 |
25 | assertEquals("com.common.test", appContext.getPackageName());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/basecommon/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
21 |
22 |
23 |
26 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/basecommon/src/main/assets/question.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": [
3 | {
4 | "id": 1,
5 | "title": "一、以下谁叫小红",
6 | "rightAnswer": 1,
7 | "answer": [
8 | {
9 | "id": 1,
10 | "answer": "小红"
11 | },
12 | {
13 | "id": 2,
14 | "answer": "小明"
15 | },
16 | {
17 | "id": 3,
18 | "answer": "小张"
19 | }
20 | ],
21 | "typeDesc": "单选",
22 | "type": 1
23 | },
24 | {
25 | "id": 2,
26 | "title": "二、以下谁姓张",
27 | "rightAnswer": "1,4",
28 | "answer": [
29 | {
30 | "id": 1,
31 | "answer": "张三"
32 | },
33 | {
34 | "id": 2,
35 | "answer": "赵四"
36 | },
37 | {
38 | "id": 3,
39 | "answer": "王五"
40 | },
41 | {
42 | "id": 4,
43 | "answer": "张龙"
44 | }
45 | ],
46 | "typeDesc": "多选",
47 | "type": 2
48 | },
49 | {
50 | "id": 3,
51 | "title": "三、以下哪个动物会汪汪叫",
52 | "rightAnswer": 1,
53 | "answer": [
54 | {
55 | "id": 1,
56 | "answer": "小狗"
57 | },
58 | {
59 | "id": 2,
60 | "answer": "小猫"
61 | },
62 | {
63 | "id": 3,
64 | "answer": "小猪"
65 | }
66 | ],
67 | "typeDesc": "单选",
68 | "type": 1
69 | },
70 | {
71 | "id": 4,
72 | "title": "四、以下什么动物是水里游的",
73 | "rightAnswer": "2,3,4",
74 | "answer": [
75 | {
76 | "id": 1,
77 | "answer": "奶牛"
78 | },
79 | {
80 | "id": 2,
81 | "answer": "金鱼"
82 | },
83 | {
84 | "id": 3,
85 | "answer": "鲸鱼"
86 | },
87 | {
88 | "id": 4,
89 | "answer": "海豚"
90 | }
91 | ],
92 | "typeDesc": "多选",
93 | "type": 2
94 | },
95 | {
96 | "id": 5,
97 | "title": "五、你爱吃什么水果",
98 | "rightAnswer": "",
99 | "answer": [],
100 | "typeDesc": "填空",
101 | "type": 3
102 | }
103 | ]
104 | }
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/base/BaseApplication.java:
--------------------------------------------------------------------------------
1 | package com.common.base;
2 |
3 | import android.app.Application;
4 | import android.view.Gravity;
5 |
6 | import com.blankj.utilcode.util.ToastUtils;
7 | import com.common.util.SpUtil;
8 | import com.liulishuo.filedownloader.FileDownloader;
9 |
10 | public class BaseApplication extends Application {
11 |
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | SpUtil.init(this);
16 | initToast();
17 | FileDownloader.setup(this);
18 | }
19 |
20 | private void initToast(){
21 | ToastUtils toastUtils = ToastUtils.getDefaultMaker();
22 | toastUtils.setGravity(Gravity.CENTER,0,0);
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/base/mvp/BaseMvpActivity.java:
--------------------------------------------------------------------------------
1 | package com.common.base.mvp;
2 |
3 | import androidx.lifecycle.Lifecycle;
4 |
5 | import com.common.base.BaseActivity;
6 | import com.uber.autodispose.AutoDispose;
7 | import com.uber.autodispose.AutoDisposeConverter;
8 | import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | *
14 | * @Desc: Mvp Activity 基类
15 | */
16 | public abstract class BaseMvpActivity
17 | extends BaseActivity implements BaseView {
18 |
19 | protected P mPresenter;
20 |
21 | /**
22 | * 接触View绑定
23 | */
24 | @Override
25 | protected void onDestroy() {
26 | if (mPresenter != null && mPresenter.isViewAttached())
27 | mPresenter.detachView();
28 | super.onDestroy();
29 | }
30 |
31 | /**
32 | * 绑定生命周期 防止MVP内存泄漏
33 | *
34 | * @param
35 | * @return
36 | */
37 | @Override
38 | public AutoDisposeConverter bindAutoDispose() {
39 | return AutoDispose.autoDisposable(AndroidLifecycleScopeProvider
40 | .from(this, Lifecycle.Event.ON_DESTROY));
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/base/mvp/BaseMvpFragment.java:
--------------------------------------------------------------------------------
1 | package com.common.base.mvp;
2 |
3 | import androidx.lifecycle.Lifecycle;
4 |
5 | import com.common.base.BaseFragment;
6 | import com.uber.autodispose.AutoDispose;
7 | import com.uber.autodispose.AutoDisposeConverter;
8 | import com.uber.autodispose.android.lifecycle.AndroidLifecycleScopeProvider;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | *
14 | * @Desc:
15 | */
16 | public abstract class BaseMvpFragment
17 | extends BaseFragment
18 | implements BaseView {
19 |
20 | private T mPresenter;
21 |
22 | @Override
23 | public void onDestroyView() {
24 | if (mPresenter != null && mPresenter.isViewAttached())
25 | mPresenter.detachView();
26 | super.onDestroyView();
27 | }
28 |
29 | /**
30 | * 绑定生命周期 防止MVP内存泄漏
31 | *
32 | * @param :
33 | * @return
34 | */
35 | @Override
36 | public AutoDisposeConverter bindAutoDispose() {
37 | return AutoDispose.autoDisposable(AndroidLifecycleScopeProvider
38 | .from(this, Lifecycle.Event.ON_DESTROY));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/base/mvp/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.common.base.mvp;
2 |
3 | /**
4 | * @Author: 张鹏飞
5 | * @Email: 1271396448@qq.com
6 | *
7 | * @Desc: Presenter基类
8 | */
9 | public class BasePresenter {
10 |
11 | protected V mView;
12 |
13 | /**
14 | * 绑定View 一般初始化调用
15 | *
16 | * @param view: view
17 | */
18 | public void attachView(V view) {
19 | this.mView = view;
20 | }
21 |
22 | /**
23 | * 解绑View 一般在destroy调用
24 | */
25 | public void detachView() {
26 | this.mView = null;
27 | }
28 |
29 | /**
30 | * View 是否绑定
31 | *
32 | * @return: 是否绑定
33 | */
34 | public boolean isViewAttached() {
35 | return mView != null;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/base/mvp/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.common.base.mvp;
2 |
3 | import com.uber.autodispose.AutoDisposeConverter;
4 |
5 | /**
6 | * @Author: 张鹏飞
7 | * @Email: 1271396448@qq.com
8 | *
9 | * @Desc:
10 | */
11 | public interface BaseView {
12 |
13 | /**
14 | * 绑定Android生命周期 防止RxJava内存泄漏
15 | *
16 | * @param
17 | * @return
18 | */
19 | AutoDisposeConverter bindAutoDispose();
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/constants/Constants.java:
--------------------------------------------------------------------------------
1 | package com.common.constants;
2 |
3 | /**
4 | * @Author: 张鹏飞
5 | * @Email: 1271396448@qq.com
6 | * @Date: 2020/11/12
7 | *
8 | * @Desc: 常量类
9 | */
10 | public class Constants {
11 | //文件存储根路径
12 | public static final String SD_ROOT_DIR = "/zpf/file/";
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/constants/HttpConstants.java:
--------------------------------------------------------------------------------
1 | package com.common.constants;
2 |
3 | /**
4 | * 网络相关参数
5 | */
6 | public class HttpConstants {
7 |
8 | public static final String BASE_URL = "http://119.45.229.87:1271/";
9 | //成功码
10 | public static final int CODE_SUCCESS = 10000;
11 | //链接超时时间
12 | public static final int TIME_OUT_CONNECT = 8;
13 | //读取超时时间
14 | public static final int TIME_OUT_READ = 8;
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/XRetrofit.java:
--------------------------------------------------------------------------------
1 | package com.common.http;
2 |
3 |
4 | import com.common.constants.HttpConstants;
5 | import com.common.http.api.ApiService;
6 | import com.common.http.intercept.HttpIntercept;
7 |
8 | import java.util.concurrent.TimeUnit;
9 |
10 | import okhttp3.OkHttpClient;
11 | import retrofit2.Retrofit;
12 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
13 | import retrofit2.converter.gson.GsonConverterFactory;
14 |
15 | /**
16 | * @Author: 张鹏飞
17 | * @Email: 1271396448@qq.com
18 | *
19 | * @Desc: 网络请求入口
20 | */
21 | public class XRetrofit {
22 | private static ApiService apiService;
23 |
24 | /**
25 | * 请求的入口
26 | *
27 | * @return
28 | */
29 | public static ApiService getApi() {
30 | if (apiService == null) {
31 | synchronized (ApiService.class) {
32 | if (apiService == null)
33 | apiService = initRetrofit().create(ApiService.class);
34 | }
35 | }
36 | return apiService;
37 | }
38 |
39 | /**
40 | * 初始化Retrofit
41 | *
42 | * @return
43 | */
44 | private static Retrofit initRetrofit() {
45 | return new Retrofit.Builder()
46 | .baseUrl(HttpConstants.BASE_URL)
47 | .addConverterFactory(GsonConverterFactory.create())
48 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
49 | .client(initOkHttpClient())
50 | .build();
51 | }
52 |
53 | /**
54 | * 初始化OkHttp
55 | *
56 | * @return
57 | */
58 | private static OkHttpClient initOkHttpClient() {
59 | return new OkHttpClient.Builder()
60 | .addInterceptor(new HttpIntercept())
61 | .addInterceptor(new HttpIntercept().httpBodyIntercept())
62 | .connectTimeout(HttpConstants.TIME_OUT_CONNECT, TimeUnit.SECONDS)
63 | .readTimeout(HttpConstants.TIME_OUT_READ, TimeUnit.SECONDS)
64 | .build();
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/api/ApiService.java:
--------------------------------------------------------------------------------
1 | package com.common.http.api;
2 |
3 |
4 | import com.common.http.base.BaseResponse;
5 | import com.common.http.bean.ExampleBean;
6 | import com.common.http.bean.ExampleFileBean;
7 | import com.common.http.bean.ExampleListBean;
8 |
9 | import java.util.HashMap;
10 | import java.util.List;
11 |
12 | import io.reactivex.Observable;
13 | import okhttp3.MultipartBody;
14 | import okhttp3.RequestBody;
15 | import retrofit2.http.Body;
16 | import retrofit2.http.DELETE;
17 | import retrofit2.http.FieldMap;
18 | import retrofit2.http.FormUrlEncoded;
19 | import retrofit2.http.GET;
20 | import retrofit2.http.Multipart;
21 | import retrofit2.http.POST;
22 | import retrofit2.http.PUT;
23 | import retrofit2.http.Part;
24 | import retrofit2.http.PartMap;
25 | import retrofit2.http.QueryMap;
26 |
27 | /**
28 | * @Author: 张鹏飞
29 | * @Email: 1271396448@qq.com
30 | *
31 | * @Desc: BaseResponse 是后台返回的数据,T代表Data里面的数据 无数据返回可直接写BaseReponse
32 | */
33 | public interface ApiService {
34 |
35 | /**
36 | * Get请求
37 | *
38 | * @param map
39 | * @return
40 | */
41 | @GET("api/get")
42 | Observable> testGet(@QueryMap HashMap map);
43 |
44 | /**
45 | * Post请求
46 | *
47 | * @param map
48 | * @return
49 | */
50 | @POST("api/post")
51 | @FormUrlEncoded
52 | Observable testPost(@FieldMap HashMap map);
53 |
54 | /**
55 | * Put请求
56 | *
57 | * @param map
58 | * @return
59 | */
60 | @PUT("api/put")
61 | @FormUrlEncoded
62 | Observable testPut(@FieldMap HashMap map);
63 |
64 | /**
65 | * Delete请求
66 | *
67 | * @param map
68 | * @return
69 | */
70 | @DELETE("api/delete")
71 | Observable> testDelete(@QueryMap HashMap map);
72 |
73 | /**
74 | * post提交json格式数据
75 | *
76 | * @param body
77 | * @return
78 | */
79 | @POST("api/postJson")
80 | Observable> testPostJson(@Body RequestBody body);
81 |
82 | /**
83 | * 文件上传
84 | *
85 | * @param file
86 | * @param map
87 | * @return
88 | */
89 | @POST("api/uploadFile")
90 | @Multipart
91 | Observable> testUploadFile(@Part MultipartBody.Part file, @PartMap HashMap map);
92 |
93 | /**
94 | * 例子3: RequestBody
95 | *
96 | * @return
97 | */
98 | @POST("api/postJson")
99 | Observable> testLogin(@Body RequestBody body);
100 |
101 | /**
102 | * 获取集合
103 | *
104 | * @param map
105 | * @return
106 | */
107 | @GET("api/getList")
108 | Observable>> getList(@QueryMap HashMap map);
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/base/BaseObserver.java:
--------------------------------------------------------------------------------
1 | package com.common.http.base;
2 |
3 |
4 | import android.content.Context;
5 | import android.net.ParseException;
6 |
7 | import androidx.appcompat.app.AlertDialog;
8 |
9 | import com.blankj.utilcode.util.NetworkUtils;
10 | import com.blankj.utilcode.util.ToastUtils;
11 | import com.common.R;
12 | import com.google.gson.JsonSyntaxException;
13 |
14 | import org.json.JSONException;
15 |
16 | import java.net.SocketException;
17 | import java.net.SocketTimeoutException;
18 | import java.net.UnknownHostException;
19 |
20 | import io.reactivex.Observer;
21 | import io.reactivex.disposables.Disposable;
22 | import retrofit2.HttpException;
23 |
24 | /**
25 | * @Author: 张鹏飞
26 | * @Email: 1271396448@qq.com
27 | *
28 | * @Desc: 实现Observer 来统一处理,拦截
29 | */
30 | public abstract class BaseObserver implements Observer> {
31 |
32 | private Context context;
33 | private AlertDialog loadingDialog;
34 | private Disposable disposable;
35 |
36 |
37 | @Override
38 | public void onSubscribe(Disposable d) {
39 | disposable = d;
40 | }
41 |
42 | public BaseObserver() {
43 | super();
44 | }
45 |
46 | /**
47 | * 需要弹窗,实例化此方法
48 | *
49 | * @param context
50 | */
51 | public BaseObserver(Context context) {
52 | this.context = context;
53 | //弹窗在这里写,每次调用网络都实现这个方法
54 | // if (loadingDialog == null)
55 | // new AlertDialog.Builder(context);
56 | // loadingDialog.show();
57 | }
58 |
59 | @Override
60 | public void onNext(BaseResponse response) {
61 | if (loadingDialog != null)
62 | loadingDialog.dismiss();
63 | onSuccess(response);
64 | if (response.isSuccess()) {
65 | onSuccess(response.getData());
66 | } else {
67 | ToastUtils.showShort(response.getMsg());
68 | }
69 | }
70 |
71 |
72 | @Override
73 | public void onError(Throwable e) {
74 | if (loadingDialog != null)
75 | loadingDialog.dismiss();
76 | if (!NetworkUtils.isConnected()) {
77 | ToastUtils.showShort(R.string.error_net);
78 | } else if (e instanceof HttpException
79 | || e instanceof UnknownHostException
80 | || e instanceof SocketException) {//服务器错误
81 | ToastUtils.showShort(R.string.error_server);
82 | } else if (e instanceof SocketTimeoutException) {//连接超时等
83 | ToastUtils.showShort(R.string.error_time_out);
84 | } else if (e instanceof JsonSyntaxException
85 | || e instanceof JSONException
86 | || e instanceof ParseException) {//数据解析异常
87 | ToastUtils.showShort(R.string.error_data_parse);
88 | } else {//未知异常
89 | ToastUtils.showShort(R.string.error_unknow);
90 | }
91 | }
92 |
93 | @Override
94 | public void onComplete() {
95 | }
96 |
97 | /**
98 | * 请求成功 只返回data的数据
99 | *
100 | * @param response: 数据
101 | */
102 | public abstract void onSuccess(T response);
103 |
104 | /**
105 | * 请求成功 需要单独处理状态码时实现该方法
106 | *
107 | * @param baseResponse: 带状态码的数据
108 | */
109 | public void onSuccess(BaseResponse baseResponse) {
110 |
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/base/BaseResponse.java:
--------------------------------------------------------------------------------
1 | package com.common.http.base;
2 |
3 | import com.common.constants.HttpConstants;
4 |
5 | /**
6 | * @Author: 张鹏飞
7 | * @Email: 1271396448@qq.com
8 | *
9 | * @Desc: 数据统一返回格式
10 | */
11 | public class BaseResponse {
12 |
13 | private int code;
14 | private String msg;
15 | private T data;
16 |
17 | public int getCode() {
18 | return code;
19 | }
20 |
21 | public void setCode(int code) {
22 | this.code = code;
23 | }
24 |
25 | public String getMsg() {
26 | return msg;
27 | }
28 |
29 | public void setMsg(String msg) {
30 | this.msg = msg;
31 | }
32 |
33 | public T getData() {
34 | return data;
35 | }
36 |
37 | public void setData(T data) {
38 | this.data = data;
39 | }
40 |
41 | public boolean isSuccess(){
42 | return code == HttpConstants.CODE_SUCCESS;
43 | }
44 |
45 | @Override
46 | public String toString() {
47 | return "BaseResponse{" +
48 | "code=" + code +
49 | ", msg='" + msg + '\'' +
50 | ", data=" + data +
51 | '}';
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/base/RxJavaHelper.java:
--------------------------------------------------------------------------------
1 | package com.common.http.base;
2 |
3 | import io.reactivex.Observable;
4 | import io.reactivex.ObservableSource;
5 | import io.reactivex.ObservableTransformer;
6 | import io.reactivex.android.schedulers.AndroidSchedulers;
7 | import io.reactivex.schedulers.Schedulers;
8 |
9 | /**
10 | * @Author: 张鹏飞
11 | * @Email: 1271396448@qq.com
12 | *
13 | * @Desc: Rxjava2线程切换操作封装
14 | */
15 | public class RxJavaHelper {
16 |
17 | public static ObservableTransformer observeOnMainThread(){
18 | return new ObservableTransformer() {
19 | @Override
20 | public ObservableSource apply(Observable upstream) {
21 | return upstream.subscribeOn(Schedulers.io())
22 | .unsubscribeOn(Schedulers.io())
23 | .observeOn(AndroidSchedulers.mainThread());
24 | }
25 | };
26 | }
27 |
28 | }
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/bean/ExampleBean.java:
--------------------------------------------------------------------------------
1 | package com.common.http.bean;
2 |
3 | /**
4 | * @Author: 张鹏飞
5 | * @Date: 2020/9/3
6 | * @Email: 1271396448@qq.com
7 | *
8 | * @Desc: 返回的整个的信息 sample: {"code":10000,"msg":"请求成功","data":{"username":"用户名","password":"密码"}} 只需要写data里面的就可以
9 | */
10 | public class ExampleBean {
11 |
12 | private String username;
13 | private String password;
14 |
15 | public String getUsername() {
16 | return username;
17 | }
18 |
19 | public void setUsername(String username) {
20 | this.username = username;
21 | }
22 |
23 | public String getPassword() {
24 | return password;
25 | }
26 |
27 | public void setPassword(String password) {
28 | this.password = password;
29 | }
30 |
31 | @Override
32 | public String toString() {
33 | return "ExampleBean{" +
34 | "username='" + username + '\'' +
35 | ", password='" + password + '\'' +
36 | '}';
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/bean/ExampleFileBean.java:
--------------------------------------------------------------------------------
1 | package com.common.http.bean;
2 |
3 | /**
4 | * @Author: 张鹏飞
5 | * @Date: 2020/11/12
6 | * @Email: 1271396448@qq.com
7 | *
8 | * @Desc: 返回的整个的信息 sample: {"code":10000,"msg":"请求成功","data":{"fileUrl":"文件地址"}} 只需要写data里面的就可以
9 | */
10 | public class ExampleFileBean {
11 |
12 | private String fileUrl;
13 |
14 | public String getFileUrl() {
15 | return fileUrl;
16 | }
17 |
18 | public void setFileUrl(String fileUrl) {
19 | this.fileUrl = fileUrl;
20 | }
21 |
22 | @Override
23 | public String toString() {
24 | return "ExampleFileBean{" +
25 | "fileUrl='" + fileUrl + '\'' +
26 | '}';
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/bean/ExampleListBean.java:
--------------------------------------------------------------------------------
1 | package com.common.http.bean;
2 |
3 | /**
4 | * @Author: 张鹏飞
5 | * @Email: 1271396448@qq.com
6 | * @Date: 2020/11/18
7 | *
8 | * @Desc: 集合例子Bean
9 | */
10 | public class ExampleListBean {
11 |
12 | private int id;
13 | private String title;
14 | private String content;
15 | private String time;
16 |
17 | /**
18 | * 多选用到,如果选中就设为true,未选中就设置为false
19 | */
20 | private boolean checked;
21 |
22 | public boolean isChecked() {
23 | return checked;
24 | }
25 |
26 | public void setChecked(boolean checked) {
27 | this.checked = checked;
28 | }
29 |
30 | public int getId() {
31 | return id;
32 | }
33 |
34 | public void setId(int id) {
35 | this.id = id;
36 | }
37 |
38 | public String getTitle() {
39 | return title;
40 | }
41 |
42 | public void setTitle(String title) {
43 | this.title = title;
44 | }
45 |
46 | public String getContent() {
47 | return content;
48 | }
49 |
50 | public void setContent(String content) {
51 | this.content = content;
52 | }
53 |
54 | public String getTime() {
55 | return time;
56 | }
57 |
58 | public void setTime(String time) {
59 | this.time = time;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/helper/Mobile.java:
--------------------------------------------------------------------------------
1 | package com.common.http.helper;
2 |
3 | import java.security.PublicKey;
4 | import java.util.HashMap;
5 |
6 | /**
7 | * @Author: 张鹏飞
8 | * @Email: 1271396448@qq.com
9 | *
10 | * @Desc: 接口参数封装
11 | */
12 | public class Mobile {
13 |
14 | /**
15 | * example参数
16 | *
17 | * @return
18 | */
19 | public static HashMap userLogin(String params1, String params2) {
20 | HashMap map = new HashMap<>();
21 | map.put("params1", params1);
22 | map.put("params2", params2);
23 | return map;
24 | }
25 |
26 | /**
27 | * 公共的map
28 | *
29 | * @param username
30 | * @param password
31 | * @return
32 | */
33 | public static HashMap commonParamsMap(String username, String password) {
34 | HashMap map = new HashMap<>();
35 | //用户名的参数key: username
36 | map.put("username", username);
37 | //密码的参数key: password
38 | map.put("password", password);
39 | return map;
40 | }
41 |
42 | /**
43 | * 获取集合
44 | * @param page: 页数
45 | * @param pageNum: 每页的条目数
46 | * @return
47 | */
48 | public static HashMap getList(int page, int pageNum) {
49 | HashMap map = new HashMap<>();
50 | map.put("page",page);
51 | map.put("pageNum",pageNum);
52 | return map;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/helper/RequestBodyHelper.java:
--------------------------------------------------------------------------------
1 | package com.common.http.helper;
2 |
3 | import com.google.gson.Gson;
4 |
5 | import java.util.HashMap;
6 |
7 | import okhttp3.MediaType;
8 | import okhttp3.RequestBody;
9 |
10 | /**
11 | * Created by zhang on 2020/7/17
12 | *
13 | * HashMap转RequestBody
14 | */
15 | public class RequestBodyHelper {
16 |
17 | public static RequestBody getRequestBody(HashMap map) {
18 | Gson gson = new Gson();
19 | String toJson = gson.toJson(map);
20 | return RequestBody.create(MediaType.parse("application/json;charset=utf-8"), toJson);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/helper/upload/OnUploadFileListener.java:
--------------------------------------------------------------------------------
1 | package com.common.http.helper.upload;
2 |
3 | /**
4 | * @Author: 张
5 | * @Email: 1271396448@qq.com
6 | * @Date: 2019/7/22 2:34 PM
7 | *
8 | * 文件上传结果监听
9 | */
10 |
11 | public interface OnUploadFileListener {
12 | //上传成功
13 | void onUploadFileSuccess(String imgUrl);
14 |
15 | //上传失败
16 | void onUploadFileFailed(String errorMsg);
17 | }
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/helper/upload/UploadFileHelper.java:
--------------------------------------------------------------------------------
1 | package com.common.http.helper.upload;
2 |
3 | import android.content.Context;
4 |
5 | import com.common.http.XRetrofit;
6 | import com.common.http.base.BaseObserver;
7 | import com.common.http.base.RxJavaHelper;
8 | import com.common.http.bean.ExampleFileBean;
9 | import com.common.http.helper.CompressHelper;
10 | import com.common.http.helper.Mobile;
11 | import com.common.util.BitmapUtil;
12 |
13 | import java.io.File;
14 | import java.io.UnsupportedEncodingException;
15 | import java.net.URLEncoder;
16 |
17 | import okhttp3.MediaType;
18 | import okhttp3.MultipartBody;
19 | import okhttp3.RequestBody;
20 |
21 | /**
22 | * @Author: 张
23 | * @Email: 1271396448@qq.com
24 | * @Date: 2019/7/22 2:29 PM
25 | *
26 | * 文件上传辅助类
27 | */
28 | public class UploadFileHelper {
29 |
30 | /**
31 | * 上传文件
32 | *
33 | * @param context:
34 | * @param imgPath; 图片路径
35 | */
36 | public static void uploadFile(Context context, String imgPath, OnUploadFileListener onUploadFileListener) {
37 | String fileName = "file_name.png";
38 | //压缩图片
39 | File uploadFile = CompressHelper.getDefault(context).compressToFile(new File(imgPath));
40 | RequestBody body = MultipartBody.create(MediaType.parse("multipart/form-data"), uploadFile);
41 | try {
42 | fileName = URLEncoder.encode(uploadFile.getName(), "UTF-8");
43 | } catch (UnsupportedEncodingException e) {
44 | e.printStackTrace();
45 | }
46 | //file 是后台定义的文件的参数名
47 | MultipartBody.Part part = MultipartBody.Part.createFormData("file", fileName, body);
48 | XRetrofit.getApi()
49 | .testUploadFile(part, Mobile.commonParamsMap("参数1", "参数2"))
50 | .compose(new RxJavaHelper().observeOnMainThread())
51 | .subscribe(new BaseObserver(context) {
52 | @Override
53 | public void onSuccess(ExampleFileBean response) {
54 | if (response == null) {
55 | if (onUploadFileListener != null)
56 | onUploadFileListener.onUploadFileFailed("服务器返回为空");
57 | return;
58 | }
59 | //上传成功,返回在线url地址
60 | if (onUploadFileListener != null)
61 | onUploadFileListener.onUploadFileSuccess(response.getFileUrl());
62 | //删除压缩的文件
63 | BitmapUtil.deleteImage(context, uploadFile);
64 | }
65 |
66 | @Override
67 | public void onError(Throwable e) {
68 | super.onError(e);
69 | //上传失败
70 | if (onUploadFileListener != null)
71 | onUploadFileListener.onUploadFileFailed(e.getMessage());
72 | //删除压缩的文件
73 | BitmapUtil.deleteImage(context, uploadFile);
74 | }
75 | });
76 | }
77 |
78 | }
79 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/http/intercept/HttpIntercept.java:
--------------------------------------------------------------------------------
1 | package com.common.http.intercept;
2 |
3 |
4 | import com.blankj.utilcode.util.LogUtils;
5 |
6 | import java.io.IOException;
7 |
8 | import okhttp3.HttpUrl;
9 | import okhttp3.Interceptor;
10 | import okhttp3.Request;
11 | import okhttp3.Response;
12 | import okhttp3.logging.HttpLoggingInterceptor;
13 |
14 | /**
15 | * @Author: 张鹏飞
16 | * @Email: 1271396448@qq.com
17 | *
18 | * @Desc: 网络拦截器
19 | */
20 | public class HttpIntercept implements Interceptor {
21 | @Override
22 | public Response intercept(Chain chain) throws IOException {
23 | Request request = chain.request();
24 | HttpUrl build = request.url()
25 | .newBuilder()
26 | .addQueryParameter("userId", "userId")//公共参数
27 | .build();
28 | Request requestNew = request.newBuilder()
29 | .url(build)
30 | .addHeader("userId", "userId")//请求头
31 | .build();
32 | return chain.proceed(requestNew);
33 | }
34 |
35 | /**
36 | * 数据请求拦截器
37 | *
38 | * @return
39 | */
40 | public HttpLoggingInterceptor httpBodyIntercept() {
41 | HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
42 | @Override
43 | public void log(String message) {
44 | LogUtils.i(message);
45 | }
46 | });
47 | logging.setLevel(HttpLoggingInterceptor.Level.BODY);
48 | return logging;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/BaseSectionRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter;
2 |
3 | import android.view.ViewGroup;
4 |
5 | import com.common.library.bravh_rvadapter.entity.SectionEntity;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
11 | */
12 | public abstract class BaseSectionRecyclerAdapter extends BaseRecyclerAdapter {
13 |
14 |
15 | protected int mSectionHeadResId;
16 | protected static final int SECTION_HEADER_VIEW = 0x00000444;
17 |
18 | /**
19 | * Same as QuickAdapter#QuickAdapter(Context,int) but with
20 | * some initialization data.
21 | *
22 | * @param sectionHeadResId The section head layout_game_detail_outs_more_image_progress_bar id for each item
23 | * @param layoutResId The layout_game_detail_outs_more_image_progress_bar resource id of each item.
24 | * @param data A new list is created out of this one to avoid mutable list
25 | */
26 | public BaseSectionRecyclerAdapter(int layoutResId, int sectionHeadResId, List data) {
27 | super(layoutResId, data);
28 | this.mSectionHeadResId = sectionHeadResId;
29 | }
30 |
31 | @Override
32 | protected int getDefItemViewType(int position) {
33 | return mData.get(position).isHeader ? SECTION_HEADER_VIEW : 0;
34 | }
35 |
36 | @Override
37 | protected K onCreateDefViewHolder(ViewGroup parent, int viewType) {
38 | if (viewType == SECTION_HEADER_VIEW)
39 | return createBaseViewHolder(getItemView(mSectionHeadResId, parent));
40 |
41 | return super.onCreateDefViewHolder(parent, viewType);
42 | }
43 |
44 | @Override
45 | protected boolean isFixedViewType(int type) {
46 | return super.isFixedViewType(type) || type == SECTION_HEADER_VIEW;
47 | }
48 |
49 | @Override
50 | public void onBindViewHolder(K holder, int position) {
51 | switch (holder.getItemViewType()) {
52 | case SECTION_HEADER_VIEW:
53 | setFullSpan(holder);
54 | convertHead(holder, getItem(position - getHeaderLayoutCount()));
55 | break;
56 | default:
57 | super.onBindViewHolder(holder, position);
58 | break;
59 | }
60 | }
61 |
62 | protected abstract void convertHead(K holder, T item);
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/MultipleItemRvAdapter.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter;
2 |
3 | import android.util.SparseArray;
4 | import android.view.View;
5 |
6 | import androidx.annotation.Nullable;
7 |
8 | import com.common.library.bravh_rvadapter.provider.BaseItemProvider;
9 | import com.common.library.bravh_rvadapter.util.MultiTypeDelegate;
10 | import com.common.library.bravh_rvadapter.util.ProviderDelegate;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * https://github.com/chaychan
16 | * @author ChayChan
17 | * @description:
18 | * When there are multiple entries, avoid too much business logic in convert(),Put the logic of each item in the corresponding ItemProvider
19 | * 当有多种条目的时候,避免在convert()中做太多的业务逻辑,把逻辑放在对应的ItemProvider中
20 | * @date 2018/3/21 9:55
21 | */
22 |
23 | public abstract class MultipleItemRvAdapter extends BaseRecyclerAdapter {
24 |
25 | private SparseArray mItemProviders;
26 | protected ProviderDelegate mProviderDelegate;
27 |
28 | public MultipleItemRvAdapter(@Nullable List data) {
29 | super(data);
30 | }
31 |
32 | /**
33 | * 用于adapter构造函数完成参数的赋值后调用
34 | * Called after the assignment of the argument to the adapter constructor
35 | */
36 | public void finishInitialize() {
37 | mProviderDelegate = new ProviderDelegate();
38 |
39 | setMultiTypeDelegate(new MultiTypeDelegate() {
40 |
41 | @Override
42 | protected int getItemType(T t) {
43 | return getViewType(t);
44 | }
45 | });
46 |
47 | registerItemProvider();
48 |
49 | mItemProviders = mProviderDelegate.getItemProviders();
50 |
51 | for (int i = 0; i < mItemProviders.size(); i++) {
52 | int key = mItemProviders.keyAt(i);
53 | BaseItemProvider provider = mItemProviders.get(key);
54 | provider.mData = mData;
55 | getMultiTypeDelegate().registerItemType(key, provider.layout());
56 | }
57 | }
58 |
59 | protected abstract int getViewType(T t);
60 |
61 | public abstract void registerItemProvider();
62 |
63 | @Override
64 | protected void convert(V helper, T item) {
65 | int itemViewType = helper.getItemViewType();
66 | BaseItemProvider provider = mItemProviders.get(itemViewType);
67 |
68 | provider.mContext = helper.itemView.getContext();
69 |
70 | int position = helper.getLayoutPosition() - getHeaderLayoutCount();
71 | provider.convert(helper, item, position);
72 |
73 | bindClick(helper, item, position, provider);
74 | }
75 |
76 | private void bindClick(final V helper, final T item, final int position, final BaseItemProvider provider) {
77 | OnItemClickListener clickListener = getOnItemClickListener();
78 | OnItemLongClickListener longClickListener = getOnItemLongClickListener();
79 |
80 | if (clickListener != null && longClickListener != null){
81 | //如果已经设置了子条目点击监听和子条目长按监听
82 | // If you have set up a sub-entry click monitor and sub-entries long press listen
83 | return;
84 | }
85 |
86 | View itemView = helper.itemView;
87 |
88 | if (clickListener == null){
89 | //如果没有设置点击监听,则回调给itemProvider
90 | //Callback to itemProvider if no click listener is set
91 | itemView.setOnClickListener(new View.OnClickListener() {
92 | @Override
93 | public void onClick(View v) {
94 | provider.onClick(helper, item, position);
95 | }
96 | });
97 | }
98 |
99 | if (longClickListener == null){
100 | //如果没有设置长按监听,则回调给itemProvider
101 | // If you do not set a long press listener, callback to the itemProvider
102 | itemView.setOnLongClickListener(new View.OnLongClickListener() {
103 | @Override
104 | public boolean onLongClick(View v) {
105 | return provider.onLongClick(helper, item, position);
106 | }
107 | });
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/animation/AlphaInAnimation.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 |
8 | /**
9 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
10 | */
11 | public class AlphaInAnimation implements BaseAnimation {
12 | private static final float DEFAULT_ALPHA_FROM = 0f;
13 | private final float mFrom;
14 |
15 | public AlphaInAnimation() {
16 | this(DEFAULT_ALPHA_FROM);
17 | }
18 |
19 | public AlphaInAnimation(float from) {
20 | mFrom = from;
21 | }
22 |
23 | @Override
24 | public Animator[] getAnimators(View view) {
25 | return new Animator[]{ObjectAnimator.ofFloat(view, "alpha", mFrom, 1f)};
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/animation/BaseAnimation.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.view.View;
5 |
6 | /**
7 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
8 | */
9 | public interface BaseAnimation {
10 | Animator[] getAnimators(View view);
11 | }
12 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/animation/ScaleInAnimation.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 |
8 | /**
9 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
10 | */
11 | public class ScaleInAnimation implements BaseAnimation {
12 | private static final float DEFAULT_SCALE_FROM = .5f;
13 | private final float mFrom;
14 |
15 | public ScaleInAnimation() {
16 | this(DEFAULT_SCALE_FROM);
17 | }
18 |
19 | public ScaleInAnimation(float from) {
20 | mFrom = from;
21 | }
22 |
23 | @Override
24 | public Animator[] getAnimators(View view) {
25 | ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", mFrom, 1f);
26 | ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", mFrom, 1f);
27 | return new ObjectAnimator[]{scaleX, scaleY};
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/animation/SlideInBottomAnimation.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 |
8 | /**
9 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
10 | */
11 | public class SlideInBottomAnimation implements BaseAnimation {
12 | @Override
13 | public Animator[] getAnimators(View view) {
14 | return new Animator[]{
15 | ObjectAnimator.ofFloat(view, "translationY", view.getMeasuredHeight(), 0)
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/animation/SlideInLeftAnimation.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 |
8 | /**
9 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
10 | */
11 | public class SlideInLeftAnimation implements BaseAnimation {
12 | @Override
13 | public Animator[] getAnimators(View view) {
14 | return new Animator[]{
15 | ObjectAnimator.ofFloat(view, "translationX", -view.getRootView().getWidth(), 0)
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/animation/SlideInRightAnimation.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.animation;
2 |
3 | import android.animation.Animator;
4 | import android.animation.ObjectAnimator;
5 | import android.view.View;
6 |
7 |
8 | /**
9 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
10 | */
11 | public class SlideInRightAnimation implements BaseAnimation {
12 | @Override
13 | public Animator[] getAnimators(View view) {
14 | return new Animator[]{
15 | ObjectAnimator.ofFloat(view, "translationX", view.getRootView().getWidth(), 0)
16 | };
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/entity/AbstractExpandableItem.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.entity;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | /**
7 | * A helper to implement expandable item.
8 | * if you don't want to extent a class, you can also implement the interface IExpandable
9 | * Created by luoxw on 2016/8/9.
10 | */
11 | public abstract class AbstractExpandableItem implements IExpandable {
12 | protected boolean mExpandable = false;
13 | protected List mSubItems;
14 |
15 | @Override
16 | public boolean isExpanded() {
17 | return mExpandable;
18 | }
19 |
20 | @Override
21 | public void setExpanded(boolean expanded) {
22 | mExpandable = expanded;
23 | }
24 |
25 | @Override
26 | public List getSubItems() {
27 | return mSubItems;
28 | }
29 |
30 | public boolean hasSubItem() {
31 | return mSubItems != null && mSubItems.size() > 0;
32 | }
33 |
34 | public void setSubItems(List list) {
35 | mSubItems = list;
36 | }
37 |
38 | public T getSubItem(int position) {
39 | if (hasSubItem() && position < mSubItems.size()) {
40 | return mSubItems.get(position);
41 | } else {
42 | return null;
43 | }
44 | }
45 |
46 | public int getSubItemPosition(T subItem) {
47 | return mSubItems != null ? mSubItems.indexOf(subItem) : -1;
48 | }
49 |
50 | public void addSubItem(T subItem) {
51 | if (mSubItems == null) {
52 | mSubItems = new ArrayList<>();
53 | }
54 | mSubItems.add(subItem);
55 | }
56 |
57 | public void addSubItem(int position, T subItem) {
58 | if (mSubItems != null && position >= 0 && position < mSubItems.size()) {
59 | mSubItems.add(position, subItem);
60 | } else {
61 | addSubItem(subItem);
62 | }
63 | }
64 |
65 | public boolean contains(T subItem) {
66 | return mSubItems != null && mSubItems.contains(subItem);
67 | }
68 |
69 | public boolean removeSubItem(T subItem) {
70 | return mSubItems != null && mSubItems.remove(subItem);
71 | }
72 |
73 | public boolean removeSubItem(int position) {
74 | if (mSubItems != null && position >= 0 && position < mSubItems.size()) {
75 | mSubItems.remove(position);
76 | return true;
77 | }
78 | return false;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/entity/IExpandable.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.entity;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * implement the interface if the item is expandable
7 | * Created by luoxw on 2016/8/8.
8 | */
9 | public interface IExpandable {
10 | boolean isExpanded();
11 | void setExpanded(boolean expanded);
12 | List getSubItems();
13 |
14 | /**
15 | * Get the level of this item. The level start from 0.
16 | * If you don't care about the level, just return a negative.
17 | */
18 | int getLevel();
19 | }
20 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/entity/MultiItemEntity.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.entity;
2 |
3 | /**
4 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
5 | */
6 | public interface MultiItemEntity {
7 | int getItemType();
8 | }
9 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/entity/SectionEntity.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
7 | */
8 | public abstract class SectionEntity implements Serializable {
9 | public boolean isHeader;
10 | public T t;
11 | public String header;
12 |
13 | public SectionEntity(boolean isHeader, String header) {
14 | this.isHeader = isHeader;
15 | this.header = header;
16 | this.t = null;
17 | }
18 |
19 | public SectionEntity(T t) {
20 | this.isHeader = false;
21 | this.header = null;
22 | this.t = t;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/entity/SectionMultiEntity.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.entity;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
7 | */
8 | public abstract class SectionMultiEntity implements Serializable, MultiItemEntity {
9 |
10 | public boolean isHeader;
11 | public T t;
12 | public String header;
13 |
14 | public SectionMultiEntity(boolean isHeader, String header) {
15 | this.isHeader = isHeader;
16 | this.header = header;
17 | this.t = null;
18 | }
19 |
20 | public SectionMultiEntity(T t) {
21 | this.isHeader = false;
22 | this.header = null;
23 | this.t = t;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/listener/OnItemDragListener.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.listener;
2 |
3 |
4 | import androidx.recyclerview.widget.RecyclerView;
5 |
6 | /**
7 | * Created by luoxw on 2016/6/20.
8 | */
9 | public interface OnItemDragListener {
10 | void onItemDragStart(RecyclerView.ViewHolder viewHolder, int pos);
11 |
12 | void onItemDragMoving(RecyclerView.ViewHolder source, int from, RecyclerView.ViewHolder target, int to);
13 |
14 | void onItemDragEnd(RecyclerView.ViewHolder viewHolder, int pos);
15 | }
16 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/listener/OnItemSwipeListener.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.listener;
2 |
3 | import android.graphics.Canvas;
4 |
5 | import androidx.recyclerview.widget.RecyclerView;
6 |
7 | /**
8 | * Created by luoxw on 2016/6/23.
9 | */
10 | public interface OnItemSwipeListener {
11 | /**
12 | * Called when the swipe action start.
13 | */
14 | void onItemSwipeStart(RecyclerView.ViewHolder viewHolder, int pos);
15 |
16 | /**
17 | * Called when the swipe action is over.
18 | * If you change the view on the start, you should reset is here, no matter the item has swiped or not.
19 | *
20 | * @param pos If the view is swiped, pos will be negative.
21 | */
22 | void clearView(RecyclerView.ViewHolder viewHolder, int pos);
23 |
24 | /**
25 | * Called when item is swiped, the view is going to be removed from the adapter.
26 | */
27 | void onItemSwiped(RecyclerView.ViewHolder viewHolder, int pos);
28 |
29 | /**
30 | * Draw on the empty edge when swipe moving
31 | *
32 | * @param canvas the empty edge's canvas
33 | * @param viewHolder The ViewHolder which is being interacted by the User or it was
34 | * interacted and simply animating to its original position
35 | * @param dX The amount of horizontal displacement caused by user's action
36 | * @param dY The amount of vertical displacement caused by user's action
37 | * @param isCurrentlyActive True if this view is currently being controlled by the user or
38 | * false it is simply animating back to its original state.
39 | */
40 | void onItemSwipeMoving(Canvas canvas, RecyclerView.ViewHolder viewHolder, float dX, float dY, boolean isCurrentlyActive);
41 | }
42 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/loadmore/LoadMoreView.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.loadmore;
2 |
3 | import androidx.annotation.IdRes;
4 | import androidx.annotation.LayoutRes;
5 |
6 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
7 |
8 | /**
9 | * Created by BlingBling on 2016/11/11.
10 | */
11 |
12 | public abstract class LoadMoreView {
13 |
14 | public static final int STATUS_DEFAULT = 1;
15 | public static final int STATUS_LOADING = 2;
16 | public static final int STATUS_FAIL = 3;
17 | public static final int STATUS_END = 4;
18 |
19 | private int mLoadMoreStatus = STATUS_DEFAULT;
20 | private boolean mLoadMoreEndGone = false;
21 |
22 | public void setLoadMoreStatus(int loadMoreStatus) {
23 | this.mLoadMoreStatus = loadMoreStatus;
24 | }
25 |
26 | public int getLoadMoreStatus() {
27 | return mLoadMoreStatus;
28 | }
29 |
30 | public void convert(RecyclerViewHolder holder) {
31 | switch (mLoadMoreStatus) {
32 | case STATUS_LOADING:
33 | visibleLoading(holder, true);
34 | visibleLoadFail(holder, false);
35 | visibleLoadEnd(holder, false);
36 | break;
37 | case STATUS_FAIL:
38 | visibleLoading(holder, false);
39 | visibleLoadFail(holder, true);
40 | visibleLoadEnd(holder, false);
41 | break;
42 | case STATUS_END:
43 | visibleLoading(holder, false);
44 | visibleLoadFail(holder, false);
45 | visibleLoadEnd(holder, true);
46 | break;
47 | case STATUS_DEFAULT:
48 | visibleLoading(holder, false);
49 | visibleLoadFail(holder, false);
50 | visibleLoadEnd(holder, false);
51 | break;
52 | default:
53 | break;
54 | }
55 | }
56 |
57 | private void visibleLoading(RecyclerViewHolder holder, boolean visible) {
58 | holder.setGone(getLoadingViewId(), visible);
59 | }
60 |
61 | private void visibleLoadFail(RecyclerViewHolder holder, boolean visible) {
62 | holder.setGone(getLoadFailViewId(), visible);
63 | }
64 |
65 | private void visibleLoadEnd(RecyclerViewHolder holder, boolean visible) {
66 | final int loadEndViewId = getLoadEndViewId();
67 | if (loadEndViewId != 0) {
68 | holder.setGone(loadEndViewId, visible);
69 | }
70 | }
71 |
72 | public final void setLoadMoreEndGone(boolean loadMoreEndGone) {
73 | this.mLoadMoreEndGone = loadMoreEndGone;
74 | }
75 |
76 | public final boolean isLoadEndMoreGone() {
77 | if (getLoadEndViewId() == 0) {
78 | return true;
79 | }
80 | return mLoadMoreEndGone;
81 | }
82 |
83 | /**
84 | * No more data is hidden
85 | *
86 | * @return true for no more data hidden load more
87 | */
88 | @Deprecated
89 | public boolean isLoadEndGone() {
90 | return mLoadMoreEndGone;
91 | }
92 |
93 | /**
94 | * load more layout_game_detail_outs_more_image_progress_bar
95 | *
96 | * @return
97 | */
98 | public abstract
99 | @LayoutRes
100 | int getLayoutId();
101 |
102 | /**
103 | * loading view
104 | *
105 | * @return
106 | */
107 | protected abstract
108 | @IdRes
109 | int getLoadingViewId();
110 |
111 | /**
112 | * load fail view
113 | *
114 | * @return
115 | */
116 | protected abstract
117 | @IdRes
118 | int getLoadFailViewId();
119 |
120 | /**
121 | * load end view, you can return 0
122 | *
123 | * @return
124 | */
125 | protected abstract
126 | @IdRes
127 | int getLoadEndViewId();
128 | }
129 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/loadmore/SimpleLoadMoreView.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.loadmore;
2 |
3 |
4 | import com.common.R;
5 |
6 | /**
7 | * Created by BlingBling on 2016/10/11.
8 | */
9 |
10 | public final class SimpleLoadMoreView extends LoadMoreView {
11 |
12 | @Override
13 | public int getLayoutId() {
14 | return R.layout.brvah_quick_view_load_more;
15 | }
16 |
17 | @Override
18 | protected int getLoadingViewId() {
19 | return R.id.load_more_loading_view;
20 | }
21 |
22 | @Override
23 | protected int getLoadFailViewId() {
24 | return R.id.load_more_load_fail_view;
25 | }
26 |
27 | @Override
28 | protected int getLoadEndViewId() {
29 | return R.id.load_more_load_end_view;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/provider/BaseItemProvider.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.provider;
2 |
3 | import android.content.Context;
4 |
5 | import com.common.library.bravh_rvadapter.RecyclerViewHolder;
6 |
7 | import java.util.List;
8 |
9 | /**
10 | * https://github.com/chaychan
11 | * @author ChayChan
12 | * @description: The base class of ItemProvider
13 | * @date 2018/3/21 10:41
14 | */
15 |
16 | public abstract class BaseItemProvider {
17 |
18 | public Context mContext;
19 | public List mData;
20 |
21 | //子类须重写该方法返回viewType
22 | //Rewrite this method to return viewType
23 | public abstract int viewType();
24 |
25 | //子类须重写该方法返回layout
26 | //Rewrite this method to return layout_game_detail_outs_more_image_progress_bar
27 | public abstract int layout();
28 |
29 | public abstract void convert(V helper, T data, int position);
30 |
31 | //子类若想实现条目点击事件则重写该方法
32 | //Subclasses override this method if you want to implement an item click event
33 | public void onClick(V helper, T data, int position){};
34 |
35 | //子类若想实现条目长按事件则重写该方法
36 | //Subclasses override this method if you want to implement an item long press event
37 | public boolean onLongClick(V helper, T data, int position){return false;};
38 | }
39 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/util/ItemProviderException.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.util;
2 |
3 | /**
4 | * @author ChayChan
5 | * @description: ItemProviderException
6 | * @date 2018/4/12 9:10
7 | */
8 |
9 | public class ItemProviderException extends NullPointerException {
10 |
11 | public ItemProviderException(String message) {
12 | super(message);
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/util/MultiTypeDelegate.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.util;
2 |
3 | import android.util.SparseIntArray;
4 |
5 | import androidx.annotation.LayoutRes;
6 |
7 | import java.util.List;
8 |
9 | import static com.common.library.bravh_rvadapter.BaseMultiItemRecyclerAdapter.TYPE_NOT_FOUND;
10 |
11 |
12 | /**
13 | * help you to achieve multi type easily
14 | *
15 | * Created by tysheng
16 | * Date: 2017/4/6 08:41.
17 | * Email: tyshengsx@gmail.com
18 | *
19 | *
20 | * more information: https://github.com/CymChad/BaseRecyclerViewAdapterHelper/issues/968
21 | */
22 |
23 | public abstract class MultiTypeDelegate {
24 |
25 | private static final int DEFAULT_VIEW_TYPE = -0xff;
26 | private SparseIntArray layouts;
27 | private boolean autoMode, selfMode;
28 |
29 | public MultiTypeDelegate(SparseIntArray layouts) {
30 | this.layouts = layouts;
31 | }
32 |
33 | public MultiTypeDelegate() {
34 | }
35 |
36 | public final int getDefItemViewType(List data, int position) {
37 | T item = data.get(position);
38 | return item != null ? getItemType(item) : DEFAULT_VIEW_TYPE;
39 | }
40 |
41 | /**
42 | * get the item type from specific entity.
43 | *
44 | * @param t entity
45 | * @return item type
46 | */
47 | protected abstract int getItemType(T t);
48 |
49 | public final int getLayoutId(int viewType) {
50 | return this.layouts.get(viewType, TYPE_NOT_FOUND);
51 | }
52 |
53 | private void addItemType(int type, @LayoutRes int layoutResId) {
54 | if (this.layouts == null) {
55 | this.layouts = new SparseIntArray();
56 | }
57 | this.layouts.put(type, layoutResId);
58 | }
59 |
60 | /**
61 | * auto increase type vale, start from 0.
62 | *
63 | * @param layoutResIds layout_game_detail_outs_more_image_progress_bar id arrays
64 | * @return MultiTypeDelegate
65 | */
66 | public MultiTypeDelegate registerItemTypeAutoIncrease(@LayoutRes int... layoutResIds) {
67 | autoMode = true;
68 | checkMode(selfMode);
69 | for (int i = 0; i < layoutResIds.length; i++) {
70 | addItemType(i, layoutResIds[i]);
71 | }
72 | return this;
73 | }
74 |
75 | /**
76 | * set your own type one by one.
77 | *
78 | * @param type type value
79 | * @param layoutResId layout_game_detail_outs_more_image_progress_bar id
80 | * @return MultiTypeDelegate
81 | */
82 | public MultiTypeDelegate registerItemType(int type, @LayoutRes int layoutResId) {
83 | selfMode = true;
84 | checkMode(autoMode);
85 | addItemType(type, layoutResId);
86 | return this;
87 | }
88 |
89 | private void checkMode(boolean mode) {
90 | if (mode) {
91 | throw new IllegalArgumentException("Don't mess two register mode");
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/util/ProviderDelegate.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.util;
2 |
3 | import android.util.SparseArray;
4 |
5 | import com.common.library.bravh_rvadapter.provider.BaseItemProvider;
6 |
7 |
8 | /**
9 | * https://github.com/chaychan
10 | * @author ChayChan
11 | * @date 2018/3/21 11:04
12 | */
13 |
14 | public class ProviderDelegate {
15 |
16 | private SparseArray mItemProviders = new SparseArray<>();
17 |
18 | public void registerProvider(BaseItemProvider provider){
19 | if (provider == null){
20 | throw new ItemProviderException("ItemProvider can not be null");
21 | }
22 |
23 | int viewType = provider.viewType();
24 |
25 | if (mItemProviders.get(viewType) == null){
26 | mItemProviders.put(viewType,provider);
27 | }
28 | }
29 |
30 | public SparseArray getItemProviders(){
31 | return mItemProviders;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/library/bravh_rvadapter/util/TouchEventUtil.java:
--------------------------------------------------------------------------------
1 | package com.common.library.bravh_rvadapter.util;
2 |
3 | import android.view.MotionEvent;
4 |
5 | public class TouchEventUtil {
6 |
7 | public static String getTouchAction(int actionId) {
8 | String actionName = "Unknow:id=" + actionId;
9 | switch (actionId) {
10 | case MotionEvent.ACTION_DOWN:
11 | actionName = "ACTION_DOWN";
12 | break;
13 | case MotionEvent.ACTION_MOVE:
14 | actionName = "ACTION_MOVE";
15 | break;
16 | case MotionEvent.ACTION_UP:
17 | actionName = "ACTION_UP";
18 | break;
19 | case MotionEvent.ACTION_CANCEL:
20 | actionName = "ACTION_CANCEL";
21 | break;
22 | case MotionEvent.ACTION_OUTSIDE:
23 | actionName = "ACTION_OUTSIDE";
24 | break;
25 | default:
26 | break;
27 | }
28 | return actionName;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/GetPathFromUri.java:
--------------------------------------------------------------------------------
1 | package com.common.util;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.content.ContentUris;
5 | import android.content.Context;
6 | import android.database.Cursor;
7 | import android.net.Uri;
8 | import android.os.Build;
9 | import android.os.Environment;
10 | import android.provider.DocumentsContract;
11 | import android.provider.MediaStore;
12 |
13 | /**
14 | * @Author: 张
15 | * @Email: 1271396448@qq.com
16 | * @Date: 2016/11/13
17 | *
18 | * 获取相册返回照片
19 | */
20 |
21 | public class GetPathFromUri {
22 | /**
23 | * 根据Uri获取图片的绝对路径
24 | *
25 | * @param context 上下文对象
26 | * @param uri 图片的Uri
27 | * @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
28 | */
29 | public static String getRealPathFromUri(Context context, Uri uri) {
30 | int sdkVersion = Build.VERSION.SDK_INT;
31 | if (sdkVersion >= 19) { // api >= 19
32 | return getRealPathFromUriAboveApi19(context, uri);
33 | } else { // api < 19
34 | return getRealPathFromUriBelowAPI19(context, uri);
35 | }
36 | }
37 |
38 | /**
39 | * 适配api19以下(不包括api19),根据uri获取图片的绝对路径
40 | *
41 | * @param context 上下文对象
42 | * @param uri 图片的Uri
43 | * @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
44 | */
45 | private static String getRealPathFromUriBelowAPI19(Context context, Uri uri) {
46 | return getDataColumn(context, uri, null, null);
47 | }
48 |
49 | /**
50 | * 适配api19及以上,根据uri获取图片的绝对路径
51 | *
52 | * @param context 上下文对象
53 | * @param uri 图片的Uri
54 | * @return 如果Uri对应的图片存在, 那么返回该图片的绝对路径, 否则返回null
55 | */
56 | @SuppressLint("NewApi")
57 | private static String getRealPathFromUriAboveApi19(Context context, Uri uri) {
58 | String filePath = null;
59 | if (DocumentsContract.isDocumentUri(context, uri)) {
60 | // 如果是document类型的 uri, 则通过document id来进行处理
61 | String documentId = DocumentsContract.getDocumentId(uri);
62 | if (isMediaDocument(uri)) { // MediaProvider
63 | // 使用':'分割
64 | String id = documentId.split(":")[1];
65 |
66 | String selection = MediaStore.Images.Media._ID + "=?";
67 | String[] selectionArgs = {id};
68 | filePath = getDataColumn(context, MediaStore.Images.Media.EXTERNAL_CONTENT_URI, selection, selectionArgs);
69 | } else if (isDownloadsDocument(uri)) { // DownloadsProvider
70 | Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(documentId));
71 | filePath = getDataColumn(context, contentUri, null, null);
72 | }
73 | } else if ("content".equalsIgnoreCase(uri.getScheme())) {
74 | // 如果是 content 类型的 Uri
75 | filePath = getDataColumn(context, uri, null, null);
76 | } else if ("file".equals(uri.getScheme())) {
77 | // 如果是 file 类型的 Uri,直接获取图片对应的路径
78 | filePath = uri.getPath();
79 | }
80 | return filePath;
81 | }
82 |
83 | /**
84 | * 获取数据库表中的 _data 列,即返回Uri对应的文件路径
85 | *
86 | */
87 | private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
88 | String path = null;
89 |
90 | String[] projection = new String[]{MediaStore.Images.Media.DATA};
91 | Cursor cursor = null;
92 | try {
93 | cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
94 | if (cursor != null && cursor.moveToFirst()) {
95 | int columnIndex = cursor.getColumnIndexOrThrow(projection[0]);
96 | path = cursor.getString(columnIndex);
97 | }
98 | } catch (Exception e) {
99 | if (cursor != null) {
100 | cursor.close();
101 | }
102 | }
103 | return path;
104 | }
105 |
106 | /**
107 | * @param uri the Uri to check
108 | * @return Whether the Uri authority is MediaProvider
109 | */
110 | private static boolean isMediaDocument(Uri uri) {
111 | return "com.android.providers.media.documents".equals(uri.getAuthority());
112 | }
113 |
114 | /**
115 | * @param uri the Uri to check
116 | * @return Whether the Uri authority is DownloadsProvider
117 | */
118 | private static boolean isDownloadsDocument(Uri uri) {
119 | return "com.android.providers.downloads.documents".equals(uri.getAuthority());
120 | }
121 | }
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/ParamUtil.java:
--------------------------------------------------------------------------------
1 | package com.common.util;
2 |
3 | import android.widget.EditText;
4 |
5 | /**
6 | * @Author: 张鹏飞
7 | * @Email: 1271396448@qq.com
8 | * @Date: 2020/8/30 13:27
9 | *
10 | * Desc: 参数处理的工具类
11 | */
12 | public class ParamUtil {
13 | /**
14 | * 字符串是否相同
15 | * @param str1
16 | * @param str2
17 | * @return
18 | */
19 | public static boolean isEquals(String str1, String str2) {
20 | return str1.equals(str2);
21 | }
22 |
23 | /**
24 | * 获取输入框字符串
25 | * @param editText
26 | * @return
27 | */
28 | public static String getEditStr(EditText editText) {
29 | return editText.getText().toString().trim();
30 | }
31 |
32 |
33 | /**
34 | * 验证是否为空参
35 | *
36 | * @param stringObj
37 | * @return
38 | */
39 | public static boolean isBlank(Object stringObj) {
40 | return null == stringObj || "".equals(stringObj.toString().trim());
41 | }
42 |
43 |
44 | /**
45 | * 字符串是否为空
46 | *
47 | * @param s
48 | * @return
49 | */
50 | public static boolean isBlank(CharSequence s) {
51 | if (s == null) {
52 | return true;
53 | } else {
54 | return s.length() == 0;
55 | }
56 | }
57 |
58 | /**
59 | * 数值是否为空
60 | *
61 | * @param value: 数字
62 | * @return
63 | */
64 | public static boolean isBlank(Integer value) {
65 | if (value == null) {
66 | return true;
67 | } else {
68 | return value == 0;
69 | }
70 | }
71 |
72 | /**
73 | * 数值是否为空
74 | *
75 | * @param value: 数字
76 | * @return
77 | */
78 | public static boolean isBlank(Long value) {
79 | if (value == null) {
80 | return true;
81 | } else {
82 | return value == 0;
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/SpUtil.java:
--------------------------------------------------------------------------------
1 | package com.common.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import java.util.Set;
7 |
8 | /**
9 | * Created by zhang on 2020/7/17
10 | *
11 | * Sp存储
12 | */
13 | public class SpUtil {
14 |
15 | private final static String SP_NAME = "sp_name";
16 | private static SharedPreferences sp;
17 | private static SharedPreferences.Editor edit;
18 |
19 | public static void init(Context context) {
20 | sp = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE);
21 | edit = sp.edit();
22 | }
23 |
24 |
25 | /**
26 | * obj仅限int,float,boolean,long,String类型
27 | */
28 | public static void put(String key, Object obj) {
29 | SharedPreferences.Editor editor = sp.edit();
30 | if (obj instanceof String) {
31 | editor.putString(key, (String) obj);
32 | } else if (obj instanceof Integer) {
33 | editor.putInt(key, (int) obj);
34 | } else if (obj instanceof Boolean) {
35 | editor.putBoolean(key, (boolean) obj);
36 | } else if (obj instanceof Float) {
37 | editor.putFloat(key, (float) obj);
38 | } else if (obj instanceof Long) {
39 | editor.putLong(key, (long) obj);
40 | } else if (obj instanceof Set) {
41 | editor.putStringSet(key, (Set) obj);
42 | }
43 | editor.apply();
44 | }
45 |
46 | public static String getString(String key){
47 | return sp.getString(key, "");
48 | }
49 |
50 | public static int getInt(String key){
51 | return sp.getInt(key, 0);
52 | }
53 | public static long getLong(String key){
54 | return sp.getLong(key, 0);
55 | }
56 |
57 | public static boolean getBoolean(String key){
58 | return sp.getBoolean(key, false);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/filedownload/FileDownloadHelper.java:
--------------------------------------------------------------------------------
1 | package com.common.util.filedownload;
2 |
3 | import com.blankj.utilcode.constant.PermissionConstants;
4 | import com.blankj.utilcode.util.AppUtils;
5 | import com.blankj.utilcode.util.LogUtils;
6 | import com.blankj.utilcode.util.PermissionUtils;
7 | import com.blankj.utilcode.util.ToastUtils;
8 | import com.liulishuo.filedownloader.BaseDownloadTask;
9 | import com.liulishuo.filedownloader.FileDownloadListener;
10 | import com.liulishuo.filedownloader.FileDownloadSampleListener;
11 | import com.liulishuo.filedownloader.FileDownloader;
12 |
13 | /**
14 | * @Author: 张
15 | * @Email: 1271396448@qq.com
16 | * @Date: 2019/8/16 5:17 PM
17 | *
18 | * 文件下载辅助类
19 | */
20 | public class FileDownloadHelper {
21 |
22 | private BaseDownloadTask baseDownloadTask;
23 |
24 | /**
25 | * 下载文件
26 | *
27 | * @param downloadUrl: 下载地址
28 | * @param savePath: 保存路径
29 | * @param isForceReDownload: 是否强制重新下载
30 | * @param onDownloadListener: 监听
31 | */
32 | public void downloadFile(String downloadUrl, String savePath, boolean isForceReDownload, OnDownloadListener onDownloadListener) {
33 | if (PermissionUtils.isGranted(PermissionConstants.STORAGE)) {
34 | //有权限
35 | startDownload(downloadUrl, savePath, isForceReDownload, onDownloadListener);
36 | } else {
37 | //没有权限
38 | PermissionUtils permission = PermissionUtils.permission(PermissionConstants.STORAGE);
39 | permission.request();
40 | permission.callback(new PermissionUtils.SimpleCallback() {
41 | @Override
42 | public void onGranted() {
43 | //同意
44 | startDownload(downloadUrl, savePath, isForceReDownload, onDownloadListener);
45 | }
46 |
47 | @Override
48 | public void onDenied() {
49 | ToastUtils.showShort("请开启文件读写权限");
50 | }
51 | });
52 | }
53 | }
54 |
55 |
56 | private void startDownload(String downloadUrl, String savePath, boolean isForceReDownload, OnDownloadListener onDownloadListener) {
57 | String[] split = downloadUrl.split("\\.");
58 | String fileName = "downloadFile." + split[split.length - 1];
59 | String filePath = savePath + fileName;
60 | baseDownloadTask = FileDownloader.getImpl().create(downloadUrl)
61 | .setPath(filePath)
62 | .setCallbackProgressTimes(300)
63 | .setForceReDownload(isForceReDownload)
64 | .setMinIntervalUpdateSpeed(400)
65 | .setListener(new FileDownloadListener() {
66 | @Override
67 | protected void pending(BaseDownloadTask task, int soFarBytes, int totalBytes) {
68 |
69 | }
70 |
71 | @Override
72 | protected void progress(BaseDownloadTask task, int soFarBytes, int totalBytes) {
73 | LogUtils.e("speed---" + task.getSpeed());
74 | onDownloadListener.onProgress(task.getId(), task.getSpeed(), soFarBytes, totalBytes);
75 | }
76 |
77 | @Override
78 | protected void completed(BaseDownloadTask task) {
79 | onDownloadListener.onComplete(filePath);
80 | }
81 |
82 | @Override
83 | protected void paused(BaseDownloadTask task, int soFarBytes, int totalBytes) {
84 |
85 | }
86 |
87 | @Override
88 | protected void error(BaseDownloadTask task, Throwable e) {
89 | onDownloadListener.onError(e);
90 | }
91 |
92 | @Override
93 | protected void warn(BaseDownloadTask task) {
94 |
95 | }
96 | });
97 | baseDownloadTask.start();
98 | }
99 |
100 | /**
101 | * 暂停下载
102 | */
103 | public void pause() {
104 | baseDownloadTask.pause();
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/filedownload/OnDownloadListener.java:
--------------------------------------------------------------------------------
1 | package com.common.util.filedownload;
2 |
3 | /**
4 | * @Author: 张
5 | * @Email: 1271396448@qq.com
6 | * @Date: 2019/8/16 6:05 PM
7 | *
8 | * 下载监听回调
9 | */
10 | public interface OnDownloadListener {
11 |
12 | void onPending(int id, int soFarBytes, int totalBytes);
13 |
14 | void onProgress(int id, int speed, int soFarBytes, int totalBytes);
15 |
16 | void onComplete(String path);
17 |
18 | void onError(Throwable e);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/glide/GlideUtil.java:
--------------------------------------------------------------------------------
1 | package com.common.util.glide;
2 |
3 | import android.graphics.drawable.Drawable;
4 | import android.widget.ImageView;
5 |
6 | import com.blankj.utilcode.util.Utils;
7 | import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
8 | import com.bumptech.glide.request.RequestOptions;
9 |
10 | /**
11 | * @Author: 张鹏飞
12 | * @Email: 1271396448@qq.com
13 | * @Date: 2020/11/16
14 | *
15 | * @Desc: Glide工具类 GlideApp爆红需要执行开发工具 Build 的Make Project
16 | */
17 | public class GlideUtil {
18 | /**
19 | * 加载默认图
20 | *
21 | * @param url: 图片地址
22 | * @param targetView: 目标View
23 | * @param placeHolder: 占位图
24 | */
25 | public static void loadImage(String url, ImageView targetView, Drawable placeHolder) {
26 | GlideApp.with(Utils.getApp())
27 | .load(url)
28 | .placeholder(placeHolder)
29 | .error(placeHolder)
30 | .centerCrop()
31 | .into(targetView);
32 | }
33 | /**
34 | * 加载圆图
35 | *
36 | * @param url: 图片地址
37 | * @param targetView: 目标View
38 | * @param placeHolder: 占位图
39 | */
40 | public static void loadCircleImage(String url, ImageView targetView, Drawable placeHolder) {
41 | GlideApp.with(Utils.getApp())
42 | .load(url)
43 | .placeholder(placeHolder)
44 | .error(placeHolder)
45 | .circleCrop()
46 | .into(targetView);
47 | }
48 |
49 | /**
50 | * 加载圆角图片
51 | *
52 | * @param url: 图片地址
53 | * @param targetView: 目标View
54 | * @param placeHolder: 占位图
55 | */
56 | public static void loadCornerImage(String url, ImageView targetView, int radius, Drawable placeHolder) {
57 | GlideApp.with(Utils.getApp())
58 | .asBitmap()
59 | .apply(RequestOptions.bitmapTransform(new RoundedCorners(radius)))
60 | .placeholder(placeHolder)
61 | .error(placeHolder)
62 | .load(url)
63 | .into(targetView);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/util/glide/MyGlideModule.java:
--------------------------------------------------------------------------------
1 | package com.common.util.glide;
2 |
3 | import com.bumptech.glide.annotation.GlideModule;
4 | import com.bumptech.glide.module.AppGlideModule;
5 |
6 | /**
7 | * @Author: 张鹏飞
8 | * @Email: 1271396448@qq.com
9 | * @Date: 2020/11/16
10 | *
11 | * @Desc: GlideApp
12 | */
13 | @GlideModule
14 | public class MyGlideModule extends AppGlideModule {
15 | }
16 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/weight/CommonRecyclerView.java:
--------------------------------------------------------------------------------
1 | package com.common.weight;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.util.AttributeSet;
6 | import android.view.View;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.annotation.Nullable;
10 | import androidx.recyclerview.widget.RecyclerView;
11 |
12 | import com.common.R;
13 |
14 | /**
15 | * @Author: 张鹏飞
16 | * * @Email: 1271396448@qq.com
17 | * @Date: 2019/6/27 3:19 PM
18 | *
19 | * 重写RecyclerView,优化一些属性
20 | */
21 | public class CommonRecyclerView extends RecyclerView {
22 |
23 | //横向滑动速率
24 | private float scrollSpeedX = 2;
25 | //纵向滑动速率
26 | private float scrollSpeedY = 2;
27 |
28 | public CommonRecyclerView(@NonNull Context context, @Nullable AttributeSet attrs) {
29 | super(context, attrs);
30 | TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CommonRecyclerView);
31 | scrollSpeedX = typedArray.getFloat(R.styleable.CommonRecyclerView_recyclerSpeedX, 2);
32 | scrollSpeedY = typedArray.getFloat(R.styleable.CommonRecyclerView_recyclerSpeedY, 2);
33 | typedArray.recycle();
34 | }
35 |
36 | /**
37 | * 滑动到边界时无阴影
38 | */
39 | @Override
40 | public void setOverScrollMode(int overScrollMode) {
41 | super.setOverScrollMode(View.OVER_SCROLL_NEVER);
42 | }
43 |
44 | /**
45 | * 不显示垂直滑动条
46 | */
47 | @Override
48 | public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled) {
49 | super.setVerticalScrollBarEnabled(false);
50 | }
51 |
52 | /**
53 | * 不显示水平滑动条
54 | */
55 | @Override
56 | public void setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled) {
57 | super.setHorizontalFadingEdgeEnabled(false);
58 | }
59 |
60 | /**
61 | * 滑动速率
62 | * @param velocityX: 纵向滑动速率
63 | * @param velocityY: 横向滑动速率
64 | */
65 | @Override
66 | public boolean fling(int velocityX, int velocityY) {
67 | return super.fling((int)(velocityX / scrollSpeedX), (int)(velocityY / scrollSpeedY));
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/basecommon/src/main/java/com/common/weight/CommonViewPager.java:
--------------------------------------------------------------------------------
1 | package com.common.weight;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.view.View;
6 |
7 | import androidx.annotation.NonNull;
8 | import androidx.annotation.Nullable;
9 | import androidx.viewpager.widget.ViewPager;
10 |
11 | /**
12 | * @Author: 张鹏飞
13 | * @Email: 1271396448@qq.com
14 | * @Date: 2020/11/13
15 | *
16 | * @Desc:
17 | */
18 | public class CommonViewPager extends ViewPager {
19 | public CommonViewPager(@NonNull Context context) {
20 | super(context);
21 | }
22 |
23 | public CommonViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
24 | super(context, attrs);
25 | }
26 |
27 | /**
28 | * 滑动到边界时无阴影
29 | */
30 | @Override
31 | public void setOverScrollMode(int overScrollMode) {
32 | super.setOverScrollMode(View.OVER_SCROLL_NEVER);
33 | }
34 |
35 | /**
36 | * 不显示垂直滑动条
37 | */
38 | @Override
39 | public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled) {
40 | super.setVerticalScrollBarEnabled(false);
41 | }
42 |
43 | /**
44 | * 不显示水平滑动条
45 | */
46 | @Override
47 | public void setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled) {
48 | super.setHorizontalFadingEdgeEnabled(false);
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/drawable-xhdpi/ic_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/drawable-xhdpi/ic_back.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/drawable-xhdpi/ic_placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/drawable-xhdpi/ic_placeholder.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/drawable-xhdpi/ic_release.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/drawable-xhdpi/ic_release.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/drawable-xhdpi/ic_title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/drawable-xhdpi/ic_title.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/drawable/bg_f5f5_corner_8.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/layout/brvah_quick_view_load_more.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
20 |
21 |
29 |
30 |
31 |
36 |
37 |
38 |
44 |
45 |
46 |
47 |
52 |
53 |
59 |
60 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/basecommon/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/basecommon/src/main/res/values/attrs.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 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 | #FF0000
8 |
9 | #03DAC5
10 | #FFFFFF
11 | #000000
12 |
13 | #F5F5F5
14 | #787878
15 |
16 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | QuickAndroid
3 |
4 |
5 | 您当前的网络连接不可用
6 | 服务器异常
7 | 连接超时
8 | 数据解析异常
9 | 程序异常
10 |
11 | 正在加载中…
12 | 加载失败,请点我重试
13 | 没有更多数据
14 |
15 |
--------------------------------------------------------------------------------
/basecommon/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/basecommon/src/test/java/com/common/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.common;
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 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | apply from: "config.gradle"
2 | buildscript {
3 |
4 | repositories {
5 | google()
6 | jcenter()
7 |
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.6.3'
11 |
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 |
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/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=-Xmx1536m
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 | android.injected.testOnly = false
21 |
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/manitozhang/QuickAndroid/a02bbfe8bb62db87b4719113524baa30d8bb76e0/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Sep 18 11:14:11 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-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='QuickAndroid'
2 | include ':app'
3 | include ':basecommon'
4 |
--------------------------------------------------------------------------------