Skip to content

Commit

Permalink
Added Methods - onError, onComplete
Browse files Browse the repository at this point in the history
Changed Method - onResult to onNext
  • Loading branch information
shashkiranr committed Oct 1, 2017
1 parent 18ce7de commit 86506e3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
10 changes: 0 additions & 10 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion app/src/main/java/fyi/rxretrofittest/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,19 @@ protected void onCreate(Bundle savedInstanceState) {


@Override
public void getResult(Object result) {
public void onNext(Object result) {
ApiDetail apiDetail = (ApiDetail) result;
Log.d(TAG, "apidetail to string " + result.toString());
}

@Override
public void onError(Throwable e) {
Log.d(TAG, "onError: " + e.toString());
}

@Override
public void onComplete() {
Log.d(TAG, "onComplete: ");

}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Sep 17 15:37:54 EDT 2017
#Sun Oct 01 16:23:16 EDT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
12 changes: 10 additions & 2 deletions rxretrofit/src/main/java/fyi/library/rxretrofit/RxRetrofit.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void onSubscribe(@io.reactivex.annotations.NonNull Disposable d) {
public void onNext(@io.reactivex.annotations.NonNull Object object) {
try {
JsonElement jsonElement = gson.toJsonTree(object);
rxRetrofitCallBack.getResult(gson.fromJson(jsonElement, returnClassType));
rxRetrofitCallBack.onNext(gson.fromJson(jsonElement, returnClassType));

} catch (Exception e) {
Log.d(TAG, "callback methods are not found " + e.getMessage());
Expand All @@ -59,10 +59,12 @@ public void onNext(@io.reactivex.annotations.NonNull Object object) {
@Override
public void onError(@io.reactivex.annotations.NonNull Throwable e) {
Log.d(TAG, "onError: " + e.getMessage());
rxRetrofitCallBack.onError(e);
}

@Override
public void onComplete() {
rxRetrofitCallBack.onComplete();
}
};

Expand All @@ -82,6 +84,12 @@ public void onComplete() {
}

public interface RxRetrofitCallBack {
void getResult(Object result);

void onNext(Object result);

void onError(Throwable e);

void onComplete();

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fyi.library.rxretrofit;

import java.util.Map;
import java.util.Objects;

import io.reactivex.Observable;
import retrofit2.http.GET;
Expand Down

0 comments on commit 86506e3

Please sign in to comment.