added current user score
This commit is contained in:
parent
e3c7675c6a
commit
b0d435aae4
@ -2,11 +2,9 @@ package com.example.gallery.adapters;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RatingBar;
|
import android.widget.RatingBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -111,7 +109,7 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
|
|||||||
Publication post = visiblePosts.get(position);
|
Publication post = visiblePosts.get(position);
|
||||||
|
|
||||||
// ---------- USER SCORE ----------
|
// ---------- USER SCORE ----------
|
||||||
int userScore = post.user_score != null ? post.user_score : 0;
|
int userScore = post.current_user_score != null ? post.current_user_score : 0;
|
||||||
holder.userRatingBar.setOnRatingBarChangeListener(null);
|
holder.userRatingBar.setOnRatingBarChangeListener(null);
|
||||||
holder.userRatingBar.setRating(userScore);
|
holder.userRatingBar.setRating(userScore);
|
||||||
holder.yourRating.setText(String.valueOf(userScore));
|
holder.yourRating.setText(String.valueOf(userScore));
|
||||||
@ -177,7 +175,7 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
|
|||||||
|
|
||||||
RatingResponse body = response.body();
|
RatingResponse body = response.body();
|
||||||
|
|
||||||
current.user_score = score;
|
current.current_user_score = score;
|
||||||
|
|
||||||
|
|
||||||
if (body.average_score != null) {
|
if (body.average_score != null) {
|
||||||
@ -186,13 +184,13 @@ public class PostsAdapter extends RecyclerView.Adapter<PostsAdapter.PostViewHold
|
|||||||
|
|
||||||
for (Publication p : allPosts) {
|
for (Publication p : allPosts) {
|
||||||
if (p.pk == current.pk) {
|
if (p.pk == current.pk) {
|
||||||
p.user_score = current.user_score;
|
p.current_user_score = current.current_user_score;
|
||||||
p.average_score = current.average_score;
|
p.average_score = current.average_score;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.yourRating.setText(String.valueOf(current.user_score));
|
holder.yourRating.setText(String.valueOf(current.current_user_score));
|
||||||
holder.averageRatingBar.setRating(current.average_score);
|
holder.averageRatingBar.setRating(current.average_score);
|
||||||
holder.txtAverageValue.setText(
|
holder.txtAverageValue.setText(
|
||||||
String.format("%.1f", current.average_score)
|
String.format("%.1f", current.average_score)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ public class Publication implements Serializable {
|
|||||||
public String content_type;
|
public String content_type;
|
||||||
public boolean is_pinned;
|
public boolean is_pinned;
|
||||||
public Float average_score;
|
public Float average_score;
|
||||||
public Integer user_score;
|
public Integer current_user_score;
|
||||||
|
|
||||||
@SerializedName("user_detail")
|
@SerializedName("user_detail")
|
||||||
public UserDetail user_detail;
|
public UserDetail user_detail;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user