Long click category to set other categories to the opposite

This commit is contained in:
seven332 committed 2018-12-14 13:40:47 +08:00
1 parent b5f36dafdc
commit 0553fda3fa
2 files changed
+29 -5

No files matched your search

@@ -21,15 +21,15 @@ import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TableLayout;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.client.EhConfig;
import com.hippo.widget.CheckTextView;
import com.hippo.yorozuya.NumberUtils;
public class CategoryTable extends TableLayout {
public class CategoryTable extends TableLayout implements View.OnLongClickListener {
private static final String STATE_KEY_SUPER = "super";
private static final String STATE_KEY_CATEGORY = "category";
@@ -45,6 +45,8 @@ public class CategoryTable extends TableLayout {
private CheckTextView mAsianPorn;
private CheckTextView mMisc;
private CheckTextView[] mOptions;
public CategoryTable(Context context) {
super(context);
init();
@@ -78,6 +80,29 @@ public class CategoryTable extends TableLayout {
ViewGroup row4 = (ViewGroup) getChildAt(4);
mAsianPorn = (CheckTextView) row4.getChildAt(0);
mMisc = (CheckTextView) row4.getChildAt(1);
mOptions = new CheckTextView[] {
mDoujinshi, mManga, mArtistCG, mGameCG, mWestern,
mNonH, mImageSets, mCosplay, mAsianPorn, mMisc
};
for (CheckTextView option : mOptions) {
option.setOnLongClickListener(this);
}
}
@Override
public boolean onLongClick(View v) {
if (v instanceof CheckTextView) {
boolean checked = ((CheckTextView) v).isChecked();
for (CheckTextView option : mOptions) {
if (option != v) {
option.setChecked(!checked, false);
}
}
}
return true;
}
/**
@@ -27,12 +27,11 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Interpolator;
import android.widget.TextView;
import com.hippo.ehviewer.R;
import com.hippo.hotspot.Hotspot;
import com.hippo.hotspot.Hotspotable;
@@ -40,7 +39,7 @@ import com.hippo.yorozuya.AnimationUtils;
import com.hippo.yorozuya.MathUtils;
import com.hippo.yorozuya.SimpleAnimatorListener;
public class CheckTextView extends TextView implements OnClickListener, Hotspotable {
public class CheckTextView extends AppCompatTextView implements OnClickListener, Hotspotable {
private static final String STATE_KEY_SUPER = "super";
private static final String STATE_KEY_CHECKED = "checked";