Improved layout and behaviour of itemview

This commit is contained in:
daniel oeh 2012-07-12 22:27:34 +02:00
parent bf1d4cb248
commit 1ae00a0f25
4 changed files with 34 additions and 26 deletions

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent" >
android:orientation="vertical" >
<LinearLayout <LinearLayout
android:layout_width="fill_parent" android:layout_width="fill_parent"
@ -13,29 +12,32 @@
android:id="@+id/txtvItemname" android:id="@+id/txtvItemname"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="16dp" /> android:layout_margin="8dp"
android:textSize="18dp" />
<TextView <TextView
android:id="@+id/txtvPublished" android:id="@+id/txtvPublished"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textStyle="italic" android:layout_marginBottom="8dp"
android:textColor="@color/gray" /> android:layout_marginLeft="8dp"
</LinearLayout> android:layout_marginRight="8dp"
<TextView android:textColor="@color/gray"
android:textStyle="italic" />
<View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="1dp"
android:layout_marginTop="8dp" android:layout_marginBottom="8dp"
android:background="@color/gray" android:layout_marginLeft="8dp"
android:textColor="@color/white" android:layout_marginRight="8dp"
android:textStyle="bold" android:background="@color/ics_gray" />
android:gravity="center_horizontal"
android:text="@string/description_label"/>
<FrameLayout <FrameLayout
android:id="@+id/description_fragment" android:id="@+id/description_fragment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" > android:layout_height="wrap_content" >
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>
</ScrollView>

View File

@ -43,6 +43,7 @@ public class ItemviewActivity extends SherlockFragmentActivity {
StorageUtils.checkStorageAvailability(this); StorageUtils.checkStorageAvailability(this);
manager = FeedManager.getInstance(); manager = FeedManager.getInstance();
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
getSupportActionBar().setDisplayShowTitleEnabled(false);
extractFeeditem(); extractFeeditem();
populateUI(); populateUI();
} }
@ -90,8 +91,8 @@ public class ItemviewActivity extends SherlockFragmentActivity {
FragmentManager fragmentManager = getSupportFragmentManager(); FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager FragmentTransaction fragmentTransaction = fragmentManager
.beginTransaction(); .beginTransaction();
ItemDescriptionFragment fragment = ItemDescriptionFragment ItemDescriptionFragment fragment = ItemDescriptionFragment.newInstance(
.newInstance(item); item, false);
fragmentTransaction.add(R.id.description_fragment, fragment); fragmentTransaction.add(R.id.description_fragment, fragment);
fragmentTransaction.commit(); fragmentTransaction.commit();
} }

View File

@ -702,7 +702,7 @@ public class MediaplayerActivity extends SherlockFragmentActivity implements
return activity.coverFragment; return activity.coverFragment;
case POS_DESCR: case POS_DESCR:
activity.descriptionFragment = ItemDescriptionFragment activity.descriptionFragment = ItemDescriptionFragment
.newInstance(activity.media.getItem()); .newInstance(activity.media.getItem(), true);
return activity.descriptionFragment; return activity.descriptionFragment;
default: default:
return CoverFragment.newInstance(null); return CoverFragment.newInstance(null);

View File

@ -26,19 +26,22 @@ public class ItemDescriptionFragment extends SherlockFragment {
private static final String TAG = "ItemDescriptionFragment"; private static final String TAG = "ItemDescriptionFragment";
private static final String ARG_FEED_ID = "arg.feedId"; private static final String ARG_FEED_ID = "arg.feedId";
private static final String ARG_FEEDITEM_ID = "arg.feedItemId"; private static final String ARG_FEEDITEM_ID = "arg.feedItemId";
private static final String ARG_SCROLLBAR_ENABLED = "arg.scrollbarEnabled";
private static final String WEBVIEW_STYLE = "<head><style type=\"text/css\"> * { font-family: Helvetica; line-height: 1.5em; font-size: 12pt; } a { font-style: normal; text-decoration: none; font-weight: normal; color: #00A8DF; }</style></head>"; private static final String WEBVIEW_STYLE = "<head><style type=\"text/css\"> * { font-family: Helvetica; line-height: 1.5em; font-size: 12pt; } a { font-style: normal; text-decoration: none; font-weight: normal; color: #00A8DF; }</style></head>";
private boolean scrollbarEnabled;
private WebView webvDescription; private WebView webvDescription;
private FeedItem item; private FeedItem item;
private AsyncTask<Void, Void, Void> webViewLoader; private AsyncTask<Void, Void, Void> webViewLoader;
public static ItemDescriptionFragment newInstance(FeedItem item) { public static ItemDescriptionFragment newInstance(FeedItem item, boolean scrollbarEnabled) {
ItemDescriptionFragment f = new ItemDescriptionFragment(); ItemDescriptionFragment f = new ItemDescriptionFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong(ARG_FEED_ID, item.getFeed().getId()); args.putLong(ARG_FEED_ID, item.getFeed().getId());
args.putLong(ARG_FEEDITEM_ID, item.getId()); args.putLong(ARG_FEEDITEM_ID, item.getId());
args.putBoolean(ARG_SCROLLBAR_ENABLED, scrollbarEnabled);
f.setArguments(args); f.setArguments(args);
return f; return f;
} }
@ -47,6 +50,7 @@ public class ItemDescriptionFragment extends SherlockFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
webvDescription = new WebView(getActivity()); webvDescription = new WebView(getActivity());
webvDescription.setHorizontalScrollBarEnabled(scrollbarEnabled);
return webvDescription; return webvDescription;
} }
@ -82,6 +86,7 @@ public class ItemDescriptionFragment extends SherlockFragment {
Bundle args = getArguments(); Bundle args = getArguments();
long feedId = args.getLong(ARG_FEED_ID, -1); long feedId = args.getLong(ARG_FEED_ID, -1);
long itemId = args.getLong(ARG_FEEDITEM_ID, -1); long itemId = args.getLong(ARG_FEEDITEM_ID, -1);
scrollbarEnabled = args.getBoolean(ARG_SCROLLBAR_ENABLED, true);
if (feedId != -1 && itemId != -1) { if (feedId != -1 && itemId != -1) {
Feed feed = manager.getFeed(feedId); Feed feed = manager.getFeed(feedId);
item = manager.getFeedItem(itemId, feed); item = manager.getFeedItem(itemId, feed);