mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 10:37:51 +02:00
Update support library and kotlin
This commit is contained in:
@ -79,7 +79,7 @@ class LibraryAdapter(private val controller: LibraryController) : RecyclerViewPa
|
||||
/**
|
||||
* Returns the position of the view.
|
||||
*/
|
||||
override fun getItemPosition(obj: Any?): Int {
|
||||
override fun getItemPosition(obj: Any): Int {
|
||||
val view = obj as? LibraryCategoryView ?: return POSITION_NONE
|
||||
val index = categories.indexOfFirst { it.id == view.category.id }
|
||||
return if (index == -1) POSITION_NONE else index
|
||||
|
@ -64,7 +64,7 @@ class ReaderCustomFilterDialog : DialogFragment() {
|
||||
* @param savedState The last saved instance state of the Fragment.
|
||||
*/
|
||||
override fun onCreateDialog(savedState: Bundle?): Dialog {
|
||||
val dialog = MaterialDialog.Builder(activity)
|
||||
val dialog = MaterialDialog.Builder(activity!!)
|
||||
.customView(R.layout.reader_custom_filter_dialog, false)
|
||||
.positiveText(android.R.string.ok)
|
||||
.build()
|
||||
|
@ -24,7 +24,7 @@ class ReaderSettingsDialog : DialogFragment() {
|
||||
private lateinit var subscriptions: CompositeSubscription
|
||||
|
||||
override fun onCreateDialog(savedState: Bundle?): Dialog {
|
||||
val dialog = MaterialDialog.Builder(activity)
|
||||
val dialog = MaterialDialog.Builder(activity!!)
|
||||
.title(R.string.label_settings)
|
||||
.customView(R.layout.reader_settings_dialog, true)
|
||||
.positiveText(android.R.string.ok)
|
||||
@ -40,8 +40,11 @@ class ReaderSettingsDialog : DialogFragment() {
|
||||
viewer.onItemSelectedListener = IgnoreFirstSpinnerListener { position ->
|
||||
subscriptions += Observable.timer(250, MILLISECONDS, AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
(activity as ReaderActivity).presenter.updateMangaViewer(position)
|
||||
activity.recreate()
|
||||
val readerActivity = activity as? ReaderActivity
|
||||
if (readerActivity != null) {
|
||||
readerActivity.presenter.updateMangaViewer(position)
|
||||
readerActivity.recreate()
|
||||
}
|
||||
}
|
||||
}
|
||||
viewer.setSelection((activity as ReaderActivity).presenter.manga.viewer, false)
|
||||
|
@ -100,12 +100,12 @@ abstract class PagerReader : BaseReader() {
|
||||
/**
|
||||
* Text color for black theme.
|
||||
*/
|
||||
val whiteColor by lazy { ContextCompat.getColor(context, R.color.textColorSecondaryDark) }
|
||||
val whiteColor by lazy { ContextCompat.getColor(context!!, R.color.textColorSecondaryDark) }
|
||||
|
||||
/**
|
||||
* Text color for white theme.
|
||||
*/
|
||||
val blackColor by lazy { ContextCompat.getColor(context, R.color.textColorSecondaryLight) }
|
||||
val blackColor by lazy { ContextCompat.getColor(context!!, R.color.textColorSecondaryLight) }
|
||||
|
||||
/**
|
||||
* Initializes the pager.
|
||||
|
@ -24,7 +24,7 @@ class HorizontalPager(context: Context) : ViewPager(context), Pager {
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
try {
|
||||
if (ev.action and MotionEvent.ACTION_MASK == MotionEvent.ACTION_DOWN) {
|
||||
if (currentItem == 0 || currentItem == adapter.count - 1) {
|
||||
if (currentItem == 0 || currentItem == adapter!!.count - 1) {
|
||||
startDragX = ev.x
|
||||
}
|
||||
}
|
||||
@ -50,7 +50,7 @@ class HorizontalPager(context: Context) : ViewPager(context), Pager {
|
||||
|
||||
startDragX = 0f
|
||||
}
|
||||
} else if (currentItem == adapter.count - 1) {
|
||||
} else if (currentItem == adapter!!.count - 1) {
|
||||
if (ev.action and MotionEvent.ACTION_MASK == MotionEvent.ACTION_UP) {
|
||||
val displacement = startDragX - ev.x
|
||||
|
||||
|
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerReader
|
||||
class LeftToRightReader : PagerReader() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? {
|
||||
return HorizontalPager(activity).apply { initializePager(this) }
|
||||
return HorizontalPager(activity!!).apply { initializePager(this) }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerReader
|
||||
class RightToLeftReader : PagerReader() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? {
|
||||
return HorizontalPager(activity).apply {
|
||||
return HorizontalPager(activity!!).apply {
|
||||
rotation = 180f
|
||||
initializePager(this)
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.PagerReader
|
||||
class VerticalReader : PagerReader() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedState: Bundle?): View? {
|
||||
return VerticalPager(activity).apply { initializePager(this) }
|
||||
return VerticalPager(activity!!).apply { initializePager(this) }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import android.support.annotation.DrawableRes;
|
||||
import android.support.v4.os.ParcelableCompat;
|
||||
import android.support.v4.os.ParcelableCompatCreatorCallbacks;
|
||||
import android.support.v4.view.AccessibilityDelegateCompat;
|
||||
import android.support.v4.view.KeyEventCompat;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
import android.support.v4.view.VelocityTrackerCompat;
|
||||
@ -2598,14 +2597,10 @@ public class VerticalViewPagerImpl extends ViewGroup {
|
||||
handled = arrowScroll(FOCUS_RIGHT);
|
||||
break;
|
||||
case KeyEvent.KEYCODE_TAB:
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
|
||||
// before Android 3.0. Ignore the tab key on those devices.
|
||||
if (KeyEventCompat.hasNoModifiers(event)) {
|
||||
handled = arrowScroll(FOCUS_FORWARD);
|
||||
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
|
||||
handled = arrowScroll(FOCUS_BACKWARD);
|
||||
}
|
||||
if (event.hasNoModifiers()) {
|
||||
handled = arrowScroll(FOCUS_FORWARD);
|
||||
} else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
|
||||
handled = arrowScroll(FOCUS_BACKWARD);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -73,7 +73,7 @@ class WebtoonReader : BaseReader() {
|
||||
private var scrollDistance: Int = 0
|
||||
|
||||
val screenHeight by lazy {
|
||||
val display = activity.windowManager.defaultDisplay
|
||||
val display = activity!!.windowManager.defaultDisplay
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
val metrics = DisplayMetrics()
|
||||
@ -91,7 +91,7 @@ class WebtoonReader : BaseReader() {
|
||||
val screenHeight = resources.displayMetrics.heightPixels
|
||||
scrollDistance = screenHeight * 3 / 4
|
||||
|
||||
layoutManager = PreCachingLayoutManager(activity)
|
||||
layoutManager = PreCachingLayoutManager(activity!!)
|
||||
layoutManager.extraLayoutSpace = screenHeight / 2
|
||||
|
||||
recycler = RecyclerView(activity).apply {
|
||||
|
@ -194,7 +194,7 @@ class SettingsDownloadController : SettingsController() {
|
||||
File.separator + "downloads"
|
||||
|
||||
return mutableListOf(File(defaultDir)) +
|
||||
ContextCompat.getExternalFilesDirs(activity, "").filterNotNull()
|
||||
ContextCompat.getExternalFilesDirs(activity!!, "").filterNotNull()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user