Removed unused code from Itemview

This commit is contained in:
daniel oeh 2012-06-22 14:30:31 +02:00
parent 426df3f49f
commit 55f33875a4
2 changed files with 29 additions and 128 deletions

View File

@ -1,56 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout 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"> android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent" <LinearLayout
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:orientation="horizontal"> android:layout_height="wrap_content"
<ImageView android:orientation="vertical" >
android:id="@+id/imgvFeedimage"
android:layout_height="90dip" <TextView
android:layout_width="90dip" android:id="@+id/txtvItemname"
android:layout_alignParentLeft="true"/> android:layout_width="fill_parent"
<LinearLayout android:layout_height="wrap_content" />
android:layout_width="wrap_content"
android:layout_height="fill_parent" <TextView
android:orientation="vertical"> android:id="@+id/txtvPublished"
<TextView android:layout_width="fill_parent"
android:id="@+id/txtvItemname" android:layout_height="wrap_content" />
android:layout_width="fill_parent" </LinearLayout>
android:layout_height="wrap_content"/>
<TextView <WebView
android:id="@+id/txtvPublished" android:id="@+id/webvDescription"
android:layout_width="fill_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:orientation="horizontal">
<Button
android:id="@+id/butPlay"
android:text="@string/play_label"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/butDownload"
android:text="@string/download_label"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/butRemove"
android:text="@string/remove_label"
android:layout_weight="1"
android:layout_width="0px"
android:layout_height="wrap_content"/>
</LinearLayout>
<WebView
android:id="@+id/webvDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout> </LinearLayout>

View File

@ -35,16 +35,11 @@ public class ItemviewActivity extends SherlockActivity {
private static final String TAG = "ItemviewActivity"; private static final String TAG = "ItemviewActivity";
private FeedManager manager; private FeedManager manager;
private DownloadRequester requester;
private FeedItem item; private FeedItem item;
// Widgets // Widgets
private ImageView imgvImage;
private TextView txtvTitle; private TextView txtvTitle;
private TextView txtvPublished; private TextView txtvPublished;
private Button butPlay;
private Button butDownload;
private Button butRemove;
private WebView webvDescription; private WebView webvDescription;
@Override @Override
@ -54,39 +49,12 @@ public class ItemviewActivity extends SherlockActivity {
extractFeeditem(); extractFeeditem();
populateUI(); populateUI();
butDownload.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
requester = DownloadRequester.getInstance();
requester.downloadMedia(v.getContext(), item.getMedia());
//getDownloadStatus();
}
});
butPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//manager.playMedia(v.getContext(), item.getMedia());
}
});
butRemove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (manager.deleteFeedMedia(v.getContext(), item.getMedia())) {
//setNotDownloadedState();
}
}
});
} }
@Override @Override
public void onStop() { public void onStop() {
super.onStop(); super.onStop();
Log.d(TAG, "Stopping Activity"); Log.d(TAG, "Stopping Activity");
downloadObserver.cancel(true);
} }
/** Extracts FeedItem object the activity is supposed to display */ /** Extracts FeedItem object the activity is supposed to display */
@ -108,10 +76,6 @@ public class ItemviewActivity extends SherlockActivity {
setContentView(R.layout.feeditemview); setContentView(R.layout.feeditemview);
txtvTitle = (TextView) findViewById(R.id.txtvItemname); txtvTitle = (TextView) findViewById(R.id.txtvItemname);
txtvPublished = (TextView) findViewById(R.id.txtvPublished); txtvPublished = (TextView) findViewById(R.id.txtvPublished);
imgvImage = (ImageView) findViewById(R.id.imgvFeedimage);
butPlay = (Button) findViewById(R.id.butPlay);
butDownload = (Button) findViewById(R.id.butDownload);
butRemove = (Button) findViewById(R.id.butRemove);
webvDescription = (WebView) findViewById(R.id.webvDescription); webvDescription = (WebView) findViewById(R.id.webvDescription);
setTitle(item.getFeed().getTitle()); setTitle(item.getFeed().getTitle());
@ -119,26 +83,10 @@ public class ItemviewActivity extends SherlockActivity {
.getTime(), System.currentTimeMillis(), DateFormat.MEDIUM, .getTime(), System.currentTimeMillis(), DateFormat.MEDIUM,
DateFormat.SHORT)); DateFormat.SHORT));
txtvTitle.setText(item.getTitle()); txtvTitle.setText(item.getTitle());
if (item.getFeed().getImage() != null) {
imgvImage
.setImageBitmap(item.getFeed().getImage().getImageBitmap());
}
webvDescription.loadData(item.getDescription(), "text/html", null); webvDescription.loadData(item.getDescription(), "text/html", null);
} }
private void getDownloadStatus(Menu menu) { /* TODO implement
FeedMedia media = item.getMedia();
if (media.getFile_url() == null) {
setNotDownloadedState(menu);
} else if (media.isDownloaded()) {
setDownloadedState(menu);
} else {
// observe
setDownloadingState(menu);
//downloadObserver.execute(media);
}
}
final DownloadObserver downloadObserver = new DownloadObserver(this) { final DownloadObserver downloadObserver = new DownloadObserver(this) {
@Override @Override
protected void onProgressUpdate( protected void onProgressUpdate(
@ -156,7 +104,7 @@ public class ItemviewActivity extends SherlockActivity {
} }
} }
}; };
*/
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
return FeedItemMenuHandler.onCreateMenu(new MenuInflater(this), menu); return FeedItemMenuHandler.onCreateMenu(new MenuInflater(this), menu);
@ -175,23 +123,4 @@ public class ItemviewActivity extends SherlockActivity {
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
return FeedItemMenuHandler.onPrepareMenu(menu, item); return FeedItemMenuHandler.onPrepareMenu(menu, item);
} }
private void setDownloadingState(Menu menu) {
butDownload.setEnabled(false);
butPlay.setEnabled(false);
butRemove.setEnabled(false);
}
private void setDownloadedState(Menu menu) {
butDownload.setEnabled(false);
butPlay.setEnabled(true);
butRemove.setEnabled(true);
}
private void setNotDownloadedState(Menu menu) {
butPlay.setEnabled(false);
butDownload.setEnabled(true);
butRemove.setEnabled(false);
}
} }