[Android] Fix video grid not updated after deletion
Geoffrey Métais
git at videolan.org
Mon Jan 4 16:50:55 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jan 4 16:44:28 2016 +0100| [4eed54b74d64744b091d01a000868efe1c90af48] | committer: Geoffrey Métais
Fix video grid not updated after deletion
> https://code.videolan.org/videolan/vlc-android/commit/4eed54b74d64744b091d01a000868efe1c90af48
---
vlc-android/src/org/videolan/vlc/gui/MainActivity.java | 7 ++++++-
.../src/org/videolan/vlc/gui/SecondaryActivity.java | 18 ++++++++++++++++--
.../org/videolan/vlc/gui/video/MediaInfoFragment.java | 3 ++-
.../org/videolan/vlc/gui/video/VideoGridFragment.java | 2 +-
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index 048840a..ffad79a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -100,6 +100,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
private static final int ACTIVITY_RESULT_PREFERENCES = 1;
private static final int ACTIVITY_RESULT_OPEN = 2;
+ private static final int ACTIVITY_RESULT_SECONDARY = 3;
private static final int ACTIVITY_SHOW_INFOLAYOUT = 2;
private static final int ACTIVITY_SHOW_PROGRESSBAR = 3;
private static final int ACTIVITY_HIDE_PROGRESSBAR = 4;
@@ -485,7 +486,7 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
i.putExtra("fragment", fragmentTag);
if (param != null)
i.putExtra("param", param);
- startActivity(i);
+ startActivityForResult(i, ACTIVITY_RESULT_SECONDARY);
// Slide down the audio player if needed.
slideDownAudioPlayer();
}
@@ -660,6 +661,10 @@ public class MainActivity extends AudioPlayerContainerActivity implements Search
}
} else if (requestCode == ACTIVITY_RESULT_OPEN && resultCode == RESULT_OK){
MediaUtils.openUri(this, data.getData());
+ } else if (requestCode == ACTIVITY_RESULT_SECONDARY) {
+ if (resultCode == PreferencesActivity.RESULT_RESCAN) {
+ mMediaLibrary.scanMediaItems(true);
+ }
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
index cfcf4cf..34224f2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/SecondaryActivity.java
@@ -23,28 +23,32 @@
package org.videolan.vlc.gui;
+import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Menu;
import android.view.MenuItem;
-import org.videolan.vlc.media.MediaLibrary;
-import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.AudioAlbumFragment;
import org.videolan.vlc.gui.audio.AudioAlbumsSongsFragment;
import org.videolan.vlc.gui.audio.EqualizerFragment;
import org.videolan.vlc.gui.browser.StorageBrowserFragment;
+import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.gui.video.MediaInfoFragment;
import org.videolan.vlc.gui.video.VideoGridFragment;
import org.videolan.vlc.gui.video.VideoListAdapter;
import org.videolan.vlc.interfaces.ISortable;
+import org.videolan.vlc.media.MediaLibrary;
+import org.videolan.vlc.media.MediaWrapper;
import java.util.ArrayList;
public class SecondaryActivity extends AudioPlayerContainerActivity {
public final static String TAG = "VLC/SecondaryActivity";
+ public static final int ACTIVITY_RESULT_SECONDARY = 3;
+
public static final String ALBUMS_SONGS = "albumsSongs";
public static final String ALBUM = "album";
public static final String EQUALIZER = "equalizer";
@@ -90,6 +94,16 @@ public class SecondaryActivity extends AudioPlayerContainerActivity {
}
@Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == ACTIVITY_RESULT_SECONDARY) {
+ if (resultCode == PreferencesActivity.RESULT_RESCAN) {
+ MediaLibrary.getInstance().scanMediaItems(true);
+ }
+ }
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
if (mFragment instanceof VideoGridFragment)
getMenuInflater().inflate(R.menu.video_group, menu);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
index 3dec20b..9328906 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/MediaInfoFragment.java
@@ -47,6 +47,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.helpers.BitmapUtil;
import org.videolan.vlc.gui.helpers.UiTools;
+import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.media.MediaDatabase;
import org.videolan.vlc.media.MediaLibrary;
import org.videolan.vlc.media.MediaWrapper;
@@ -350,8 +351,8 @@ public class MediaInfoFragment extends ListFragment {
fragment.mDelete.setVisibility(View.GONE);
break;
case EXIT:
+ fragment.getActivity().setResult(PreferencesActivity.RESULT_RESCAN);
fragment.getActivity().finish();
- MediaLibrary.getInstance().scanMediaItems(true);
break;
case SHOW_SUBTITLES:
fragment.mSubtitles.setVisibility(View.VISIBLE);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index a524778..d0dbbf6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -297,7 +297,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
Intent i = new Intent(activity, SecondaryActivity.class);
i.putExtra("fragment", "mediaInfo");
i.putExtra("param", media.getLocation());
- startActivity(i);
+ startActivityForResult(i, SecondaryActivity.ACTIVITY_RESULT_SECONDARY);
}
return true;
case R.id.video_list_delete:
More information about the Android
mailing list