diff --git a/app/src/main/java/com/hippo/ehviewer/ui/BlackListActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/BlackListActivity.java index a499ace63..33c28e1ed 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/BlackListActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/BlackListActivity.java @@ -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); @@ -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); } } @@ -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); @@ -283,20 +284,18 @@ private class FilterAdapter extends RecyclerView.Adapter { 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: @@ -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); @@ -358,7 +357,7 @@ private class FilterList { public static final int MODE_HEADER = -1; - private final List mTitleBlackList; + private List mTitleBlackList; private BlackList mTitleHeader; @@ -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; @@ -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) { diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java index 56e3983c3..1d2bf0365 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryCommentsScene.java @@ -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; } } diff --git a/app/src/main/java/com/hippo/util/BlackListUtils.java b/app/src/main/java/com/hippo/util/BlackListUtils.java index c0960af23..1995b9346 100644 --- a/app/src/main/java/com/hippo/util/BlackListUtils.java +++ b/app/src/main/java/com/hippo/util/BlackListUtils.java @@ -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; diff --git a/app/src/main/res/layout/activity_blacklist.xml b/app/src/main/res/layout/activity_blacklist.xml index f53cf9712..4eacadee5 100644 --- a/app/src/main/res/layout/activity_blacklist.xml +++ b/app/src/main/res/layout/activity_blacklist.xml @@ -21,7 +21,7 @@ android:layout_height="match_parent"> diff --git a/app/src/main/res/layout/dialog_add_blacklist.xml b/app/src/main/res/layout/dialog_add_blacklist.xml index 2324f1026..f411d4090 100644 --- a/app/src/main/res/layout/dialog_add_blacklist.xml +++ b/app/src/main/res/layout/dialog_add_blacklist.xml @@ -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">