├── .gitignore
├── README.md
├── ScreenShot
├── qrcode.png
├── 体系.png
├── 公众号列表.png
├── 妹子列表.png
├── 妹子预览.png
├── 我的.png
├── 搜索.png
├── 收藏.png
├── 注册.png
├── 登录.png
├── 详情页.png
├── 项目.png
└── 首页.png
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
├── release
│ ├── app-release.apk
│ └── output.json
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── xing
│ │ └── wanandroid
│ │ └── MainApp.java
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ └── values
│ └── strings.xml
├── build.gradle
├── common_base
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── xing
│ │ └── commonbase
│ │ ├── annotation
│ │ ├── BindEventBus.java
│ │ └── UserLoginTrace.java
│ │ ├── base
│ │ ├── BaseActivity.java
│ │ ├── BaseApplication.java
│ │ ├── BaseFragment.java
│ │ ├── BaseLazyFragment.java
│ │ ├── BaseMVPActivity.java
│ │ ├── BaseMVPFragment.java
│ │ ├── BaseObserver.java
│ │ └── BaseResponse.java
│ │ ├── bean
│ │ └── ProjectResult.java
│ │ ├── constants
│ │ └── Constants.java
│ │ ├── http
│ │ ├── ApiException.java
│ │ ├── ExceptionHandler.java
│ │ ├── InterceptorUtil.java
│ │ ├── RetrofitClient.java
│ │ └── SSLSocketClient.java
│ │ ├── interceptor
│ │ └── LoginInterceptor.java
│ │ ├── json
│ │ ├── FastJsonConverterFactory.java
│ │ ├── FastJsonRequestBodyConverter.java
│ │ └── FastJsonResponseBodyConverter.java
│ │ ├── manager
│ │ └── UserLoginManager.java
│ │ ├── mvp
│ │ ├── BasePresenter.java
│ │ ├── IPresenter.java
│ │ └── IView.java
│ │ ├── receiver
│ │ └── NetworkChangeReceiver.java
│ │ ├── util
│ │ ├── AppUtil.java
│ │ ├── BlurUtil.java
│ │ ├── CompressUtil.java
│ │ ├── DensityUtil.java
│ │ ├── DeviceUtil.java
│ │ ├── EventBusHelper.java
│ │ ├── IntentUtil.java
│ │ ├── NetworkUtil.java
│ │ ├── SharedPreferenceUtil.java
│ │ ├── SoftKeyboardUtil.java
│ │ ├── StatusBarUtil.java
│ │ └── ToastUtil.java
│ │ └── widget
│ │ ├── BadgeRadioButton.java
│ │ ├── CircleImageView.java
│ │ ├── IndicatorView.java
│ │ ├── ItemView.java
│ │ ├── LinearItemDecoration.java
│ │ ├── NoNetworkTip.java
│ │ ├── ProgressWebView.java
│ │ ├── WebProgressBar.java
│ │ ├── ZoomScrollView.java
│ │ ├── flow
│ │ ├── FlowAdapter.java
│ │ ├── FlowChildPosition.java
│ │ └── FlowLayout.java
│ │ └── gridviewpager
│ │ ├── GridPagerAdapter.java
│ │ ├── GridRecyclerAdapter.java
│ │ ├── GridViewPager.java
│ │ └── GridViewPagerAdapter.java
│ └── res
│ ├── anim
│ ├── anim_alpha.xml
│ ├── anim_web_enter.xml
│ └── anim_web_exit.xml
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable-xhdpi
│ └── ic_close.png
│ ├── drawable-xxhdpi
│ ├── ic_favorite.png
│ ├── ic_favorite_fill.png
│ ├── ic_right_more.png
│ ├── icon_back.png
│ ├── splash.png
│ └── test.jpeg
│ ├── drawable
│ ├── ic_launcher_background.xml
│ ├── selector_mine_item.xml
│ ├── shape_bottom_shadow.xml
│ └── shape_circle_white.xml
│ ├── layout
│ ├── item_grid_viewpager.xml
│ ├── layout_back.xml
│ ├── layout_grid_viewpager.xml
│ ├── layout_item_view.xml
│ ├── layout_no_network_tip.xml
│ └── layout_toolbar.xml
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-v19
│ └── dimens.xml
│ └── values
│ ├── attrs.xml
│ ├── colors.xml
│ ├── dimens.xml
│ ├── ids.xml
│ ├── strings.xml
│ └── styles.xml
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── keystore
└── keystore.jks
├── module_gank
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── debug
│ └── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── xing
│ │ └── module
│ │ └── gank
│ │ ├── activity
│ │ ├── ImageMeiziActivity.java
│ │ └── ImagePreviewActivity.java
│ │ ├── adapter
│ │ ├── ImagePreviewAdapter.java
│ │ └── MeiziAdapter.java
│ │ ├── apiservice
│ │ └── GankApiService.java
│ │ ├── bean
│ │ └── MeiziResult.java
│ │ ├── contract
│ │ └── MeiziContract.java
│ │ └── presenter
│ │ └── MeiziPresenter.java
│ └── res
│ ├── drawable-xxhdpi
│ ├── ic_grid.png
│ └── ic_list.png
│ ├── drawable
│ └── shape_image_save_bg.xml
│ ├── layout
│ ├── activity_image_preview.xml
│ ├── activity_meizi_image.xml
│ ├── item_image_preview.xml
│ └── item_meizi.xml
│ ├── menu
│ └── menu_image_meizi.xml
│ └── values
│ └── strings.xml
├── module_main
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── debug
│ └── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── xing
│ │ └── main
│ │ ├── activity
│ │ ├── AboutActivity.java
│ │ ├── FavoriteActivity.java
│ │ ├── MainActivity.java
│ │ ├── SearchActivity.java
│ │ ├── SystemArticleActivity.java
│ │ ├── WeChatArticleListActivity.java
│ │ └── WebViewActivity.java
│ │ ├── adapter
│ │ ├── FavoriteAdapter.java
│ │ ├── HomeArticleAdapter.java
│ │ ├── ProjectPagerAdapter.java
│ │ ├── ProjectRecyclerAdapter.java
│ │ ├── SearchHistoryAdapter.java
│ │ ├── SearchResultAdapter.java
│ │ ├── SystemArticleAdapter.java
│ │ ├── SystemLeftAdapter.java
│ │ ├── SystemRightAdapter.java
│ │ └── WeChatArticleAdapter.java
│ │ ├── annotation
│ │ └── UserLoginTrace.java
│ │ ├── aop
│ │ └── UserLoginAspect.java
│ │ ├── apiservice
│ │ └── MainApiService.java
│ │ ├── bean
│ │ ├── BannerResult.java
│ │ ├── FavoriteAddResult.java
│ │ ├── FavoriteResult.java
│ │ ├── HomeArticleResult.java
│ │ ├── ProjectPageItem.java
│ │ ├── ProjectResult.java
│ │ ├── ProjectTabItem.java
│ │ ├── SearchHotKey.java
│ │ ├── SearchResult.java
│ │ ├── SystemArticleResult.java
│ │ ├── SystemResult.java
│ │ ├── WeChatArticleResult.java
│ │ ├── WeChatAuthorResult.java
│ │ └── db
│ │ │ └── SearchHistory.java
│ │ ├── contract
│ │ ├── FavoriteContract.java
│ │ ├── HomeContract.java
│ │ ├── MainContract.java
│ │ ├── ProjectContract.java
│ │ ├── ProjectPageContract.java
│ │ ├── SearchHistoryContract.java
│ │ ├── SearchResultContract.java
│ │ ├── SystemArticleContract.java
│ │ ├── SystemContract.java
│ │ ├── WeChatArticleListContract.java
│ │ └── WebContract.java
│ │ ├── db
│ │ ├── DaoMaster.java
│ │ ├── DaoSession.java
│ │ ├── DbManager.java
│ │ └── SearchHistoryDao.java
│ │ ├── fragment
│ │ ├── CategoryFragment.java
│ │ ├── HomeFragment.java
│ │ ├── MineFragment.java
│ │ ├── ProjectFragment.java
│ │ ├── ProjectPageFragment.java
│ │ ├── SearchHistoryFragment.java
│ │ ├── SearchResultFragment.java
│ │ └── SystemFragment.java
│ │ ├── imageloader
│ │ └── GlideImageLoader.java
│ │ └── presenter
│ │ ├── FavoritePresenter.java
│ │ ├── HomePresenter.java
│ │ ├── MainPresenter.java
│ │ ├── ProjectPagePresenter.java
│ │ ├── ProjectPresenter.java
│ │ ├── SearchHistoryPresenter.java
│ │ ├── SearchResultPresenter.java
│ │ ├── SystemArticlePresenter.java
│ │ ├── SystemPresenter.java
│ │ ├── WeChatArticlePresenter.java
│ │ └── WebPresenter.java
│ └── res
│ ├── drawable-xhdpi
│ ├── ic_home_logo_black.png
│ └── ic_home_logo_white.png
│ ├── drawable-xxhdpi
│ ├── ic_delete.png
│ ├── ic_delete_all.png
│ ├── ic_mine_about.png
│ ├── ic_mine_favorite.png
│ ├── ic_mine_happy.png
│ ├── ic_mine_setting.png
│ ├── ic_search.png
│ ├── ic_share.png
│ ├── icon_menu_category_sel.png
│ ├── icon_menu_category_unsel.png
│ ├── icon_menu_home_sel.png
│ ├── icon_menu_home_unsel.png
│ ├── icon_menu_mine_sel.png
│ ├── icon_menu_mine_unsel.png
│ ├── icon_menu_project_sel.png
│ ├── icon_menu_project_unsel.png
│ ├── icon_menu_system_sel.png
│ ├── icon_menu_system_unsel.png
│ ├── icon_menu_wechat_sel.png
│ └── icon_menu_wechat_unsel.png
│ ├── drawable
│ ├── selector_menu_category.xml
│ ├── selector_menu_home.xml
│ ├── selector_menu_mine.xml
│ ├── selector_menu_project.xml
│ ├── selector_menu_system.xml
│ ├── shape_home_input.xml
│ ├── shape_home_input_dark.xml
│ ├── shape_home_wechat_bg.xml
│ └── shape_search_history_bg.xml
│ ├── layout
│ ├── activity_about.xml
│ ├── activity_favorite.xml
│ ├── activity_main.xml
│ ├── activity_search.xml
│ ├── activity_system_article.xml
│ ├── activity_we_chat_article_list.xml
│ ├── activity_web_view.xml
│ ├── fragment_home.xml
│ ├── fragment_mine.xml
│ ├── fragment_project.xml
│ ├── fragment_project_page.xml
│ ├── fragment_search_history.xml
│ ├── fragment_search_result.xml
│ ├── fragment_system.xml
│ ├── item_home_article.xml
│ ├── item_home_wechat_authors.xml
│ ├── item_recycler_project.xml
│ ├── item_search_history_content.xml
│ ├── item_search_result.xml
│ ├── item_system_left.xml
│ ├── item_system_right.xml
│ ├── layout_home_header.xml
│ └── layout_search_history_header.xml
│ ├── menu
│ └── menu_web.xml
│ └── values
│ └── strings.xml
├── module_usercenter
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── debug
│ └── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── xing
│ │ └── usercenter
│ │ ├── activity
│ │ ├── LoginActivity.java
│ │ ├── RegisterActivity.java
│ │ └── SplashActivity.java
│ │ ├── apiservice
│ │ └── UserCenterApiService.java
│ │ ├── bean
│ │ ├── LoginResult.java
│ │ └── RegisterResult.java
│ │ ├── contract
│ │ ├── LoginContract.java
│ │ └── RegisterContract.java
│ │ └── presenter
│ │ ├── LoginPresenter.java
│ │ └── RegisterPresenter.java
│ └── res
│ ├── drawable-xhdpi
│ ├── login_icon_password.png
│ ├── login_icon_phone.png
│ ├── login_icon_pwd_visible.png
│ └── login_input_bg.9.png
│ ├── drawable-xxhdpi
│ ├── splash_tip.png
│ └── splash_water.png
│ ├── drawable
│ ├── selector_login_btn_bg.xml
│ └── splash_bg.xml
│ ├── layout
│ ├── activity_login.xml
│ ├── activity_register.xml
│ └── activity_splash.xml
│ └── values
│ ├── strings.xml
│ └── styles.xml
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches/build_file_checksums.ser
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | .DS_Store
9 | /build
10 | /captures
11 | .externalNativeBuild
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WanAndroid
2 | 基于 wanandroid.com 和 gank.io API 开发的 MVP + Retrofit + RxJava2 组件化模式开发的 Android APP
3 |
4 | ### 效果图:
5 | 










