Disable zero rating to gallery
This commit is contained in:
1 parent
f727554afd
commit
901c0ae3ec
3 files changed
+31
-13
No files matched your search
@@ -98,7 +98,7 @@ import com.hippo.widget.AutoWrapLayout;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.widget.ObservedTextView;
|
||||
import com.hippo.widget.ProgressView;
|
||||
import com.hippo.widget.ProgressiveRatingBar;
|
||||
import com.hippo.ehviewer.widget.GalleryRatingBar;
|
||||
import com.hippo.widget.SimpleGridAutoSpanLayout;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
@@ -1706,17 +1706,17 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
private class RateDialogHelper implements ProgressiveRatingBar.OnUserRateListener,
|
||||
private class RateDialogHelper implements GalleryRatingBar.OnUserRateListener,
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
@Nullable
|
||||
private ProgressiveRatingBar mRatingBar;
|
||||
private GalleryRatingBar mRatingBar;
|
||||
@Nullable
|
||||
private TextView mRatingText;
|
||||
|
||||
public void setDialog(Dialog dialog, float rating) {
|
||||
mRatingText = (TextView) ViewUtils.$$(dialog, R.id.rating_text);
|
||||
mRatingBar = (ProgressiveRatingBar) ViewUtils.$$(dialog, R.id.rating_view);
|
||||
mRatingBar = (GalleryRatingBar) ViewUtils.$$(dialog, R.id.rating_view);
|
||||
mRatingText.setText(getRatingText(rating, getResources2()));
|
||||
mRatingBar.setRating(rating);
|
||||
mRatingBar.setOnUserRateListener(this);
|
||||
|
||||
+26
-8
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Hippo Seven
|
||||
* Copyright 2014-2016 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -14,33 +14,44 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.widget;
|
||||
package com.hippo.ehviewer.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.support.v7.widget.AppCompatRatingBar;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.RatingBar;
|
||||
|
||||
public class ProgressiveRatingBar extends AppCompatRatingBar {
|
||||
public class GalleryRatingBar extends AppCompatRatingBar
|
||||
implements RatingBar.OnRatingBarChangeListener {
|
||||
|
||||
private OnUserRateListener mListener;
|
||||
|
||||
public ProgressiveRatingBar(Context context) {
|
||||
public GalleryRatingBar(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
public ProgressiveRatingBar(Context context, AttributeSet attrs) {
|
||||
|
||||
public GalleryRatingBar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
public ProgressiveRatingBar(Context context, AttributeSet attrs,
|
||||
|
||||
public GalleryRatingBar(Context context, AttributeSet attrs,
|
||||
int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setOnRatingBarChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
||||
if (isPressed() && mListener != null) {
|
||||
if (mListener != null) {
|
||||
mListener.onUserRate(getRating());
|
||||
}
|
||||
}
|
||||
@@ -49,6 +60,13 @@ public class ProgressiveRatingBar extends AppCompatRatingBar {
|
||||
mListener = l;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
|
||||
if (rating <= 0.0f) {
|
||||
setRating(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnUserRateListener {
|
||||
void onUserRate(float rating);
|
||||
}
|
||||
Reference in new issue
Block a user