Commit 090f40cd authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Fix context menu for regular browser

parent 8328c8ab
......@@ -61,9 +61,11 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
MediaDatabase mDbManager;
LinkedList<String> mMediaDirsLocation;
List<String> mCustomDirsLocation;
String mEmptyDirectoryString;
public BaseBrowserAdapter(BaseBrowserFragment fragment){
this.fragment = fragment;
mEmptyDirectoryString = fragment.getString(R.string.directory_empty);
}
@Override
......@@ -98,7 +100,7 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
final MediaWrapper media = (MediaWrapper) getItem(position);
boolean hasContextMenu = (media.getType() == MediaWrapper.TYPE_AUDIO ||
media.getType() == MediaWrapper.TYPE_VIDEO ||
(media.getType() == MediaWrapper.TYPE_DIR && Util.canWrite(media.getLocation())));
(media.getType() == MediaWrapper.TYPE_DIR && !TextUtils.equals(media.getDescription(), mEmptyDirectoryString)));
vh.checkBox.setVisibility(View.GONE);
vh.title.setText(media.getTitle());
if (!TextUtils.isEmpty(media.getDescription())) {
......@@ -262,7 +264,6 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
mMediaDirsLocation.add(dir.getPath());
}
mCustomDirsLocation = Arrays.asList(CustomDirectories.getCustomDirectories());
mMediaDirsLocation.addAll(mCustomDirsLocation);
}
public void addAll(ArrayList<MediaWrapper> mediaList){
......
......@@ -172,16 +172,6 @@ public class FileBrowserFragment extends BaseBrowserFragment {
mAlertDialog = builder.show();
}
protected void setContextMenu(MenuInflater inflater, Menu menu, int position) {
if (mRoot) {
BaseBrowserAdapter.Storage storage = (BaseBrowserAdapter.Storage) mAdapter.getItem(position);
boolean isCustom = CustomDirectories.contains(storage.getPath());
if (isCustom)
inflater.inflate(R.menu.directory_custom_dir, menu);
} else
super.setContextMenu(inflater, menu, position);
}
@Override
protected boolean handleContextItemSelected(MenuItem item, int position) {
if (mRoot) {
......
......@@ -28,6 +28,8 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
......@@ -36,6 +38,7 @@ import org.videolan.libvlc.Media;
import org.videolan.vlc.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.CustomDirectories;
public class StorageBrowserFragment extends FileBrowserFragment implements View.OnClickListener {
......@@ -46,7 +49,6 @@ public class StorageBrowserFragment extends FileBrowserFragment implements View.
public StorageBrowserFragment(){
mHandler = new BrowserFragmentHandler(this);
mAdapter = new StorageBrowserAdapter(this);
ROOT = AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY;
}
......@@ -58,6 +60,7 @@ public class StorageBrowserFragment extends FileBrowserFragment implements View.
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
mAdapter = new StorageBrowserAdapter(this);
if (bundle == null)
bundle = getArguments();
if (bundle != null){
......@@ -134,6 +137,16 @@ public class StorageBrowserFragment extends FileBrowserFragment implements View.
ft.commit();
}
protected void setContextMenu(MenuInflater inflater, Menu menu, int position) {
if (mRoot) {
BaseBrowserAdapter.Storage storage = (BaseBrowserAdapter.Storage) mAdapter.getItem(position);
boolean isCustom = CustomDirectories.contains(storage.getPath());
if (isCustom)
inflater.inflate(R.menu.directory_custom_dir, menu);
} else
super.setContextMenu(inflater, menu, position);
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.fab_add_custom_dir){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment