mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 06:17:57 +01:00 
			
		
		
		
	Minor Improvements (#405)
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							f21a030cf8
						
					
				
				
					commit
					9cf5a4cac0
				
			| @@ -55,9 +55,9 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     override fun onCreate(savedInstanceState: Bundle?) { | ||||
|     override fun onCreate(savedState: Bundle?) { | ||||
|         setAppTheme() | ||||
|         super.onCreate(savedInstanceState) | ||||
|         super.onCreate(savedState) | ||||
|  | ||||
|         // Inflate activity_edit_categories.xml. | ||||
|         setContentView(R.layout.activity_edit_categories) | ||||
|   | ||||
| @@ -18,8 +18,6 @@ import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder | ||||
| import eu.kanade.tachiyomi.ui.base.fragment.BaseFragment | ||||
| import eu.kanade.tachiyomi.ui.manga.MangaActivity | ||||
| import eu.kanade.tachiyomi.util.toast | ||||
| import kotlinx.android.synthetic.main.fragment_catalogue.* | ||||
| import kotlinx.android.synthetic.main.fragment_library.* | ||||
| import kotlinx.android.synthetic.main.fragment_library_category.* | ||||
| import rx.Subscription | ||||
| import uy.kohesive.injekt.injectLazy | ||||
| @@ -69,7 +67,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli | ||||
|     /** | ||||
|      * display mode | ||||
|      */ | ||||
|     private var displayAsList: Boolean = false; | ||||
|     private var displayAsList: Boolean = false | ||||
|  | ||||
|     companion object { | ||||
|         /** | ||||
| @@ -109,6 +107,8 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli | ||||
|         library_list.adapter = adapter | ||||
|         library_list.layoutManager = LinearLayoutManager(activity) | ||||
|  | ||||
|  | ||||
|  | ||||
|         if (libraryFragment.actionMode != null) { | ||||
|             setSelectionMode(FlexibleAdapter.MODE_MULTI) | ||||
|         } | ||||
| @@ -119,7 +119,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli | ||||
|                 // Set again the adapter to recalculate the covers height | ||||
|                 .subscribe { recycler.adapter = adapter } | ||||
|  | ||||
|         searchSubscription = libraryPresenter.searchSubject.subscribe { text -> | ||||
|         searchSubscription = libraryPresenter.searchSubject?.subscribe { text -> | ||||
|             adapter.searchText = text | ||||
|             adapter.updateDataSet() | ||||
|         } | ||||
| @@ -179,7 +179,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli | ||||
|  | ||||
|  | ||||
|         libraryMangaSubscription = libraryPresenter.libraryMangaSubject | ||||
|                 .subscribe { onNextLibraryManga(it) } | ||||
|                 ?.subscribe { onNextLibraryManga(it) } | ||||
|  | ||||
|     } | ||||
|  | ||||
| @@ -247,7 +247,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli | ||||
|      * | ||||
|      * @param manga the manga to open. | ||||
|      */ | ||||
|     protected fun openManga(manga: Manga) { | ||||
|     private fun openManga(manga: Manga) { | ||||
|         // Notify the presenter a manga is being opened. | ||||
|         libraryPresenter.onOpenManga() | ||||
|  | ||||
|   | ||||
| @@ -138,7 +138,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback | ||||
|         if (savedState != null) { | ||||
|             activeCategory = savedState.getInt(CATEGORY_KEY) | ||||
|             query = savedState.getString(QUERY_KEY) | ||||
|             presenter.searchSubject.onNext(query) | ||||
|             presenter.searchSubject?.onNext(query) | ||||
|         } else { | ||||
|             activeCategory = presenter.preferences.lastUsedCategory().getOrDefault() | ||||
|         } | ||||
| @@ -283,7 +283,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback | ||||
|  | ||||
|         // Notify the subject the query has changed. | ||||
|         if (isResumed) { | ||||
|             presenter.searchSubject.onNext(query) | ||||
|             presenter.searchSubject?.onNext(query) | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @@ -311,7 +311,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback | ||||
|         view_pager.post { if (isAdded) tabs.setScrollPosition(view_pager.currentItem, 0f, true) } | ||||
|  | ||||
|         // Send the manga map to child fragments after the adapter is updated. | ||||
|         presenter.libraryMangaSubject.onNext(LibraryMangaEvent(mangaMap)) | ||||
|         presenter.libraryMangaSubject?.onNext(LibraryMangaEvent(mangaMap)) | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -1,11 +1,8 @@ | ||||
| package eu.kanade.tachiyomi.ui.library | ||||
|  | ||||
| import android.view.View | ||||
| import com.bumptech.glide.Glide | ||||
| import com.bumptech.glide.load.engine.DiskCacheStrategy | ||||
| import eu.kanade.tachiyomi.data.database.models.Manga | ||||
| import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder | ||||
| import kotlinx.android.synthetic.main.item_catalogue_grid.view.* | ||||
|  | ||||
| /** | ||||
|  * Generic class used to hold the displayed data of a manga in the library. | ||||
|   | ||||
| @@ -30,24 +30,28 @@ class LibraryListHolder(private val view: View, | ||||
|      */ | ||||
|     override fun onSetValues(manga: Manga) { | ||||
|         // Update the title of the manga. | ||||
|         view.title.text = manga.title | ||||
|         itemView.title.text = manga.title | ||||
|  | ||||
|         // Update the unread count and its visibility. | ||||
|         with(view.unread_text) { | ||||
|         with(itemView.unread_text) { | ||||
|             visibility = if (manga.unread > 0) View.VISIBLE else View.GONE | ||||
|             text = manga.unread.toString() | ||||
|         } | ||||
|  | ||||
|  | ||||
|         // Create thumbnail onclick to simulate long click | ||||
|         itemView.thumbnail.setOnClickListener { | ||||
|             // Simulate long click on this view to enter selection mode | ||||
|             onLongClick(itemView) | ||||
|         } | ||||
|  | ||||
|         // Update the cover. | ||||
|         Glide.clear(view.thumbnail) | ||||
|         Glide.with(view.context) | ||||
|         Glide.clear(itemView.thumbnail) | ||||
|         Glide.with(itemView.context) | ||||
|                 .load(manga) | ||||
|                 .diskCacheStrategy(DiskCacheStrategy.RESULT) | ||||
|                 .centerCrop() | ||||
|                 .dontAnimate() | ||||
|                 .into(view.thumbnail) | ||||
|                 .into(itemView.thumbnail) | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -39,12 +39,12 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() { | ||||
|     /** | ||||
|      * Search query of the library. | ||||
|      */ | ||||
|     val searchSubject = BehaviorSubject.create<String>() | ||||
|     val searchSubject: BehaviorSubject<String>? = BehaviorSubject.create<String>() | ||||
|  | ||||
|     /** | ||||
|      * Subject to notify the library's viewpager for updates. | ||||
|      */ | ||||
|     val libraryMangaSubject = BehaviorSubject.create<LibraryMangaEvent>() | ||||
|     val libraryMangaSubject: BehaviorSubject<LibraryMangaEvent>? = BehaviorSubject.create<LibraryMangaEvent>() | ||||
|  | ||||
|     /** | ||||
|      * Database. | ||||
| @@ -247,7 +247,7 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() { | ||||
|      * | ||||
|      * @param mangas the list of manga. | ||||
|      */ | ||||
|     fun getCommonCategories(mangas: List<Manga>) = mangas.toSet() | ||||
|     fun getCommonCategories(mangas: List<Manga>): Collection<Category> = mangas.toSet() | ||||
|             .map { db.getCategoriesForManga(it).executeAsBlocking() } | ||||
|             .reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) } | ||||
|  | ||||
| @@ -307,7 +307,6 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() { | ||||
|      * Changes the active display mode. | ||||
|      */ | ||||
|     fun swapDisplayMode() { | ||||
|         var currentMode: Boolean = displayAsList | ||||
|         preferences.libraryAsList().set(!displayAsList) | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user