diff --git a/app/build.gradle b/app/build.gradle index 171248d09e..78e4ca1e9d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -92,6 +92,7 @@ dependencies { final DAGGER_VERSION = '2.2' final OKHTTP_VERSION = '3.2.0' final RETROFIT_VERSION = '2.0.1' + final NUCLEUS_VERSION = '3.0.0-beta' final STORIO_VERSION = '1.8.0' final MOCKITO_VERSION = '1.10.19' @@ -142,7 +143,9 @@ dependencies { kapt "com.pushtorefresh.storio:sqlite-annotations-processor:$STORIO_VERSION" // Model View Presenter - compile 'info.android15.nucleus:nucleus:3.0.0-beta' + compile "info.android15.nucleus:nucleus:$NUCLEUS_VERSION" + compile "info.android15.nucleus:nucleus-support-v4:$NUCLEUS_VERSION" + compile "info.android15.nucleus:nucleus-support-v7:$NUCLEUS_VERSION" // Dependency injection compile "com.google.dagger:dagger:$DAGGER_VERSION" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/ActivityMixin.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/ActivityMixin.kt new file mode 100644 index 0000000000..41773a9d59 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/ActivityMixin.kt @@ -0,0 +1,75 @@ +package eu.kanade.tachiyomi.ui.base.activity + +import android.Manifest +import android.content.pm.PackageManager +import android.os.Build +import android.support.v4.app.ActivityCompat +import android.support.v4.content.ContextCompat +import android.support.v7.app.ActionBar +import android.support.v7.app.AppCompatActivity +import android.support.v7.widget.Toolbar +import eu.kanade.tachiyomi.App +import eu.kanade.tachiyomi.R + +interface ActivityMixin { + + fun setupToolbar(toolbar: Toolbar, backNavigation: Boolean = true) { + setSupportActionBar(toolbar) + getSupportActionBar()?.setDisplayHomeAsUpEnabled(true) + if (backNavigation) { + toolbar.setNavigationOnClickListener { onBackPressed() } + } + } + + fun setAppTheme() { + setTheme(when (App.get(getActivity()).appTheme) { + 2 -> R.style.Theme_Tachiyomi_Dark + else -> R.style.Theme_Tachiyomi + }) + } + + fun setToolbarTitle(title: String) { + getSupportActionBar()?.title = title + } + + fun setToolbarTitle(titleResource: Int) { + getSupportActionBar()?.title = getString(titleResource) + } + + fun setToolbarSubtitle(title: String) { + getSupportActionBar()?.subtitle = title + } + + fun setToolbarSubtitle(titleResource: Int) { + getSupportActionBar()?.subtitle = getString(titleResource) + } + + /** + * Requests read and write permissions on Android M and higher. + */ + fun requestPermissionsOnMarshmallow() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (ContextCompat.checkSelfPermission(getActivity(), + Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + + ActivityCompat.requestPermissions(getActivity(), + arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE), + 1) + + } + } + } + + fun getActivity(): AppCompatActivity + + fun onBackPressed() + + fun getSupportActionBar(): ActionBar? + + fun setSupportActionBar(toolbar: Toolbar?) + + fun setTheme(resource: Int) + + fun getString(resource: Int): String + +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt index efe2218dfd..999b64ba1f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseActivity.kt @@ -1,76 +1,9 @@ package eu.kanade.tachiyomi.ui.base.activity -import android.Manifest -import android.content.pm.PackageManager -import android.graphics.Color -import android.os.Build -import android.support.design.widget.Snackbar -import android.support.v4.app.ActivityCompat -import android.support.v4.content.ContextCompat import android.support.v7.app.AppCompatActivity -import android.support.v7.widget.Toolbar -import android.view.View -import android.widget.TextView -import eu.kanade.tachiyomi.App -import eu.kanade.tachiyomi.R -open class BaseActivity : AppCompatActivity() { +abstract class BaseActivity : AppCompatActivity(), ActivityMixin { - protected fun setupToolbar(toolbar: Toolbar, backNavigation: Boolean = true) { - setSupportActionBar(toolbar) - supportActionBar?.setDisplayHomeAsUpEnabled(true) - if (backNavigation) { - toolbar.setNavigationOnClickListener { onBackPressed() } - } - } + override fun getActivity() = this - fun setAppTheme() { - when (app.appTheme) { - 2 -> setTheme(R.style.Theme_Tachiyomi_Dark) - else -> setTheme(R.style.Theme_Tachiyomi) - } - } - - fun setToolbarTitle(title: String) { - supportActionBar?.title = title - } - - fun setToolbarTitle(titleResource: Int) { - supportActionBar?.title = getString(titleResource) - } - - fun setToolbarSubtitle(title: String) { - supportActionBar?.subtitle = title - } - - fun setToolbarSubtitle(titleResource: Int) { - supportActionBar?.subtitle = getString(titleResource) - } - - /** - * Requests read and write permissions on Android M and higher. - */ - fun requestPermissionsOnMarshmallow() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (ContextCompat.checkSelfPermission(this, - Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - - ActivityCompat.requestPermissions(this, - arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE), - 1) - - } - } - } - - protected val app: App - get() = App.get(this) - - inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit) { - val snack = Snackbar.make(this, message, length) - val textView = snack.view.findViewById(android.support.design.R.id.snackbar_text) as TextView - textView.setTextColor(Color.WHITE) - snack.f() - snack.show() - } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java deleted file mode 100644 index 910697d8d3..0000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.java +++ /dev/null @@ -1,94 +0,0 @@ -package eu.kanade.tachiyomi.ui.base.activity; - -import android.os.Bundle; -import android.support.annotation.NonNull; - -import eu.kanade.tachiyomi.App; -import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter; -import nucleus.factory.PresenterFactory; -import nucleus.factory.ReflectionPresenterFactory; -import nucleus.presenter.Presenter; -import nucleus.view.PresenterLifecycleDelegate; -import nucleus.view.ViewWithPresenter; - -/** - * This class is an example of how an activity could controls it's presenter. - * You can inherit from this class or copy/paste this class's code to - * create your own view implementation. - * - * @param
a type of presenter to return with {@link #getPresenter}. - */ -public abstract class BaseRxActivity
extends BaseActivity implements ViewWithPresenter
{ - - private static final String PRESENTER_STATE_KEY = "presenter_state"; - - private final PresenterLifecycleDelegate
presenterDelegate = - new PresenterLifecycleDelegate<>(ReflectionPresenterFactory.
fromViewClass(getClass())); - - /** - * Returns a current presenter factory. - */ - public PresenterFactory
getPresenterFactory() { - return presenterDelegate.getPresenterFactory(); - } - - /** - * Sets a presenter factory. - * Call this method before onCreate/onFinishInflate to override default {@link ReflectionPresenterFactory} presenter factory. - * Use this method for presenter dependency injection. - */ - @Override - public void setPresenterFactory(PresenterFactory
presenterFactory) { - presenterDelegate.setPresenterFactory(presenterFactory); - } - - /** - * Returns a current attached presenter. - * This method is guaranteed to return a non-null value between - * onResume/onPause and onAttachedToWindow/onDetachedFromWindow calls - * if the presenter factory returns a non-null value. - * - * @return a currently attached presenter or null. - */ - public P getPresenter() { - return presenterDelegate.getPresenter(); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - final PresenterFactory
superFactory = getPresenterFactory(); - setPresenterFactory(new PresenterFactory
() { - @Override - public P createPresenter() { - P presenter = superFactory.createPresenter(); - App app = (App) getApplication(); - app.getComponentReflection().inject(presenter); - ((BasePresenter) presenter).setContext(app.getApplicationContext()); - return presenter; - } - }); - - super.onCreate(savedInstanceState); - if (savedInstanceState != null) - presenterDelegate.onRestoreInstanceState(savedInstanceState.getBundle(PRESENTER_STATE_KEY)); - } - - @Override - protected void onSaveInstanceState(@NonNull Bundle outState) { - super.onSaveInstanceState(outState); - outState.putBundle(PRESENTER_STATE_KEY, presenterDelegate.onSaveInstanceState()); - } - - @Override - protected void onResume() { - super.onResume(); - presenterDelegate.onResume(this); - } - - @Override - protected void onDestroy() { - super.onDestroy(); - presenterDelegate.onDropView(); - presenterDelegate.onDestroy(!isChangingConfigurations()); - } -} diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt new file mode 100644 index 0000000000..6f83dfdec2 --- /dev/null +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseRxActivity.kt @@ -0,0 +1,24 @@ +package eu.kanade.tachiyomi.ui.base.activity + +import android.os.Bundle +import eu.kanade.tachiyomi.App +import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter +import nucleus.view.NucleusAppCompatActivity + +abstract class BaseRxActivity
> : NucleusAppCompatActivity
(), ActivityMixin {
+
+ override fun onCreate(savedState: Bundle?) {
+ val superFactory = presenterFactory
+ setPresenterFactory {
+ superFactory.createPresenter().apply {
+ val app = application as App
+ app.componentReflection.inject(this)
+ context = app.applicationContext
+ }
+ }
+ super.onCreate(savedState)
+ }
+
+ override fun getActivity() = this
+
+}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/FlexibleViewHolder.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/FlexibleViewHolder.java
deleted file mode 100644
index 8ca4d3b139..0000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/FlexibleViewHolder.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package eu.kanade.tachiyomi.ui.base.adapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.view.View;
-
-import eu.davidea.flexibleadapter.FlexibleAdapter;
-
-public abstract class FlexibleViewHolder extends RecyclerView.ViewHolder
- implements View.OnClickListener, View.OnLongClickListener {
-
- private final FlexibleAdapter adapter;
- private final OnListItemClickListener onListItemClickListener;
-
- public FlexibleViewHolder(View itemView,FlexibleAdapter adapter,
- OnListItemClickListener onListItemClickListener) {
- super(itemView);
- this.adapter = adapter;
-
- this.onListItemClickListener = onListItemClickListener;
-
- this.itemView.setOnClickListener(this);
- this.itemView.setOnLongClickListener(this);
- }
-
- @Override
- public void onClick(View view) {
- if (onListItemClickListener.onListItemClick(getAdapterPosition())) {
- toggleActivation();
- }
- }
-
- @Override
- public boolean onLongClick(View view) {
- onListItemClickListener.onListItemLongClick(getAdapterPosition());
- toggleActivation();
- return true;
- }
-
- protected void toggleActivation() {
- itemView.setActivated(adapter.isSelected(getAdapterPosition()));
- }
-
- public interface OnListItemClickListener {
- boolean onListItemClick(int position);
- void onListItemLongClick(int position);
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/FlexibleViewHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/FlexibleViewHolder.kt
new file mode 100644
index 0000000000..ed5e39e65d
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/FlexibleViewHolder.kt
@@ -0,0 +1,39 @@
+package eu.kanade.tachiyomi.ui.base.adapter
+
+import android.support.v7.widget.RecyclerView
+import android.view.View
+
+import eu.davidea.flexibleadapter.FlexibleAdapter
+
+abstract class FlexibleViewHolder(view: View,
+ private val adapter: FlexibleAdapter<*, *>,
+ private val itemClickListener: FlexibleViewHolder.OnListItemClickListener) :
+ RecyclerView.ViewHolder(view), View.OnClickListener, View.OnLongClickListener {
+
+ init {
+ view.setOnClickListener(this)
+ view.setOnLongClickListener(this)
+ }
+
+ override fun onClick(view: View) {
+ if (itemClickListener.onListItemClick(adapterPosition)) {
+ toggleActivation()
+ }
+ }
+
+ override fun onLongClick(view: View): Boolean {
+ itemClickListener.onListItemLongClick(adapterPosition)
+ toggleActivation()
+ return true
+ }
+
+ protected fun toggleActivation() {
+ itemView.isActivated = adapter.isSelected(adapterPosition)
+ }
+
+ interface OnListItemClickListener {
+ fun onListItemClick(position: Int): Boolean
+ fun onListItemLongClick(position: Int)
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/ItemTouchHelperAdapter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/ItemTouchHelperAdapter.java
deleted file mode 100644
index 7f335bd86a..0000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/ItemTouchHelperAdapter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2015 Paul Burke
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package eu.kanade.tachiyomi.ui.base.adapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.helper.ItemTouchHelper;
-
-/**
- * Interface to listen for a move or dismissal event from a {@link ItemTouchHelper.Callback}.
- *
- * @author Paul Burke (ipaulpro)
- */
-public interface ItemTouchHelperAdapter {
-
- /**
- * Called when an item has been dragged far enough to trigger a move. This is called every time
- * an item is shifted, and not at the end of a "drop" event. a type of presenter to return with {@link #getPresenter}.
- */
-public abstract class BaseRxFragment extends BaseFragment implements ViewWithPresenter {
-
- private static final String PRESENTER_STATE_KEY = "presenter_state";
- private final PresenterLifecycleDelegate presenterDelegate =
- new PresenterLifecycleDelegate<>(ReflectionPresenterFactory. fromViewClass(getClass()));
-
- /**
- * Returns a current presenter factory.
- */
- public PresenterFactory getPresenterFactory() {
- return presenterDelegate.getPresenterFactory();
- }
-
- /**
- * Sets a presenter factory.
- * Call this method before onCreate/onFinishInflate to override default {@link ReflectionPresenterFactory} presenter factory.
- * Use this method for presenter dependency injection.
- */
- @Override
- public void setPresenterFactory(PresenterFactory presenterFactory) {
- presenterDelegate.setPresenterFactory(presenterFactory);
- }
-
- /**
- * Returns a current attached presenter.
- * This method is guaranteed to return a non-null value between
- * onResume/onPause and onAttachedToWindow/onDetachedFromWindow calls
- * if the presenter factory returns a non-null value.
- *
- * @return a currently attached presenter or null.
- */
- public P getPresenter() {
- return presenterDelegate.getPresenter();
- }
-
- @Override
- public void onCreate(Bundle bundle) {
- final PresenterFactory superFactory = getPresenterFactory();
- setPresenterFactory(new PresenterFactory () {
- @Override
- public P createPresenter() {
- P presenter = superFactory.createPresenter();
- App app = (App) getActivity().getApplication();
- app.getComponentReflection().inject(presenter);
- ((BasePresenter) presenter).setContext(app.getApplicationContext());
- return presenter;
- }
- });
-
- super.onCreate(bundle);
- if (bundle != null)
- presenterDelegate.onRestoreInstanceState(bundle.getBundle(PRESENTER_STATE_KEY));
- }
-
- @Override
- public void onSaveInstanceState(Bundle bundle) {
- super.onSaveInstanceState(bundle);
- bundle.putBundle(PRESENTER_STATE_KEY, presenterDelegate.onSaveInstanceState());
- }
-
- @Override
- public void onResume() {
- super.onResume();
- presenterDelegate.onResume(this);
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- presenterDelegate.onDropView();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- presenterDelegate.onDestroy(!getActivity().isChangingConfigurations());
- }
-}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.kt
new file mode 100644
index 0000000000..03f20d5f10
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/BaseRxFragment.kt
@@ -0,0 +1,21 @@
+package eu.kanade.tachiyomi.ui.base.fragment
+
+import android.os.Bundle
+import eu.kanade.tachiyomi.App
+import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
+import nucleus.view.NucleusSupportFragment
+
+abstract class BaseRxFragment > : NucleusSupportFragment (), FragmentMixin {
+
+ override fun onCreate(savedState: Bundle?) {
+ val superFactory = presenterFactory
+ setPresenterFactory {
+ superFactory.createPresenter().apply {
+ val app = activity.application as App
+ app.componentReflection.inject(this)
+ context = app.applicationContext
+ }
+ }
+ super.onCreate(savedState)
+ }
+}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/FragmentMixin.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/FragmentMixin.kt
new file mode 100644
index 0000000000..4d7fcc8cd5
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/fragment/FragmentMixin.kt
@@ -0,0 +1,22 @@
+package eu.kanade.tachiyomi.ui.base.fragment
+
+import android.support.v4.app.FragmentActivity
+import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
+
+interface FragmentMixin {
+
+ fun setToolbarTitle(title: String) {
+ baseActivity.setToolbarTitle(title)
+ }
+
+ fun setToolbarTitle(resourceId: Int) {
+ baseActivity.setToolbarTitle(getString(resourceId))
+ }
+
+ val baseActivity: BaseActivity
+ get() = getActivity() as BaseActivity
+
+ fun getActivity(): FragmentActivity
+
+ fun getString(resource: Int): String
+}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt
index f86d1a5cdf..2f25572c3b 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt
@@ -260,7 +260,7 @@ class CategoryActivity : BaseRxActivity
- *
- * Implementations should call {@link RecyclerView.Adapter#notifyItemMoved(int, int)} after
- * adjusting the underlying data to reflect this move.
- *
- * @param fromPosition The start position of the moved item.
- * @param toPosition Then resolved position of the moved item.
- *
- * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder)
- * @see RecyclerView.ViewHolder#getAdapterPosition()
- */
- void onItemMove(int fromPosition, int toPosition);
-
-
- /**
- * Called when an item has been dismissed by a swipe.
- *
- * Implementations should call {@link RecyclerView.Adapter#notifyItemRemoved(int)} after
- * adjusting the underlying data to reflect this removal.
- *
- * @param position The position of the item dismissed.
- *
- * @see RecyclerView#getAdapterPositionFor(RecyclerView.ViewHolder)
- * @see RecyclerView.ViewHolder#getAdapterPosition()
- */
- void onItemDismiss(int position);
-}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/ItemTouchHelperAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/ItemTouchHelperAdapter.kt
new file mode 100644
index 0000000000..8fbb68fc30
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/ItemTouchHelperAdapter.kt
@@ -0,0 +1,36 @@
+package eu.kanade.tachiyomi.ui.base.adapter
+
+/**
+ * Interface to listen for a move or dismissal event from a [ItemTouchHelper.Callback].
+ *
+ * @author Paul Burke (ipaulpro)
+ */
+interface ItemTouchHelperAdapter {
+
+ /**
+ * Called when an item has been dragged far enough to trigger a move. This is called every time
+ * an item is shifted, and **not** at the end of a "drop" event.
+ *
+ * Implementations should call [RecyclerView.Adapter.notifyItemMoved] after
+ * adjusting the underlying data to reflect this move.
+ *
+ * @param fromPosition The start position of the moved item.
+ * @param toPosition Then resolved position of the moved item.
+ * @see [RecyclerView.getAdapterPositionFor]
+ * @see [RecyclerView.ViewHolder.getAdapterPosition]
+ */
+ fun onItemMove(fromPosition: Int, toPosition: Int)
+
+
+ /**
+ * Called when an item has been dismissed by a swipe.
+ *
+ * Implementations should call [RecyclerView.Adapter.notifyItemRemoved] after
+ * adjusting the underlying data to reflect this removal.
+ *
+ * @param position The position of the item dismissed.
+ * @see RecyclerView.getAdapterPositionFor
+ * @see RecyclerView.ViewHolder.getAdapterPosition
+ */
+ fun onItemDismiss(position: Int)
+}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/OnStartDragListener.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/OnStartDragListener.java
deleted file mode 100644
index 26bfcb4ceb..0000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/OnStartDragListener.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package eu.kanade.tachiyomi.ui.base.adapter;
-
-import android.support.v7.widget.RecyclerView;
-
-public interface OnStartDragListener {
-
- /**
- * Called when a view is requesting a start of a drag.
- *
- * @param viewHolder The holder of the view to drag.
- */
- void onStartDrag(RecyclerView.ViewHolder viewHolder);
-}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/OnStartDragListener.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/OnStartDragListener.kt
new file mode 100644
index 0000000000..3589c12017
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/OnStartDragListener.kt
@@ -0,0 +1,13 @@
+package eu.kanade.tachiyomi.ui.base.adapter
+
+import android.support.v7.widget.RecyclerView
+
+interface OnStartDragListener {
+
+ /**
+ * Called when a view is requesting a start of a drag.
+ *
+ * @param viewHolder The holder of the view to drag.
+ */
+ fun onStartDrag(viewHolder: RecyclerView.ViewHolder)
+}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SimpleItemTouchHelperCallback.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SimpleItemTouchHelperCallback.java
deleted file mode 100644
index 2091e5c0fe..0000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SimpleItemTouchHelperCallback.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package eu.kanade.tachiyomi.ui.base.adapter;
-
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.helper.ItemTouchHelper;
-
-public class SimpleItemTouchHelperCallback extends ItemTouchHelper.Callback {
-
- private final ItemTouchHelperAdapter adapter;
-
- public SimpleItemTouchHelperCallback(ItemTouchHelperAdapter adapter) {
- this.adapter = adapter;
- }
-
- @Override
- public boolean isLongPressDragEnabled() {
- return true;
- }
-
- @Override
- public boolean isItemViewSwipeEnabled() {
- return true;
- }
-
- @Override
- public int getMovementFlags(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder) {
- int dragFlags = ItemTouchHelper.UP | ItemTouchHelper.DOWN;
- int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
- return makeMovementFlags(dragFlags, swipeFlags);
- }
-
-
- @Override
- public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder,
- RecyclerView.ViewHolder target) {
- adapter.onItemMove(viewHolder.getAdapterPosition(), target.getAdapterPosition());
- return true;
- }
-
- @Override
- public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
- adapter.onItemDismiss(viewHolder.getAdapterPosition());
- }
-
-}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SimpleItemTouchHelperCallback.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SimpleItemTouchHelperCallback.kt
new file mode 100644
index 0000000000..bfbbecc087
--- /dev/null
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SimpleItemTouchHelperCallback.kt
@@ -0,0 +1,28 @@
+package eu.kanade.tachiyomi.ui.base.adapter
+
+import android.support.v7.widget.RecyclerView
+import android.support.v7.widget.helper.ItemTouchHelper
+
+open class SimpleItemTouchHelperCallback(private val adapter: ItemTouchHelperAdapter) : ItemTouchHelper.Callback() {
+
+ override fun isLongPressDragEnabled() = true
+
+ override fun isItemViewSwipeEnabled() = true
+
+ override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
+ val dragFlags = ItemTouchHelper.UP or ItemTouchHelper.DOWN
+ val swipeFlags = ItemTouchHelper.START or ItemTouchHelper.END
+ return ItemTouchHelper.Callback.makeMovementFlags(dragFlags, swipeFlags)
+ }
+
+ override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder,
+ target: RecyclerView.ViewHolder): Boolean {
+ adapter.onItemMove(viewHolder.adapterPosition, target.adapterPosition)
+ return true
+ }
+
+ override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int) {
+ adapter.onItemDismiss(viewHolder.adapterPosition)
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java b/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java
deleted file mode 100644
index 3756df15e9..0000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/adapter/SmartFragmentStatePagerAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package eu.kanade.tachiyomi.ui.base.adapter;
-
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentStatePagerAdapter;
-import android.util.SparseArray;
-import android.view.ViewGroup;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public abstract class SmartFragmentStatePagerAdapter extends FragmentStatePagerAdapter {
- // Sparse array to keep track of registered fragments in memory
- private final SparseArray