6 |
7 | ### dependenices
8 |
9 | - Retrofit Okhttp
10 | - Rxjava2
11 | - Glide
12 | - EventBus
13 | - PhotoView
14 | - SmartRefreshLayout
15 | - BaseRecyclerViewAdapterHelper
16 | - greendao
17 | - banner
18 | - andpermission
19 | - aspectj
20 | - arouter
21 |
22 | ### APK 体验
23 | [点击下载安装](https://github.com/xing16/WanAndroid/raw/1b009f4c331ba40e57d6ac25e65f552a2a4c4223/app/release/app-release.apk)
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/ScreenShot/qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/qrcode.png
--------------------------------------------------------------------------------
/ScreenShot/体系.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/体系.png
--------------------------------------------------------------------------------
/ScreenShot/公众号列表.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/公众号列表.png
--------------------------------------------------------------------------------
/ScreenShot/妹子列表.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/妹子列表.png
--------------------------------------------------------------------------------
/ScreenShot/妹子预览.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/妹子预览.png
--------------------------------------------------------------------------------
/ScreenShot/我的.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/我的.png
--------------------------------------------------------------------------------
/ScreenShot/搜索.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/搜索.png
--------------------------------------------------------------------------------
/ScreenShot/收藏.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/收藏.png
--------------------------------------------------------------------------------
/ScreenShot/注册.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/注册.png
--------------------------------------------------------------------------------
/ScreenShot/登录.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/登录.png
--------------------------------------------------------------------------------
/ScreenShot/详情页.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/详情页.png
--------------------------------------------------------------------------------
/ScreenShot/项目.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/项目.png
--------------------------------------------------------------------------------
/ScreenShot/首页.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/ScreenShot/首页.png
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 28
5 | defaultConfig {
6 | applicationId "com.xing.wanandroid"
7 | compileSdkVersion rootProject.ext.android.compileSdkVersion
8 | buildToolsVersion rootProject.ext.android.buildToolsVersion
9 | defaultConfig {
10 | minSdkVersion rootProject.ext.android.minSdkVersion
11 | targetSdkVersion rootProject.ext.android.targetSdkVersion
12 | versionCode rootProject.ext.android.versionCode
13 | versionName rootProject.ext.android.versionName
14 |
15 | renderscriptTargetApi 19
16 | renderscriptSupportModeEnabled true
17 |
18 | javaCompileOptions {
19 | annotationProcessorOptions {
20 | arguments = [AROUTER_MODULE_NAME: project.getName()]
21 | }
22 | }
23 | }
24 | }
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | implementation project(':common_base')
35 | if (!isRunAlone.toBoolean()) {
36 | implementation project(':module_usercenter')
37 | implementation project(':module_main')
38 | implementation project(':module_gank')
39 | }
40 | // 如果 app 主工程中使用了 Arouter 注解,那就需要这个 annotationProcessor
41 | annotationProcessor rootProject.ext.dependencies['arouter-compiler']
42 | }
43 |
--------------------------------------------------------------------------------
/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/release/app-release.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/app/release/app-release.apk
--------------------------------------------------------------------------------
/app/release/output.json:
--------------------------------------------------------------------------------
1 | [{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/xing/wanandroid/MainApp.java:
--------------------------------------------------------------------------------
1 | package com.xing.wanandroid;
2 |
3 | import android.content.Context;
4 |
5 | import com.xing.commonbase.base.BaseApplication;
6 |
7 | public class MainApp extends BaseApplication {
8 |
9 | private static Context mContext;
10 |
11 | @Override
12 | public void onCreate() {
13 | super.onCreate();
14 | mContext = this;
15 | }
16 |
17 | public static Context getAppContext() {
18 | return mContext;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | WanAndroid
3 |
4 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: "config.gradle"
3 | buildscript {
4 |
5 | repositories {
6 | google()
7 | jcenter()
8 | maven { url 'https://maven.google.com' }
9 | mavenCentral() // add repository
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.2.1'
13 | //避免butterKnife在library中使用出现id冲突
14 | classpath 'org.greenrobot:greendao-gradle-plugin:3.2.2' // add plugin
15 | classpath 'org.aspectj:aspectjtools:1.8.9'
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | google()
25 | jcenter()
26 | maven { url "https://jitpack.io" }
27 | }
28 | }
29 |
30 | task clean(type: Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/common_base/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/common_base/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/common_base/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/annotation/BindEventBus.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Target(ElementType.TYPE)
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface BindEventBus {
11 | }
12 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/annotation/UserLoginTrace.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface UserLoginTrace {
11 | int value();
12 | }
13 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.base;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.support.v4.app.Fragment;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 |
11 | import com.xing.commonbase.annotation.BindEventBus;
12 | import com.xing.commonbase.util.EventBusHelper;
13 |
14 | import org.greenrobot.eventbus.EventBus;
15 |
16 | public abstract class BaseFragment extends Fragment {
17 | protected Context mContext;
18 |
19 | @Override
20 | public void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | if (this.getClass().isAnnotationPresent(BindEventBus.class)) {
23 | EventBusHelper.register(this);
24 | }
25 | }
26 |
27 | @Override
28 | public void onAttach(Activity activity) {
29 | super.onAttach(activity);
30 | mContext = activity;
31 | }
32 |
33 | @Override
34 | public void onAttach(Context context) {
35 | super.onAttach(context);
36 | mContext = context;
37 | }
38 |
39 | @Override
40 | public final View onCreateView(LayoutInflater inflater, ViewGroup container,
41 | Bundle savedInstanceState) {
42 | View rootView = inflater.inflate(getLayoutResId(), container, false);
43 | initView(rootView);
44 | initData();
45 | return rootView;
46 | }
47 |
48 | protected abstract int getLayoutResId();
49 |
50 | protected abstract void initView(View rootView);
51 |
52 | protected abstract void initData();
53 |
54 | @Override
55 | public void onDetach() {
56 | super.onDetach();
57 | }
58 |
59 | @Override
60 | public void onDestroy() {
61 | super.onDestroy();
62 | if (this.getClass().isAnnotationPresent(BindEventBus.class)) {
63 | EventBus.getDefault().unregister(this);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/base/BaseLazyFragment.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.view.View;
6 |
7 | import com.xing.commonbase.mvp.IPresenter;
8 |
9 |
10 | public abstract class BaseLazyFragment
extends BaseMVPFragment
{
11 |
12 | /**
13 | * Fragment 中的 View 是否创建完成
14 | */
15 | protected boolean isViewCreated;
16 |
17 | /**
18 | * Fragment 是否对用户可见
19 | */
20 | protected boolean isVisible;
21 |
22 | /**
23 | * Fragment 左右切换时,只在第一次显示时请求数据
24 | */
25 | protected boolean isFirstLoad = true;
26 |
27 |
28 | public BaseLazyFragment() {
29 | }
30 |
31 | /**
32 | * Fragment 中创建完成的回调方法
33 | *
34 | * @param view
35 | * @param savedInstanceState
36 | */
37 | @Override
38 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
39 | super.onViewCreated(view, savedInstanceState);
40 | isViewCreated = true;
41 | lazyLoad();
42 | }
43 |
44 |
45 | @Override
46 | public void setUserVisibleHint(boolean isVisibleToUser) {
47 | super.setUserVisibleHint(isVisibleToUser);
48 | if (isVisibleToUser) {
49 | isVisible = true;
50 | onVisible();
51 | } else {
52 | isVisible = false;
53 | onInvisible();
54 | }
55 | }
56 |
57 | private void onInvisible() {
58 |
59 | }
60 |
61 | protected void onVisible() {
62 | lazyLoad();
63 | }
64 |
65 |
66 | /**
67 | * (1) isViewCreated 参数在系统调用 onViewCreated 时设置为 true,这时onCreateView方法已调用完毕(一般我们在这方法
68 | * 里执行findviewbyid等方法),确保 loadData()方法不会报空指针异常。
69 | *
70 | * (2) isVisible 参数在 fragment 可见时通过系统回调 setUserVisibileHint 方法设置为true,不可见时为false,
71 | * 这是 fragment 实现懒加载的关键。
72 | *
73 | * (3) isFirstLoad 确保 ViewPager 来回切换时 TabFragment 的 loadData()方法不会被重复调用,loadData()在该
74 | * Fragment 的整个生命周期只调用一次,第一次调用 loadData()方法后马上执行 isFirst = false。
75 | */
76 | private void lazyLoad() {
77 | /**
78 | *这里进行双重标记判断,是因为setUserVisibleHint会多次回调,
79 | * 并且会在onCreateView执行前回调,必须确保onCreateView加载完毕且页面可见,才加载数据
80 | */
81 | if (isViewCreated && isVisible && isFirstLoad) {
82 | loadData();
83 | isFirstLoad = false;
84 | }
85 | }
86 |
87 | /**
88 | * 子类实现加载数据
89 | */
90 | protected abstract void loadData();
91 | }
92 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/base/BaseMVPActivity.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.base;
2 |
3 | import com.xing.commonbase.mvp.IPresenter;
4 | import com.xing.commonbase.mvp.IView;
5 |
6 | import butterknife.ButterKnife;
7 | import butterknife.Unbinder;
8 |
9 | public abstract class BaseMVPActivity
extends BaseActivity implements IView {
10 | protected P presenter;
11 | private Unbinder unbinder;
12 |
13 | @Override
14 | protected void initData() {
15 | super.initData();
16 | presenter = createPresenter();
17 | // presenter 绑定 view
18 | if (presenter != null) {
19 | presenter.attachView(this);
20 | }
21 | unbinder = ButterKnife.bind(this);
22 |
23 | }
24 |
25 | protected abstract int getLayoutResId();
26 |
27 | protected abstract P createPresenter();
28 |
29 | @Override
30 | public void onDestroy() {
31 | super.onDestroy();
32 | // Activity 销毁时取消所有的订阅
33 | if (presenter != null) {
34 | presenter.detachView();
35 | presenter = null;
36 | }
37 | if (unbinder != null) {
38 | unbinder.unbind();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/base/BaseMVPFragment.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.base;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.os.Bundle;
6 | import android.view.View;
7 |
8 | import com.xing.commonbase.annotation.BindEventBus;
9 | import com.xing.commonbase.mvp.IPresenter;
10 | import com.xing.commonbase.mvp.IView;
11 | import com.xing.commonbase.util.EventBusHelper;
12 |
13 | public abstract class BaseMVPFragment
extends BaseFragment implements IView {
14 |
15 | protected Context mContext;
16 | protected P presenter;
17 |
18 | @Override
19 | public void onCreate(Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | presenter = createPresenter();
22 | if (presenter != null) {
23 | presenter.attachView(this);
24 | }
25 | }
26 |
27 | @Override
28 | public void onAttach(Activity activity) {
29 | super.onAttach(activity);
30 | mContext = activity;
31 | }
32 |
33 | @Override
34 | public void onAttach(Context context) {
35 | super.onAttach(context);
36 | mContext = context;
37 | }
38 |
39 |
40 | // @Override
41 | // public final View onCreateView(LayoutInflater inflater, ViewGroup container,
42 | // Bundle savedInstanceState) {
43 | // View rootView = inflater.inflate(getLayoutResId(), container, false);
44 | //
45 | // initView(rootView);
46 | // initData();
47 | // return rootView;
48 | // }
49 |
50 | protected abstract P createPresenter();
51 |
52 | protected abstract int getLayoutResId();
53 |
54 | protected abstract void initView(View rootView);
55 |
56 | protected abstract void initData();
57 |
58 | @Override
59 | public void onDetach() {
60 | super.onDetach();
61 | }
62 |
63 | @Override
64 | public void onDestroy() {
65 | super.onDestroy();
66 | if (presenter != null) {
67 | presenter.detachView();
68 | presenter = null;
69 | }
70 | if (this.getClass().isAnnotationPresent(BindEventBus.class)) {
71 | EventBusHelper.unregister(this);
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/base/BaseObserver.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.base;
2 |
3 | import com.xing.commonbase.http.ApiException;
4 | import com.xing.commonbase.http.ExceptionHandler;
5 | import com.xing.commonbase.mvp.IView;
6 |
7 | import io.reactivex.observers.DisposableObserver;
8 |
9 | public abstract class BaseObserver extends DisposableObserver> {
10 | private IView baseView;
11 |
12 | public BaseObserver() {
13 |
14 | }
15 |
16 | public BaseObserver(IView baseView) {
17 | this.baseView = baseView;
18 | }
19 |
20 | @Override
21 | protected void onStart() {
22 | super.onStart();
23 | if (baseView != null) {
24 | baseView.showLoading();
25 | }
26 | }
27 |
28 | @Override
29 | public void onNext(BaseResponse baseResponse) {
30 | if (baseView != null) {
31 | baseView.hideLoading();
32 | }
33 | int errcode = baseResponse.getErrorCode();
34 | String errmsg = baseResponse.getErrorMsg();
35 | // 兼容 gank api
36 | boolean isOk = !baseResponse.isError();
37 | if (errcode == 0 || errcode == 200) { // wanandroid api
38 | T data = baseResponse.getData();
39 | // 将服务端获取到的正常数据传递给上层调用方
40 | onSuccess(data);
41 | } else if (isOk) { // gank api
42 | T data = baseResponse.getResults();
43 | onSuccess(data);
44 | } else {
45 | onError(new ApiException(errcode, errmsg));
46 | }
47 | }
48 |
49 | /**
50 | * 回调正常数据
51 | *
52 | * @param data
53 | */
54 | protected abstract void onSuccess(T data);
55 |
56 | /**
57 | * 异常处理,包括两方面数据:
58 | * (1) 服务端没有没有返回数据,HttpException,如网络异常,连接超时;
59 | * (2) 服务端返回了数据,但 errcode!=0,即服务端返回的data为空,如 密码错误,App登陆超时,token失效
60 | */
61 | @Override
62 | public void onError(Throwable e) {
63 | ExceptionHandler.handleException(e);
64 | }
65 |
66 | @Override
67 | public void onComplete() {
68 | if (baseView != null) {
69 | baseView.hideLoading();
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/base/BaseResponse.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.base;
2 |
3 | /**
4 | * 网络请求返回的数据,按格式统一包装成 BaseResponse 类
5 | * Created by Administrator on 2018/9/15.
6 | */
7 |
8 | public class BaseResponse {
9 |
10 | private int errorCode = -1;
11 | private String errorMsg;
12 | private T data;
13 | /**
14 | * 兼容 gank api
15 | */
16 | private T results;
17 | private boolean error = true;
18 |
19 | public int getErrorCode() {
20 | return errorCode;
21 | }
22 |
23 | public void setErrorCode(int errorCode) {
24 | this.errorCode = errorCode;
25 | }
26 |
27 | public String getErrorMsg() {
28 | return errorMsg;
29 | }
30 |
31 | public void setErrorMsg(String errorMsg) {
32 | this.errorMsg = errorMsg;
33 | }
34 |
35 | public T getData() {
36 | return data;
37 | }
38 |
39 | public void setData(T data) {
40 | this.data = data;
41 | }
42 |
43 | public boolean isError() {
44 | return error;
45 | }
46 |
47 | public T getResults() {
48 | return results;
49 | }
50 |
51 | public void setResults(T results) {
52 | this.results = results;
53 | }
54 |
55 | public void setError(boolean error) {
56 | this.error = error;
57 | }
58 |
59 | @Override
60 | public String toString() {
61 | return "BaseResponse{" +
62 | "errorCode=" + errorCode +
63 | ", errorMsg='" + errorMsg + '\'' +
64 | ", data=" + data +
65 | '}';
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/bean/ProjectResult.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.bean;
2 |
3 | public class ProjectResult {
4 | }
5 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/constants/Constants.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.constants;
2 |
3 | public class Constants {
4 | public static final String IS_ALL = "isAll";
5 | public static final String IS_PAGE = "isPage";
6 | public static final String PROGRAMA_ID = "programaId";
7 | public static final String PARAMS = "params";
8 | public static final String PAGE = "page";
9 | public static final String PAGE_SIZE = "pageSize";
10 |
11 |
12 | // access-token file name
13 | public static final String File_TOKEN = "accessToken";
14 | public static final String ACCESS_TOKEN = "accessToken";
15 | // phone,password
16 | public static final String USER_LOGIN = "userLogin";
17 | public static final String USERNAME = "phone";
18 | public static final String PASSWORD = "password";
19 |
20 |
21 | public static final String URL = "url";
22 | public static final String ID = "id";
23 | public static final String SIGNATURE = "signature";
24 |
25 | public static final String KEY_WORD = "key_word";
26 | public static final String AUTHOR = "author";
27 | public static final String TITLE = "title";
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/http/ApiException.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.http;
2 |
3 | public class ApiException extends RuntimeException {
4 |
5 | private int errcode;
6 | private String errmsg;
7 |
8 | public ApiException() {
9 |
10 | }
11 |
12 | public ApiException(int code, String msg) {
13 | this.errcode = code;
14 | this.errmsg = msg;
15 | }
16 |
17 | public int getErrcode() {
18 | return errcode;
19 | }
20 |
21 | public void setErrcode(int errcode) {
22 | this.errcode = errcode;
23 | }
24 |
25 | public String getErrmsg() {
26 | return errmsg;
27 | }
28 |
29 | public void setErrmsg(String errmsg) {
30 | this.errmsg = errmsg;
31 | }
32 |
33 | @Override
34 | public String toString() {
35 | return "ApiException{" +
36 | "errcode=" + errcode +
37 | ", errmsg='" + errmsg + '\'' +
38 | '}';
39 | }
40 | }
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/http/InterceptorUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.http;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.io.IOException;
6 |
7 | import okhttp3.Interceptor;
8 | import okhttp3.Request;
9 | import okhttp3.Response;
10 | import okhttp3.logging.HttpLoggingInterceptor;
11 |
12 | public class InterceptorUtil {
13 | public static Interceptor headerInterceptor() {
14 | return new Interceptor() {
15 | @Override
16 | public Response intercept(Chain chain) throws IOException {
17 | Request originalRequest = chain.request();
18 | Request.Builder builder = originalRequest.newBuilder();
19 | builder.addHeader("X-APP-Agent", "corp_zx_app")
20 | .addHeader("X-OS", "Android")
21 | // .addHeader("X-APP-ID", "20181018000061")
22 | .addHeader("X-APP-ID", "20181130000009")
23 | .addHeader("X-DEVICE-TYPE", "USERNAME")
24 | .addHeader("appId", "281")
25 | .addHeader("businessType", "610001");
26 |
27 | String token = "";
28 | if (!TextUtils.isEmpty(token)) {
29 | builder.addHeader("Access-Token", token);
30 | }
31 | Request request = builder.build();
32 | return chain.proceed(request);
33 | }
34 | };
35 | }
36 |
37 | public static Interceptor logInterceptor() {
38 | return new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/http/RetrofitClient.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.http;
2 |
3 | import com.franmontiel.persistentcookiejar.ClearableCookieJar;
4 | import com.franmontiel.persistentcookiejar.PersistentCookieJar;
5 | import com.franmontiel.persistentcookiejar.cache.SetCookieCache;
6 | import com.franmontiel.persistentcookiejar.persistence.SharedPrefsCookiePersistor;
7 | import com.xing.commonbase.base.BaseApplication;
8 | import com.xing.commonbase.json.FastJsonConverterFactory;
9 |
10 | import java.util.concurrent.TimeUnit;
11 |
12 | import okhttp3.OkHttpClient;
13 | import retrofit2.Retrofit;
14 | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
15 |
16 | public class RetrofitClient {
17 |
18 | private static final String API_HOST = "https://www.wanandroid.com/";
19 | private static RetrofitClient instance;
20 | private static OkHttpClient okHttpClient;
21 | private static Retrofit retrofit;
22 |
23 | private RetrofitClient() {
24 |
25 | ClearableCookieJar cookieJar =
26 | new PersistentCookieJar(new SetCookieCache(),
27 | new SharedPrefsCookiePersistor(BaseApplication.getApplication()));
28 |
29 | okHttpClient = new OkHttpClient.Builder()
30 | .connectTimeout(15, TimeUnit.SECONDS)
31 | .readTimeout(15, TimeUnit.SECONDS)
32 | .cookieJar(cookieJar)
33 | .sslSocketFactory(SSLSocketClient.getSSLSocketFactory())
34 | .hostnameVerifier(SSLSocketClient.getHostnameVerifier())
35 | .addInterceptor(InterceptorUtil.logInterceptor())
36 | .addInterceptor(InterceptorUtil.headerInterceptor())
37 | .build();
38 |
39 | retrofit = new Retrofit.Builder()
40 | .baseUrl(API_HOST)
41 | .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
42 | .addConverterFactory(FastJsonConverterFactory.create()) // 使用 fastjson 解析器解析 json
43 | .client(okHttpClient)
44 | .build();
45 |
46 | }
47 |
48 |
49 | public static RetrofitClient getInstance() {
50 | if (instance == null) {
51 | synchronized (RetrofitClient.class) {
52 | if (instance == null) {
53 | instance = new RetrofitClient();
54 | }
55 | }
56 | }
57 | return instance;
58 | }
59 |
60 | public OkHttpClient getOkHttpClient() {
61 | return okHttpClient;
62 | }
63 |
64 | public Retrofit getRetrofit() {
65 | return retrofit;
66 | }
67 | }
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/http/SSLSocketClient.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.http;
2 |
3 | import java.security.SecureRandom;
4 | import java.security.cert.X509Certificate;
5 |
6 | import javax.net.ssl.HostnameVerifier;
7 | import javax.net.ssl.SSLContext;
8 | import javax.net.ssl.SSLSession;
9 | import javax.net.ssl.SSLSocketFactory;
10 | import javax.net.ssl.TrustManager;
11 | import javax.net.ssl.X509TrustManager;
12 |
13 | public class SSLSocketClient {
14 | //获取这个SSLSocketFactory
15 | public static SSLSocketFactory getSSLSocketFactory() {
16 | try {
17 | SSLContext sslContext = SSLContext.getInstance("SSL");
18 | sslContext.init(null, getTrustManager(), new SecureRandom());
19 | return sslContext.getSocketFactory();
20 | } catch (Exception e) {
21 | throw new RuntimeException(e);
22 | }
23 | }
24 |
25 | //获取TrustManager
26 | public static TrustManager[] getTrustManager() {
27 | TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
28 | @Override
29 | public void checkClientTrusted(X509Certificate[] chain, String authType) {
30 | }
31 |
32 | @Override
33 | public void checkServerTrusted(X509Certificate[] chain, String authType) {
34 | }
35 |
36 | @Override
37 | public X509Certificate[] getAcceptedIssuers() {
38 | return new X509Certificate[]{};
39 | }
40 | }};
41 | return trustAllCerts;
42 | }
43 |
44 | // 获取HostnameVerifier
45 | public static HostnameVerifier getHostnameVerifier() {
46 | HostnameVerifier hostnameVerifier = new HostnameVerifier() {
47 | @Override
48 | public boolean verify(String s, SSLSession sslSession) {
49 | return true;
50 | }
51 | };
52 | return hostnameVerifier;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/interceptor/LoginInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.interceptor;
2 |
3 | import android.content.Context;
4 | import android.util.Log;
5 |
6 | import com.alibaba.android.arouter.facade.Postcard;
7 | import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
8 | import com.alibaba.android.arouter.facade.template.IInterceptor;
9 |
10 | /**
11 | * 登录拦截器
12 | */
13 | //@Interceptor(name = "loginInterceptor", priority = 2)
14 | public class LoginInterceptor implements IInterceptor {
15 | private static final String TAG = "LoginInterceptor";
16 |
17 | @Override
18 | public void process(Postcard postcard, InterceptorCallback callback) {
19 | String path = postcard.getPath();
20 |
21 | callback.onContinue(postcard);
22 | // // 已经登录
23 | // if (UserLoginManager.getInstance().isLoggedin()) {
24 | // callback.onContinue(postcard);
25 | // } else { // 没有登录
26 | //
27 | // }
28 | }
29 |
30 | @Override
31 | public void init(Context context) {
32 | Log.e(TAG, "init: ");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/json/FastJsonConverterFactory.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.json;
2 |
3 | import java.lang.annotation.Annotation;
4 | import java.lang.reflect.Type;
5 |
6 | import okhttp3.RequestBody;
7 | import okhttp3.ResponseBody;
8 | import retrofit2.Converter;
9 | import retrofit2.Retrofit;
10 |
11 | public class FastJsonConverterFactory extends Converter.Factory {
12 | public static FastJsonConverterFactory create() {
13 | return new FastJsonConverterFactory();
14 | }
15 |
16 | @Override
17 | public Converter responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
18 | return new FastJsonResponseBodyConverter<>(type);
19 | }
20 |
21 | @Override
22 | public Converter, RequestBody> requestBodyConverter(Type type, Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
23 | return new FastJsonRequestBodyConverter<>();
24 | }
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/json/FastJsonRequestBodyConverter.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.json;
2 |
3 | import com.alibaba.fastjson.JSON;
4 |
5 | import java.io.IOException;
6 |
7 | import okhttp3.MediaType;
8 | import okhttp3.RequestBody;
9 | import retrofit2.Converter;
10 |
11 | class FastJsonRequestBodyConverter implements Converter {
12 |
13 | private static final MediaType MEDIA_TYPE = MediaType.parse("application/json;charset=UTF-8");
14 |
15 | @Override
16 | public RequestBody convert(T value) throws IOException {
17 | return RequestBody.create(MEDIA_TYPE,JSON.toJSONBytes(value));
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/json/FastJsonResponseBodyConverter.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.json;
2 |
3 | import com.alibaba.fastjson.JSON;
4 |
5 | import java.io.IOException;
6 | import java.lang.reflect.Type;
7 |
8 | import okhttp3.ResponseBody;
9 | import okio.BufferedSource;
10 | import okio.Okio;
11 | import retrofit2.Converter;
12 |
13 | class FastJsonResponseBodyConverter implements Converter {
14 | private final Type type;
15 |
16 | public FastJsonResponseBodyConverter(Type type) {
17 | this.type = type;
18 | }
19 |
20 |
21 | @Override
22 | public T convert(ResponseBody value) throws IOException {
23 | BufferedSource bufferedSource = Okio.buffer(value.source());
24 | String tempStr = bufferedSource.readUtf8();
25 | bufferedSource.close();
26 | return JSON.parseObject(tempStr,type);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/manager/UserLoginManager.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.manager;
2 |
3 | public class UserLoginManager {
4 |
5 | /**
6 | * 是否已登录
7 | */
8 | private boolean loggedIn = false;
9 |
10 | private UserLoginManager() {
11 |
12 | }
13 |
14 | public static class UserLoginManagerHolder {
15 | private static final UserLoginManager instance = new UserLoginManager();
16 | }
17 |
18 | public static UserLoginManager getInstance() {
19 | return UserLoginManagerHolder.instance;
20 | }
21 |
22 | public boolean isLoggedin() {
23 | return loggedIn;
24 | }
25 |
26 | public void setLoggedin(boolean loggedIn) {
27 | this.loggedIn = loggedIn;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/mvp/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.mvp;
2 |
3 | import android.content.Context;
4 |
5 | import com.xing.commonbase.base.BaseObserver;
6 | import com.xing.commonbase.http.RetrofitClient;
7 |
8 | import java.lang.ref.WeakReference;
9 |
10 | import io.reactivex.Observable;
11 | import io.reactivex.android.schedulers.AndroidSchedulers;
12 | import io.reactivex.disposables.CompositeDisposable;
13 | import io.reactivex.schedulers.Schedulers;
14 |
15 | public class BasePresenter implements IPresenter {
16 |
17 | // protected V view;
18 | protected WeakReference viewRef;
19 | // 管理订阅关系,用于取消订阅
20 | protected CompositeDisposable compositeDisposable;
21 |
22 | protected Context mContext;
23 |
24 | public BasePresenter() {
25 |
26 | }
27 |
28 |
29 | /**
30 | * 绑定 View ,一般在初始化时调用
31 | *
32 | * @param view
33 | */
34 | public void attachView(V view) {
35 | viewRef = new WeakReference<>(view);
36 | V v = viewRef.get();
37 | // this.view = view;
38 | }
39 |
40 | /**
41 | * 解除绑定 View,一般在 onDestroy 中调用
42 | */
43 | public void detachView() {
44 | this.viewRef = null;
45 | unsubscribe();
46 | }
47 |
48 | /**
49 | * 是否绑定了View,一般在发起网络请求之前调用
50 | *
51 | * @return
52 | */
53 | public boolean isViewAttached() {
54 | return viewRef.get() != null;
55 | }
56 |
57 | public V getView() {
58 | return viewRef.get();
59 | }
60 |
61 |
62 | /**
63 | * 添加订阅
64 | */
65 | public void addSubscribe(Observable> observable, BaseObserver observer) {
66 | if (compositeDisposable == null) {
67 | compositeDisposable = new CompositeDisposable();
68 | }
69 | BaseObserver baseObserver = observable.subscribeOn(Schedulers.newThread())
70 | .observeOn(AndroidSchedulers.mainThread())
71 | .subscribeWith(observer);
72 | compositeDisposable.add(baseObserver);
73 | }
74 |
75 | /**
76 | * 取消订阅
77 | */
78 | public void unsubscribe() {
79 | if (compositeDisposable != null) {
80 | compositeDisposable.dispose();
81 | }
82 | }
83 |
84 | protected T create(Class clazz) {
85 | return RetrofitClient.getInstance().getRetrofit().create(clazz);
86 | }
87 | }
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/mvp/IPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.mvp;
2 |
3 | public interface IPresenter {
4 |
5 | /**
6 | * 绑定 View ,一般在初始化时调用
7 | *
8 | * @param view
9 | */
10 | void attachView(V view);
11 |
12 | /**
13 | * 解除绑定 View,一般在 onDestroy 中调用
14 | */
15 | void detachView();
16 |
17 | /**
18 | * 是否绑定了View,一般在发起网络请求之前调用
19 | *
20 | * @return
21 | */
22 | boolean isViewAttached();
23 |
24 | V getView();
25 | }
26 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/mvp/IView.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.mvp;
2 |
3 | public interface IView {
4 |
5 | /**
6 | * 显示 loading
7 | */
8 | void showLoading();
9 |
10 | /**
11 | * 隐藏 loading
12 | */
13 | void hideLoading();
14 | }
15 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/receiver/NetworkChangeReceiver.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.receiver;
2 |
3 | import android.app.Activity;
4 | import android.content.BroadcastReceiver;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.os.Build;
8 | import android.support.annotation.RequiresApi;
9 | import android.util.Log;
10 |
11 | import com.xing.commonbase.util.NetworkUtil;
12 | import com.xing.commonbase.widget.NoNetworkTip;
13 |
14 | public class NetworkChangeReceiver extends BroadcastReceiver {
15 |
16 | private static final String TAG = "NetworkChangeReceiver";
17 | private Activity activity;
18 | private NoNetworkTip noNetworkTip;
19 |
20 | public NetworkChangeReceiver(Activity activity) {
21 | this.activity = activity;
22 | }
23 |
24 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
25 | @Override
26 | public void onReceive(Context context, Intent intent) {
27 | Log.e(TAG, "onReceive: ");
28 | if (noNetworkTip == null) {
29 | noNetworkTip = new NoNetworkTip(activity);
30 | }
31 | if (NetworkUtil.isNetworkAvailable(context)) {
32 | if (noNetworkTip != null && noNetworkTip.isShowing()) {
33 | noNetworkTip.dismiss();
34 | }
35 | } else {
36 | if (noNetworkTip != null && !noNetworkTip.isShowing()) {
37 | noNetworkTip.show();
38 | }
39 | }
40 | }
41 |
42 | public void onDestroy() {
43 | if (noNetworkTip != null && noNetworkTip.isShowing()) {
44 | noNetworkTip.dismiss();
45 | }
46 | activity = null;
47 | noNetworkTip = null;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/AppUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.content.pm.ApplicationInfo;
5 | import android.content.pm.PackageInfo;
6 | import android.content.pm.PackageManager;
7 |
8 | public class AppUtil {
9 |
10 | private AppUtil() {
11 | throw new UnsupportedOperationException("cannot be instantiated");
12 | }
13 |
14 | public static String getAppVersion() {
15 | return null;
16 | }
17 |
18 | public static String getAppName(Context context) {
19 | PackageManager pm = context.getPackageManager();
20 | //获取包信息
21 | try {
22 | PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0);
23 | //获取应用 信息
24 | ApplicationInfo applicationInfo = packageInfo.applicationInfo;
25 | //获取albelRes
26 | int labelRes = applicationInfo.labelRes;
27 | //返回App的名称
28 | return context.getResources().getString(labelRes);
29 | } catch (PackageManager.NameNotFoundException e) {
30 | e.printStackTrace();
31 | }
32 | return null;
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/BlurUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.graphics.Bitmap;
5 | import android.renderscript.Allocation;
6 | import android.renderscript.Element;
7 | import android.renderscript.RenderScript;
8 | import android.renderscript.ScriptIntrinsicBlur;
9 |
10 | public class BlurUtil {
11 |
12 | private BlurUtil() {
13 | throw new UnsupportedOperationException("cannot be instantiated");
14 | }
15 |
16 | /**
17 | * @param radius 取值(0,25]
18 | * @param bitmap
19 | * @return
20 | */
21 | public static Bitmap blur(Context context, Bitmap bitmap, int radius) {
22 | RenderScript rs = RenderScript.create(context);
23 | // 创建输出bitmap
24 | Bitmap outputBitmap = Bitmap.createBitmap(bitmap);
25 | // 创建用于输入的脚本类型
26 | Allocation input = Allocation.createFromBitmap(rs, bitmap);
27 | // 创建用于输出的脚本类型
28 | Allocation output = Allocation.createFromBitmap(rs, outputBitmap);
29 | ScriptIntrinsicBlur scriptIntrinsicBlur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs));
30 | scriptIntrinsicBlur.setRadius(radius);
31 | scriptIntrinsicBlur.setInput(input);
32 | scriptIntrinsicBlur.forEach(output);
33 | output.copyTo(outputBitmap);
34 | return outputBitmap;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/CompressUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.graphics.Bitmap;
4 |
5 | /**
6 | * 图片压缩
7 | */
8 | public class CompressUtil {
9 | private CompressUtil() {
10 | throw new UnsupportedOperationException("cannot be instantiated");
11 | }
12 |
13 | public static Bitmap compress(Bitmap bitmap,int width,int height) {
14 |
15 | return null;
16 | }
17 |
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/DensityUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.util.TypedValue;
5 |
6 | /**
7 | * dp,px 相互转化工具类
8 | */
9 | public class DensityUtil {
10 |
11 | private DensityUtil() {
12 | throw new UnsupportedOperationException("cannot be instantiated");
13 | }
14 |
15 | /**
16 | * dp转px
17 | */
18 | public static int dp2px(Context context, float dpVal) {
19 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
20 | dpVal, context.getResources().getDisplayMetrics());
21 | }
22 |
23 | /**
24 | * sp转px
25 | */
26 | public static int sp2px(Context context, float spVal) {
27 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP,
28 | spVal, context.getResources().getDisplayMetrics());
29 | }
30 |
31 | /**
32 | * px转dp
33 | */
34 | public static float px2dp(Context context, float pxVal) {
35 | final float scale = context.getResources().getDisplayMetrics().density;
36 | return (pxVal / scale);
37 | }
38 |
39 | /**
40 | * px转sp
41 | */
42 | public static float px2sp(Context context, float pxVal) {
43 | return (pxVal / context.getResources().getDisplayMetrics().scaledDensity);
44 | }
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/DeviceUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | public class DeviceUtil {
4 | private DeviceUtil() {
5 | throw new UnsupportedOperationException("cannot be instantiated");
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/EventBusHelper.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 |
4 | import org.greenrobot.eventbus.EventBus;
5 |
6 | public class EventBusHelper {
7 |
8 | private EventBusHelper() {
9 | throw new UnsupportedOperationException("can't be init");
10 | }
11 |
12 | public static void register(Object object) {
13 | EventBus.getDefault().register(object);
14 | }
15 |
16 | public static void unregister(Object object) {
17 | EventBus.getDefault().unregister(object);
18 | }
19 |
20 | public static void post(Object event) {
21 | EventBus.getDefault().post(event);
22 | }
23 |
24 | public static void postSticky(Object object) {
25 | EventBus.getDefault().postSticky(object);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/IntentUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 |
7 | public class IntentUtil {
8 | private IntentUtil() {
9 | throw new UnsupportedOperationException("cannot be instantiated");
10 | }
11 |
12 | public static void startActivity(Context context, Class clazz) {
13 | Intent intent = new Intent(context, clazz);
14 | context.startActivity(intent);
15 | }
16 |
17 | public static void startActivity(Context context, Class clazz, Bundle bundle) {
18 | Intent intent = new Intent(context, clazz);
19 | intent.putExtras(bundle);
20 | context.startActivity(intent);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/NetworkUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | /**
8 | * 网络链接工具类
9 | */
10 | public class NetworkUtil {
11 |
12 | private NetworkUtil() {
13 | throw new UnsupportedOperationException("cannot be instantiated");
14 | }
15 |
16 | /**
17 | * 网络链接是否可用
18 | *
19 | * @param context
20 | * @return
21 | */
22 | public static boolean isNetworkAvailable(Context context) {
23 | ConnectivityManager connectivityManager =
24 | (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
25 | if (connectivityManager != null) {
26 | NetworkInfo[] networkInfos = connectivityManager.getAllNetworkInfo();
27 | for (NetworkInfo networkInfo : networkInfos) {
28 | NetworkInfo.State state = networkInfo.getState();
29 | if (state == NetworkInfo.State.CONNECTED) {
30 | return true;
31 | }
32 | }
33 | }
34 | return false;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/SharedPreferenceUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import com.xing.commonbase.base.BaseApplication;
7 |
8 | public class SharedPreferenceUtil {
9 |
10 | private SharedPreferenceUtil() {
11 | throw new UnsupportedOperationException("cannot be instantiated");
12 | }
13 |
14 | public static void write(String name, String key, Object value) {
15 | SharedPreferences sp = BaseApplication.getApplication().getSharedPreferences(name, Context.MODE_PRIVATE);
16 | SharedPreferences.Editor editor = sp.edit();
17 | if (value instanceof String) {
18 | editor.putString(key, (String) value);
19 | } else if (value instanceof Integer) {
20 | editor.putInt(key, (Integer) value);
21 | } else if (value instanceof Float) {
22 | editor.putFloat(key, (Float) value);
23 | } else if (value instanceof Long) {
24 | editor.putLong(key, (Long) value);
25 | } else if (value instanceof Boolean) {
26 | editor.putBoolean(key, (Boolean) value);
27 | }
28 | editor.apply();
29 | }
30 |
31 | public static String read(String name, String key, String defValue) {
32 | SharedPreferences sp = BaseApplication.getApplication().getSharedPreferences(name, Context.MODE_PRIVATE);
33 | return sp.getString(key, defValue);
34 | }
35 |
36 | public static int read(String name, String key, int defValue) {
37 | SharedPreferences sp = BaseApplication.getApplication().getSharedPreferences(name, Context.MODE_PRIVATE);
38 | return sp.getInt(key, defValue);
39 | }
40 |
41 | public static boolean read(String name, String key, boolean defValue) {
42 | SharedPreferences sp = BaseApplication.getApplication().getSharedPreferences(name, Context.MODE_PRIVATE);
43 | return sp.getBoolean(key, defValue);
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/SoftKeyboardUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.view.View;
5 | import android.view.inputmethod.InputMethodManager;
6 |
7 | public class SoftKeyboardUtil {
8 |
9 | private SoftKeyboardUtil() {
10 | throw new UnsupportedOperationException("cannot be instantiated");
11 | }
12 |
13 | /**
14 | * 隐藏软键盘
15 | *
16 | * @param view
17 | */
18 | public static void hideSoftKeyboard(View view) {
19 | InputMethodManager imm = (InputMethodManager) view.getContext()
20 | .getSystemService(Context.INPUT_METHOD_SERVICE);
21 | if (imm != null) {
22 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/util/ToastUtil.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.util;
2 |
3 | import android.content.Context;
4 | import android.widget.Toast;
5 |
6 | public class ToastUtil {
7 |
8 | private static Toast toast;
9 |
10 | private ToastUtil() {
11 |
12 | }
13 |
14 | public static void show(Context context, int resId) {
15 | if (toast == null) {
16 | toast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
17 | } else {
18 | toast.setText(resId);
19 | }
20 | toast.show();
21 | }
22 |
23 | public static void show(Context context, CharSequence text) {
24 | if (toast == null) {
25 | toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
26 | } else {
27 | toast.setText(text);
28 | }
29 | toast.show();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/widget/WebProgressBar.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.widget;
2 |
3 | import android.content.Context;
4 | import android.graphics.Canvas;
5 | import android.graphics.Color;
6 | import android.graphics.Paint;
7 | import android.util.AttributeSet;
8 | import android.util.TypedValue;
9 | import android.view.View;
10 |
11 | /**
12 | * WebView 渐变增长进度的进度条
13 | */
14 | public class WebProgressBar extends View {
15 | private int progress = 0;
16 | private int height = dp2Px(5);
17 | private Paint paint;
18 |
19 | public WebProgressBar(Context context, AttributeSet attrs) {
20 | super(context, attrs);
21 | }
22 |
23 | public WebProgressBar(Context context) {
24 | super(context);
25 | paint = new Paint(Paint.DITHER_FLAG);
26 | paint.setStyle(Paint.Style.STROKE);
27 | paint.setStrokeWidth(height);
28 | paint.setAntiAlias(true);
29 | paint.setColor(Color.parseColor("#ff616161"));
30 | }
31 |
32 | /**
33 | * WebViewProgressBar 作用于 progress 属性进行增长动画,
34 | * 故需要提供 set() 方法
35 | *
36 | * @param progress
37 | */
38 | public void setProgress(int progress) {
39 | this.progress = progress;
40 | invalidate();
41 | }
42 |
43 | public int getProgress() {
44 | return progress;
45 | }
46 |
47 | @Override
48 | protected void onDraw(Canvas canvas) {
49 | canvas.drawRect(0, 0, getWidth() * progress / 100, height, paint);
50 | }
51 |
52 | private int dp2Px(int dpValue) {
53 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dpValue, getResources().getDisplayMetrics());
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/widget/flow/FlowAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.widget.flow;
2 |
3 | import android.view.View;
4 | import android.view.ViewGroup;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Arrays;
8 | import java.util.List;
9 |
10 | public abstract class FlowAdapter {
11 |
12 | private List dataList;
13 |
14 | public FlowAdapter(List list) {
15 | this.dataList = list;
16 | }
17 |
18 | public FlowAdapter(T[] list) {
19 | this.dataList = new ArrayList<>(Arrays.asList(list));
20 | }
21 |
22 | public T getItem(int position) {
23 | return dataList.get(position);
24 | }
25 |
26 | public int getCount() {
27 | return dataList == null ? 0 : dataList.size();
28 | }
29 |
30 | public abstract View getView(int position, T t, ViewGroup parent);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/widget/flow/FlowChildPosition.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.widget.flow;
2 |
3 | public class FlowChildPosition {
4 |
5 | public int left;
6 | public int top;
7 | public int right;
8 | public int bottom;
9 |
10 | public FlowChildPosition() {
11 | }
12 |
13 | public FlowChildPosition(int left, int top, int right, int bottom) {
14 | this.left = left;
15 | this.top = top;
16 | this.right = right;
17 | this.bottom = bottom;
18 | }
19 |
20 | @Override
21 | public String toString() {
22 | return "FlowChildPosition{" +
23 | "left=" + left +
24 | ", top=" + top +
25 | ", right=" + right +
26 | ", bottom=" + bottom +
27 | '}';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/common_base/src/main/java/com/xing/commonbase/widget/gridviewpager/GridViewPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.commonbase.widget.gridviewpager;
2 |
3 | import java.util.List;
4 |
5 | public abstract class GridViewPagerAdapter {
6 |
7 | private List list;
8 |
9 | public GridViewPagerAdapter(List list) {
10 | this.list = list;
11 | }
12 |
13 | public List getDataList() {
14 | return list;
15 | }
16 |
17 | public abstract void bindData(GridRecyclerAdapter.ViewHolder viewHolder, T t, int position);
18 |
19 | }
--------------------------------------------------------------------------------
/common_base/src/main/res/anim/anim_alpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/common_base/src/main/res/anim/anim_web_enter.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/common_base/src/main/res/anim/anim_web_exit.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xhdpi/ic_close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xhdpi/ic_close.png
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xxhdpi/ic_favorite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xxhdpi/ic_favorite.png
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xxhdpi/ic_favorite_fill.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xxhdpi/ic_favorite_fill.png
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xxhdpi/ic_right_more.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xxhdpi/ic_right_more.png
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xxhdpi/icon_back.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xxhdpi/icon_back.png
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xxhdpi/splash.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xxhdpi/splash.png
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable-xxhdpi/test.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/drawable-xxhdpi/test.jpeg
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable/selector_mine_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable/shape_bottom_shadow.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
8 |
9 |
--------------------------------------------------------------------------------
/common_base/src/main/res/drawable/shape_circle_white.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/common_base/src/main/res/layout/item_grid_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/common_base/src/main/res/layout/layout_back.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/common_base/src/main/res/layout/layout_grid_viewpager.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
25 |
26 |
--------------------------------------------------------------------------------
/common_base/src/main/res/layout/layout_item_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
14 |
15 |
22 |
23 |
32 |
33 |
41 |
42 |
43 |
44 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/common_base/src/main/res/layout/layout_no_network_tip.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
15 |
16 |
--------------------------------------------------------------------------------
/common_base/src/main/res/layout/layout_toolbar.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
--------------------------------------------------------------------------------
/common_base/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/common_base/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/common_base/src/main/res/values-v19/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 25dp
4 |
--------------------------------------------------------------------------------
/common_base/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 |
--------------------------------------------------------------------------------
/common_base/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ffff
4 | #ffff
5 | #ffff
6 | #ff616161
7 | #ffeaeaea
8 | #ff616161
9 | #ff868686
10 | #fff5f5f5
11 | #fff4f5f6
12 | #ffaaaaaa
13 | #ff333333
14 | #ff999999
15 | #fffcfcfc
16 |
--------------------------------------------------------------------------------
/common_base/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 0dp
4 |
--------------------------------------------------------------------------------
/common_base/src/main/res/values/ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/common_base/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | common_base
3 | 收藏
4 | 登录
5 | 搜索
6 | 轻松一刻
7 | 关于
8 | 设置
9 |
10 |
--------------------------------------------------------------------------------
/common_base/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
--------------------------------------------------------------------------------
/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 | # 标示各个业务组件是否以 application 单独运行,修改后需要同步才能生效
15 | isRunAlone=false
16 |
17 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/keystore/keystore.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/keystore/keystore.jks
--------------------------------------------------------------------------------
/module_gank/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_gank/build.gradle:
--------------------------------------------------------------------------------
1 | if (isRunAlone.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 |
7 | android {
8 | compileSdkVersion rootProject.ext.android.compileSdkVersion
9 | buildToolsVersion rootProject.ext.android.buildToolsVersion
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.android.minSdkVersion
12 | targetSdkVersion rootProject.ext.android.targetSdkVersion
13 | versionCode rootProject.ext.android.versionCode
14 | versionName rootProject.ext.android.versionName
15 |
16 | javaCompileOptions {
17 | annotationProcessorOptions {
18 | arguments = [AROUTER_MODULE_NAME: project.getName()]
19 | }
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | sourceSets {
31 | main {
32 | if (isRunAlone.toBoolean()) {
33 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
34 | } else {
35 | manifest.srcFile 'src/main/AndroidManifest.xml'
36 | java {
37 | // 全部 module 一起编译时剔除 debug 目录
38 | exclude '**/debug/**'
39 | }
40 | }
41 | }
42 | }
43 |
44 | }
45 |
46 | dependencies {
47 | implementation project(':common_base')
48 | // arouter-compiler
49 | annotationProcessor rootProject.ext.dependencies['arouter-compiler']
50 | annotationProcessor rootProject.ext.dependencies['glide-compiler']
51 | }
52 |
--------------------------------------------------------------------------------
/module_gank/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module_gank/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/module_gank/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/module_gank/src/main/java/com/xing/module/gank/adapter/ImagePreviewAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.module.gank.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 | import com.chad.library.adapter.base.BaseQuickAdapter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 | import com.github.chrisbanes.photoview.OnOutsidePhotoTapListener;
10 | import com.github.chrisbanes.photoview.OnPhotoTapListener;
11 | import com.github.chrisbanes.photoview.PhotoView;
12 | import com.xing.module.gank.R;
13 | import com.xing.module.gank.activity.ImagePreviewActivity;
14 | import com.xing.module.gank.bean.MeiziResult;
15 |
16 | import java.util.List;
17 |
18 | public class ImagePreviewAdapter extends BaseQuickAdapter {
19 |
20 | public ImagePreviewAdapter(int layoutResId, @Nullable List data) {
21 | super(layoutResId, data);
22 | }
23 |
24 | public ImagePreviewAdapter(@Nullable List data) {
25 | super(data);
26 | }
27 |
28 | @Override
29 | protected void convert(BaseViewHolder helper, MeiziResult item) {
30 | PhotoView photoView = helper.getView(R.id.pv_photo);
31 | photoView.setOnOutsidePhotoTapListener(new OnOutsidePhotoTapListener() {
32 | @Override
33 | public void onOutsidePhotoTap(ImageView imageView) {
34 | finishActivity();
35 | }
36 | });
37 | photoView.setOnPhotoTapListener(new OnPhotoTapListener() {
38 | @Override
39 | public void onPhotoTap(ImageView view, float x, float y) {
40 | finishActivity();
41 | }
42 | });
43 | Glide.with(mContext)
44 | .load(item.getUrl())
45 | .into(photoView);
46 |
47 | }
48 |
49 | private void finishActivity() {
50 | if (mContext instanceof ImagePreviewActivity) {
51 | ((ImagePreviewActivity) mContext).finish();
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/module_gank/src/main/java/com/xing/module/gank/adapter/MeiziAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.module.gank.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 | import com.chad.library.adapter.base.BaseQuickAdapter;
8 | import com.chad.library.adapter.base.BaseViewHolder;
9 | import com.xing.module.gank.R;
10 | import com.xing.module.gank.bean.MeiziResult;
11 |
12 | import java.util.List;
13 |
14 | public class MeiziAdapter extends BaseQuickAdapter {
15 |
16 | public MeiziAdapter(int layoutResId, @Nullable List data) {
17 | super(layoutResId, data);
18 | }
19 |
20 | public MeiziAdapter(@Nullable List data) {
21 | super(data);
22 | }
23 |
24 | @Override
25 | protected void convert(BaseViewHolder helper, MeiziResult item) {
26 | ImageView imageView = helper.getView(R.id.iv_meizi_image);
27 | Glide.with(mContext)
28 | .load(item.getUrl())
29 | .into(imageView);
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/module_gank/src/main/java/com/xing/module/gank/apiservice/GankApiService.java:
--------------------------------------------------------------------------------
1 | package com.xing.module.gank.apiservice;
2 |
3 |
4 | import com.xing.commonbase.base.BaseResponse;
5 | import com.xing.module.gank.bean.MeiziResult;
6 |
7 | import java.util.List;
8 |
9 | import io.reactivex.Observable;
10 | import okhttp3.ResponseBody;
11 | import retrofit2.http.GET;
12 | import retrofit2.http.Path;
13 | import retrofit2.http.Streaming;
14 | import retrofit2.http.Url;
15 |
16 | public interface GankApiService {
17 |
18 | @GET("http://gank.io/api/data/福利/{pageSize}/{page}")
19 | Observable>> getMeiziList(@Path("pageSize") int pageSize, @Path("page") int page);
20 |
21 | @Streaming
22 | @GET
23 | Observable downloadImage(@Url String url);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/module_gank/src/main/java/com/xing/module/gank/contract/MeiziContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.module.gank.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.module.gank.bean.MeiziResult;
5 |
6 | import java.util.List;
7 |
8 | public interface MeiziContract {
9 |
10 | interface View extends IView {
11 | void onMeiziList(List meiziResults);
12 | }
13 |
14 | interface Presenter {
15 | void getMeiziList(int pageSize, int page);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/module_gank/src/main/java/com/xing/module/gank/presenter/MeiziPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.module.gank.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.module.gank.apiservice.GankApiService;
6 | import com.xing.module.gank.bean.MeiziResult;
7 | import com.xing.module.gank.contract.MeiziContract;
8 |
9 | import java.util.List;
10 |
11 | public class MeiziPresenter extends BasePresenter implements MeiziContract.Presenter {
12 |
13 | @Override
14 | public void getMeiziList(int pageSize, int page) {
15 | addSubscribe(create(GankApiService.class).getMeiziList(pageSize, page),
16 | new BaseObserver>(getView()) {
17 |
18 | @Override
19 | protected void onSuccess(List data) {
20 | if (isViewAttached()) {
21 | getView().onMeiziList(data);
22 | }
23 | }
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/drawable-xxhdpi/ic_grid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_gank/src/main/res/drawable-xxhdpi/ic_grid.png
--------------------------------------------------------------------------------
/module_gank/src/main/res/drawable-xxhdpi/ic_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_gank/src/main/res/drawable-xxhdpi/ic_list.png
--------------------------------------------------------------------------------
/module_gank/src/main/res/drawable/shape_image_save_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | -
4 |
5 |
6 |
7 |
8 |
9 |
10 | -
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/layout/activity_image_preview.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
21 |
22 |
30 |
31 |
47 |
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/layout/activity_meizi_image.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
16 |
17 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/layout/item_image_preview.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/layout/item_meizi.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
17 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/menu/menu_image_meizi.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/module_gank/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_gank
3 | 妹子
4 | %1$d / %2$d
5 |
6 |
--------------------------------------------------------------------------------
/module_main/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_main/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module_main/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
12 |
16 |
19 |
22 |
25 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/module_main/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
16 |
17 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
30 |
34 |
35 |
38 |
41 |
44 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.activity;
2 |
3 | import android.support.v7.widget.Toolbar;
4 | import android.view.View;
5 |
6 | import com.alibaba.android.arouter.facade.annotation.Route;
7 | import com.xing.commonbase.base.BaseActivity;
8 | import com.xing.main.R;
9 |
10 | @Route(path = "/main/AboutActivity")
11 | public class AboutActivity extends BaseActivity {
12 |
13 | @Override
14 | protected int getLayoutResId() {
15 | return R.layout.activity_about;
16 | }
17 |
18 | @Override
19 | protected void initView() {
20 | Toolbar toolbar = findViewById(R.id.toolbar);
21 | setSupportActionBar(toolbar);
22 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
23 | getSupportActionBar().setTitle(R.string.about);
24 | toolbar.setNavigationOnClickListener(new View.OnClickListener() {
25 | @Override
26 | public void onClick(View v) {
27 | finish();
28 | }
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/FavoriteAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.FavoriteResult;
9 |
10 | import java.util.List;
11 |
12 | public class FavoriteAdapter extends BaseQuickAdapter {
13 |
14 |
15 | public FavoriteAdapter(int layoutResId, @Nullable List data) {
16 | super(layoutResId, data);
17 | }
18 |
19 | @Override
20 | protected void convert(BaseViewHolder helper, FavoriteResult.DatasBean item) {
21 | helper.setText(R.id.tv_article_title, item.getTitle())
22 | .setText(R.id.tv_article_author, item.getAuthor())
23 | .setText(R.id.tv_article_time, item.getNiceDate());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/HomeArticleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.HomeArticleResult;
9 |
10 | import java.util.List;
11 |
12 | public class HomeArticleAdapter extends BaseQuickAdapter {
13 |
14 | public HomeArticleAdapter(int layoutResId) {
15 | super(layoutResId);
16 | }
17 |
18 | public HomeArticleAdapter(int layoutResId, @Nullable List data) {
19 | super(layoutResId, data);
20 | }
21 |
22 | @Override
23 | protected void convert(BaseViewHolder helper, HomeArticleResult.DatasBean item) {
24 | helper.setText(R.id.tv_article_title, item.getTitle())
25 | .setText(R.id.tv_article_author, item.getAuthor())
26 | .setText(R.id.tv_article_time, item.getNiceDate());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/ProjectPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 |
4 | import android.support.annotation.NonNull;
5 | import android.support.annotation.Nullable;
6 | import android.support.v4.app.Fragment;
7 | import android.support.v4.app.FragmentManager;
8 | import android.support.v4.app.FragmentPagerAdapter;
9 | import android.view.ViewGroup;
10 |
11 | import com.xing.main.bean.ProjectPageItem;
12 |
13 | import java.util.List;
14 |
15 | public class ProjectPagerAdapter extends FragmentPagerAdapter {
16 |
17 | private List projectPageItems;
18 |
19 | public ProjectPagerAdapter(FragmentManager fm) {
20 | super(fm);
21 | }
22 |
23 | public void setPages(List pageItemList) {
24 | this.projectPageItems = pageItemList;
25 | notifyDataSetChanged();
26 | }
27 |
28 | @Override
29 | public Fragment getItem(int i) {
30 | return projectPageItems.get(i).getFragment();
31 | }
32 |
33 | @Override
34 | public int getCount() {
35 | return projectPageItems == null ? 0 : projectPageItems.size();
36 | }
37 |
38 | @Nullable
39 | @Override
40 | public CharSequence getPageTitle(int position) {
41 | return projectPageItems.get(position).getName();
42 | }
43 |
44 | @Override
45 | public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) {
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/ProjectRecyclerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.text.TextUtils;
5 | import android.widget.ImageView;
6 |
7 | import com.bumptech.glide.Glide;
8 | import com.chad.library.adapter.base.BaseQuickAdapter;
9 | import com.chad.library.adapter.base.BaseViewHolder;
10 | import com.xing.main.R;
11 | import com.xing.main.bean.ProjectResult;
12 |
13 | import java.util.List;
14 |
15 | public class ProjectRecyclerAdapter extends BaseQuickAdapter {
16 |
17 | public ProjectRecyclerAdapter(int layoutResId, @Nullable List data) {
18 | super(layoutResId, data);
19 | }
20 |
21 | @Override
22 | protected void convert(BaseViewHolder helper, ProjectResult.DatasBean item) {
23 | helper.setText(R.id.tv_project_title, item.getTitle());
24 | helper.setText(R.id.tv_project_author, item.getAuthor() + "\t\t" + item.getNiceDate());
25 | String envelopePic = item.getEnvelopePic();
26 | if (TextUtils.isEmpty(envelopePic)) {
27 | helper.setGone(R.id.iv_project_img,false); // 隐藏图片占位
28 | }else {
29 | Glide.with(mContext)
30 | .load(envelopePic)
31 | .centerCrop()
32 | .into((ImageView) helper.getView(R.id.iv_project_img));
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/SearchHistoryAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.db.SearchHistory;
9 |
10 | import java.util.List;
11 |
12 | public class SearchHistoryAdapter extends BaseQuickAdapter {
13 |
14 | public SearchHistoryAdapter(int layoutResId, @Nullable List data) {
15 | super(layoutResId, data);
16 | }
17 |
18 | @Override
19 | protected void convert(BaseViewHolder helper, SearchHistory item) {
20 | helper.setText(R.id.tv_search_history_title, item.getKeyword());
21 | helper.addOnClickListener(R.id.iv_search_history_del);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/SearchResultAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 | import android.text.TextUtils;
5 | import android.widget.ImageView;
6 |
7 | import com.bumptech.glide.Glide;
8 | import com.chad.library.adapter.base.BaseQuickAdapter;
9 | import com.chad.library.adapter.base.BaseViewHolder;
10 | import com.xing.main.R;
11 | import com.xing.main.bean.SearchResult;
12 |
13 | import java.util.List;
14 |
15 | public class SearchResultAdapter extends BaseQuickAdapter {
16 |
17 | public SearchResultAdapter(int layoutResId, @Nullable List data) {
18 | super(layoutResId, data);
19 | }
20 |
21 | @Override
22 | protected void convert(BaseViewHolder helper, SearchResult.DatasBean item) {
23 | helper.setText(R.id.tv_search_title, item.getTitle())
24 | .setText(R.id.tv_search_desc, item.getDesc())
25 | .setText(R.id.tv_search_author, item.getAuthor())
26 | .setText(R.id.tv_search_time, item.getNiceDate());
27 | String envelopePic = item.getEnvelopePic();
28 | if (TextUtils.isEmpty(envelopePic)) {
29 | helper.setGone(R.id.iv_search_icon, false);
30 | } else {
31 | helper.setGone(R.id.iv_search_icon, true);
32 | ImageView iconImgView = helper.getView(R.id.iv_search_icon);
33 | Glide.with(mContext)
34 | .load(envelopePic)
35 | .into(iconImgView);
36 | }
37 |
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/SystemArticleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.SystemArticleResult;
9 |
10 | import java.util.List;
11 |
12 | public class SystemArticleAdapter extends BaseQuickAdapter {
13 |
14 | public SystemArticleAdapter(int layoutResId, @Nullable List data) {
15 | super(layoutResId, data);
16 | }
17 |
18 | public SystemArticleAdapter(@Nullable List data) {
19 | super(data);
20 | }
21 |
22 | @Override
23 | protected void convert(BaseViewHolder helper, SystemArticleResult.DatasBean item) {
24 | helper.setText(R.id.tv_article_title, item.getTitle())
25 | .setText(R.id.tv_article_author, item.getAuthor())
26 | .setText(R.id.tv_article_time, item.getNiceDate());
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/SystemLeftAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.SystemResult;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * 体系中一级列表(左侧) recyclerview 适配器
14 | */
15 | public class SystemLeftAdapter extends BaseQuickAdapter {
16 |
17 | public SystemLeftAdapter(int layoutResId, @Nullable List data) {
18 | super(layoutResId, data);
19 | }
20 |
21 | @Override
22 | protected void convert(BaseViewHolder helper, SystemResult item) {
23 | helper.setText(R.id.tv_system_left_title, item.getName())
24 | .setBackgroundColor(R.id.tv_system_left_title, item.isSelected() ? 0xffffffff : 0xffeeeeee);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/SystemRightAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.SystemResult;
9 |
10 | import java.util.List;
11 |
12 | /**
13 | * 体系中二级列表(右侧) recyclerview 适配器
14 | */
15 | public class SystemRightAdapter extends BaseQuickAdapter {
16 |
17 | public SystemRightAdapter(int layoutResId) {
18 | super(layoutResId);
19 | }
20 |
21 | public SystemRightAdapter(int layoutResId, @Nullable List data) {
22 | super(layoutResId, data);
23 | }
24 |
25 | @Override
26 | protected void convert(BaseViewHolder helper, SystemResult.ChildrenBean item) {
27 | helper.setText(R.id.tv_system_right_title, item.getName());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/adapter/WeChatArticleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.adapter;
2 |
3 | import android.support.annotation.Nullable;
4 |
5 | import com.chad.library.adapter.base.BaseQuickAdapter;
6 | import com.chad.library.adapter.base.BaseViewHolder;
7 | import com.xing.main.R;
8 | import com.xing.main.bean.WeChatArticleResult;
9 |
10 | import java.util.List;
11 |
12 | public class WeChatArticleAdapter extends BaseQuickAdapter {
13 |
14 | public WeChatArticleAdapter(int layoutResId) {
15 | super(layoutResId);
16 | }
17 |
18 | public WeChatArticleAdapter(int layoutResId, @Nullable List data) {
19 | super(layoutResId, data);
20 | }
21 |
22 | @Override
23 | protected void convert(BaseViewHolder helper, WeChatArticleResult.DatasBean item) {
24 | helper.setText(R.id.tv_article_title, item.getTitle())
25 | .setText(R.id.tv_article_author, item.getAuthor())
26 | .setText(R.id.tv_article_time, item.getNiceDate());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/annotation/UserLoginTrace.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target(ElementType.METHOD)
10 | public @interface UserLoginTrace {
11 | int value();
12 | }
13 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/BannerResult.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean;
2 |
3 | public class BannerResult {
4 |
5 |
6 | /**
7 | * desc : 一起来做个App吧
8 | * id : 10
9 | * imagePath : https://www.wanandroid.com/blogimgs/50c115c2-cf6c-4802-aa7b-a4334de444cd.png
10 | * isVisible : 1
11 | * order : 1
12 | * title : 一起来做个App吧
13 | * type : 0
14 | * url : http://www.wanandroid.com/blog/show/2
15 | */
16 |
17 | private String desc;
18 | private int id;
19 | private String imagePath;
20 | private int isVisible;
21 | private int order;
22 | private String title;
23 | private int type;
24 | private String url;
25 |
26 | public String getDesc() {
27 | return desc;
28 | }
29 |
30 | public void setDesc(String desc) {
31 | this.desc = desc;
32 | }
33 |
34 | public int getId() {
35 | return id;
36 | }
37 |
38 | public void setId(int id) {
39 | this.id = id;
40 | }
41 |
42 | public String getImagePath() {
43 | return imagePath;
44 | }
45 |
46 | public void setImagePath(String imagePath) {
47 | this.imagePath = imagePath;
48 | }
49 |
50 | public int getIsVisible() {
51 | return isVisible;
52 | }
53 |
54 | public void setIsVisible(int isVisible) {
55 | this.isVisible = isVisible;
56 | }
57 |
58 | public int getOrder() {
59 | return order;
60 | }
61 |
62 | public void setOrder(int order) {
63 | this.order = order;
64 | }
65 |
66 | public String getTitle() {
67 | return title;
68 | }
69 |
70 | public void setTitle(String title) {
71 | this.title = title;
72 | }
73 |
74 | public int getType() {
75 | return type;
76 | }
77 |
78 | public void setType(int type) {
79 | this.type = type;
80 | }
81 |
82 | public String getUrl() {
83 | return url;
84 | }
85 |
86 | public void setUrl(String url) {
87 | this.url = url;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/FavoriteAddResult.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean;
2 |
3 | public class FavoriteAddResult {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/ProjectPageItem.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean;
2 |
3 | import android.support.v4.app.Fragment;
4 |
5 | public class ProjectPageItem {
6 |
7 | private int id;
8 | private String name;
9 | private Fragment fragment;
10 |
11 | public ProjectPageItem() {
12 | }
13 |
14 | public ProjectPageItem(int id, String name, Fragment fragment) {
15 | this.id = id;
16 | this.name = name;
17 | this.fragment = fragment;
18 | }
19 |
20 | public int getId() {
21 | return id;
22 | }
23 |
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 |
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | public void setName(String name) {
33 | this.name = name;
34 | }
35 |
36 | public Fragment getFragment() {
37 | return fragment;
38 | }
39 |
40 | public void setFragment(Fragment fragment) {
41 | this.fragment = fragment;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/ProjectTabItem.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean;
2 |
3 | public class ProjectTabItem {
4 |
5 | private int courseId;
6 | private int id;
7 | private String name;
8 | private long order;
9 | private int parentChapterId;
10 | private boolean userControlSetTop;
11 | private int visible;
12 |
13 | public ProjectTabItem() {
14 | }
15 |
16 | public int getCourseId() {
17 | return courseId;
18 | }
19 |
20 | public void setCourseId(int courseId) {
21 | this.courseId = courseId;
22 | }
23 |
24 | public int getId() {
25 | return id;
26 | }
27 |
28 | public void setId(int id) {
29 | this.id = id;
30 | }
31 |
32 | public String getName() {
33 | return name;
34 | }
35 |
36 | public void setName(String name) {
37 | this.name = name;
38 | }
39 |
40 | public long getOrder() {
41 | return order;
42 | }
43 |
44 | public void setOrder(long order) {
45 | this.order = order;
46 | }
47 |
48 | public int getParentChapterId() {
49 | return parentChapterId;
50 | }
51 |
52 | public void setParentChapterId(int parentChapterId) {
53 | this.parentChapterId = parentChapterId;
54 | }
55 |
56 | public boolean isUserControlSetTop() {
57 | return userControlSetTop;
58 | }
59 |
60 | public void setUserControlSetTop(boolean userControlSetTop) {
61 | this.userControlSetTop = userControlSetTop;
62 | }
63 |
64 | public int getVisible() {
65 | return visible;
66 | }
67 |
68 | public void setVisible(int visible) {
69 | this.visible = visible;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/SearchHotKey.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean;
2 |
3 | public class SearchHotKey {
4 |
5 |
6 | /**
7 | * id : 6
8 | * link :
9 | * name : 面试
10 | * order : 1
11 | * visible : 1
12 | */
13 |
14 | private int id;
15 | private String link;
16 | private String name;
17 | private int order;
18 | private int visible;
19 |
20 | public int getId() {
21 | return id;
22 | }
23 |
24 | public void setId(int id) {
25 | this.id = id;
26 | }
27 |
28 | public String getLink() {
29 | return link;
30 | }
31 |
32 | public void setLink(String link) {
33 | this.link = link;
34 | }
35 |
36 | public String getName() {
37 | return name;
38 | }
39 |
40 | public void setName(String name) {
41 | this.name = name;
42 | }
43 |
44 | public int getOrder() {
45 | return order;
46 | }
47 |
48 | public void setOrder(int order) {
49 | this.order = order;
50 | }
51 |
52 | public int getVisible() {
53 | return visible;
54 | }
55 |
56 | public void setVisible(int visible) {
57 | this.visible = visible;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/WeChatAuthorResult.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | public class WeChatAuthorResult implements Serializable {
7 |
8 |
9 | /**
10 | * children : []
11 | * courseId : 13
12 | * id : 408
13 | * name : 鸿洋
14 | * order : 190000
15 | * parentChapterId : 407
16 | * userControlSetTop : false
17 | * visible : 1
18 | */
19 |
20 | private int courseId;
21 | private int id;
22 | private String name;
23 | private int order;
24 | private int parentChapterId;
25 | private boolean userControlSetTop;
26 | private int visible;
27 | private List> children;
28 |
29 | public int getCourseId() {
30 | return courseId;
31 | }
32 |
33 | public void setCourseId(int courseId) {
34 | this.courseId = courseId;
35 | }
36 |
37 | public int getId() {
38 | return id;
39 | }
40 |
41 | public void setId(int id) {
42 | this.id = id;
43 | }
44 |
45 | public String getName() {
46 | return name;
47 | }
48 |
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | public int getOrder() {
54 | return order;
55 | }
56 |
57 | public void setOrder(int order) {
58 | this.order = order;
59 | }
60 |
61 | public int getParentChapterId() {
62 | return parentChapterId;
63 | }
64 |
65 | public void setParentChapterId(int parentChapterId) {
66 | this.parentChapterId = parentChapterId;
67 | }
68 |
69 | public boolean isUserControlSetTop() {
70 | return userControlSetTop;
71 | }
72 |
73 | public void setUserControlSetTop(boolean userControlSetTop) {
74 | this.userControlSetTop = userControlSetTop;
75 | }
76 |
77 | public int getVisible() {
78 | return visible;
79 | }
80 |
81 | public void setVisible(int visible) {
82 | this.visible = visible;
83 | }
84 |
85 | public List> getChildren() {
86 | return children;
87 | }
88 |
89 | public void setChildren(List> children) {
90 | this.children = children;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/bean/db/SearchHistory.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.bean.db;
2 |
3 |
4 | import org.greenrobot.greendao.annotation.Entity;
5 | import org.greenrobot.greendao.annotation.Id;
6 | import org.greenrobot.greendao.annotation.Generated;
7 |
8 | @Entity(nameInDb = "SearchHistory")
9 | public class SearchHistory {
10 |
11 | @Id(autoincrement = true)
12 | private Long id;
13 | private String keyword;
14 | private Long time;
15 |
16 | public SearchHistory(String keyword, Long time) {
17 | this.keyword = keyword;
18 | this.time = time;
19 | }
20 |
21 |
22 | @Generated(hash = 238310654)
23 | public SearchHistory(Long id, String keyword, Long time) {
24 | this.id = id;
25 | this.keyword = keyword;
26 | this.time = time;
27 | }
28 |
29 | @Generated(hash = 1905904755)
30 | public SearchHistory() {
31 | }
32 |
33 | public Long getId() {
34 | return this.id;
35 | }
36 |
37 | public void setId(Long id) {
38 | this.id = id;
39 | }
40 |
41 | public String getKeyword() {
42 | return this.keyword;
43 | }
44 |
45 | public void setKeyword(String keyword) {
46 | this.keyword = keyword;
47 | }
48 |
49 | public Long getTime() {
50 | return this.time;
51 | }
52 |
53 | public void setTime(Long time) {
54 | this.time = time;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return "SearchHistory{" +
60 | "id=" + id +
61 | ", keyword='" + keyword + '\'' +
62 | ", time=" + time +
63 | '}';
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/FavoriteContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.FavoriteResult;
5 |
6 | public interface FavoriteContract {
7 |
8 | interface View extends IView {
9 | void onFavoriteList(FavoriteResult result);
10 | }
11 |
12 | interface Presenter {
13 | void getFavoriteList(int page);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/HomeContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.BannerResult;
5 | import com.xing.main.bean.HomeArticleResult;
6 | import com.xing.main.bean.WeChatAuthorResult;
7 |
8 | import java.util.List;
9 |
10 | public interface HomeContract {
11 |
12 | interface View extends IView {
13 | /**
14 | * banner 数据回调
15 | */
16 | void onBanner(List bannerResults);
17 |
18 | /**
19 | * 公众号数据回调
20 | */
21 | void onWeChatAuthors(List weChatAuthorResults);
22 |
23 |
24 | /**
25 | * 首页文章列表数据回调
26 | *
27 | * @param result
28 | */
29 | void onHomeArticles(HomeArticleResult result);
30 | }
31 |
32 | interface Presenter {
33 | /**
34 | * 获取 banner 数据
35 | */
36 | void getBanner();
37 |
38 | /**
39 | * 获取公众号列表
40 | */
41 | void getWeChatAuthors();
42 |
43 | /**
44 | * 获取首页文章列表
45 | */
46 | void getHomeArticles(int page);
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/MainContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 |
5 | public interface MainContract {
6 |
7 | interface View extends IView {
8 | }
9 |
10 | interface Presenter {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/ProjectContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.ProjectPageItem;
5 |
6 | import java.util.List;
7 |
8 | public interface ProjectContract {
9 |
10 | interface View extends IView {
11 | void onProjectTabs(List projectPageItemList);
12 | }
13 |
14 | interface Presenter {
15 | void getProjectTabs();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/ProjectPageContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.ProjectResult;
5 |
6 | public interface ProjectPageContract {
7 |
8 | interface View extends IView {
9 | void onProjectList(ProjectResult projectResult);
10 | }
11 |
12 | interface Presenter {
13 | void getProjects(int id, int page);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/SearchHistoryContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.SearchHotKey;
5 | import com.xing.main.bean.db.SearchHistory;
6 |
7 | import java.util.List;
8 |
9 | public interface SearchHistoryContract {
10 |
11 | interface View extends IView {
12 |
13 | /**
14 | * 搜索热词
15 | */
16 | void onSearchHotKey(List searchHotKeys);
17 |
18 | /**
19 | * 搜索历史
20 | */
21 | void onSearchHistory(List searchHistories);
22 |
23 | /**
24 | * 删除所有搜索历史
25 | */
26 | void onDeleteAllHistory();
27 |
28 |
29 | }
30 |
31 | interface Presenter {
32 |
33 | /**
34 | * 搜索热词
35 | */
36 | void getSearchHotKey();
37 |
38 | /**
39 | * 搜索历史
40 | */
41 | void getSearchHistory();
42 |
43 | /**
44 | * 删除所有搜索历史
45 | */
46 | void deleteAllHistory();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/SearchResultContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.SearchResult;
5 |
6 | public interface SearchResultContract {
7 |
8 | interface View extends IView {
9 | void onSearchResult(SearchResult searchResults);
10 | }
11 |
12 | interface Presenter {
13 | /**
14 | * 保存搜索历史记录
15 | *
16 | * @param keyword
17 | */
18 | void saveSearchHistory(String keyword);
19 |
20 | /**
21 | * 获取搜索结果
22 | *
23 | * @param page
24 | * @param keyword
25 | */
26 | void getSearchResult(int page, String keyword);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/SystemArticleContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.SystemArticleResult;
5 |
6 | public interface SystemArticleContract {
7 |
8 | interface View extends IView {
9 | void onSystemArticleList(SystemArticleResult result);
10 | }
11 |
12 | interface Presenter {
13 | void getSystemArticleList(int page, int id);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/SystemContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.SystemResult;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * 体系 contract
10 | */
11 | public interface SystemContract {
12 |
13 | interface View extends IView {
14 | void onSystemList(List systemResults);
15 | }
16 |
17 | interface Presenter {
18 | /**
19 | * 获取体系分类列表
20 | */
21 | void getSystemList();
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/WeChatArticleListContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.main.bean.WeChatArticleResult;
5 |
6 | public interface WeChatArticleListContract {
7 |
8 | interface View extends IView {
9 | void onWeChatArticleList(WeChatArticleResult result);
10 | }
11 |
12 | interface Presenter {
13 | void getWeChatArticle(int id, int page);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/contract/WebContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 |
5 | public interface WebContract {
6 | interface View extends IView {
7 | /**
8 | * 添加收藏成功回调
9 | */
10 | void onFavoriteAdded();
11 |
12 | /**
13 | * 删除收藏成功回调
14 | */
15 | void onFavoriteDeleted();
16 | }
17 |
18 | interface Presenter {
19 | /**
20 | * 添加收藏
21 | *
22 | * @param id
23 | * @param title
24 | * @param author
25 | * @param link
26 | */
27 | void addArticleFavorite(int id, String title, String author, String link);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/db/DaoSession.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.db;
2 |
3 | import java.util.Map;
4 |
5 | import org.greenrobot.greendao.AbstractDao;
6 | import org.greenrobot.greendao.AbstractDaoSession;
7 | import org.greenrobot.greendao.database.Database;
8 | import org.greenrobot.greendao.identityscope.IdentityScopeType;
9 | import org.greenrobot.greendao.internal.DaoConfig;
10 |
11 | import com.xing.main.bean.db.SearchHistory;
12 |
13 | import com.xing.main.db.SearchHistoryDao;
14 |
15 | // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
16 |
17 | /**
18 | * {@inheritDoc}
19 | *
20 | * @see org.greenrobot.greendao.AbstractDaoSession
21 | */
22 | public class DaoSession extends AbstractDaoSession {
23 |
24 | private final DaoConfig searchHistoryDaoConfig;
25 |
26 | private final SearchHistoryDao searchHistoryDao;
27 |
28 | public DaoSession(Database db, IdentityScopeType type, Map>, DaoConfig>
29 | daoConfigMap) {
30 | super(db);
31 |
32 | searchHistoryDaoConfig = daoConfigMap.get(SearchHistoryDao.class).clone();
33 | searchHistoryDaoConfig.initIdentityScope(type);
34 |
35 | searchHistoryDao = new SearchHistoryDao(searchHistoryDaoConfig, this);
36 |
37 | registerDao(SearchHistory.class, searchHistoryDao);
38 | }
39 |
40 | public void clear() {
41 | searchHistoryDaoConfig.clearIdentityScope();
42 | }
43 |
44 | public SearchHistoryDao getSearchHistoryDao() {
45 | return searchHistoryDao;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/db/DbManager.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.db;
2 |
3 | import android.database.sqlite.SQLiteDatabase;
4 |
5 | import com.xing.commonbase.base.BaseApplication;
6 |
7 | public class DbManager {
8 |
9 | private static DbManager instance;
10 | private final SearchHistoryDao searchHistoryDao;
11 |
12 | private DbManager() {
13 | DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(BaseApplication.getApplication().getApplicationContext(), "WanAndroid");
14 | SQLiteDatabase database = helper.getWritableDatabase();
15 | DaoMaster daoMaster = new DaoMaster(database);
16 | DaoSession daoSession = daoMaster.newSession();
17 | searchHistoryDao = daoSession.getSearchHistoryDao();
18 | }
19 |
20 | public static DbManager getInstance() {
21 | if (instance == null) {
22 | synchronized (DbManager.class) {
23 | if (instance == null) {
24 | instance = new DbManager();
25 | }
26 | }
27 | }
28 | return instance;
29 | }
30 |
31 | public SearchHistoryDao getSearchHistoryDao() {
32 | return searchHistoryDao;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/fragment/CategoryFragment.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.fragment;
2 |
3 | import android.content.Context;
4 | import android.support.design.widget.TabLayout;
5 | import android.support.v4.view.ViewPager;
6 | import android.view.View;
7 |
8 | import com.xing.commonbase.base.BaseMVPFragment;
9 | import com.xing.main.R;
10 | import com.xing.main.adapter.ProjectPagerAdapter;
11 | import com.xing.main.bean.ProjectPageItem;
12 | import com.xing.main.contract.ProjectContract;
13 | import com.xing.main.presenter.ProjectPresenter;
14 |
15 | import java.util.List;
16 |
17 |
18 | public class CategoryFragment extends BaseMVPFragment
19 | implements ProjectContract.View {
20 |
21 | private ViewPager viewPager;
22 | private TabLayout tabLayout;
23 |
24 | public CategoryFragment() {
25 | }
26 |
27 | @Override
28 | protected ProjectPresenter createPresenter() {
29 | return new ProjectPresenter();
30 | }
31 |
32 | @Override
33 | protected int getLayoutResId() {
34 | return R.layout.fragment_project;
35 | }
36 |
37 | @Override
38 | protected void initView(View rootView) {
39 | tabLayout = rootView.findViewById(R.id.tl_project);
40 | viewPager = rootView.findViewById(R.id.vp_project_page);
41 | }
42 |
43 | @Override
44 | protected void initData() {
45 | presenter.getProjectTabs();
46 | }
47 |
48 | @Override
49 | public void onAttach(Context context) {
50 | super.onAttach(context);
51 | }
52 |
53 | @Override
54 | public void onDetach() {
55 | super.onDetach();
56 | }
57 |
58 | @Override
59 | public void showLoading() {
60 |
61 | }
62 |
63 | @Override
64 | public void hideLoading() {
65 |
66 | }
67 |
68 | @Override
69 | public void onProjectTabs(List projectPageItemList) {
70 | ProjectPagerAdapter pagerAdapter = new ProjectPagerAdapter(getChildFragmentManager());
71 | pagerAdapter.setPages(projectPageItemList);
72 | viewPager.setAdapter(pagerAdapter);
73 | tabLayout.setupWithViewPager(viewPager);
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/imageloader/GlideImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.imageloader;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import com.bumptech.glide.Glide;
7 | import com.youth.banner.loader.ImageLoader;
8 |
9 | public class GlideImageLoader extends ImageLoader {
10 |
11 | @Override
12 | public void displayImage(Context context, Object path, ImageView imageView) {
13 | //Glide 加载图片简单用法
14 | Glide.with(context).load(path).into(imageView);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/FavoritePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.FavoriteResult;
7 | import com.xing.main.contract.FavoriteContract;
8 |
9 | public class FavoritePresenter extends BasePresenter
10 | implements FavoriteContract.Presenter {
11 |
12 | @Override
13 | public void getFavoriteList(int page) {
14 | addSubscribe(create(MainApiService.class).getFavoriteList(page), new BaseObserver(getView()) {
15 |
16 | @Override
17 | protected void onSuccess(FavoriteResult data) {
18 | if (isViewAttached()) {
19 | getView().onFavoriteList(data);
20 | }
21 | }
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/HomePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.BannerResult;
7 | import com.xing.main.bean.HomeArticleResult;
8 | import com.xing.main.bean.WeChatAuthorResult;
9 | import com.xing.main.contract.HomeContract;
10 |
11 | import java.util.List;
12 |
13 | public class HomePresenter extends BasePresenter implements HomeContract.Presenter {
14 |
15 |
16 | /**
17 | * 获取 Banner 数据
18 | */
19 | @Override
20 | public void getBanner() {
21 | addSubscribe(create(MainApiService.class).getBanner(), new BaseObserver>(getView()) {
22 | @Override
23 | protected void onSuccess(List data) {
24 | if (isViewAttached()) {
25 | getView().onBanner(data);
26 | }
27 | }
28 | });
29 | }
30 |
31 | @Override
32 | public void getWeChatAuthors() {
33 | addSubscribe(create(MainApiService.class).getWeChatAuthors(), new BaseObserver>() {
34 | @Override
35 | protected void onSuccess(List data) {
36 | if (isViewAttached()) {
37 | getView().onWeChatAuthors(data);
38 | }
39 | }
40 | });
41 | }
42 |
43 | /**
44 | * 获取首页文章数据
45 | *
46 | * @param page
47 | */
48 | @Override
49 | public void getHomeArticles(int page) {
50 | addSubscribe(create(MainApiService.class).getHomeArticles(page), new BaseObserver(getView()) {
51 | @Override
52 | protected void onSuccess(HomeArticleResult data) {
53 | if (isViewAttached()) {
54 | getView().onHomeArticles(data);
55 | }
56 | }
57 | });
58 | }
59 |
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.mvp.BasePresenter;
4 | import com.xing.main.contract.MainContract;
5 |
6 | public class MainPresenter extends BasePresenter implements MainContract.Presenter {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/ProjectPagePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.ProjectResult;
7 | import com.xing.main.contract.ProjectPageContract;
8 |
9 | public class ProjectPagePresenter extends BasePresenter
10 | implements ProjectPageContract.Presenter {
11 |
12 | @Override
13 | public void getProjects(int id, int page) {
14 | addSubscribe(create(MainApiService.class).getProjects(page, id),
15 | new BaseObserver(getView()) {
16 |
17 | @Override
18 | protected void onSuccess(ProjectResult data) {
19 | if (isViewAttached()) {
20 | getView().onProjectList(data);
21 | }
22 | }
23 | });
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/ProjectPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.ProjectPageItem;
7 | import com.xing.main.bean.ProjectTabItem;
8 | import com.xing.main.contract.ProjectContract;
9 | import com.xing.main.fragment.ProjectPageFragment;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class ProjectPresenter extends BasePresenter implements ProjectContract.Presenter {
15 |
16 |
17 | /**
18 | * project 栏目
19 | */
20 | @Override
21 | public void getProjectTabs() {
22 | addSubscribe(create(MainApiService.class).getProjectTabs(), new BaseObserver>() {
23 | @Override
24 | protected void onSuccess(List data) {
25 | List projectPageItemList = createProjectPages(data);
26 | if (isViewAttached()) {
27 | getView().onProjectTabs(projectPageItemList);
28 | }
29 |
30 | }
31 | });
32 | }
33 |
34 | private List createProjectPages(List projectItems) {
35 | if (projectItems == null || projectItems.size() == 0) {
36 | return new ArrayList<>();
37 | }
38 | List projectPageItemList = new ArrayList<>();
39 | for (ProjectTabItem projectItem : projectItems) {
40 | ProjectPageItem projectPageItem = new ProjectPageItem(projectItem.getId(),
41 | projectItem.getName(), ProjectPageFragment.newInstance(projectItem.getId()));
42 | projectPageItemList.add(projectPageItem);
43 | }
44 | return projectPageItemList;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/SystemArticlePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.SystemArticleResult;
7 | import com.xing.main.contract.SystemArticleContract;
8 |
9 | public class SystemArticlePresenter extends BasePresenter
10 | implements SystemArticleContract.Presenter {
11 |
12 | @Override
13 | public void getSystemArticleList(int page, int id) {
14 | addSubscribe(create(MainApiService.class).getSystemArticles(page, id),
15 | new BaseObserver(getView()) {
16 |
17 | @Override
18 | protected void onSuccess(SystemArticleResult data) {
19 | if (isViewAttached()) {
20 | getView().onSystemArticleList(data);
21 | }
22 | }
23 | });
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/SystemPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.SystemResult;
7 | import com.xing.main.contract.SystemContract;
8 |
9 | import java.util.List;
10 |
11 | public class SystemPresenter extends BasePresenter
12 | implements SystemContract.Presenter {
13 |
14 | @Override
15 | public void getSystemList() {
16 | addSubscribe(create(MainApiService.class).getSystemList(),
17 | new BaseObserver>(getView()) {
18 |
19 | @Override
20 | protected void onSuccess(List data) {
21 | if (isViewAttached()) {
22 | getView().onSystemList(data);
23 | }
24 | }
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/WeChatArticlePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.WeChatArticleResult;
7 | import com.xing.main.contract.WeChatArticleListContract;
8 |
9 | public class WeChatArticlePresenter extends BasePresenter
10 | implements WeChatArticleListContract.Presenter {
11 |
12 | @Override
13 | public void getWeChatArticle(int id, int page) {
14 | addSubscribe(create(MainApiService.class).getWeChatArticles(id, page),
15 | new BaseObserver(getView()) {
16 |
17 | @Override
18 | protected void onSuccess(WeChatArticleResult data) {
19 | if (isViewAttached()) {
20 | getView().onWeChatArticleList(data);
21 | }
22 | }
23 | });
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/module_main/src/main/java/com/xing/main/presenter/WebPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.main.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.main.apiservice.MainApiService;
6 | import com.xing.main.bean.FavoriteAddResult;
7 | import com.xing.main.contract.WebContract;
8 |
9 | import io.reactivex.Observable;
10 |
11 | public class WebPresenter extends BasePresenter implements WebContract.Presenter {
12 |
13 | @Override
14 | public void addArticleFavorite(int id, String title, String author, String link) {
15 | Observable observable;
16 | if (id == -1) { // 站外文章
17 | observable = create(MainApiService.class).addFavorite(title, author, link);
18 | } else { // 站内文章
19 | observable = create(MainApiService.class).addFavorite(id);
20 | }
21 | addSubscribe(observable, new BaseObserver() {
22 |
23 | @Override
24 | protected void onSuccess(FavoriteAddResult data) {
25 | if (isViewAttached()) {
26 | getView().onFavoriteAdded();
27 | }
28 | }
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_home_logo_black.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xhdpi/ic_home_logo_black.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xhdpi/ic_home_logo_white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xhdpi/ic_home_logo_white.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_delete.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_delete_all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_delete_all.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_mine_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_mine_about.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_mine_favorite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_mine_favorite.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_mine_happy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_mine_happy.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_mine_setting.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_mine_setting.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_search.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/ic_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/ic_share.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_category_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_category_sel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_category_unsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_category_unsel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_home_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_home_sel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_home_unsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_home_unsel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_mine_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_mine_sel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_mine_unsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_mine_unsel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_project_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_project_sel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_project_unsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_project_unsel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_system_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_system_sel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_system_unsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_system_unsel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_wechat_sel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_wechat_sel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable-xxhdpi/icon_menu_wechat_unsel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_main/src/main/res/drawable-xxhdpi/icon_menu_wechat_unsel.png
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/selector_menu_category.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/selector_menu_home.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/selector_menu_mine.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/selector_menu_project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/selector_menu_system.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/shape_home_input.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/shape_home_input_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/shape_home_wechat_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/module_main/src/main/res/drawable/shape_search_history_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
9 |
10 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
20 |
21 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_favorite.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
17 |
18 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_search.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
23 |
24 |
35 |
36 |
44 |
45 |
46 |
47 |
51 |
52 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_system_article.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_we_chat_article_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
16 |
17 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/activity_web_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
16 |
17 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/fragment_project.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
30 |
31 |
32 |
33 |
37 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/fragment_project_page.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
11 |
12 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/fragment_search_history.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/fragment_search_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
14 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/fragment_system.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
16 |
20 |
21 |
25 |
26 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_home_article.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
19 |
20 |
25 |
26 |
34 |
35 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_home_wechat_authors.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
20 |
21 |
31 |
32 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_recycler_project.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
24 |
25 |
34 |
35 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_search_history_content.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
29 |
30 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_search_result.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
20 |
21 |
26 |
27 |
33 |
34 |
40 |
41 |
42 |
43 |
51 |
52 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_system_left.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
21 |
22 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/item_system_right.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
21 |
22 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/layout_home_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
19 |
20 |
--------------------------------------------------------------------------------
/module_main/src/main/res/layout/layout_search_history_header.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
23 |
24 |
28 |
29 |
37 |
38 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/module_main/src/main/res/menu/menu_web.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/module_main/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_main
3 |
4 | 搜索文章
5 | 添加收藏成功
6 | 删除收藏成功
7 |
8 |
--------------------------------------------------------------------------------
/module_usercenter/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/module_usercenter/build.gradle:
--------------------------------------------------------------------------------
1 | if (isRunAlone.toBoolean()) {
2 | apply plugin: 'com.android.application'
3 | } else {
4 | apply plugin: 'com.android.library'
5 | }
6 |
7 | android {
8 | compileSdkVersion rootProject.ext.android.compileSdkVersion
9 | buildToolsVersion rootProject.ext.android.buildToolsVersion
10 | defaultConfig {
11 | minSdkVersion rootProject.ext.android.minSdkVersion
12 | targetSdkVersion rootProject.ext.android.targetSdkVersion
13 | versionCode rootProject.ext.android.versionCode
14 | versionName rootProject.ext.android.versionName
15 |
16 | javaCompileOptions {
17 | annotationProcessorOptions {
18 | arguments = [AROUTER_MODULE_NAME: project.getName()]
19 | }
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 |
30 | sourceSets {
31 | main {
32 | if (isRunAlone.toBoolean()) {
33 | manifest.srcFile 'src/main/debug/AndroidManifest.xml'
34 | } else {
35 | manifest.srcFile 'src/main/AndroidManifest.xml'
36 | java {
37 | // 全部 module 一起编译时剔除 debug 目录
38 | exclude '**/debug/**'
39 | }
40 | }
41 | }
42 | }
43 |
44 | }
45 |
46 | dependencies {
47 | implementation project(':common_base')
48 | // arouter-compiler
49 | annotationProcessor rootProject.ext.dependencies['arouter-compiler']
50 | annotationProcessor rootProject.ext.dependencies['glide-compiler']
51 | }
52 |
--------------------------------------------------------------------------------
/module_usercenter/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/activity/SplashActivity.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.activity;
2 |
3 | import com.alibaba.android.arouter.launcher.ARouter;
4 | import com.xing.commonbase.base.BaseActivity;
5 | import com.xing.usercenter.R;
6 |
7 |
8 | public class SplashActivity extends BaseActivity {
9 |
10 | @Override
11 | protected int getLayoutResId() {
12 | return R.layout.activity_splash;
13 | }
14 |
15 | @Override
16 | protected void initView() {
17 | }
18 |
19 | @Override
20 | protected void onResume() {
21 | super.onResume();
22 | gotoMainActivity();
23 | }
24 |
25 | private void gotoMainActivity() {
26 | ARouter.getInstance().build("/main/MainActivity").navigation();
27 | finish();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/apiservice/UserCenterApiService.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.apiservice;
2 |
3 | import com.xing.commonbase.base.BaseResponse;
4 | import com.xing.usercenter.bean.LoginResult;
5 | import com.xing.usercenter.bean.RegisterResult;
6 |
7 | import io.reactivex.Observable;
8 | import retrofit2.http.Field;
9 | import retrofit2.http.FormUrlEncoded;
10 | import retrofit2.http.POST;
11 |
12 | public interface UserCenterApiService {
13 | /**
14 | * 注册
15 | *
16 | * @param username
17 | * @param password
18 | * @param repassword
19 | * @return
20 | */
21 | @POST("user/register")
22 | @FormUrlEncoded
23 | Observable> register(@Field("username") String username,
24 | @Field("password") String password,
25 | @Field("repassword") String repassword);
26 |
27 |
28 | /**
29 | * 登录
30 | *
31 | * @param username
32 | * @param password
33 | * @return
34 | */
35 | @POST("user/login")
36 | @FormUrlEncoded
37 | Observable> login(@Field("username") String username,
38 | @Field("password") String password);
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/bean/LoginResult.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.bean;
2 |
3 | import java.util.List;
4 |
5 | public class LoginResult {
6 |
7 |
8 | /**
9 | * chapterTops : []
10 | * collectIds : []
11 | * email :
12 | * icon :
13 | * id : 20685
14 | * password :
15 | * token :
16 | * type : 0
17 | * username : xing2019
18 | */
19 |
20 | private String email;
21 | private String icon;
22 | private int id;
23 | private String password;
24 | private String token;
25 | private int type;
26 | private String username;
27 | private List> chapterTops;
28 | private List> collectIds;
29 |
30 | public String getEmail() {
31 | return email;
32 | }
33 |
34 | public void setEmail(String email) {
35 | this.email = email;
36 | }
37 |
38 | public String getIcon() {
39 | return icon;
40 | }
41 |
42 | public void setIcon(String icon) {
43 | this.icon = icon;
44 | }
45 |
46 | public int getId() {
47 | return id;
48 | }
49 |
50 | public void setId(int id) {
51 | this.id = id;
52 | }
53 |
54 | public String getPassword() {
55 | return password;
56 | }
57 |
58 | public void setPassword(String password) {
59 | this.password = password;
60 | }
61 |
62 | public String getToken() {
63 | return token;
64 | }
65 |
66 | public void setToken(String token) {
67 | this.token = token;
68 | }
69 |
70 | public int getType() {
71 | return type;
72 | }
73 |
74 | public void setType(int type) {
75 | this.type = type;
76 | }
77 |
78 | public String getUsername() {
79 | return username;
80 | }
81 |
82 | public void setUsername(String username) {
83 | this.username = username;
84 | }
85 |
86 | public List> getChapterTops() {
87 | return chapterTops;
88 | }
89 |
90 | public void setChapterTops(List> chapterTops) {
91 | this.chapterTops = chapterTops;
92 | }
93 |
94 | public List> getCollectIds() {
95 | return collectIds;
96 | }
97 |
98 | public void setCollectIds(List> collectIds) {
99 | this.collectIds = collectIds;
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/bean/RegisterResult.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.bean;
2 |
3 | public class RegisterResult {
4 | }
5 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/contract/LoginContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.usercenter.bean.LoginResult;
5 |
6 | public interface LoginContract {
7 |
8 | interface View extends IView {
9 | void loginSuccess(LoginResult result);
10 | }
11 |
12 | interface Presenter {
13 | void login(String phone, String password);
14 | }
15 | }
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/contract/RegisterContract.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.contract;
2 |
3 | import com.xing.commonbase.mvp.IView;
4 | import com.xing.usercenter.bean.RegisterResult;
5 |
6 | public interface RegisterContract {
7 |
8 | interface View extends IView {
9 | void registerSuccess(RegisterResult result);
10 | }
11 |
12 | interface Presenter {
13 | void register(String phone, String password, String repassword);
14 | }
15 | }
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/presenter/LoginPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.constants.Constants;
5 | import com.xing.commonbase.mvp.BasePresenter;
6 | import com.xing.commonbase.util.SharedPreferenceUtil;
7 | import com.xing.usercenter.apiservice.UserCenterApiService;
8 | import com.xing.usercenter.bean.LoginResult;
9 | import com.xing.usercenter.contract.LoginContract;
10 |
11 | public class LoginPresenter extends BasePresenter
12 | implements LoginContract.Presenter {
13 |
14 | @Override
15 | public void login(String username, String password) {
16 | addSubscribe(create(UserCenterApiService.class).login(username, password), new BaseObserver(getView()) {
17 |
18 | @Override
19 | protected void onSuccess(LoginResult data) {
20 | if (isViewAttached()) {
21 | getView().loginSuccess(data);
22 | }
23 | }
24 | });
25 | }
26 |
27 | /**
28 | * 保存 cookie 至本地
29 | *
30 | * @param result
31 | */
32 | private void saveCookie(LoginResult result) {
33 | if (result != null) {
34 | // SharedPreferenceUtils.write(Constants.File_TOKEN, Constants.ACCESS_TOKEN, result.getAccessToken());
35 | }
36 | }
37 |
38 | /**
39 | * 保存手机号和密码
40 | *
41 | * @param username
42 | * @param password
43 | */
44 | public void saveUsernamePassword(String username, String password) {
45 | SharedPreferenceUtil.write(Constants.USER_LOGIN, Constants.USERNAME, username);
46 | SharedPreferenceUtil.write(Constants.USER_LOGIN, Constants.PASSWORD, password);
47 | }
48 |
49 | public String readUsernamePassword(String key) {
50 | return SharedPreferenceUtil.read(Constants.USER_LOGIN, key, "");
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/java/com/xing/usercenter/presenter/RegisterPresenter.java:
--------------------------------------------------------------------------------
1 | package com.xing.usercenter.presenter;
2 |
3 | import com.xing.commonbase.base.BaseObserver;
4 | import com.xing.commonbase.mvp.BasePresenter;
5 | import com.xing.usercenter.apiservice.UserCenterApiService;
6 | import com.xing.usercenter.bean.RegisterResult;
7 | import com.xing.usercenter.contract.RegisterContract;
8 |
9 | public class RegisterPresenter extends BasePresenter
10 | implements RegisterContract.Presenter {
11 |
12 | private final UserCenterApiService apiService;
13 |
14 | public RegisterPresenter() {
15 | apiService = create(UserCenterApiService.class);
16 | }
17 |
18 | @Override
19 | public void register(String username, String password, String repassword) {
20 | addSubscribe(apiService.register(username, password, repassword), new BaseObserver(getView()) {
21 |
22 | @Override
23 | protected void onSuccess(RegisterResult data) {
24 | if (isViewAttached()) {
25 | getView().registerSuccess(data);
26 | }
27 | }
28 | });
29 | }
30 | }
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable-xhdpi/login_icon_password.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_usercenter/src/main/res/drawable-xhdpi/login_icon_password.png
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable-xhdpi/login_icon_phone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_usercenter/src/main/res/drawable-xhdpi/login_icon_phone.png
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable-xhdpi/login_icon_pwd_visible.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_usercenter/src/main/res/drawable-xhdpi/login_icon_pwd_visible.png
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable-xhdpi/login_input_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_usercenter/src/main/res/drawable-xhdpi/login_input_bg.9.png
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable-xxhdpi/splash_tip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_usercenter/src/main/res/drawable-xxhdpi/splash_tip.png
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable-xxhdpi/splash_water.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xing16/WanAndroid/a95556c409376eed360e837df6c31964f228c0bc/module_usercenter/src/main/res/drawable-xxhdpi/splash_water.png
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable/selector_login_btn_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 |
7 |
8 |
9 |
10 |
11 | -
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/drawable/splash_bg.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | -
7 |
11 |
12 |
13 | -
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/layout/activity_splash.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | module_usercenter
3 | 请输入用户名
4 | 请输入密码
5 | 注册账号
6 | 登录
7 | 用户注册
8 | 注册
9 |
10 |
--------------------------------------------------------------------------------
/module_usercenter/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
13 |
22 |
23 |
30 |
31 |
32 |
40 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':common_base', ':module_usercenter', ':module_main', ':module_gank'
2 |
--------------------------------------------------------------------------------