Skip to content

Commit

Permalink
Issue #509 fixed displaying current user's review for given app
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriomin committed Jul 24, 2018
1 parent bdd0b09 commit 8c4cb58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
import android.widget.ProgressBar;
import android.widget.TextView;

import com.github.yeriomin.playstoreapi.GooglePlayAPI;
import com.github.yeriomin.playstoreapi.GooglePlayException;
import com.github.yeriomin.playstoreapi.ReviewResponse;
import com.github.yeriomin.yalpstore.fragment.ButtonCancel;
import com.github.yeriomin.yalpstore.fragment.ButtonDownload;
import com.github.yeriomin.yalpstore.fragment.ButtonInstall;
Expand All @@ -42,11 +44,13 @@
import com.github.yeriomin.yalpstore.fragment.DownloadMenu;
import com.github.yeriomin.yalpstore.fragment.details.AllFragments;
import com.github.yeriomin.yalpstore.model.App;
import com.github.yeriomin.yalpstore.model.ReviewBuilder;
import com.github.yeriomin.yalpstore.task.playstore.CloneableTask;
import com.github.yeriomin.yalpstore.task.playstore.DetailsTask;

import java.io.IOException;

import static com.github.yeriomin.yalpstore.PlayStoreApiAuthenticator.PREFERENCE_APP_PROVIDED_EMAIL;
import static com.github.yeriomin.yalpstore.task.playstore.PurchaseTask.UPDATE_INTERVAL;

public class DetailsActivity extends YalpStoreActivity {
Expand Down Expand Up @@ -199,6 +203,18 @@ public CloneableTask clone() {
return task;
}

@Override
protected App getResult(GooglePlayAPI api, String... arguments) throws IOException {
App app = super.getResult(api, arguments);
if (null == app.getUserReview() && !PreferenceUtil.getBoolean(context, PREFERENCE_APP_PROVIDED_EMAIL)) {
ReviewResponse reviewResponse = api.getReview(app.getPackageName());
if (reviewResponse.hasGetResponse() && reviewResponse.getGetResponse().getReviewCount() == 1) {
app.setUserReview(ReviewBuilder.build(reviewResponse.getGetResponse().getReview(0)));
}
}
return app;
}

@Override
protected void processIOException(IOException e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static Review build(com.github.yeriomin.playstoreapi.Review reviewProto)
review.setTitle(reviewProto.getTitle());
review.setRating(reviewProto.getStarRating());
review.setUserName(reviewProto.getAuthor2().getName());
review.setUserPhotoUrl(reviewProto.getAuthor2().getUrls().getUrl());
review.setUserPhotoUrl(reviewProto.getAuthor2().getAvatar().getImageUrl());
review.setGooglePlusUrl(reviewProto.getAuthor2().getGooglePlusUrl());
return review;
}
Expand Down

0 comments on commit 8c4cb58

Please sign in to comment.