diff --git a/app/src/main/java/ani/dantotsu/App.kt b/app/src/main/java/ani/dantotsu/App.kt index 257bc6dd..d79ab1db 100644 --- a/app/src/main/java/ani/dantotsu/App.kt +++ b/app/src/main/java/ani/dantotsu/App.kt @@ -151,10 +151,10 @@ class App : MultiDexApplication() { } companion object { + private var instance: App? = null /** Reference to the application context. * * USE WITH EXTREME CAUTION!**/ - var instance: App? = null var context: Context? = null fun currentContext(): Context? { return instance?.mFTActivityLifecycleCallbacks?.currentActivity ?: context diff --git a/app/src/main/java/ani/dantotsu/Functions.kt b/app/src/main/java/ani/dantotsu/Functions.kt index 4b6300c6..bb790ad3 100644 --- a/app/src/main/java/ani/dantotsu/Functions.kt +++ b/app/src/main/java/ani/dantotsu/Functions.kt @@ -10,6 +10,7 @@ import android.app.PendingIntent import android.content.ActivityNotFoundException import android.content.ClipData import android.content.ClipboardManager +import android.content.ComponentName import android.content.Context import android.content.DialogInterface import android.content.Intent @@ -718,6 +719,23 @@ fun openLinkInBrowser(link: String?) { } } +fun openLinkInYouTube(link: String?) { + link?.let { + try { + val videoIntent = Intent(Intent.ACTION_VIEW).apply { + addCategory(Intent.CATEGORY_BROWSABLE) + data = Uri.parse(link) + setPackage("com.google.android.youtube") + } + currContext()!!.startActivity(videoIntent) + } catch (e: ActivityNotFoundException) { + openLinkInBrowser(link) + } catch (e: Exception) { + Logger.log(e) + } + } +} + fun saveImageToDownloads(title: String, bitmap: Bitmap, context: Activity) { FileProvider.getUriForFile( context, @@ -1007,7 +1025,7 @@ class EmptyAdapter(private val count: Int) : RecyclerView.AdapterComment notifications update frequency : %1$s Activities + youwu have been cuwsed :pwayge: + https://www.youtube.com/watch?v=dQw4w9WgXcQ Are you sure you want to purge all %1$s downloads? Failed to delete because of… %1$s