mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Set activated states for manga info favorite/tracker buttons
This commit is contained in:
		| @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.manga.info | ||||
| import android.view.LayoutInflater | ||||
| import android.view.View | ||||
| import android.view.ViewGroup | ||||
| import androidx.core.content.ContextCompat | ||||
| import androidx.core.view.isVisible | ||||
| import androidx.recyclerview.widget.RecyclerView | ||||
| import com.bumptech.glide.load.engine.DiskCacheStrategy | ||||
| @@ -21,7 +20,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource | ||||
| import eu.kanade.tachiyomi.ui.manga.MangaController | ||||
| import eu.kanade.tachiyomi.util.system.copyToClipboard | ||||
| import eu.kanade.tachiyomi.util.view.setChips | ||||
| import eu.kanade.tachiyomi.util.view.setTooltip | ||||
| import kotlinx.coroutines.CoroutineScope | ||||
| import kotlinx.coroutines.Dispatchers | ||||
| import kotlinx.coroutines.ExperimentalCoroutinesApi | ||||
| @@ -103,27 +101,17 @@ class MangaInfoHeaderAdapter( | ||||
|                     isVisible = true | ||||
|  | ||||
|                     if (trackCount > 0) { | ||||
|                         setCompoundDrawablesWithIntrinsicBounds( | ||||
|                             null, | ||||
|                             ContextCompat.getDrawable(context, R.drawable.ic_done_24dp), | ||||
|                             null, | ||||
|                             null | ||||
|                         ) | ||||
|                         setIconResource(R.drawable.ic_done_24dp) | ||||
|                         text = view.context.resources.getQuantityString( | ||||
|                             R.plurals.num_trackers, | ||||
|                             trackCount, | ||||
|                             trackCount | ||||
|                         ) | ||||
|                         isSelected = true | ||||
|                         isActivated = true | ||||
|                     } else { | ||||
|                         setCompoundDrawablesWithIntrinsicBounds( | ||||
|                             null, | ||||
|                             ContextCompat.getDrawable(context, R.drawable.ic_sync_24dp), | ||||
|                             null, | ||||
|                             null | ||||
|                         ) | ||||
|                         setIconResource(R.drawable.ic_sync_24dp) | ||||
|                         text = view.context.getString(R.string.manga_tracking_tab) | ||||
|                         isSelected = false | ||||
|                         isActivated = false | ||||
|                     } | ||||
|  | ||||
|                     clicks() | ||||
| @@ -139,7 +127,6 @@ class MangaInfoHeaderAdapter( | ||||
|                 binding.btnWebview.clicks() | ||||
|                     .onEach { controller.openMangaInWebView() } | ||||
|                     .launchIn(scope) | ||||
|                 binding.btnWebview.setTooltip(R.string.action_open_in_web_view) | ||||
|             } | ||||
|  | ||||
|             binding.mangaFullTitle.longClicks() | ||||
| @@ -352,18 +339,10 @@ class MangaInfoHeaderAdapter( | ||||
|             // Set the Favorite drawable to the correct one. | ||||
|             // Border drawable if false, filled drawable if true. | ||||
|             binding.btnFavorite.apply { | ||||
|                 setCompoundDrawablesWithIntrinsicBounds( | ||||
|                     null, | ||||
|                     ContextCompat.getDrawable( | ||||
|                         context, | ||||
|                         if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp | ||||
|                     ), | ||||
|                     null, | ||||
|                     null | ||||
|                 ) | ||||
|                 setIconResource(if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp) | ||||
|                 text = | ||||
|                     context.getString(if (isFavorite) R.string.in_library else R.string.add_to_library) | ||||
|                 isSelected = isFavorite | ||||
|                 isActivated = isFavorite | ||||
|             } | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user