[Android] Not need for intent broadcast for dialog progress
Geoffrey Métais
git at videolan.org
Thu Feb 4 16:19:58 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 4 16:18:54 2016 +0100| [3cc432a60295ab6dba3349248cc357b3fd452bee] | committer: Geoffrey Métais
Not need for intent broadcast for dialog progress
> https://code.videolan.org/videolan/vlc-android/commit/3cc432a60295ab6dba3349248cc357b3fd452bee
---
.../src/org/videolan/vlc/VLCApplication.java | 7 +++---
.../vlc/gui/dialogs/VlcProgressDialog.java | 29 ++--------------------
2 files changed, 5 insertions(+), 31 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/VLCApplication.java b/vlc-android/src/org/videolan/vlc/VLCApplication.java
index 6d2400e..b236b80 100644
--- a/vlc-android/src/org/videolan/vlc/VLCApplication.java
+++ b/vlc-android/src/org/videolan/vlc/VLCApplication.java
@@ -27,7 +27,6 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
-import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.util.SimpleArrayMap;
import android.util.Log;
@@ -65,7 +64,6 @@ public class VLCApplication extends Application {
new LinkedBlockingQueue<Runnable>());
private static int sDialogCounter = 0;
- LocalBroadcastManager mLocalBroadcastManager;
@Override
public void onCreate() {
@@ -191,7 +189,6 @@ public class VLCApplication extends Application {
public void onDisplay(Dialog.ProgressDialog dialog) {
String key = DialogActivity.KEY_PROGRESS + sDialogCounter++;
fireDialog(dialog, key);
- mLocalBroadcastManager = LocalBroadcastManager.getInstance(instance);
}
@Override
@@ -201,7 +198,9 @@ public class VLCApplication extends Application {
@Override
public void onProgressUpdate(Dialog.ProgressDialog dialog) {
- mLocalBroadcastManager.sendBroadcast(new Intent(VlcProgressDialog.ACTION_PROGRESS));
+ VlcProgressDialog vlcProgressDialog = (VlcProgressDialog) dialog.getContext();
+ if (vlcProgressDialog != null && vlcProgressDialog.isVisible())
+ vlcProgressDialog.updateProgress();
}
};
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcProgressDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcProgressDialog.java
index 2a54508..d18ca40 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcProgressDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/VlcProgressDialog.java
@@ -24,12 +24,6 @@
package org.videolan.vlc.gui.dialogs;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.view.View;
@@ -39,34 +33,15 @@ import org.videolan.vlc.databinding.VlcProgressDialogBinding;
public class VlcProgressDialog extends VlcDialog<Dialog.ProgressDialog, VlcProgressDialogBinding> {
- public static final String ACTION_PROGRESS = "vlc_progress";
- LocalBroadcastManager mLocalBroadcastManager;
-
@Override
int getLayout() {
return R.layout.vlc_progress_dialog;
}
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mLocalBroadcastManager = LocalBroadcastManager.getInstance(getContext());
- mLocalBroadcastManager.registerReceiver(mProgressReceiver, new IntentFilter(ACTION_PROGRESS));
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- mLocalBroadcastManager.unregisterReceiver(mProgressReceiver);
- }
-
- private final BroadcastReceiver mProgressReceiver = new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
+ public void updateProgress() {
mBinding.progress.setProgress((int) (mVlcDialog.getPosition()*100));
mBinding.cancel.setText(mVlcDialog.getCancelText());
mBinding.cancel.setVisibility(
TextUtils.isEmpty(mVlcDialog.getCancelText()) ? View.GONE : View.VISIBLE);
- }
- };
+ }
}
More information about the Android
mailing list