├── crashlytics_release_notes.txt
├── settings.gradle
├── app
├── .gitignore
├── fabric.properties
├── keystore
│ └── debug.keystore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_drawer.png
│ │ │ │ ├── drawer_shadow.9.png
│ │ │ │ ├── ic_add_white_24dp.png
│ │ │ │ ├── ic_action_content_new.png
│ │ │ │ └── ic_attach_money_white_24dp.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_drawer.png
│ │ │ │ ├── drawer_shadow.9.png
│ │ │ │ ├── ic_add_white_24dp.png
│ │ │ │ ├── ic_action_content_new.png
│ │ │ │ └── ic_attach_money_white_24dp.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_drawer.png
│ │ │ │ ├── drawer_shadow.9.png
│ │ │ │ ├── ic_add_white_24dp.png
│ │ │ │ ├── ic_action_content_new.png
│ │ │ │ └── ic_attach_money_white_24dp.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── ic_drawer.png
│ │ │ │ ├── drawer_shadow.9.png
│ │ │ │ ├── ic_add_white_24dp.png
│ │ │ │ ├── ic_action_content_new.png
│ │ │ │ └── ic_attach_money_white_24dp.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable
│ │ │ │ ├── ic_action_content_new.png
│ │ │ │ ├── percent_change_pill.xml
│ │ │ │ ├── percent_change_pill_green.xml
│ │ │ │ ├── percent_change_pill_red.xml
│ │ │ │ └── touch_selector_dark.xml
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── ic_add_white_24dp.png
│ │ │ │ └── ic_attach_money_white_24dp.png
│ │ │ ├── values-w820dp
│ │ │ │ └── dimens.xml
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── drawable-v21
│ │ │ │ └── touch_selector_dark.xml
│ │ │ ├── xml
│ │ │ │ └── appwidget_info.xml
│ │ │ ├── menu
│ │ │ │ └── menu_main.xml
│ │ │ └── layout
│ │ │ │ ├── frame_container.xml
│ │ │ │ ├── appwidget_collection.xml
│ │ │ │ ├── fragment_stocks_graph.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── appwidget_collection_item.xml
│ │ │ │ └── item_stock.xml
│ │ ├── java
│ │ │ └── rajan
│ │ │ │ └── udacity
│ │ │ │ └── stock
│ │ │ │ └── hawk
│ │ │ │ ├── injection
│ │ │ │ ├── ActivityContext.java
│ │ │ │ ├── ApplicationContext.java
│ │ │ │ ├── PerActivity.java
│ │ │ │ ├── ConfigPersistent.java
│ │ │ │ ├── module
│ │ │ │ │ ├── ActivityModule.java
│ │ │ │ │ └── ApplicationModule.java
│ │ │ │ └── component
│ │ │ │ │ ├── ActivityComponent.java
│ │ │ │ │ ├── ConfigPersistentComponent.java
│ │ │ │ │ └── ApplicationComponent.java
│ │ │ │ ├── touch_helper
│ │ │ │ ├── ItemTouchHelperAdapter.java
│ │ │ │ ├── ItemTouchHelperViewHolder.java
│ │ │ │ └── SimpleItemTouchHelperCallback.java
│ │ │ │ ├── util
│ │ │ │ ├── RxUtil.java
│ │ │ │ ├── Constants.java
│ │ │ │ ├── ViewUtil.java
│ │ │ │ ├── NetworkUtil.java
│ │ │ │ ├── ActivityUtils.java
│ │ │ │ ├── AndroidComponentUtil.java
│ │ │ │ ├── RxEventBus.java
│ │ │ │ ├── DialogFactory.java
│ │ │ │ └── Utils.java
│ │ │ │ ├── ui
│ │ │ │ ├── base
│ │ │ │ │ ├── Presenter.java
│ │ │ │ │ ├── MvpView.java
│ │ │ │ │ ├── BasePresenter.java
│ │ │ │ │ └── BaseActivity.java
│ │ │ │ ├── widget
│ │ │ │ │ ├── ListRemoteViewFactoryMvpView.java
│ │ │ │ │ ├── WidgetRemoteViewsService.java
│ │ │ │ │ ├── WidgetProvider.java
│ │ │ │ │ ├── ListRemoteViewFactoryPresenter.java
│ │ │ │ │ └── ListRemoteViewFactory.java
│ │ │ │ ├── stockgraph
│ │ │ │ │ ├── StockGraphMvpView.java
│ │ │ │ │ ├── StockGraphActivity.java
│ │ │ │ │ ├── StockGraphPresenter.java
│ │ │ │ │ └── StockGraphFragment.java
│ │ │ │ └── main
│ │ │ │ │ ├── MainMvpView.java
│ │ │ │ │ ├── StockAdapter.java
│ │ │ │ │ ├── MainPresenter.java
│ │ │ │ │ └── MainActivity.java
│ │ │ │ ├── data
│ │ │ │ ├── local
│ │ │ │ │ ├── StockBaseModel.java
│ │ │ │ │ ├── StockDatabase.java
│ │ │ │ │ ├── PreferencesHelper.java
│ │ │ │ │ └── DatabaseHelper.java
│ │ │ │ ├── ApiEndPoint.java
│ │ │ │ ├── model
│ │ │ │ │ ├── single
│ │ │ │ │ │ ├── Stock.java
│ │ │ │ │ │ ├── Result.java
│ │ │ │ │ │ └── Query.java
│ │ │ │ │ ├── multiple
│ │ │ │ │ │ ├── Stocks.java
│ │ │ │ │ │ ├── Result.java
│ │ │ │ │ │ └── Query.java
│ │ │ │ │ └── financechart
│ │ │ │ │ │ ├── Labels.java
│ │ │ │ │ │ ├── Date.java
│ │ │ │ │ │ ├── FinanceChartCallBack.java
│ │ │ │ │ │ ├── Series.java
│ │ │ │ │ │ └── Meta.java
│ │ │ │ ├── remote
│ │ │ │ │ ├── UrlBuilder.java
│ │ │ │ │ └── StocksService.java
│ │ │ │ ├── DataManager.java
│ │ │ │ └── SyncService.java
│ │ │ │ └── StockHawkApplication.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── rajan
│ │ │ └── udacity
│ │ │ └── stock
│ │ │ └── hawk
│ │ │ ├── util
│ │ │ ├── DefaultConfig.java
│ │ │ ├── RxEventBusTest.java
│ │ │ └── RxSchedulersOverrideRule.java
│ │ │ ├── DatabaseHelperTest.java
│ │ │ ├── MainPresenterTest.java
│ │ │ └── DataManagerTest.java
│ ├── debug
│ │ └── AndroidManifest.xml
│ ├── commonTest
│ │ └── java
│ │ │ └── rajan
│ │ │ └── udacity
│ │ │ └── stock
│ │ │ └── hawk
│ │ │ └── test
│ │ │ └── common
│ │ │ ├── injection
│ │ │ ├── component
│ │ │ │ └── TestComponent.java
│ │ │ └── module
│ │ │ │ └── ApplicationTestModule.java
│ │ │ ├── TestDataFactory.java
│ │ │ └── TestComponentRule.java
│ └── androidTest
│ │ └── java
│ │ └── rajan
│ │ └── udacity
│ │ └── stock
│ │ └── hawk
│ │ ├── runner
│ │ ├── RxAndroidJUnitRunner.java
│ │ └── UnlockDeviceAndroidJUnitRunner.java
│ │ ├── util
│ │ ├── RxIdlingExecutionHook.java
│ │ └── RxIdlingResource.java
│ │ └── MainActivityTest.java
├── proguard-rules.pro
└── build.gradle
├── screenshots
├── s1.png
├── s2.png
├── s3.png
├── s4.png
└── s5.png
├── images
└── check-task-diagram.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── .github
├── PULL_REQUEST_TEMPLATE.md
├── CONTRIBUTING.md
└── ISSUE_TEMPLATE.md
├── config
└── quality
│ ├── findbugs
│ └── android-exclude-filter.xml
│ ├── pmd
│ └── pmd-ruleset.xml
│ ├── quality.gradle
│ └── checkstyle
│ └── checkstyle-config.xml
├── gradlew.bat
├── CONTRIBUTING.md
├── README.md
└── gradlew
/crashlytics_release_notes.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 | *iml
3 | *.iml
4 | .idea
--------------------------------------------------------------------------------
/app/fabric.properties:
--------------------------------------------------------------------------------
1 | apiSecret=changeMeToYourRealApiSecret
2 | apiKey=changeMeToYourRealApiKey
--------------------------------------------------------------------------------
/screenshots/s1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/screenshots/s1.png
--------------------------------------------------------------------------------
/screenshots/s2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/screenshots/s2.png
--------------------------------------------------------------------------------
/screenshots/s3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/screenshots/s3.png
--------------------------------------------------------------------------------
/screenshots/s4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/screenshots/s4.png
--------------------------------------------------------------------------------
/screenshots/s5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/screenshots/s5.png
--------------------------------------------------------------------------------
/app/keystore/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/keystore/debug.keystore
--------------------------------------------------------------------------------
/images/check-task-diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/images/check-task-diagram.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Gradle performance variables
2 | org.gradle.jvmargs=-Xmx4G -XX:MaxPermSize=512m
3 | org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | .DS_Store
5 | /build
6 | .idea/
7 | *iml
8 | *.iml
9 | */build
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_drawer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-hdpi/ic_drawer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_drawer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-mdpi/ic_drawer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_drawer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xhdpi/ic_drawer.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_drawer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxhdpi/ic_drawer.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/drawer_shadow.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-hdpi/drawer_shadow.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/drawer_shadow.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-mdpi/drawer_shadow.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/drawer_shadow.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xhdpi/drawer_shadow.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_action_content_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable/ic_action_content_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-hdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-mdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxhdpi/drawer_shadow.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_action_content_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-hdpi/ic_action_content_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_action_content_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-mdpi/ic_action_content_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxxhdpi/ic_add_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_action_content_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xhdpi/ic_action_content_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_action_content_new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxhdpi/ic_action_content_new.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_attach_money_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-hdpi/ic_attach_money_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_attach_money_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-mdpi/ic_attach_money_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_attach_money_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xhdpi/ic_attach_money_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_attach_money_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxhdpi/ic_attach_money_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/ic_attach_money_white_24dp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/therajanmaurya/Stock-Hawk/HEAD/app/src/main/res/drawable-xxxhdpi/ic_attach_money_white_24dp.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/percent_change_pill.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/percent_change_pill_green.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/percent_change_pill_red.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Apr 29 15:59:49 BST 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-2.13-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/test/java/rajan/udacity/stock/hawk/util/DefaultConfig.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | /**
4 | * Robolectric default config properties
5 | */
6 | public class DefaultConfig {
7 | //The api level that Roboelectric will use to run the unit tests
8 | public static final int EMULATE_SDK = 23;
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/ActivityContext.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Qualifier;
7 |
8 | @Qualifier
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface ActivityContext {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/ApplicationContext.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Qualifier;
7 |
8 | @Qualifier
9 | @Retention(RetentionPolicy.RUNTIME)
10 | public @interface ApplicationContext {
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/touch_helper/ItemTouchHelperAdapter.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.touch_helper;
2 |
3 | /**
4 | * Created by sam_chordas on 10/6/15.
5 | * credit to Paul Burke (ipaulpro)
6 | * Interface to enable swipe to delete
7 | */
8 | public interface ItemTouchHelperAdapter {
9 |
10 | void onItemDismiss(int position);
11 | }
12 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Please make sure these boxes are checked before submitting your pull request - thanks!
2 |
3 | Fixes #{Issue Number}
4 |
5 | - [ ] Follow the style used in this project.
6 |
7 | - [ ] Run the unit tests with `./gradlew check` to make sure you didn't break anything
8 |
9 | - [ ] If you have multiple commits please combine them into one commit by squashing them.
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/util/RxUtil.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import rx.Subscription;
4 |
5 | public class RxUtil {
6 |
7 | public static void unsubscribe(Subscription subscription) {
8 | if (subscription != null && !subscription.isUnsubscribed()) {
9 | subscription.unsubscribe();
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/touch_helper/ItemTouchHelperViewHolder.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.touch_helper;
2 |
3 | /**
4 | * Created by sam_chordas on 10/6/15.
5 | * credit to Paul Burke (ipaulpro)
6 | * Interface for enabling swiping to delete
7 | */
8 | public interface ItemTouchHelperViewHolder {
9 | void onItemSelected();
10 |
11 | void onItemClear();
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #1976D2
4 | #2196F3
5 | #D50000
6 | #00C853
7 |
8 | #ffffff
9 | #000000
10 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/base/Presenter.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.base;
2 |
3 | /**
4 | * Every presenter in the app must either implement this interface or extend BasePresenter
5 | * indicating the MvpView type that wants to be attached with.
6 | */
7 | public interface Presenter {
8 |
9 | void attachView(V mvpView);
10 |
11 | void detachView();
12 | }
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/touch_selector_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/touch_selector_dark.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/base/MvpView.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.base;
2 |
3 |
4 | /**
5 | * Base interface that any class that wants to act as a View in the MVP (Model View Presenter)
6 | * pattern must implement. Generally this interface will be extended by a more specific interface
7 | * that then usually will be implemented by an Activity or Fragment.
8 | */
9 | public interface MvpView {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/data/local/StockBaseModel.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.data.local;
2 |
3 | import com.google.gson.Gson;
4 |
5 | import com.raizlabs.android.dbflow.structure.BaseModel;
6 |
7 | /**
8 | * Created by Rajan Maurya on 23/06/16.
9 | */
10 | public class StockBaseModel extends BaseModel {
11 |
12 | @Override
13 | public String toString() {
14 | return new Gson().toJson(this);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/appwidget_info.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/data/ApiEndPoint.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.data;
2 |
3 | /**
4 | * Created by Rajan Maurya on 16/08/16.
5 | */
6 | public class ApiEndPoint {
7 |
8 | public static final String YAHOO_QUERY_LANGUAGE = "yql?";
9 |
10 | public static final String RESPONSE_FORMAT =
11 | "&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables."
12 | + "org%2Falltableswithkeys&callback=";
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/config/quality/findbugs/android-exclude-filter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/PerActivity.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Scope;
7 |
8 | /**
9 | * A scoping annotation to permit objects whose lifetime should
10 | * conform to the life of the Activity to be memorised in the
11 | * correct component.
12 | */
13 | @Scope
14 | @Retention(RetentionPolicy.RUNTIME)
15 | public @interface PerActivity {
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/widget/ListRemoteViewFactoryMvpView.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.widget;
2 |
3 | import java.util.List;
4 |
5 | import rajan.udacity.stock.hawk.data.model.Quote;
6 | import rajan.udacity.stock.hawk.ui.base.MvpView;
7 |
8 | /**
9 | * Created by Rajan Maurya on 30/08/16.
10 | */
11 | public interface ListRemoteViewFactoryMvpView extends MvpView {
12 |
13 | void showStocks(List quoteList);
14 |
15 | void showStocksEmpty();
16 |
17 | void showError();
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/widget/WidgetRemoteViewsService.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.widget;
2 |
3 | import android.content.Intent;
4 | import android.widget.RemoteViewsService;
5 |
6 | /**
7 | * Created by Rajan Maurya on 30/08/16.
8 | */
9 | public class WidgetRemoteViewsService extends RemoteViewsService {
10 |
11 | @Override
12 | public RemoteViewsFactory onGetViewFactory(Intent intent) {
13 | return new ListRemoteViewFactory(this.getApplicationContext(), intent);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/commonTest/java/rajan/udacity/stock/hawk/test/common/injection/component/TestComponent.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.test.common.injection.component;
2 |
3 | import javax.inject.Singleton;
4 |
5 | import dagger.Component;
6 | import rajan.udacity.stock.hawk.injection.component.ApplicationComponent;
7 | import rajan.udacity.stock.hawk.test.common.injection.module.ApplicationTestModule;
8 |
9 | @Singleton
10 | @Component(modules = ApplicationTestModule.class)
11 | public interface TestComponent extends ApplicationComponent {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/ConfigPersistent.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import javax.inject.Scope;
7 |
8 | import rajan.udacity.stock.hawk.injection.component.ConfigPersistentComponent;
9 |
10 | /**
11 | * A scoping annotation to permit dependencies conform to the life of the
12 | * {@link ConfigPersistentComponent}
13 | */
14 | @Scope
15 | @Retention(RetentionPolicy.RUNTIME)
16 | public @interface ConfigPersistent {
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/data/local/StockDatabase.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.data.local;
2 |
3 | import com.raizlabs.android.dbflow.annotation.Database;
4 |
5 | /**
6 | * Created by Rajan Maurya on 23/08/16.
7 | */
8 |
9 | @Database(name = StockDatabase.NAME, version = StockDatabase.VERSION, foreignKeysSupported = true)
10 | public class StockDatabase {
11 |
12 | // database name will be Stocks.db
13 | public static final String NAME = "Stocks";
14 |
15 | //Always Increase the Version Number
16 | public static final int VERSION = 1;
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/stockgraph/StockGraphMvpView.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.stockgraph;
2 |
3 | import rajan.udacity.stock.hawk.data.model.financechart.FinanceChartCallBack;
4 | import rajan.udacity.stock.hawk.ui.base.MvpView;
5 |
6 | /**
7 | * Created by Rajan Maurya on 30/08/16.
8 | */
9 | public interface StockGraphMvpView extends MvpView {
10 |
11 | void showProgressBar(Boolean show);
12 |
13 | void showFinanceChartData(FinanceChartCallBack financeChartCallBack);
14 |
15 | void initGraph();
16 |
17 | void showError();
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/frame_container.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 | 24sp
7 | 22sp
8 | 20sp
9 | 18sp
10 | 16sp
11 | 14sp
12 | 16dp
13 |
14 | 240dp
15 | 300dp
16 |
17 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to become a contributor and submit your own code
2 |
3 | ## Contributing A Patch
4 |
5 | 1. Submit an issue describing your proposed change to the repo in question.
6 | 1. The repo owner will respond to your issue promptly.
7 | 1. Fork the desired repo, develop and test your code changes.
8 | 1. Ensure that your code adheres to the existing style in the sample to which
9 | you are contributing. Refer to the
10 | [Android Code Style Guide]
11 | (https://source.android.com/source/code-style.html) for the
12 | recommended coding standards for this organization.
13 | 1. Ensure that your code has an appropriate set of unit tests which all pass.
14 | 1. Submit a pull request.
15 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/module/ActivityModule.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection.module;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 |
6 | import dagger.Module;
7 | import dagger.Provides;
8 | import rajan.udacity.stock.hawk.injection.ActivityContext;
9 |
10 | @Module
11 | public class ActivityModule {
12 |
13 | private Activity mActivity;
14 |
15 | public ActivityModule(Activity activity) {
16 | mActivity = activity;
17 | }
18 |
19 | @Provides
20 | Activity provideActivity() {
21 | return mActivity;
22 | }
23 |
24 | @Provides
25 | @ActivityContext
26 | Context providesContext() {
27 | return mActivity;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ### Summary
2 |
3 | Try to describe your issue in details.
4 |
5 | ### Stock-Hawk Version
6 |
7 |
8 |
9 | ### Android Version (19, 26, etc.)
10 |
11 |
12 |
13 | ### Expected Behavior
14 |
15 | Please describe the expected behavior of the issue, starting from the first action.
16 |
17 | 1.
18 | 2.
19 | 3.
20 |
21 | ### Actual Behavior
22 |
23 | Please provide a description of what actually happens, working from the same starting point.
24 |
25 | Be descriptive: "it doesn't work" does not describe what the behavior actually is.
26 |
27 | 1.
28 | 2.
29 | 3.
30 |
31 | ### Reproducible Test Case
32 |
33 | If the issue is more complex or requires configuration, please provide a link to a project on Github that reproduces the issue.
34 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/component/ActivityComponent.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection.component;
2 |
3 | import dagger.Subcomponent;
4 | import rajan.udacity.stock.hawk.injection.PerActivity;
5 | import rajan.udacity.stock.hawk.injection.module.ActivityModule;
6 | import rajan.udacity.stock.hawk.ui.main.MainActivity;
7 | import rajan.udacity.stock.hawk.ui.stockgraph.StockGraphFragment;
8 |
9 | /**
10 | * This component inject dependencies to all Activities across the application
11 | */
12 | @PerActivity
13 | @Subcomponent(modules = ActivityModule.class)
14 | public interface ActivityComponent {
15 |
16 | void inject(MainActivity mainActivity);
17 |
18 | void inject(StockGraphFragment stockGraphFragment);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/util/Constants.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | /**
4 | * Created by Rajan Maurya on 16/08/16.
5 | */
6 | public class Constants {
7 |
8 | public static String YAHOO_STOCK_SYMBOL = "\"YHOO\"";
9 |
10 | public static String APPLE_STOCK_SYMBOL = "\"AAPL\"";
11 |
12 | public static String GOOGLE_STOCK_SYMBOL = "\"GOOG\"";
13 |
14 | public static String MICROSOFT_STOCK_SYMBOL = "\"MSFT\"";
15 |
16 | public static String SYMBOL = "symbol";
17 |
18 | public static String GRAPH_LABLES = "graph lables";
19 |
20 | public static String GRAPH_VALUES = "graph values";
21 |
22 | public static String CLICK_ACTION = "rajan.udacity.stock.hawk.quotelistwidget.CLICKQUOTE";
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/main/MainMvpView.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.main;
2 |
3 | import java.util.List;
4 |
5 | import rajan.udacity.stock.hawk.data.model.Quote;
6 | import rajan.udacity.stock.hawk.ui.base.MvpView;
7 |
8 | public interface MainMvpView extends MvpView {
9 |
10 | void showStocks(List quoteList);
11 |
12 | void showStocksEmpty();
13 |
14 | void showStock(Quote quote);
15 |
16 | void showStockDoesNotExist();
17 |
18 | void showMaterialDialogAddStock();
19 |
20 | Boolean checkSymbolExistOrNot(String symbol, List quoteList);
21 |
22 | void showStockAlreadyExist();
23 |
24 | void showChangeInPercent(Boolean changeInPercent);
25 |
26 | void updateChangeInPercent(Boolean changeInPercent);
27 |
28 | void showError();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
16 |
19 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/component/ConfigPersistentComponent.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection.component;
2 |
3 | import dagger.Component;
4 | import rajan.udacity.stock.hawk.injection.ConfigPersistent;
5 | import rajan.udacity.stock.hawk.injection.module.ActivityModule;
6 | import rajan.udacity.stock.hawk.ui.base.BaseActivity;
7 |
8 | /**
9 | * A dagger component that will live during the lifecycle of an Activity but it won't
10 | * be destroy during configuration changes. Check {@link BaseActivity} to see how this components
11 | * survives configuration changes.
12 | * Use the {@link ConfigPersistent} scope to annotate dependencies that need to survive
13 | * configuration changes (for example Presenters).
14 | */
15 | @ConfigPersistent
16 | @Component(dependencies = ApplicationComponent.class)
17 | public interface ConfigPersistentComponent {
18 |
19 | ActivityComponent activityComponent(ActivityModule activityModule);
20 |
21 | }
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/util/ViewUtil.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.res.Resources;
6 | import android.view.inputmethod.InputMethodManager;
7 |
8 | public final class ViewUtil {
9 |
10 | public static float pxToDp(float px) {
11 | float densityDpi = Resources.getSystem().getDisplayMetrics().densityDpi;
12 | return px / (densityDpi / 160f);
13 | }
14 |
15 | public static int dpToPx(int dp) {
16 | float density = Resources.getSystem().getDisplayMetrics().density;
17 | return Math.round(dp * density);
18 | }
19 |
20 | public static void hideKeyboard(Activity activity) {
21 | InputMethodManager imm =
22 | (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
23 | imm.hideSoftInputFromWindow(activity.getWindow().getDecorView().getWindowToken(), 0);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/util/NetworkUtil.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import android.content.Context;
4 | import android.net.ConnectivityManager;
5 | import android.net.NetworkInfo;
6 |
7 | import retrofit2.adapter.rxjava.HttpException;
8 |
9 | public class NetworkUtil {
10 |
11 | /**
12 | * Returns true if the Throwable is an instance of RetrofitError with an
13 | * http status code equals to the given one.
14 | */
15 | public static boolean isHttpStatusCode(Throwable throwable, int statusCode) {
16 | return throwable instanceof HttpException
17 | && ((HttpException) throwable).code() == statusCode;
18 | }
19 |
20 | public static boolean isNetworkConnected(Context context) {
21 | ConnectivityManager cm =
22 | (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
23 | NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
24 | return activeNetwork != null && activeNetwork.isConnectedOrConnecting();
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/rajan/udacity/stock/hawk/runner/RxAndroidJUnitRunner.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.runner;
2 |
3 | import android.os.Bundle;
4 | import android.support.test.espresso.Espresso;
5 |
6 | import rx.plugins.RxJavaPlugins;
7 | import rajan.udacity.stock.hawk.util.RxIdlingExecutionHook;
8 | import rajan.udacity.stock.hawk.util.RxIdlingResource;
9 |
10 | /**
11 | * Runner that registers a Espresso Indling resource that handles waiting for
12 | * RxJava Observables to finish.
13 | * WARNING - Using this runner will block the tests if the application uses long-lived hot
14 | * Observables such us event buses, etc.
15 | */
16 | public class RxAndroidJUnitRunner extends UnlockDeviceAndroidJUnitRunner {
17 |
18 | @Override
19 | public void onCreate(Bundle arguments) {
20 | super.onCreate(arguments);
21 | RxIdlingResource rxIdlingResource = new RxIdlingResource();
22 | RxJavaPlugins.getInstance()
23 | .registerObservableExecutionHook(new RxIdlingExecutionHook(rxIdlingResource));
24 | Espresso.registerIdlingResources(rxIdlingResource);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/module/ApplicationModule.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection.module;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import javax.inject.Singleton;
7 |
8 | import dagger.Module;
9 | import dagger.Provides;
10 | import rajan.udacity.stock.hawk.data.remote.StocksService;
11 | import rajan.udacity.stock.hawk.injection.ApplicationContext;
12 |
13 | /**
14 | * Provide application-level dependencies.
15 | */
16 | @Module
17 | public class ApplicationModule {
18 | protected final Application mApplication;
19 |
20 | public ApplicationModule(Application application) {
21 | mApplication = application;
22 | }
23 |
24 | @Provides
25 | Application provideApplication() {
26 | return mApplication;
27 | }
28 |
29 | @Provides
30 | @ApplicationContext
31 | Context provideContext() {
32 | return mApplication;
33 | }
34 |
35 | @Provides
36 | @Singleton
37 | StocksService provideRibotsService() {
38 | return StocksService.Creator.newStocksService();
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/appwidget_collection.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/util/ActivityUtils.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import android.support.annotation.NonNull;
4 | import android.support.v4.app.Fragment;
5 | import android.support.v4.app.FragmentManager;
6 | import android.support.v4.app.FragmentTransaction;
7 |
8 | import static com.google.gson.internal.$Gson$Preconditions.checkNotNull;
9 |
10 | /**
11 | * @author RajanMaurya
12 | *
13 | * This provides methods to help Activities load their UI.
14 | */
15 | public class ActivityUtils {
16 |
17 | /**
18 | * The {@code fragment} is added to the container view with movieId {@code frameId}. The operation is
19 | * performed by the {@code fragmentManager}.
20 | *
21 | */
22 | public static void addFragmentToActivity (@NonNull FragmentManager fragmentManager,
23 | @NonNull Fragment fragment, int frameId) {
24 | checkNotNull(fragmentManager);
25 | checkNotNull(fragment);
26 | FragmentTransaction transaction = fragmentManager.beginTransaction();
27 | transaction.add(frameId, fragment);
28 | transaction.commit();
29 | }
30 |
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/base/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.base;
2 |
3 | /**
4 | * Base class that implements the Presenter interface and provides a base implementation for
5 | * attachView() and detachView(). It also handles keeping a reference to the mvpView that
6 | * can be accessed from the children classes by calling getMvpView().
7 | */
8 | public class BasePresenter implements Presenter {
9 |
10 | private T mMvpView;
11 |
12 | @Override
13 | public void attachView(T mvpView) {
14 | mMvpView = mvpView;
15 | }
16 |
17 | @Override
18 | public void detachView() {
19 | mMvpView = null;
20 | }
21 |
22 | public boolean isViewAttached() {
23 | return mMvpView != null;
24 | }
25 |
26 | public T getMvpView() {
27 | return mMvpView;
28 | }
29 |
30 | public void checkViewAttached() {
31 | if (!isViewAttached()) throw new MvpViewNotAttachedException();
32 | }
33 |
34 | public static class MvpViewNotAttachedException extends RuntimeException {
35 | public MvpViewNotAttachedException() {
36 | super("Please call Presenter.attachView(MvpView) before" +
37 | " requesting data to the Presenter");
38 | }
39 | }
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_stocks_graph.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
19 |
20 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/injection/component/ApplicationComponent.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.injection.component;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import javax.inject.Singleton;
7 |
8 | import dagger.Component;
9 | import rajan.udacity.stock.hawk.data.DataManager;
10 | import rajan.udacity.stock.hawk.data.SyncService;
11 | import rajan.udacity.stock.hawk.data.local.DatabaseHelper;
12 | import rajan.udacity.stock.hawk.data.local.PreferencesHelper;
13 | import rajan.udacity.stock.hawk.data.remote.StocksService;
14 | import rajan.udacity.stock.hawk.injection.ApplicationContext;
15 | import rajan.udacity.stock.hawk.injection.module.ApplicationModule;
16 | import rajan.udacity.stock.hawk.ui.widget.ListRemoteViewFactory;
17 | import rajan.udacity.stock.hawk.util.RxEventBus;
18 |
19 | @Singleton
20 | @Component(modules = ApplicationModule.class)
21 | public interface ApplicationComponent {
22 |
23 | void inject(SyncService syncService);
24 |
25 | void inject(ListRemoteViewFactory listRemoteViewFactory);
26 |
27 | @ApplicationContext Context context();
28 | Application application();
29 | StocksService ribotsService();
30 | PreferencesHelper preferencesHelper();
31 | DatabaseHelper databaseHelper();
32 | DataManager dataManager();
33 | RxEventBus eventBus();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/util/AndroidComponentUtil.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import android.app.ActivityManager;
4 | import android.app.ActivityManager.RunningServiceInfo;
5 | import android.content.ComponentName;
6 | import android.content.Context;
7 | import android.content.pm.PackageManager;
8 |
9 | public final class AndroidComponentUtil {
10 |
11 | public static void toggleComponent(Context context, Class componentClass, boolean enable) {
12 | ComponentName componentName = new ComponentName(context, componentClass);
13 | PackageManager pm = context.getPackageManager();
14 | pm.setComponentEnabledSetting(componentName,
15 | enable ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED :
16 | PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
17 | PackageManager.DONT_KILL_APP);
18 | }
19 |
20 | public static boolean isServiceRunning(Context context, Class serviceClass) {
21 | ActivityManager manager =
22 | (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
23 | for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
24 | if (serviceClass.getName().equals(service.service.getClassName())) {
25 | return true;
26 | }
27 | }
28 | return false;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/rajan/udacity/stock/hawk/util/RxIdlingExecutionHook.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import rx.Observable;
4 | import rx.Subscription;
5 | import rx.plugins.RxJavaObservableExecutionHook;
6 |
7 | /**
8 | * RxJava Observable execution hook that handles updating the active subscription
9 | * count for a given Espresso RxIdlingResource.
10 | */
11 | public class RxIdlingExecutionHook extends RxJavaObservableExecutionHook {
12 |
13 | private RxIdlingResource mRxIdlingResource;
14 |
15 | public RxIdlingExecutionHook(RxIdlingResource rxIdlingResource) {
16 | mRxIdlingResource = rxIdlingResource;
17 | }
18 |
19 | @Override
20 | public Observable.OnSubscribe onSubscribeStart(
21 | Observable extends T> observableInstance, Observable.OnSubscribe onSubscribe) {
22 | mRxIdlingResource.incrementActiveSubscriptionsCount();
23 | return super.onSubscribeStart(observableInstance, onSubscribe);
24 | }
25 |
26 | @Override
27 | public Throwable onSubscribeError(Throwable e) {
28 | mRxIdlingResource.decrementActiveSubscriptionsCount();
29 | return super.onSubscribeError(e);
30 | }
31 |
32 | @Override
33 | public Subscription onSubscribeReturn(Subscription subscription) {
34 | mRxIdlingResource.decrementActiveSubscriptionsCount();
35 | return super.onSubscribeReturn(subscription);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/data/model/single/Stock.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.data.model.single;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import android.os.Parcel;
6 | import android.os.Parcelable;
7 |
8 | public class Stock implements Parcelable {
9 |
10 | public static final Creator CREATOR = new Creator() {
11 | @Override
12 | public Stock createFromParcel(Parcel source) {
13 | return new Stock(source);
14 | }
15 |
16 | @Override
17 | public Stock[] newArray(int size) {
18 | return new Stock[size];
19 | }
20 | };
21 | @SerializedName("query")
22 | Query mQuery = new Query();
23 |
24 | public Stock() {
25 | }
26 |
27 | protected Stock(Parcel in) {
28 | this.mQuery = in.readParcelable(Query.class.getClassLoader());
29 | }
30 |
31 | public Query getQuery() {
32 | return mQuery;
33 | }
34 |
35 | public void setQuery(Query query) {
36 | mQuery = query;
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return "Stock{" +
42 | "mQuery=" + mQuery +
43 | '}';
44 | }
45 |
46 | @Override
47 | public int describeContents() {
48 | return 0;
49 | }
50 |
51 | @Override
52 | public void writeToParcel(Parcel dest, int flags) {
53 | dest.writeParcelable(this.mQuery, flags);
54 | }
55 | }
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/data/model/multiple/Stocks.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.data.model.multiple;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | import android.os.Parcel;
6 | import android.os.Parcelable;
7 |
8 | public class Stocks implements Parcelable {
9 |
10 | public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
11 | @Override
12 | public Stocks createFromParcel(Parcel source) {
13 | return new Stocks(source);
14 | }
15 |
16 | @Override
17 | public Stocks[] newArray(int size) {
18 | return new Stocks[size];
19 | }
20 | };
21 | @SerializedName("query")
22 | Query mQuery = new Query();
23 |
24 | public Stocks() {
25 | }
26 |
27 | protected Stocks(Parcel in) {
28 | this.mQuery = in.readParcelable(Query.class.getClassLoader());
29 | }
30 |
31 | public Query getQuery() {
32 | return mQuery;
33 | }
34 |
35 | public void setQuery(Query query) {
36 | mQuery = query;
37 | }
38 |
39 | @Override
40 | public String toString() {
41 | return "Stocks{" +
42 | "mQuery=" + mQuery +
43 | '}';
44 | }
45 |
46 | @Override
47 | public int describeContents() {
48 | return 0;
49 | }
50 |
51 | @Override
52 | public void writeToParcel(Parcel dest, int flags) {
53 | dest.writeParcelable(this.mQuery, flags);
54 | }
55 | }
56 |
57 |
58 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/ui/widget/WidgetProvider.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.ui.widget;
2 |
3 | import android.appwidget.AppWidgetManager;
4 | import android.appwidget.AppWidgetProvider;
5 | import android.content.Context;
6 | import android.content.Intent;
7 | import android.net.Uri;
8 | import android.widget.RemoteViews;
9 |
10 | import rajan.udacity.stock.hawk.R;
11 |
12 | /**
13 | * Created by Rajan Maurya on 30/08/16.
14 | */
15 | public class WidgetProvider extends AppWidgetProvider {
16 |
17 | @Override
18 | public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
19 |
20 | // Perform this loop procedure for each App Widget that belongs to this provider
21 | for (int appWidgetId : appWidgetIds) {
22 | // Get the layout for the App Widget and attach an on-click listener
23 | // to the button
24 | RemoteViews rv = new RemoteViews(context.getPackageName(),
25 | R.layout.appwidget_collection);
26 |
27 | final Intent intent = new Intent(context, WidgetRemoteViewsService.class);
28 | intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
29 | intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
30 | rv.setRemoteAdapter(R.id.widget_list, intent);
31 |
32 | appWidgetManager.updateAppWidget(appWidgetId, rv);
33 | }
34 | super.onUpdate(context, appWidgetManager, appWidgetIds);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/commonTest/java/rajan/udacity/stock/hawk/test/common/injection/module/ApplicationTestModule.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.test.common.injection.module;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import javax.inject.Singleton;
7 |
8 | import dagger.Module;
9 | import dagger.Provides;
10 | import rajan.udacity.stock.hawk.data.DataManager;
11 | import rajan.udacity.stock.hawk.data.remote.StocksService;
12 | import rajan.udacity.stock.hawk.injection.ApplicationContext;
13 |
14 | import static org.mockito.Mockito.mock;
15 |
16 | /**
17 | * Provides application-level dependencies for an app running on a testing environment
18 | * This allows injecting mocks if necessary.
19 | */
20 | @Module
21 | public class ApplicationTestModule {
22 |
23 | private final Application mApplication;
24 |
25 | public ApplicationTestModule(Application application) {
26 | mApplication = application;
27 | }
28 |
29 | @Provides
30 | Application provideApplication() {
31 | return mApplication;
32 | }
33 |
34 | @Provides
35 | @ApplicationContext
36 | Context provideContext() {
37 | return mApplication;
38 | }
39 |
40 | /************* MOCKS *************/
41 |
42 | @Provides
43 | @Singleton
44 | DataManager provideDataManager() {
45 | return mock(DataManager.class);
46 | }
47 |
48 | @Provides
49 | @Singleton
50 | StocksService provideRibotsService() {
51 | return mock(StocksService.class);
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/rajan/udacity/stock/hawk/data/local/PreferencesHelper.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.data.local;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | import javax.inject.Inject;
7 | import javax.inject.Singleton;
8 |
9 | import rajan.udacity.stock.hawk.injection.ApplicationContext;
10 | import rx.Observable;
11 |
12 | @Singleton
13 | public class PreferencesHelper {
14 |
15 | public static final String PREF_FILE_NAME = "stocks_pref_file";
16 | public static final String PREF_CHANGE_IN_PERCENT = "change_in_percent";
17 |
18 | private final SharedPreferences mPref;
19 |
20 | @Inject
21 | public PreferencesHelper(@ApplicationContext Context context) {
22 | mPref = context.getSharedPreferences(PREF_FILE_NAME, Context.MODE_PRIVATE);
23 | }
24 |
25 | public void clear() {
26 | mPref.edit().clear().apply();
27 | }
28 |
29 | public Boolean getChangeInPercentFromPref() {
30 | return mPref.getBoolean(PREF_CHANGE_IN_PERCENT, true);
31 | }
32 |
33 | public Observable getChangeInPercent() {
34 | return Observable.just(mPref.getBoolean(PREF_CHANGE_IN_PERCENT, true));
35 | }
36 |
37 | public void setChangeInPercent(boolean changeInPercent) {
38 | mPref.edit().putBoolean(PREF_CHANGE_IN_PERCENT, changeInPercent).apply();
39 | }
40 |
41 | public Observable updateChangeInPercentInPref() {
42 | setChangeInPercent(!getChangeInPercentFromPref());
43 | return getChangeInPercent();
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/test/java/rajan/udacity/stock/hawk/util/RxEventBusTest.java:
--------------------------------------------------------------------------------
1 | package rajan.udacity.stock.hawk.util;
2 |
3 | import org.junit.Before;
4 | import org.junit.Rule;
5 | import org.junit.Test;
6 |
7 | import rx.observers.TestSubscriber;
8 |
9 | public class RxEventBusTest {
10 |
11 | private RxEventBus mEventBus;
12 |
13 | @Rule
14 | // Must be added to every test class that targets app code that uses RxJava
15 | public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule();
16 |
17 | @Before
18 | public void setUp() {
19 | mEventBus = new RxEventBus();
20 | }
21 |
22 | @Test
23 | public void postedObjectsAreReceived() {
24 | TestSubscriber