Implemented DownloadLog activity
This commit is contained in:
parent
13f1e4674e
commit
20ca5f78cd
|
@ -34,6 +34,7 @@
|
|||
|
||||
<service android:enabled="true" android:name="de.podfetcher.service.DownloadService" />
|
||||
<service android:enabled="true" android:name="de.podfetcher.service.PlaybackService" />
|
||||
<activity android:name=".activity.PreferenceActivity"></activity>
|
||||
<activity android:name=".activity.PreferenceActivity"></activity>
|
||||
<activity android:name=".activity.DownloadLogActivity"></activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
|
@ -42,4 +42,5 @@
|
|||
<string name="version_pref">Version</string>
|
||||
<string name="other_pref">Other</string>
|
||||
<string name="about_pref">About</string>
|
||||
<string name="show_download_log">Show Log</string>
|
||||
</resources>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.podfetcher.activity;
|
||||
|
||||
|
||||
import de.podfetcher.R;
|
||||
import de.podfetcher.storage.DownloadRequester;
|
||||
import de.podfetcher.adapter.DownloadlistAdapter;
|
||||
import de.podfetcher.service.DownloadObserver;
|
||||
|
@ -8,13 +9,16 @@ import de.podfetcher.service.DownloadStatus;
|
|||
import de.podfetcher.feed.FeedMedia;
|
||||
import de.podfetcher.feed.FeedFile;
|
||||
import com.actionbarsherlock.app.SherlockListActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
public class DownloadActivity extends SherlockListActivity {
|
||||
private static final String TAG = "DownloadActivity";
|
||||
|
||||
private static final int MENU_SHOW_LOG = 0;
|
||||
private DownloadlistAdapter dla;
|
||||
private DownloadRequester requester;
|
||||
|
||||
|
@ -47,4 +51,20 @@ public class DownloadActivity extends SherlockListActivity {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(Menu.NONE, MENU_SHOW_LOG, Menu.NONE, R.string.show_download_log)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case MENU_SHOW_LOG:
|
||||
startActivity(new Intent(this, DownloadLogActivity.class));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package de.podfetcher.activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import de.podfetcher.R;
|
||||
import de.podfetcher.adapter.DownloadLogAdapter;
|
||||
import de.podfetcher.feed.FeedManager;
|
||||
|
||||
public class DownloadLogActivity extends SherlockListActivity {
|
||||
private static final String TAG = "DownloadLogActivity";
|
||||
|
||||
DownloadLogAdapter dla;
|
||||
FeedManager manager;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
manager = FeedManager.getInstance();
|
||||
|
||||
dla = new DownloadLogAdapter(this, 0, manager.getDownloadLog());
|
||||
setListAdapter(dla);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -21,9 +21,9 @@ import de.podfetcher.service.DownloadStatus;
|
|||
/** Displays a list of DownloadStatus entries. */
|
||||
public class DownloadLogAdapter extends ArrayAdapter<DownloadStatus> {
|
||||
|
||||
public DownloadLogAdapter(Context context, int resource,
|
||||
public DownloadLogAdapter(Context context,
|
||||
int textViewResourceId, List<DownloadStatus> objects) {
|
||||
super(context, resource, textViewResourceId, objects);
|
||||
super(context, textViewResourceId, objects);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,6 +61,7 @@ public class DownloadLogAdapter extends ArrayAdapter<DownloadStatus> {
|
|||
if (status.isSuccessful()) {
|
||||
holder.successful.setTextColor(Color.parseColor("green"));
|
||||
holder.successful.setText("Download succeeded");
|
||||
holder.reason.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.successful.setTextColor(Color.parseColor("red"));
|
||||
holder.successful.setText("Download failed");
|
||||
|
|
|
@ -273,6 +273,7 @@ public class FeedManager {
|
|||
feeds.clear();
|
||||
categories.clear();
|
||||
extractFeedlistFromCursor(context);
|
||||
extractDownloadLogFromCursor(context);
|
||||
}
|
||||
|
||||
private void extractFeedlistFromCursor(Context context) {
|
||||
|
@ -392,4 +393,8 @@ public class FeedManager {
|
|||
return unreadItems;
|
||||
}
|
||||
|
||||
public ArrayList<DownloadStatus> getDownloadLog() {
|
||||
return downloadLog;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue