@ -97,6 +97,7 @@ import eu.kanade.tachiyomi.util.system.ThemeUtil
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.isInNightMode
import eu.kanade.tachiyomi.util.system.isInNightMode
import eu.kanade.tachiyomi.util.system.isOnline
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.launchUI
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.view.getText
import eu.kanade.tachiyomi.util.view.getText
@ -515,6 +516,14 @@ class MangaDetailsController : BaseController,
}
}
//endregion
//endregion
fun isNotOnline ( showSnackbar : Boolean = true ) : Boolean {
if ( activity == null || ! activity !! . isOnline ( ) ) {
if ( showSnackbar ) view ?. snack ( R . string . no _network _connection )
return true
}
return false
}
fun showError ( message : String ) {
fun showError ( message : String ) {
swipe _refresh ?. isRefreshing = presenter . isLoading
swipe _refresh ?. isRefreshing = presenter . isLoading
view ?. snack ( message )
view ?. snack ( message )
@ -599,7 +608,8 @@ class MangaDetailsController : BaseController,
fun refreshAdapter ( ) = adapter ?. notifyDataSetChanged ( )
fun refreshAdapter ( ) = adapter ?. notifyDataSetChanged ( )
override fun onItemClick ( view : View ? , position : Int ) : Boolean {
override fun onItemClick ( view : View ? , position : Int ) : Boolean {
val chapter = ( adapter ?. getItem ( position ) as ? ChapterItem ) ?. chapter ?: return false
val chapterItem = ( adapter ?. getItem ( position ) as ? ChapterItem ) ?: return false
val chapter = chapterItem . chapter
if ( actionMode != null ) {
if ( actionMode != null ) {
if ( startingDLChapterPos == null ) {
if ( startingDLChapterPos == null ) {
adapter ?. addSelection ( position )
adapter ?. addSelection ( position )
@ -629,6 +639,7 @@ class MangaDetailsController : BaseController,
return false
return false
}
}
openChapter ( chapter )
openChapter ( chapter )
return false
return false
}
}
@ -828,13 +839,15 @@ class MangaDetailsController : BaseController,
}
}
}
}
R . id . action _open _in _web _view -> openInWebView ( )
R . id . action _open _in _web _view -> openInWebView ( )
R . id . action _refresh _tracking -> presenter . refreshTrackers ( )
R . id . action _refresh _tracking -> presenter . refreshTrackers ( true )
R . id . action _migrate ->
R . id . action _migrate ->
if ( !is NotOnline ( ) ) {
PreMigrationController . navigateToMigration (
PreMigrationController . navigateToMigration (
presenter . preferences . skipPreMigration ( ) . getOrDefault ( ) ,
presenter . preferences . skipPreMigration ( ) . getOrDefault ( ) ,
router ,
router ,
listOf ( manga !! . id !! )
listOf ( manga !! . id !! )
)
)
}
R . id . action _mark _all _as _read -> {
R . id . action _mark _all _as _read -> {
MaterialDialog ( view !! . context ) . message ( R . string . mark _all _chapters _as _read )
MaterialDialog ( view !! . context ) . message ( R . string . mark _all _chapters _as _read )
. positiveButton ( R . string . mark _as _read ) {
. positiveButton ( R . string . mark _as _read ) {
@ -892,8 +905,8 @@ class MangaDetailsController : BaseController,
}
}
override fun openInWebView ( ) {
override fun openInWebView ( ) {
if ( isNotOnline ( ) ) return
val source = presenter . source as ? HttpSource ?: return
val source = presenter . source as ? HttpSource ?: return
val url = try {
val url = try {
source . mangaDetailsRequest ( presenter . manga ) . url . toString ( )
source . mangaDetailsRequest ( presenter . manga ) . url . toString ( )
} catch ( e : Exception ) {
} catch ( e : Exception ) {
@ -1053,6 +1066,7 @@ class MangaDetailsController : BaseController,
}
}
override fun globalSearch ( text : String ) {
override fun globalSearch ( text : String ) {
if ( isNotOnline ( ) ) return
router . pushController ( SourceSearchController ( text ) . withFadeTransaction ( ) )
router . pushController ( SourceSearchController ( text ) . withFadeTransaction ( ) )
}
}