Last active
January 26, 2017 09:45
-
-
Save amitshekhariitbhu/32bb86ec40a9032f29e962eaf995cd86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SubscriptionActivity extends Activity { | |
Subscription subscription; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
subscription = getObservable() | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(getDummyObserver()); | |
} | |
@Override | |
protected void onDestroy() { | |
super.onDestroy(); | |
// unsubscribe it when activity onDestroy is called | |
subscription.unsubscribe(); | |
} | |
public Observable<String> getObservable() { | |
return RxAndroidNetworking.download(URL, dirPath, fileName) | |
.build() | |
.getDownloadObservable(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment