Fix click synchronization between the switch and the item view in notification permission layout

This commit is contained in:
Shinokuni 2020-03-25 21:15:25 +01:00
parent 6600090525
commit b359d6c3f8
3 changed files with 4 additions and 6 deletions

View File

@ -29,11 +29,8 @@ class NotificationPermissionListAdapter(var enableAll: Boolean, val listener: (f
holder.binding.notificationSwitch.isChecked = feed.isNotificationEnabled
holder.binding.notificationSwitch.isEnabled = enableAll
holder.binding.notificationSwitch.setOnCheckedChangeListener { _, isChecked ->
if (isChecked != feed.isNotificationEnabled) listener(feed)
}
holder.itemView.setOnClickListener { if (enableAll) listener(feed) }
holder.itemView.setOnClickListener { if (enableAll) listener(getItem(position)) }
GlideApp.with(holder.itemView.context)
.load(feed.iconUrl)

View File

@ -24,6 +24,6 @@ class NotificationPermissionViewModel(application: Application) : AndroidViewMod
fun setFeedNotificationState(feed: Feed): Completable = database.feedDao()
.updateFeedNotificationState(feed.id, !feed.isNotificationEnabled)
fun setAllFeedsNotificationState(enabled: Boolean) = database.feedDao()
fun setAllFeedsNotificationState(enabled: Boolean): Completable = database.feedDao()
.updateAllFeedsNotificationState(account?.id!!, enabled)
}

View File

@ -43,7 +43,8 @@
android:id="@+id/notification_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true" />
android:layout_alignParentEnd="true"
android:clickable="false" />
</RelativeLayout>