[Android] TV: Fix download display with LeanBack library
Geoffrey Métais
git at videolan.org
Mon Apr 18 16:49:36 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr 18 16:48:56 2016 +0200| [e386e11851b8ea2a5175144c070c2ff053289cc1] | committer: Geoffrey Métais
TV: Fix download display with LeanBack library
> https://code.videolan.org/videolan/vlc-android/commit/e386e11851b8ea2a5175144c070c2ff053289cc1
---
.../org/videolan/vlc/util/SubtitlesDownloader.java | 29 +++++++++++++++-------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java b/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
index 64e2d83..c4c8caf 100644
--- a/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
+++ b/vlc-android/src/org/videolan/vlc/util/SubtitlesDownloader.java
@@ -33,11 +33,13 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
+import android.widget.Toast;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.BuildConfig;
@@ -484,15 +486,24 @@ public class SubtitlesDownloader {
private void showSnackBar(final String text) {
if (mContext == null)
return;
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- View v = mContext.findViewById(R.id.fragment_placeholder);
- if (v == null)
- v = mContext.getWindow().getDecorView();
- UiTools.snacker(v, text);
- }
- });
+ if (mContext instanceof AppCompatActivity) {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ View v = mContext.findViewById(R.id.fragment_placeholder);
+ if (v == null)
+ v = mContext.getWindow().getDecorView();
+ UiTools.snacker(v, text);
+ }
+ });
+ } else {
+ mHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
}
Handler mHandler = new Handler(Looper.getMainLooper()) {
More information about the Android
mailing list