Commit d37c8ec0 authored by Ludovic Fauvet's avatar Ludovic Fauvet

VideoGridFragment: Determine if we need to show the items in list or grid

parent 03b4e833
......@@ -9,7 +9,6 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="auto_fit"
android:columnWidth="150dip"
android:fastScrollEnabled="true"
android:horizontalSpacing="20dp"
android:verticalSpacing="20dp"
......
......@@ -37,6 +37,7 @@ import org.videolan.vlc.gui.CommonDialogs;
import org.videolan.vlc.gui.PreferencesActivity;
import org.videolan.vlc.interfaces.ISortable;
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
......@@ -88,6 +89,7 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
}
@Override
@TargetApi(11)
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.video_grid, container, false);
......@@ -96,6 +98,23 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
mLayoutFlipperLoading = (LinearLayout) v.findViewById(R.id.layout_flipper_loading);
mTextViewNomedia = (TextView) v.findViewById(R.id.textview_nomedia);
/* Determine if we need to show items in list or grid */
int columns = 1;
GridView gv = (GridView)v.findViewById(android.R.id.list);
if (android.os.Build.VERSION.SDK_INT >= 11)
columns = gv.getNumColumns();
if (columns == 1) {
gv.setNumColumns(1);
gv.setStretchMode(GridView.STRETCH_COLUMN_WIDTH);
gv.setHorizontalSpacing(0);
gv.setVerticalSpacing(0);
mVideoAdapter.setListMode(true);
} else {
float density = getResources().getDisplayMetrics().density;
gv.setColumnWidth((int) (150 * density + 0.5f));
}
return v;
}
......
......@@ -47,6 +47,7 @@ public class VideoListAdapter extends ArrayAdapter<Media>
private int mSortDirection = 1;
private int mSortBy = SORT_BY_TITLE;
private String mLastMRL;
private boolean mListMode = false;
public VideoListAdapter(Context context) {
super(context, 0);
......@@ -128,7 +129,10 @@ public class VideoListAdapter extends ArrayAdapter<Media>
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.video_grid_item, parent, false);
if (!mListMode)
v = inflater.inflate(R.layout.video_grid_item, parent, false);
else
v = inflater.inflate(R.layout.video_list_item, parent, false);
holder = new ViewHolder();
holder.layout = v.findViewById(R.id.layout_item);
holder.thumbnail = (ImageView) v.findViewById(R.id.ml_item_thumbnail);
......@@ -187,4 +191,8 @@ public class VideoListAdapter extends ArrayAdapter<Media>
TextView subtitle;
ImageView more;
}
public void setListMode(boolean value) {
mListMode = value;
}
}
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