forked from organicmaps/organicmaps
[android] Added User's rating records UI
This commit is contained in:
parent
53cd9e762c
commit
eca73a0e95
6 changed files with 53 additions and 8 deletions
|
@ -26,7 +26,7 @@
|
|||
android:id="@+id/rb__rate"
|
||||
style="@style/MwmWidget.RatingBar.Ugc"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="24dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:numStars="5"
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?cardBackground"
|
||||
android:orientation="vertical"
|
||||
tools:showIn="@layout/place_page_ugc">
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
|
@ -24,4 +28,4 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?dividerHorizontal"/>
|
||||
</merge>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?cardBackground"
|
||||
android:orientation="vertical">
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?cardBackground"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
|
|
|
@ -233,8 +233,6 @@
|
|||
<style name="MwmWidget.RatingBar" parent="android:Widget.RatingBar">
|
||||
<item name="android:progressDrawable">@drawable/rating_bar</item>
|
||||
<item name="android:indeterminateDrawable">@drawable/rating_bar</item>
|
||||
<item name="android:minHeight">24dp</item>
|
||||
<item name="android:maxHeight">24dp</item>
|
||||
</style>
|
||||
|
||||
<style name="MwmWidget.RatingBarSmall" parent="android:Widget.RatingBar">
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.io.Serializable;
|
|||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -50,6 +51,20 @@ public class UGC implements Serializable
|
|||
return Collections.synchronizedList(Arrays.asList(mRatings));
|
||||
}
|
||||
|
||||
//TODO: remove it after core is ready.
|
||||
@NonNull
|
||||
public List<Rating> getUserRatings()
|
||||
{
|
||||
return new ArrayList<Rating>(){
|
||||
{
|
||||
add(new Rating("service", 8.3f));
|
||||
add(new Rating("food", 3.4f));
|
||||
add(new Rating("quality", 5.0f));
|
||||
add(new Rating("cleaning", 7.9f));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<Review> getReviews()
|
||||
{
|
||||
|
@ -78,7 +93,7 @@ public class UGC implements Serializable
|
|||
private final String mName;
|
||||
private float mValue;
|
||||
|
||||
private Rating(@NonNull String name, float value)
|
||||
Rating(@NonNull String name, float value)
|
||||
{
|
||||
mName = name;
|
||||
mValue = value;
|
||||
|
|
|
@ -246,6 +246,8 @@ public class PlacePageView extends RelativeLayout
|
|||
private final UGCReviewAdapter mUGCReviewAdapter = new UGCReviewAdapter();
|
||||
@NonNull
|
||||
private final UGCRatingRecordsAdapter mUGCRatingRecordsAdapter = new UGCRatingRecordsAdapter();
|
||||
@NonNull
|
||||
private final UGCRatingRecordsAdapter mUGCUserRatingRecordsAdapter = new UGCRatingRecordsAdapter();
|
||||
|
||||
// Downloader`s stuff
|
||||
private DownloaderStatusIcon mDownloaderIcon;
|
||||
|
@ -306,6 +308,7 @@ public class PlacePageView extends RelativeLayout
|
|||
if (ugc.getReviews() != null)
|
||||
mUGCReviewAdapter.setItems(ugc.getReviews());
|
||||
mUGCRatingRecordsAdapter.setItems(ugc.getRatings());
|
||||
mUGCUserRatingRecordsAdapter.setItems(ugc.getUserRatings());
|
||||
UiUtils.show(mUgcView);
|
||||
}
|
||||
|
||||
|
@ -686,7 +689,8 @@ public class PlacePageView extends RelativeLayout
|
|||
rvHotelReview.setHasFixedSize(false);
|
||||
rvHotelReview.setAdapter(mUGCReviewAdapter);
|
||||
|
||||
RecyclerView rvRatingRecords = (RecyclerView) findViewById(R.id.rv__summary_rating_records);
|
||||
View summaryRatingContainer = findViewById(R.id.summary_rating_records);
|
||||
RecyclerView rvRatingRecords = (RecyclerView) summaryRatingContainer.findViewById(R.id.rv__summary_rating_records);
|
||||
rvRatingRecords.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
rvRatingRecords.getLayoutManager().setAutoMeasureEnabled(true);
|
||||
rvRatingRecords.setNestedScrollingEnabled(false);
|
||||
|
@ -694,6 +698,30 @@ public class PlacePageView extends RelativeLayout
|
|||
rvRatingRecords.addItemDecoration(
|
||||
ItemDecoratorFactory.createRatingRecordDecorator(getContext(), LinearLayoutManager.HORIZONTAL));
|
||||
rvRatingRecords.setAdapter(mUGCRatingRecordsAdapter);
|
||||
|
||||
View userReviewContainer = findViewById(R.id.user_rating_records);
|
||||
RecyclerView rvUserRatingRecords = (RecyclerView) userReviewContainer.findViewById(R.id.rv__summary_rating_records);
|
||||
rvUserRatingRecords.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
rvUserRatingRecords.getLayoutManager().setAutoMeasureEnabled(true);
|
||||
rvUserRatingRecords.setNestedScrollingEnabled(false);
|
||||
rvUserRatingRecords.setHasFixedSize(false);
|
||||
rvUserRatingRecords.addItemDecoration(
|
||||
ItemDecoratorFactory.createRatingRecordDecorator(getContext(), LinearLayoutManager.HORIZONTAL));
|
||||
rvUserRatingRecords.setAdapter(mUGCUserRatingRecordsAdapter);
|
||||
|
||||
View userComment = findViewById(R.id.rl_user_review);
|
||||
TextView name = (TextView) userComment.findViewById(R.id.name);
|
||||
TextView date = (TextView) userComment.findViewById(R.id.date);
|
||||
TextView review = (TextView) userComment.findViewById(R.id.review);
|
||||
//TODO: remove it after core is ready.
|
||||
name.setText("Your review");
|
||||
date.setText("10 May 2017");
|
||||
review.setText("Go first thing in the morning when they open...You will get in right" +
|
||||
"away if you do..." +
|
||||
"" +
|
||||
"Amazing food...");
|
||||
userComment.findViewById(R.id.rating).setVisibility(GONE);
|
||||
|
||||
}
|
||||
|
||||
private void initHotelRatingView()
|
||||
|
|
Loading…
Add table
Reference in a new issue