improved import filter
This commit is contained in:
parent
edc1ccce56
commit
e826276d53
|
@ -1065,14 +1065,16 @@ public class DataStoreUtils implements Constants {
|
|||
}
|
||||
}
|
||||
|
||||
public static void removeFromFilter(Context context, ParcelableUser user) {
|
||||
public static void removeFromFilter(Context context, Collection<ParcelableUser> users) {
|
||||
List<String> userKeyValues = new ArrayList<>();
|
||||
List<String> linkValues = new ArrayList<>();
|
||||
List<String> keywordValues = new ArrayList<>();
|
||||
final ContentResolver cr = context.getContentResolver();
|
||||
for (ParcelableUser user : users) {
|
||||
// Delete from filtered users
|
||||
cr.delete(Filters.Users.CONTENT_URI, Expression.equalsArgs(Filters.Users.USER_KEY).getSQL(),
|
||||
new String[]{user.key.toString()});
|
||||
userKeyValues.add(user.key.toString());
|
||||
// Delete user mention from keywords
|
||||
cr.delete(Filters.Keywords.CONTENT_URI, Expression.equalsArgs(Filters.Keywords.VALUE).getSQL(),
|
||||
new String[]{"@" + user.screen_name});
|
||||
keywordValues.add("@" + user.screen_name);
|
||||
|
||||
// Delete user link (without scheme) from links
|
||||
Uri userLink = LinkCreator.getUserWebLink(user);
|
||||
|
@ -1081,8 +1083,11 @@ public class DataStoreUtils implements Constants {
|
|||
if ((idx = linkWithoutScheme.indexOf("://")) >= 0) {
|
||||
linkWithoutScheme = linkWithoutScheme.substring(idx + 3);
|
||||
}
|
||||
cr.delete(Filters.Links.CONTENT_URI, Expression.equalsArgs(Filters.Links.VALUE).getSQL(),
|
||||
new String[]{linkWithoutScheme});
|
||||
linkValues.add(linkWithoutScheme);
|
||||
}
|
||||
ContentResolverUtils.bulkDelete(cr, Filters.Users.CONTENT_URI, Filters.Users.USER_KEY, userKeyValues, null);
|
||||
ContentResolverUtils.bulkDelete(cr, Filters.Keywords.CONTENT_URI, Filters.Keywords.VALUE, keywordValues, null);
|
||||
ContentResolverUtils.bulkDelete(cr, Filters.Links.CONTENT_URI, Filters.Links.VALUE, linkValues, null);
|
||||
}
|
||||
|
||||
public interface UpdateActivityAction {
|
||||
|
|
|
@ -856,7 +856,7 @@ class UserFragment : BaseSupportFragment(), OnClickListener, OnLinkClickListener
|
|||
R.id.add_to_filter -> {
|
||||
if (userRelationship == null) return true
|
||||
if (userRelationship.filtering) {
|
||||
DataStoreUtils.removeFromFilter(context, user)
|
||||
DataStoreUtils.removeFromFilter(context, listOf(user))
|
||||
Utils.showInfoMessage(activity, R.string.message_user_unmuted, false)
|
||||
getFriendship()
|
||||
} else {
|
||||
|
|
|
@ -188,6 +188,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Ba
|
|||
val selectedUsers = rangeOfSize(adapter.userStartIndex, adapter.userCount - 1)
|
||||
.filter { adapter.isItemChecked(it) }
|
||||
.map { adapter.getUser(it)!! }
|
||||
selectedUsers.forEach { it.is_filtered = true }
|
||||
ProgressDialogFragment.show(childFragmentManager, "import_progress")
|
||||
task {
|
||||
DataStoreUtils.addToFilter(context, selectedUsers, filterEverywhere)
|
||||
|
@ -195,6 +196,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Ba
|
|||
executeAfterFragmentResumed {
|
||||
(childFragmentManager.findFragmentByTag("import_progress") as? DialogFragment)?.dismiss()
|
||||
}
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,7 +371,7 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Ba
|
|||
}
|
||||
|
||||
val checkedCount: Int get() {
|
||||
return itemStates.count { it.value }
|
||||
return data?.count { !it.is_filtered && itemStates[it.key] ?: false } ?: 0
|
||||
}
|
||||
|
||||
fun setItemChecked(position: Int, value: Boolean) {
|
||||
|
@ -409,6 +411,8 @@ abstract class BaseFiltersImportFragment : AbsContentListRecyclerViewFragment<Ba
|
|||
checkBox.setOnCheckedChangeListener(null)
|
||||
checkBox.isChecked = (adapter as SelectableUsersAdapter).isItemChecked(layoutPosition)
|
||||
checkBox.setOnCheckedChangeListener(checkChangedListener)
|
||||
itemView.isEnabled = !user.is_filtered
|
||||
checkBox.isEnabled = !user.is_filtered
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
android:id="@+id/name"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:duplicateParentState="true"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
|
@ -63,6 +64,7 @@
|
|||
android:id="@+id/screenName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:duplicateParentState="true"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
|
|
Loading…
Reference in New Issue