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