Skip to content

Commit

Permalink
finsh blacklist
Browse files Browse the repository at this point in the history
  • Loading branch information
xj committed Dec 24, 2020
1 parent ca21778 commit 95a4a9f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
45 changes: 23 additions & 22 deletions app/src/main/java/com/hippo/ehviewer/ui/BlackListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

mFilterList = new FilterList();

mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);
mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view1);
TextView tip = (TextView) ViewUtils.$$(this, R.id.tip);
mViewTransition = new ViewTransition(mRecyclerView, tip);

Expand All @@ -94,7 +94,7 @@ private void updateView(boolean animation) {

if (null == mFilterList || 0 == mFilterList.size()) {
mViewTransition.showView(1, animation);
} else {
}else {
mViewTransition.showView(0, animation);
}
}
Expand Down Expand Up @@ -208,6 +208,7 @@ public void onClick(View v) {
blackList.badgayname = text;
blackList.add_time = TimeUtils.getTimeNow();
blackList.angrywith = "/手动添加/";
blackList.mode=1;

mFilterList.add(blackList);

Expand Down Expand Up @@ -283,20 +284,18 @@ private class FilterAdapter extends RecyclerView.Adapter<FilterHolder> {
public int getItemViewType(int position) {
if (null == mFilterList) {
return TYPE_ITEM;
}else {
return TYPE_HEADER;
}

// if (mFilterList.get(position).mode == FilterList.MODE_HEADER) {
// return TYPE_HEADER;
// } else {
// return TYPE_ITEM;
// }
if (mFilterList.get(position).mode == FilterList.MODE_HEADER) {
return TYPE_HEADER;
} else {
return TYPE_ITEM;
}
}

@Override
public FilterHolder onCreateViewHolder(ViewGroup parent, int viewType) {
int layoutId;
int layoutId ;
switch (viewType) {
default:
case TYPE_ITEM:
Expand All @@ -323,16 +322,16 @@ public void onBindViewHolder(FilterHolder holder, int position) {
return;
}
BlackList blackList = mFilterList.get(position);
holder.text.setText(blackList.badgayname);
holder.text.setPaintFlags(holder.text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
// if (FilterList.MODE_HEADER == blackList.mode) {
// holder.text.setText(blackList.badgayname);
// } else {
// holder.text.setText(blackList.badgayname);
// // add a delete line if the filter is disabled
// holder.text.setPaintFlags(holder.text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
//
// }
// holder.text.setText(blackList.badgayname);
// holder.text.setPaintFlags(holder.text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
if (FilterList.MODE_HEADER == blackList.mode) {
holder.text.setText(blackList.badgayname);
} else {
holder.text.setText(blackList.badgayname);
// add a delete line if the filter is disabled
holder.text.setPaintFlags(holder.text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));

}
// Filter filter = mFilterList.get(position);
// if (FilterList.MODE_HEADER == filter.mode) {
// holder.text.setText(filter.text);
Expand All @@ -358,7 +357,7 @@ private class FilterList {
public static final int MODE_HEADER = -1;


private final List<BlackList> mTitleBlackList;
private List<BlackList> mTitleBlackList;

private BlackList mTitleHeader;

Expand All @@ -377,7 +376,7 @@ public int size() {
private BlackList getTitleHeader() {
if (null == mTitleHeader) {
mTitleHeader = new BlackList();
// mTitleHeader.mode = MODE_HEADER;
mTitleHeader.mode = MODE_HEADER;
mTitleHeader.badgayname = getString(R.string.blacklist_id);
}
return mTitleHeader;
Expand All @@ -403,10 +402,12 @@ public BlackList get(int index) {

public void add(BlackList blackList) {
EhDB.insertBlackList(blackList);
mTitleBlackList.add(blackList);
}

public void delete(BlackList blackList) {
EhDB.deleteBlackList(blackList);
mTitleBlackList.remove(blackList);
}

// public void trigger(Filter filter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ public void onClick(DialogInterface dialog, int which) {
case R.id.join_blacklist:
EhDB.insertBlackList(BlackListUtils.parseBlacklist(comment));
mCommentList.DeleteComment(position);
mRecyclerView.invalidate();
mAdapter.notifyDataSetChanged();
updateView(true);
break;
}
}
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/com/hippo/util/BlackListUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static BlackList parseBlacklist(GalleryComment comment){

blackList.badgayname = comment.user;
blackList.angrywith = comment.comment;
blackList.mode = 1;
blackList.add_time = TimeUtils.getTimeNow();

return blackList;
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_blacklist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
android:layout_height="match_parent">

<com.hippo.easyrecyclerview.EasyRecyclerView
android:id="@+id/recycler_view"
android:id="@+id/recycler_view1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/keyline_margin"/>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/dialog_add_blacklist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:hint="@string/blacklist_reason_text">
android:hint="@string/blacklist_text">

<com.hippo.widget.HackyTextInputEditText
android:id="@+id/reason_text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private static void addBlackList(Schema schema) {
entity.addStringProperty("reason");
entity.addStringProperty("angrywith");
entity.addStringProperty("add_time");

entity.addIntProperty("mode");
}


Expand All @@ -96,7 +96,7 @@ private static void adjustBlackList() throws Exception {
javaClass.getField("reason").setPublic();
javaClass.getField("angrywith").setPublic();
javaClass.getField("add_time").setPublic();

javaClass.getField("mode").setPublic();
javaClass.addMethod("\t@Override\n" +
"\tpublic String toString() {\n" +
"\t\treturn badgayname;\n" +
Expand Down

0 comments on commit 95a4a9f

Please sign in to comment.