From fd1a95c05551725711e87d585621448b7c23c427 Mon Sep 17 00:00:00 2001 From: Aritra Roy Date: Sun, 15 Oct 2017 01:17:46 +0530 Subject: [PATCH] Updated README and some minor improvements in the sample app --- README.md | 79 ++++++++++--------- .../aritraroy/rxmagnetodemo/MainActivity.java | 28 +++---- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index d34c467..f15d230 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A fast, light-weight and powerful Play Store information fetcher for Android. ### Specs -[ ![Download](https://api.bintray.com/packages/aritraroy/maven/rxmagneto/images/download.svg) ](https://bintray.com/aritraroy/maven/rxmagneto/_latestVersion) [![API](https://img.shields.io/badge/API-15%2B-orange.svg?style=flat)](https://android-arsenal.com/api?level=15) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RxMagneto-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5362) +[ ![Download](https://api.bintray.com/packages/aritraroy/maven/rxmagneto/images/download.svg) ](https://bintray.com/aritraroy/maven/rxmagneto/_latestVersion) [![API](https://img.shields.io/badge/API-14%2B-orange.svg?style=flat)](https://android-arsenal.com/api?level=14) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-RxMagneto-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/5362) ![RxMagneto](https://github.com/aritraroy/RxMagneto/blob/master/raw/logo_250.png) @@ -22,7 +22,7 @@ This library is available in **jCenter** which is the default Maven repository u dependencies { // other dependencies here - compile 'com.andrognito.rxmagneto:rxmagneto:1.0.0' + compile 'com.andrognito.rxmagneto:rxmagneto:2.0.0' } ``` @@ -32,14 +32,20 @@ dependencies { com.andrognito.rxmagneto rxmagneto - 1.0.0 + 2.0.0 pom ``` +# Migrating to Version 2 + +RxMagneto 2 brings some breaking changes from version 1. The entire library is re-written using RxJava 2. All the Observables are now changed into Singles, so there will be some re-work for you. You also do NOT need to perform these operations in the background thread as it is automatically done for you. + +The core functionality of the library remains the same. Every feature in the new version of this library works in the same way and returns the same result as the previous version. + + ### Spread Some :heart: -[![GitHub stars](https://img.shields.io/github/stars/aritraroy/RxMagneto.svg?style=social&label=Star)](https://github.com/aritraroy) [![GitHub followers](https://img.shields.io/github/followers/aritraroy.svg?style=social&label=Follow)](https://github.com/aritraroy) -[![Twitter Follow](https://img.shields.io/twitter/follow/aritraroy93.svg?style=social)](https://twitter.com/aritraroy93) +[![GitHub stars](https://img.shields.io/github/stars/aritraroy/RxMagneto.svg?style=social&label=Star)](https://github.com/aritraroy) [![GitHub followers](https://img.shields.io/github/followers/aritraroy.svg?style=social&label=Follow)](https://github.com/aritraroy) [![Twitter Follow](https://img.shields.io/twitter/follow/aritraroy93.svg?style=social)](https://twitter.com/aritraroy93) ## Use Cases @@ -66,7 +72,7 @@ RxMagneto rxMagneto = RxMagneto.getInstance(); rxMagneto.initialize(this); ``` -The initialize method takes a Context object. It can either be an Application context or Activity context. +The initialize method takes a `Context` object. It can either be an `Application` context or `Activity` context. ## Quick Example @@ -77,14 +83,13 @@ Here is a quick example for you to get started right away in less than a minute. RxMagneto rxMagneto = RxMagneto.getInstance(); rxMagneto.initialize(this); -Observable observable = rxMagneto.grabVersion(packageName); -observable.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(s -> { - Log.d("RxMagneto", "Version: " + s); - }, throwable -> { - Log.d("RxMagneto", "Error"); - }); +Single version = rxMagneto.grabVersion(packageName); +version.observeOn(AndroidSchedulers.mainThread()) + .subscribe(s -> { + Log.d("RxMagneto", "Version: " + s); + }, throwable -> { + Log.d("RxMagneto", "Error"); + }); ``` ## All Features @@ -97,95 +102,95 @@ Here is a list of all the featues offered by RxMagneto. I will be actively takin Gets the Play Store URL of the specified package. You can make this call in the main thread of the application. ```java -Observable urlObservable = rxMagneto.grabUrl(packageName); +Single urlSingle = rxMagneto.grabUrl(packageName); ``` ### Get Verified Play Store URL -Gets the verified Play Store URL of the specified package. You can NOT make this call in the main thread of the application. +Gets the verified Play Store URL of the specified package. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable urlObservable = rxMagneto.grabVerifiedUrl(packageName); +Single urlSingle = rxMagneto.grabVerifiedUrl(packageName); ``` ### Get Version -Gets the latest version of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the latest version of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable versionObservable = rxMagneto.grabVersion(packageName); +Single versionSingle = rxMagneto.grabVersion(packageName); ``` ### Check If Update Is Available -Check if an update is available for the specified package from Play Store. You can NOT make this call in the main thread of the application. +Check if an update is available for the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable updateAvailableObservable = rxMagneto.isUpgradeAvailable(packageName); +Single updateAvailableSingle = rxMagneto.isUpgradeAvailable(packageName); ``` ### Get Downloads -Gets the no. of downloads of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the no. of downloads of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable downloadsObservable = rxMagneto.grabDownloads(packageName); +Single downloadsSingle = rxMagneto.grabDownloads(packageName); ``` ### Get Last Published Date -Gets the last published date of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the last published date of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable publishedDateObservable = rxMagneto.grabPublishedDate(packageName); +Single publishedDateSingle = rxMagneto.grabPublishedDate(packageName); ``` ### Get OS Requirements -Gets the OS requirements of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the OS requirements of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable osRequirementsObservable = rxMagneto.grabOsRequirements(packageName); +Single osRequirementsSingle = rxMagneto.grabOsRequirements(packageName); ``` ### Get Content Rating -Gets the content rating of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the content rating of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable contentRatingObservable = rxMagneto.grabContentRating(packageName); +Single contentRatingSingle = rxMagneto.grabContentRating(packageName); ``` ### Get App Rating -Gets the app rating of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the app rating of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable appRatingObservable = rxMagneto.grabAppRating(packageName); +Single appRatingSingle = rxMagneto.grabAppRating(packageName); ``` ### Get App Ratings Count -Gets the no. of app ratings of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the no. of app ratings of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable appRatingsCount = rxMagneto.grabAppRatingsCount(packageName); +Single appRatingsCountSingle = rxMagneto.grabAppRatingsCount(packageName); ``` ### Get Recent Changelog (as Array) -Gets the recent changelog (as array) of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the recent changelog (as array) of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable> changelogObservable = rxMagneto.grabPlayStoreRecentChangelogArray(packageName); +Single> changelogSingle = rxMagneto.grabPlayStoreRecentChangelogArray(packageName); ``` ### Get Recent Changelog (as String) -Gets the recent changelog (as string) of the specified package from Play Store. You can NOT make this call in the main thread of the application. +Gets the recent changelog (as string) of the specified package from Play Store. It automatically performs the operation in a background thread, so that you do NOT need to explicitly do it. ```java -Observable changelogObservable = rxMagneto.grabPlayStoreRecentChangelog(packageName); +Single changelogSingle = rxMagneto.grabPlayStoreRecentChangelog(packageName); ``` # Contribution diff --git a/app/src/main/java/com/aritraroy/rxmagnetodemo/MainActivity.java b/app/src/main/java/com/aritraroy/rxmagnetodemo/MainActivity.java index 2bbce21..bb4d220 100644 --- a/app/src/main/java/com/aritraroy/rxmagnetodemo/MainActivity.java +++ b/app/src/main/java/com/aritraroy/rxmagnetodemo/MainActivity.java @@ -25,7 +25,6 @@ import io.reactivex.Single; import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.schedulers.Schedulers; public class MainActivity extends AppCompatActivity { @@ -146,8 +145,7 @@ private void getPlayStoreVersion(String packageName) { getResources().getString(R.string.message_grabbing)); Single versionSingle = rxMagneto.grabVersion(packageName); - versionSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + versionSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -167,8 +165,7 @@ private void checkIsUpdateAvailable(String packageName) { getResources().getString(R.string.message_grabbing)); Single updateAvailableSingle = rxMagneto.isUpgradeAvailable(packageName); - updateAvailableSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + updateAvailableSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(aBoolean -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -190,8 +187,7 @@ private void getDownloads(String packageName) { getResources().getString(R.string.message_grabbing)); Single downloadsSingle = rxMagneto.grabDownloads(packageName); - downloadsSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + downloadsSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -212,8 +208,7 @@ private void getLastPublishedDate(String packageName) { getResources().getString(R.string.message_grabbing)); Single publishedDateSingle = rxMagneto.grabPublishedDate(packageName); - publishedDateSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + publishedDateSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -234,8 +229,7 @@ private void getOSRequirements(String packageName) { getResources().getString(R.string.message_grabbing)); Single osRequirementsSingle = rxMagneto.grabOsRequirements(packageName); - osRequirementsSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + osRequirementsSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -256,8 +250,7 @@ private void getContentRating(String packageName) { getResources().getString(R.string.message_grabbing)); Single contentRatingSingle = rxMagneto.grabContentRating(packageName); - contentRatingSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + contentRatingSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -278,8 +271,7 @@ private void getAppRating(String packageName) { getResources().getString(R.string.message_grabbing)); Single appRatingSingle = rxMagneto.grabAppRating(packageName); - appRatingSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + appRatingSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -300,8 +292,7 @@ private void getAppRatingsCount(String packageName) { getResources().getString(R.string.message_grabbing)); Single appRatingsCountSingle = rxMagneto.grabAppRatingsCount(packageName); - appRatingsCountSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + appRatingsCountSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -322,8 +313,7 @@ private void getRecentChangelog(String packageName) { getResources().getString(R.string.message_grabbing)); Single changelogSingle = rxMagneto.grabPlayStoreRecentChangelog(packageName); - changelogSingle.subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) + changelogSingle.observeOn(AndroidSchedulers.mainThread()) .subscribe(s -> { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss();