├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ ├── values-v21 │ │ │ └── styles.xml │ │ ├── drawable │ │ │ ├── side_nav_bar.xml │ │ │ ├── ic_menu.xml │ │ │ ├── ic_close.xml │ │ │ ├── ic_story_list.xml │ │ │ ├── ic_feedback.xml │ │ │ ├── ic_about.xml │ │ │ ├── ic_network_error.xml │ │ │ └── ic_settings.xml │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ ├── layout │ │ │ ├── fragment_story_detail.xml │ │ │ ├── content_story_detail.xml │ │ │ ├── content_story_list.xml │ │ │ ├── activity_story_detail.xml │ │ │ ├── app_bar_story_list.xml │ │ │ ├── app_bar.xml │ │ │ ├── activity_splash.xml │ │ │ ├── activity_story_list.xml │ │ │ ├── nav_header_story_list.xml │ │ │ ├── fragment_story_list.xml │ │ │ └── item_story.xml │ │ └── menu │ │ │ └── activity_story_list_drawer.xml │ │ ├── java │ │ └── org │ │ │ └── attentiveness │ │ │ └── news │ │ │ ├── base │ │ │ ├── BasePresenter.java │ │ │ ├── BaseView.java │ │ │ ├── BaseFragment.java │ │ │ └── BaseActivity.java │ │ │ ├── util │ │ │ ├── schedulers │ │ │ │ ├── BaseSchedulerProvider.java │ │ │ │ └── SchedulerProvider.java │ │ │ ├── LogUtil.java │ │ │ └── DateUtil.java │ │ │ ├── exception │ │ │ └── NetworkException.java │ │ │ ├── net │ │ │ ├── StoryService.java │ │ │ └── HttpManager.java │ │ │ ├── detail │ │ │ ├── StoryDetailContract.java │ │ │ ├── StoryDetailActivity.java │ │ │ ├── StoryDetailPresenter.java │ │ │ └── StoryDetailFragment.java │ │ │ ├── data │ │ │ ├── source │ │ │ │ ├── StoriesDataSource.java │ │ │ │ ├── local │ │ │ │ │ ├── StoriesPersistenceContract.java │ │ │ │ │ ├── StoriesDbHelper.java │ │ │ │ │ └── LocalStoriesDataSource.java │ │ │ │ ├── remote │ │ │ │ │ └── RemoteStoriesDataSource.java │ │ │ │ └── StoriesDataRepository.java │ │ │ ├── Story.java │ │ │ ├── News.java │ │ │ └── StoryDetail.java │ │ │ ├── list │ │ │ ├── StoryListContract.java │ │ │ ├── ScrollChildSwipeRefreshLayout.java │ │ │ ├── LoadMoreListener.java │ │ │ ├── StoryListAdapter.java │ │ │ ├── StoryListActivity.java │ │ │ ├── StoryListPresenter.java │ │ │ └── StoryListFragment.java │ │ │ └── splash │ │ │ └── SplashActivity.java │ │ └── AndroidManifest.xml ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── documents ├── event_flow.png ├── News_Android.vp └── requirements_analysis.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── README.md ├── gradle.properties ├── gradlew.bat ├── gradlew └── LICENSE /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' -------------------------------------------------------------------------------- /documents/event_flow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/documents/event_flow.png -------------------------------------------------------------------------------- /documents/News_Android.vp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/documents/News_Android.vp -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/attentiveness/News/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.base; 2 | 3 | 4 | public interface BasePresenter { 5 | 6 | void subscribe(); 7 | 8 | void unsubscribe(); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/base/BaseView.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.base; 2 | 3 | 4 | import android.support.annotation.NonNull; 5 | 6 | public interface BaseView { 7 | 8 | void setPresenter(@NonNull T presenter); 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 05 21:23:04 CST 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | > 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/side_nav_bar.xml: -------------------------------------------------------------------------------- 1 | 3 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #4CAF50 4 | #326917 5 | #FF4081 6 | 7 | #FFFFFF 8 | #E0E0E0 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 160dp 5 | 6 | 16dp 7 | 16dp 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/util/schedulers/BaseSchedulerProvider.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.util.schedulers; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import io.reactivex.Scheduler; 6 | 7 | 8 | public interface BaseSchedulerProvider { 9 | 10 | @NonNull 11 | Scheduler computation(); 12 | 13 | @NonNull 14 | Scheduler io(); 15 | 16 | @NonNull 17 | Scheduler ui(); 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_close.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/exception/NetworkException.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.exception; 2 | 3 | public class NetworkException extends Exception { 4 | 5 | public NetworkException() { 6 | super(); 7 | } 8 | 9 | public NetworkException(Throwable throwable) { 10 | super(throwable); 11 | } 12 | 13 | public NetworkException(String message) { 14 | super(message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_story_list.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_feedback.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .gradle/ 3 | 4 | build/ 5 | */build/ 6 | 7 | local.properties 8 | 9 | *.iml 10 | */*.iml 11 | 12 | # Crashlytics configuations 13 | com_crashlytics_export_strings.xml 14 | crashlytics-build.properties 15 | 16 | # Eclipse project files 17 | .classpath 18 | .project 19 | 20 | # OSX files 21 | .DS_Store 22 | .DS_Store? 23 | 24 | # Windows thumbnail db 25 | ehthumbs.db 26 | Thumbs.db 27 | 28 | # OS-specific files 29 | ._* 30 | .Spotlight-V100 31 | .Trashes 32 | 33 | # Log Files 34 | *.log -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # News 2 | The News app is a simple android app, which uses the MVP architecture. 3 | 4 | # Features 5 | * Use MVP architecture 6 | * Use popular third party libraries, such as: RxJava, OkHttp, Retrofit, Picasso and so on 7 | * Use different test methods to test different layers 8 | * Use Repository Design Pattern 9 | 10 | # Contributors 11 | [@WolfHan](https://github.com/wolfhan) 12 | [@Richard-Cao](https://github.com/Richard-Cao) 13 | 14 | # License 15 | Apache License 2.0 16 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/net/StoryService.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.net; 2 | 3 | import org.attentiveness.news.data.News; 4 | import org.attentiveness.news.data.StoryDetail; 5 | 6 | import io.reactivex.Observable; 7 | import retrofit2.http.GET; 8 | import retrofit2.http.Path; 9 | 10 | public interface StoryService { 11 | 12 | @GET("before/{date}") 13 | Observable getStoryList(@Path("date") String date); 14 | 15 | @GET("{id}") 16 | Observable getStoryDetail(@Path("id") int storyId); 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_story_detail.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.base; 2 | 3 | 4 | import android.support.design.widget.Snackbar; 5 | import android.support.v4.app.Fragment; 6 | import android.view.View; 7 | 8 | /** 9 | * Base Fragment 10 | */ 11 | public class BaseFragment extends Fragment { 12 | 13 | public BaseFragment() { 14 | // Required empty public constructor 15 | } 16 | 17 | protected void showMessage(View anchorView, String message) { 18 | Snackbar.make(anchorView, message, Snackbar.LENGTH_SHORT).show(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/detail/StoryDetailContract.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.detail; 2 | 3 | import org.attentiveness.news.base.BasePresenter; 4 | import org.attentiveness.news.base.BaseView; 5 | import org.attentiveness.news.data.StoryDetail; 6 | 7 | interface StoryDetailContract { 8 | 9 | interface View extends BaseView { 10 | 11 | void showStoryDetail(StoryDetail storyDetail); 12 | 13 | void showError(String message); 14 | 15 | boolean isActive(); 16 | 17 | } 18 | 19 | interface Presenter extends BasePresenter { 20 | 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_story_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_story_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_story_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_story_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_about.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/data/source/StoriesDataSource.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.data.source; 2 | 3 | import android.support.annotation.NonNull; 4 | 5 | import org.attentiveness.news.data.Story; 6 | import org.attentiveness.news.data.StoryDetail; 7 | 8 | import java.util.List; 9 | 10 | import io.reactivex.Observable; 11 | 12 | public interface StoriesDataSource { 13 | 14 | Observable> getStories(String date); 15 | 16 | Observable getStoryDetail(int storyId); 17 | 18 | void saveStories(@NonNull List storyList); 19 | 20 | void refreshStories(); 21 | 22 | void deleteAllStories(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_network_error.xml: -------------------------------------------------------------------------------- 1 | 6 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/util/LogUtil.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.util; 2 | 3 | import android.util.Log; 4 | 5 | public class LogUtil { 6 | 7 | private static boolean mDebug = true; 8 | 9 | public static void d(String message) { 10 | d("News", message); 11 | } 12 | 13 | public static void d(String tag, String message) { 14 | if (mDebug) { 15 | Log.d(tag, message); 16 | } 17 | } 18 | 19 | public static void e(String message) { 20 | e("News", message); 21 | } 22 | 23 | public static void e(String tag, String message) { 24 | if (mDebug) { 25 | Log.e(tag, message); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/java/org/attentiveness/news/data/source/local/StoriesPersistenceContract.java: -------------------------------------------------------------------------------- 1 | package org.attentiveness.news.data.source.local; 2 | 3 | import android.provider.BaseColumns; 4 | 5 | final class StoriesPersistenceContract { 6 | 7 | // To prevent someone from accidentally instantiating the contract class, 8 | // give it an empty constructor. 9 | private StoriesPersistenceContract() { 10 | } 11 | 12 | /* Inner class that defines the table contents */ 13 | static abstract class StoryEntry implements BaseColumns { 14 | static final String TABLE_NAME = "story"; 15 | static final String COLUMN_NAME_STORY_ID = "storyId"; 16 | static final String COLUMN_NAME_TITLE = "title"; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/richardcao/developer/android-sdk-macosx/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 |