[Android] Use the same layout for the game list and the folder browser. Since the UI layouts are exactly the same.
This commit is contained in:
parent
64b83a18b2
commit
93ed4adb02
|
@ -2,10 +2,10 @@
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
android:padding="3dip">
|
android:padding="3dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/ImageIcon"
|
android:id="@+id/ListItemIcon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
|
|
||||||
|
@ -14,11 +14,11 @@
|
||||||
android:layout_marginRight="6dip"/>
|
android:layout_marginRight="6dip"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/FolderSubTitle"
|
android:id="@+id/ListItemSubTitle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="26dip"
|
android:layout_height="26dip"
|
||||||
|
|
||||||
android:layout_toRightOf="@id/ImageIcon"
|
android:layout_toRightOf="@id/ListItemIcon"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
|
||||||
|
@ -26,14 +26,14 @@
|
||||||
android:ellipsize="marquee"/>
|
android:ellipsize="marquee"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/FolderTitle"
|
android:id="@+id/ListItemTitle"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
||||||
android:layout_toRightOf="@id/ImageIcon"
|
android:layout_toRightOf="@id/ListItemIcon"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_above="@id/FolderSubTitle"
|
android:layout_above="@id/ListItemSubTitle"
|
||||||
android:layout_alignWithParentIfMissing="true"
|
android:layout_alignWithParentIfMissing="true"
|
||||||
|
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
|
@ -1,43 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
|
||||||
android:padding="3dp" >
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/GameItemIcon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="fill_parent"
|
|
||||||
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_marginRight="6dip" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/GameItemSubText"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="26dip"
|
|
||||||
|
|
||||||
android:layout_toRightOf="@id/GameItemIcon"
|
|
||||||
android:layout_alignParentBottom="true"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/GameItemTitle"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
|
|
||||||
android:layout_toRightOf="@id/GameItemIcon"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentTop="true"
|
|
||||||
android:layout_above="@id/GameItemSubText"
|
|
||||||
android:layout_alignWithParentIfMissing="true"
|
|
||||||
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public final class FolderBrowser extends Fragment
|
||||||
if (!currDir.getPath().equalsIgnoreCase("/"))
|
if (!currDir.getPath().equalsIgnoreCase("/"))
|
||||||
dir.add(0, new FolderBrowserItem("..", getString(R.string.parent_directory), currDir.getParent()));
|
dir.add(0, new FolderBrowserItem("..", getString(R.string.parent_directory), currDir.getParent()));
|
||||||
|
|
||||||
adapter = new FolderBrowserAdapter(m_activity, R.layout.folderbrowser, dir);
|
adapter = new FolderBrowserAdapter(m_activity, R.layout.gamelist_folderbrowser_list, dir);
|
||||||
mDrawerList = (ListView) rootView.findViewById(R.id.gamelist);
|
mDrawerList = (ListView) rootView.findViewById(R.id.gamelist);
|
||||||
mDrawerList.setAdapter(adapter);
|
mDrawerList.setAdapter(adapter);
|
||||||
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
|
mDrawerList.setOnItemClickListener(mMenuItemClickListener);
|
||||||
|
|
|
@ -57,37 +57,37 @@ public final class FolderBrowserAdapter extends ArrayAdapter<FolderBrowserItem>
|
||||||
final FolderBrowserItem item = items.get(position);
|
final FolderBrowserItem item = items.get(position);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
ImageView iconView = (ImageView) v.findViewById(R.id.ImageIcon);
|
ImageView icon = (ImageView) v.findViewById(R.id.ListItemIcon);
|
||||||
TextView mainText = (TextView) v.findViewById(R.id.FolderTitle);
|
TextView title = (TextView) v.findViewById(R.id.ListItemTitle);
|
||||||
TextView subtitleText = (TextView) v.findViewById(R.id.FolderSubTitle);
|
TextView subtitle = (TextView) v.findViewById(R.id.ListItemSubTitle);
|
||||||
|
|
||||||
if(mainText != null)
|
if(title != null)
|
||||||
{
|
{
|
||||||
mainText.setText(item.getName());
|
title.setText(item.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(subtitleText != null)
|
if(subtitle != null)
|
||||||
{
|
{
|
||||||
// Remove the subtitle for all folders, except for the parent directory folder.
|
// Remove the subtitle for all folders, except for the parent directory folder.
|
||||||
if (item.isDirectory() && !item.getSubtitle().equals(c.getResources().getString(R.string.parent_directory)))
|
if (item.isDirectory() && !item.getSubtitle().equals(c.getResources().getString(R.string.parent_directory)))
|
||||||
{
|
{
|
||||||
subtitleText.setVisibility(View.GONE);
|
subtitle.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
subtitleText.setText(item.getSubtitle());
|
subtitle.setText(item.getSubtitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconView != null)
|
if (icon != null)
|
||||||
{
|
{
|
||||||
if (item.isDirectory())
|
if (item.isDirectory())
|
||||||
{
|
{
|
||||||
iconView.setImageResource(R.drawable.ic_menu_folder);
|
icon.setImageResource(R.drawable.ic_menu_folder);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iconView.setImageResource(R.drawable.ic_menu_file);
|
icon.setImageResource(R.drawable.ic_menu_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,9 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem>
|
||||||
final GameListItem item = items.get(position);
|
final GameListItem item = items.get(position);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
TextView title = (TextView) v.findViewById(R.id.GameItemTitle);
|
TextView title = (TextView) v.findViewById(R.id.ListItemTitle);
|
||||||
TextView subtitle = (TextView) v.findViewById(R.id.GameItemSubText);
|
TextView subtitle = (TextView) v.findViewById(R.id.ListItemSubTitle);
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.GameItemIcon);
|
ImageView icon = (ImageView) v.findViewById(R.id.ListItemIcon);
|
||||||
|
|
||||||
if (title != null)
|
if (title != null)
|
||||||
title.setText(item.getName());
|
title.setText(item.getName());
|
||||||
|
|
|
@ -98,7 +98,7 @@ public final class GameListFragment extends Fragment
|
||||||
}
|
}
|
||||||
Collections.sort(fls);
|
Collections.sort(fls);
|
||||||
|
|
||||||
mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_layout, fls);
|
mGameAdapter = new GameListAdapter(mMe, R.layout.gamelist_folderbrowser_list, fls);
|
||||||
mMainList.setAdapter(mGameAdapter);
|
mMainList.setAdapter(mGameAdapter);
|
||||||
|
|
||||||
if (fls.isEmpty())
|
if (fls.isEmpty())
|
||||||
|
|
Loading…
Reference in New Issue