mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Resolve merge conflicts
This commit is contained in:
		| @@ -6,6 +6,7 @@ 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 | ||||
| import eu.kanade.tachiyomi.R | ||||
| @@ -39,8 +40,8 @@ class MangaInfoHeaderAdapter( | ||||
| ) : | ||||
|     RecyclerView.Adapter<MangaInfoHeaderAdapter.HeaderViewHolder>() { | ||||
|  | ||||
|     private var manga: Manga? = null | ||||
|     private var source: Source? = null | ||||
|     private var manga: Manga = controller.presenter.manga | ||||
|     private var source: Source = controller.presenter.source | ||||
|     private var numChapters: Int? = null | ||||
|  | ||||
|     private val scope = CoroutineScope(Job() + Dispatchers.Main) | ||||
| @@ -65,7 +66,7 @@ class MangaInfoHeaderAdapter( | ||||
|      * @param manga manga object containing information about manga. | ||||
|      * @param source the source of the manga. | ||||
|      */ | ||||
|     fun update(manga: Manga, source: Source?) { | ||||
|     fun update(manga: Manga, source: Source) { | ||||
|         this.manga = manga | ||||
|         this.source = source | ||||
|  | ||||
| @@ -80,10 +81,6 @@ class MangaInfoHeaderAdapter( | ||||
|  | ||||
|     inner class HeaderViewHolder(private val view: View) : RecyclerView.ViewHolder(view) { | ||||
|         fun bind() { | ||||
|             if (manga == null) { | ||||
|                 return | ||||
|             } | ||||
|  | ||||
|             // For rounded corners | ||||
|             binding.mangaCover.clipToOutline = true | ||||
|  | ||||
| @@ -143,6 +140,21 @@ class MangaInfoHeaderAdapter( | ||||
|                 } | ||||
|                 .launchIn(scope) | ||||
|  | ||||
|             binding.mangaArtist.longClicks() | ||||
|                 .onEach { | ||||
|                     controller.activity?.copyToClipboard( | ||||
|                         binding.mangaArtist.text.toString(), | ||||
|                         binding.mangaArtist.text.toString() | ||||
|                     ) | ||||
|                 } | ||||
|                 .launchIn(scope) | ||||
|  | ||||
|             binding.mangaArtist.clicks() | ||||
|                 .onEach { | ||||
|                     controller.performGlobalSearch(binding.mangaArtist.text.toString()) | ||||
|                 } | ||||
|                 .launchIn(scope) | ||||
|  | ||||
|             binding.mangaSummary.longClicks() | ||||
|                 .onEach { | ||||
|                     controller.activity?.copyToClipboard( | ||||
| @@ -161,7 +173,7 @@ class MangaInfoHeaderAdapter( | ||||
|                 } | ||||
|                 .launchIn(scope) | ||||
|  | ||||
|             setMangaInfo(manga!!, source) | ||||
|             setMangaInfo(manga, source) | ||||
|             setChapterInfo() | ||||
|         } | ||||
|  | ||||
| @@ -172,19 +184,25 @@ class MangaInfoHeaderAdapter( | ||||
|          * @param source the source of the manga. | ||||
|          */ | ||||
|         private fun setMangaInfo(manga: Manga, source: Source?) { | ||||
|             // update full title TextView. | ||||
|             // Update full title TextView. | ||||
|             binding.mangaFullTitle.text = if (manga.title.isBlank()) { | ||||
|                 view.context.getString(R.string.unknown) | ||||
|             } else { | ||||
|                 manga.title | ||||
|             } | ||||
|  | ||||
|             // Update author/artist TextView. | ||||
|             val authors = listOf(manga.author, manga.artist).filter { !it.isNullOrBlank() }.distinct() | ||||
|             binding.mangaAuthor.text = if (authors.isEmpty()) { | ||||
|             // Update author TextView. | ||||
|             binding.mangaAuthor.text = if (manga.author.isNullOrBlank()) { | ||||
|                 view.context.getString(R.string.unknown) | ||||
|             } else { | ||||
|                 authors.joinToString(", ") | ||||
|                 manga.author | ||||
|             } | ||||
|  | ||||
|             // Update artist TextView. | ||||
|             val hasArtist = !manga.artist.isNullOrBlank() && manga.artist != manga.author | ||||
|             binding.mangaArtist.isVisible = hasArtist | ||||
|             if (hasArtist) { | ||||
|                 binding.mangaArtist.text = manga.artist | ||||
|             } | ||||
|  | ||||
|             // If manga source is known update source TextView. | ||||
| @@ -215,20 +233,16 @@ class MangaInfoHeaderAdapter( | ||||
|             setFavoriteButtonState(manga.favorite) | ||||
|  | ||||
|             // Set cover if it wasn't already. | ||||
|             val mangaThumbnail = manga.toMangaThumbnail() | ||||
|  | ||||
|             GlideApp.with(view.context) | ||||
|                 .load(mangaThumbnail) | ||||
|                 .diskCacheStrategy(DiskCacheStrategy.RESOURCE) | ||||
|                 .centerCrop() | ||||
|                 .into(binding.mangaCover) | ||||
|  | ||||
|             binding.backdrop?.let { | ||||
|                 GlideApp.with(view.context) | ||||
|                     .load(mangaThumbnail) | ||||
|                     .diskCacheStrategy(DiskCacheStrategy.RESOURCE) | ||||
|                     .centerCrop() | ||||
|                     .into(it) | ||||
|             if (binding.mangaCover.drawable == null) { | ||||
|                 val mangaThumbnail = manga.toMangaThumbnail() | ||||
|                 listOf(binding.mangaCover, binding.backdrop) | ||||
|                     .forEach { | ||||
|                         GlideApp.with(view.context) | ||||
|                             .load(mangaThumbnail) | ||||
|                             .diskCacheStrategy(DiskCacheStrategy.RESOURCE) | ||||
|                             .centerCrop() | ||||
|                             .into(it) | ||||
|                     } | ||||
|             } | ||||
|  | ||||
|             // Manga info section | ||||
|   | ||||
| @@ -80,16 +80,23 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer { | ||||
|             } | ||||
|         }) | ||||
|         pager.tapListener = { event -> | ||||
|             val positionX = event.x | ||||
|             val tappingInverted = config.tappingInverted | ||||
|  | ||||
|             val leftSideTap = positionX < pager.width * 0.33f && config.tappingEnabled | ||||
|             val rightSideTap = positionX > pager.width * 0.66f && config.tappingEnabled | ||||
|  | ||||
|             when { | ||||
|                 leftSideTap && !tappingInverted || rightSideTap && tappingInverted -> moveLeft() | ||||
|                 rightSideTap && !tappingInverted || leftSideTap && tappingInverted -> moveRight() | ||||
|                 else -> activity.toggleMenu() | ||||
|             if (this is VerticalPagerViewer) { | ||||
|                 val positionY = event.y | ||||
|                 when { | ||||
|                     positionY < pager.height * 0.33f && config.tappingEnabled -> moveLeft() | ||||
|                     positionY > pager.height * 0.66f && config.tappingEnabled -> moveRight() | ||||
|                     else -> activity.toggleMenu() | ||||
|                 } | ||||
|             } else { | ||||
|                 val positionX = event.x | ||||
|                 val leftSideTap = positionX < pager.width * 0.33f && config.tappingEnabled | ||||
|                 val rightSideTap = positionX > pager.width * 0.66f && config.tappingEnabled | ||||
|                 when { | ||||
|                     leftSideTap && !tappingInverted || rightSideTap && tappingInverted -> moveLeft() | ||||
|                     rightSideTap && !tappingInverted || leftSideTap && tappingInverted -> moveRight() | ||||
|                     else -> activity.toggleMenu() | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         pager.longTapListener = f@{ | ||||
|   | ||||
| @@ -24,6 +24,7 @@ class PagerViewerAdapter(private val viewer: PagerViewer) : ViewPagerAdapter() { | ||||
|         private set | ||||
|  | ||||
|     var currentChapter: ReaderChapter? = null | ||||
|  | ||||
|     /** | ||||
|      * Updates this adapter with the given [chapters]. It handles setting a few pages of the | ||||
|      * next/previous chapter to allow seamless transitions and inverting the pages if the viewer | ||||
|   | ||||
| @@ -93,13 +93,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr | ||||
|             } | ||||
|         }) | ||||
|         recycler.tapListener = { event -> | ||||
|             val positionX = event.rawX | ||||
|             val positionY = event.rawY | ||||
|             when { | ||||
|                 positionY < recycler.height * 0.25 && config.tappingEnabled -> scrollUp() | ||||
|                 positionY > recycler.height * 0.75 && config.tappingEnabled -> scrollDown() | ||||
|                 positionX < recycler.width * 0.33 && config.tappingEnabled -> scrollUp() | ||||
|                 positionX > recycler.width * 0.66 && config.tappingEnabled -> scrollDown() | ||||
|                 positionY < recycler.height * 0.33f && config.tappingEnabled -> scrollUp() | ||||
|                 positionY > recycler.height * 0.66f && config.tappingEnabled -> scrollDown() | ||||
|                 else -> activity.toggleMenu() | ||||
|             } | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user