├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── github
│ │ └── cyc
│ │ └── wanandroid
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── github
│ │ │ └── cyc
│ │ │ └── wanandroid
│ │ │ ├── app
│ │ │ ├── Constant.java
│ │ │ ├── GlideImageLoader.java
│ │ │ ├── Injection.java
│ │ │ ├── MyAppGlideModule.java
│ │ │ ├── NoProguard.java
│ │ │ ├── ScrollToTop.java
│ │ │ └── WanApplication.java
│ │ │ ├── base
│ │ │ ├── activity
│ │ │ │ └── BaseActivity.java
│ │ │ ├── adapter
│ │ │ │ ├── BaseAdapter.java
│ │ │ │ ├── BasePagerAdapter.java
│ │ │ │ └── BaseTagAdapter.java
│ │ │ ├── fragment
│ │ │ │ ├── BaseFragment.java
│ │ │ │ └── BaseLazyFragment.java
│ │ │ ├── viewholder
│ │ │ │ └── BaseViewHolder.java
│ │ │ └── viewmodel
│ │ │ │ ├── BaseItemViewModel.java
│ │ │ │ └── BaseViewModel.java
│ │ │ ├── behavior
│ │ │ ├── BottomNavigationBehavior.java
│ │ │ └── FloatingActionButtonBehavior.java
│ │ │ ├── binding
│ │ │ └── WanBindingAdapter.java
│ │ │ ├── data
│ │ │ ├── DataManager.java
│ │ │ └── source
│ │ │ │ ├── HttpDataSource.java
│ │ │ │ └── IHttpDataSource.java
│ │ │ ├── enums
│ │ │ ├── LoadState.java
│ │ │ └── RefreshState.java
│ │ │ ├── http
│ │ │ ├── HttpCode.java
│ │ │ ├── RetrofitManager.java
│ │ │ ├── api
│ │ │ │ └── ApiService.java
│ │ │ ├── base
│ │ │ │ ├── BaseObserver.java
│ │ │ │ └── ObserverX.java
│ │ │ └── model
│ │ │ │ ├── Article.java
│ │ │ │ ├── ArticleList.java
│ │ │ │ ├── Banner.java
│ │ │ │ ├── Chapter.java
│ │ │ │ ├── Navigation.java
│ │ │ │ ├── Response.java
│ │ │ │ └── Tag.java
│ │ │ ├── module
│ │ │ ├── details
│ │ │ │ ├── activity
│ │ │ │ │ └── DetailsActivity.java
│ │ │ │ └── viewmodel
│ │ │ │ │ └── DetailsViewModel.java
│ │ │ ├── main
│ │ │ │ ├── activity
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ └── SystemDetailsActivity.java
│ │ │ │ ├── adapter
│ │ │ │ │ ├── ArticleListAdapter.java
│ │ │ │ │ ├── ArticleListPagerAdapter.java
│ │ │ │ │ ├── NavigationListAdapter.java
│ │ │ │ │ ├── NavigationTagAdapter.java
│ │ │ │ │ ├── ProjectListAdapter.java
│ │ │ │ │ ├── ProjectListPagerAdapter.java
│ │ │ │ │ └── SystemListAdapter.java
│ │ │ │ ├── fragment
│ │ │ │ │ ├── ArticleListFragment.java
│ │ │ │ │ ├── HomepageFragment.java
│ │ │ │ │ ├── NavigationFragment.java
│ │ │ │ │ ├── ProjectFragment.java
│ │ │ │ │ ├── ProjectListFragment.java
│ │ │ │ │ ├── SystemFragment.java
│ │ │ │ │ └── WeChatFragment.java
│ │ │ │ ├── model
│ │ │ │ │ ├── BannerData.java
│ │ │ │ │ └── HomepageData.java
│ │ │ │ ├── viewholder
│ │ │ │ │ ├── ArticleViewHolder.java
│ │ │ │ │ ├── BannerViewHolder.java
│ │ │ │ │ ├── NavigationViewHolder.java
│ │ │ │ │ ├── ProjectViewHolder.java
│ │ │ │ │ └── SystemViewHolder.java
│ │ │ │ └── viewmodel
│ │ │ │ │ ├── ArticleListViewModel.java
│ │ │ │ │ ├── HomepageViewModel.java
│ │ │ │ │ ├── MainViewModel.java
│ │ │ │ │ ├── NavigationViewModel.java
│ │ │ │ │ ├── ProjectListViewModel.java
│ │ │ │ │ ├── ProjectViewModel.java
│ │ │ │ │ ├── SystemViewModel.java
│ │ │ │ │ ├── WeChatViewModel.java
│ │ │ │ │ └── item
│ │ │ │ │ ├── ArticleViewModel.java
│ │ │ │ │ ├── BannerViewModel.java
│ │ │ │ │ ├── NavigationViewModel.java
│ │ │ │ │ ├── ProjectViewModel.java
│ │ │ │ │ └── SystemViewModel.java
│ │ │ └── splash
│ │ │ │ ├── activity
│ │ │ │ └── SplashActivity.java
│ │ │ │ └── viewmodel
│ │ │ │ └── SplashViewModel.java
│ │ │ ├── navigator
│ │ │ ├── DetailsNavigator.java
│ │ │ ├── MainNavigator.java
│ │ │ └── SystemDetailsNavigator.java
│ │ │ └── utils
│ │ │ ├── ResourceUtils.java
│ │ │ ├── RxUtils.java
│ │ │ ├── ToastUtils.java
│ │ │ └── Utils.java
│ └── res
│ │ ├── color
│ │ └── selector_bottom_nav_item_color.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── animated_rotate_loading.xml
│ │ ├── ic_about.xml
│ │ ├── ic_arrow_back.xml
│ │ ├── ic_arrow_right.xml
│ │ ├── ic_arrow_upward.xml
│ │ ├── ic_error.xml
│ │ ├── ic_homepage.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── ic_menu.xml
│ │ ├── ic_navigation.xml
│ │ ├── ic_project.xml
│ │ ├── ic_settings.xml
│ │ ├── ic_system.xml
│ │ ├── ic_timelapse.xml
│ │ ├── ic_we_chat.xml
│ │ ├── selector_navigation_tag.xml
│ │ ├── shape_label_green.xml
│ │ └── shape_label_red.xml
│ │ ├── layout
│ │ ├── activity_base.xml
│ │ ├── activity_details.xml
│ │ ├── activity_main.xml
│ │ ├── activity_splash.xml
│ │ ├── activity_system_details.xml
│ │ ├── fragment_article_list.xml
│ │ ├── fragment_base.xml
│ │ ├── fragment_homepage.xml
│ │ ├── fragment_navigation.xml
│ │ ├── fragment_project.xml
│ │ ├── fragment_project_list.xml
│ │ ├── fragment_system.xml
│ │ ├── fragment_we_chat.xml
│ │ ├── item_article.xml
│ │ ├── item_banner.xml
│ │ ├── item_navigation.xml
│ │ ├── item_project.xml
│ │ ├── item_system.xml
│ │ ├── view_load_error.xml
│ │ ├── view_loading.xml
│ │ ├── view_nav_header.xml
│ │ ├── view_navigation_tag.xml
│ │ ├── view_no_data.xml
│ │ ├── view_no_network.xml
│ │ └── view_toolbar.xml
│ │ ├── menu
│ │ ├── menu_bottom_nav.xml
│ │ └── menu_drawer_nav.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── arrays.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ ├── strings_behavior.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── github
│ └── cyc
│ └── wanandroid
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── node_modules
├── conventional-commit-types
│ ├── .npmignore
│ ├── .travis.yml
│ ├── README.md
│ ├── index.json
│ └── package.json
├── cz-conventional-changelog
│ ├── .npmignore
│ ├── .travis.yml
│ ├── README.md
│ ├── engine.js
│ ├── index.js
│ └── package.json
├── lodash.map
│ ├── LICENSE
│ ├── README.md
│ ├── index.js
│ └── package.json
├── longest
│ ├── LICENSE
│ ├── README.md
│ ├── index.js
│ └── package.json
├── right-pad
│ ├── .npmignore
│ ├── README.md
│ ├── examples
│ │ └── basic.js
│ ├── package.json
│ └── rightpad.js
└── word-wrap
│ ├── LICENSE
│ ├── README.md
│ ├── index.d.ts
│ ├── index.js
│ └── package.json
├── package-lock.json
├── package.json
├── screenshots
├── 01-Homepage.jpg
├── 02-System.jpg
├── 03-WeChat.jpg
├── 04-Navigation.jpg
└── 05-Project.jpg
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea
3 | .gradle
4 | /local.properties
5 | /.idea/caches/build_file_checksums.ser
6 | /.idea/libraries
7 | /.idea/modules.xml
8 | /.idea/workspace.xml
9 | .DS_Store
10 | /build
11 | /captures
12 | .externalNativeBuild
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WanAndroid-Java
2 | 玩Android客户端
3 |
4 | ## 项目简介
5 | 一款基于玩Android开放API开发的玩Android客户端。整个项目采用MVVM + Retrofit + RxJava架构进行开发。
6 |
7 | ## 项目截图
8 |
9 |
13 |
14 | ## 项目版本
15 |
16 | ### v1.0.0
17 |
18 | * 基本功能
19 |
20 | ## 技术要点
21 |
22 | * 采用MVVM模式开发,视图操作和业务逻辑解耦
23 | * 采用DataBinding框架实现View与数据的绑定,View层做到极度简洁
24 | * 采用Lifecycle实现ViewModel的生命周期回调
25 | * 采用Retrofit + RxJava实现网络请求
26 | * 采用Glide实现图片加载
27 |
28 | ## 感谢
29 |
30 | ### API
31 |
32 | * [玩Android](https://www.wanandroid.com/)
33 |
34 | ### 开源库
35 |
36 | * [MVVM](https://github.com/googlesamples/android-architecture/tree/todo-mvvm-databinding/)
37 | * [OkHttp](https://github.com/square/okhttp)
38 | * [Retrofit](https://github.com/square/retrofit)
39 | * [RxJava](https://github.com/ReactiveX/RxJava)
40 | * [RxAndroid](https://github.com/ReactiveX/RxAndroid)
41 | * [Glide](https://github.com/bumptech/glide)
42 | * [Material design icons](https://github.com/google/material-design-icons)
43 | * [Commitizen](https://github.com/commitizen/cz-cli)
44 | * [LeakCanary](https://github.com/square/leakcanary)
45 | * [Logger](https://github.com/orhanobut/logger)
46 | * [MaterialRefreshLayout](https://github.com/android-cjj/Android-MaterialRefreshLayout)
47 | * [Banner](https://github.com/youth5201314/banner)
48 | * [AgentWeb](https://github.com/Justson/AgentWeb)
49 | * [VerticalTabLayout](https://github.com/qstumn/VerticalTabLayout)
50 | * [FlowLayout](https://github.com/hongyangAndroid/FlowLayout)
51 |
52 | ## 声明
53 | 本项目纯属学习交流使用。
54 |
55 | ## LICENSE
56 |
57 | Copyright (c) 2019-present, chongyucaiyan.
58 |
59 | Licensed under the Apache License, Version 2.0 (the "License");
60 | you may not use this file except in compliance with the License.
61 | You may obtain a copy of the License at
62 |
63 | http://www.apache.org/licenses/LICENSE-2.0
64 |
65 | Unless required by applicable law or agreed to in writing, software
66 | distributed under the License is distributed on an "AS IS" BASIS,
67 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
68 | See the License for the specific language governing permissions and
69 | limitations under the License.
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/github/cyc/wanandroid/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.github.cyc.wanandroid", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/Constant.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | /**
4 | * 常量
5 | */
6 | public interface Constant {
7 |
8 | String BASE_URL = "https://www.wanandroid.com/";
9 | String ABOUT_URL = "https://github.com/chongyucaiyan/WanAndroid-Java";
10 |
11 | String KEY_URL = "key_url";
12 | String KEY_ID = "key_id";
13 | String KEY_CHAPTER = "key_chapter";
14 |
15 | long SPLASH_TIME = 2000;
16 | long EXIT_TIME = 2000;
17 |
18 | long TIMEOUT_CONNECT = 10;
19 | long TIMEOUT_READ = 10;
20 | long TIMEOUT_WRITE = 10;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/GlideImageLoader.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | import android.content.Context;
4 | import android.widget.ImageView;
5 |
6 | import com.youth.banner.loader.ImageLoader;
7 |
8 | /**
9 | * Glide图片加载器。供Banner控件使用
10 | */
11 | public class GlideImageLoader extends ImageLoader {
12 |
13 | @Override
14 | public void displayImage(Context context, Object path, ImageView imageView) {
15 | GlideApp.with(context).load(path).into(imageView);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/Injection.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | import com.github.cyc.wanandroid.data.DataManager;
4 | import com.github.cyc.wanandroid.data.source.HttpDataSource;
5 | import com.github.cyc.wanandroid.http.RetrofitManager;
6 | import com.github.cyc.wanandroid.http.api.ApiService;
7 |
8 | /**
9 | * 依赖注入
10 | */
11 | public final class Injection {
12 |
13 | private Injection() {
14 |
15 | }
16 |
17 | /**
18 | * 提供DataManager
19 | *
20 | * @return DataManager
21 | */
22 | public static DataManager provideDataManager() {
23 | return DataManager.getInstance(HttpDataSource.getInstance(RetrofitManager.get().create(ApiService.class)));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/MyAppGlideModule.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 |
6 | import com.bumptech.glide.GlideBuilder;
7 | import com.bumptech.glide.annotation.GlideModule;
8 | import com.bumptech.glide.load.DecodeFormat;
9 | import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
10 | import com.bumptech.glide.load.engine.cache.LruResourceCache;
11 | import com.bumptech.glide.module.AppGlideModule;
12 | import com.bumptech.glide.request.RequestOptions;
13 |
14 | /**
15 | * Glide模块。配置Glide
16 | */
17 | @GlideModule
18 | public class MyAppGlideModule extends AppGlideModule {
19 |
20 | private static final long SIZE_MEMORY_CACHE = 1024 * 1024 * 20;
21 | private static final long SIZE_DISK_CACHE = 1024 * 1024 * 100;
22 |
23 | @Override
24 | public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder) {
25 | builder.setDefaultRequestOptions(new RequestOptions().format(DecodeFormat.PREFER_RGB_565))
26 | .setMemoryCache(new LruResourceCache(SIZE_MEMORY_CACHE))
27 | .setDiskCache(new InternalCacheDiskCacheFactory(context, SIZE_DISK_CACHE));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/NoProguard.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | /**
4 | * 实现该接口的类不混淆
5 | */
6 | public interface NoProguard {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/ScrollToTop.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | /**
4 | * 滚动到顶部接口
5 | */
6 | public interface ScrollToTop {
7 |
8 | /**
9 | * 滚动到顶部
10 | */
11 | void scrollToTop();
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/app/WanApplication.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.app;
2 |
3 | import android.app.Application;
4 | import android.support.annotation.Nullable;
5 |
6 | import com.github.cyc.wanandroid.BuildConfig;
7 | import com.github.cyc.wanandroid.R;
8 | import com.orhanobut.logger.AndroidLogAdapter;
9 | import com.orhanobut.logger.FormatStrategy;
10 | import com.orhanobut.logger.Logger;
11 | import com.orhanobut.logger.PrettyFormatStrategy;
12 | import com.squareup.leakcanary.LeakCanary;
13 | import com.squareup.leakcanary.RefWatcher;
14 |
15 | public class WanApplication extends Application {
16 |
17 | private static WanApplication sWanApplication;
18 |
19 | private static RefWatcher sRefWatcher;
20 |
21 | @Override
22 | public void onCreate() {
23 | super.onCreate();
24 | if (LeakCanary.isInAnalyzerProcess(this)) {
25 | // This process is dedicated to LeakCanary for heap analysis.
26 | // You should not init your app in this process.
27 | return;
28 | }
29 |
30 | sRefWatcher = LeakCanary.install(this);
31 | // Normal app init code...
32 |
33 | sWanApplication = this;
34 |
35 | initLogger();
36 | }
37 |
38 | public static WanApplication getInstance() {
39 | return sWanApplication;
40 | }
41 |
42 | public static RefWatcher getRefWatcher() {
43 | return sRefWatcher;
44 | }
45 |
46 | private void initLogger() {
47 | FormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
48 | .tag(getString(R.string.app_name))
49 | .build();
50 |
51 | Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) {
52 |
53 | @Override
54 | public boolean isLoggable(int priority, @Nullable String tag) {
55 | return BuildConfig.DEBUG;
56 | }
57 | });
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/app/src/main/java/com/github/cyc/wanandroid/base/adapter/BaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.github.cyc.wanandroid.base.adapter;
2 |
3 | import android.databinding.ObservableList;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 |
7 | /**
8 | * Adapter的基类
9 | */
10 | public abstract class BaseAdapter extends RecyclerView.Adapter {
11 |
12 | protected ObservableList