mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-24 16:02:13 +01:00
Added intermediate progressbar to main Activity
This commit is contained in:
parent
a2e0c6eecc
commit
703972e3c0
@ -55,14 +55,5 @@
|
||||
android:textSize="20dp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imgvRefreshing"
|
||||
android:src="@drawable/navigation_refresh"
|
||||
android:layout_width="55dip"
|
||||
android:layout_height="55dip"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="gone" />
|
||||
|
||||
</RelativeLayout>
|
@ -1,13 +1,18 @@
|
||||
package de.podfetcher.activity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import com.actionbarsherlock.view.Window;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.app.ActionBar.Tab;
|
||||
@ -22,6 +27,8 @@ import de.podfetcher.fragment.ItemlistFragment;
|
||||
import de.podfetcher.fragment.FeedlistFragment;
|
||||
import de.podfetcher.fragment.QueueFragment;
|
||||
import de.podfetcher.fragment.UnreadItemlistFragment;
|
||||
import de.podfetcher.service.DownloadService;
|
||||
import de.podfetcher.storage.DownloadRequester;
|
||||
|
||||
public class PodfetcherActivity extends SherlockFragmentActivity {
|
||||
private static final String TAG = "PodfetcherActivity";
|
||||
@ -36,6 +43,7 @@ public class PodfetcherActivity extends SherlockFragmentActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
manager = FeedManager.getInstance();
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
setContentView(R.layout.main);
|
||||
// Set up tabs
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
@ -71,6 +79,38 @@ public class PodfetcherActivity extends SherlockFragmentActivity {
|
||||
actionBar.addTab(tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
unregisterReceiver(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
updateProgressBarVisibility();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||
registerReceiver(contentUpdate, filter);
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
updateProgressBarVisibility();
|
||||
}
|
||||
};
|
||||
|
||||
private void updateProgressBarVisibility() {
|
||||
if (DownloadService.isRunning && DownloadRequester.getInstance().isDownloadingFeeds()) {
|
||||
setSupportProgressBarIndeterminateVisibility(true);
|
||||
} else {
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch(item.getItemId()) {
|
||||
|
@ -23,7 +23,7 @@ import android.graphics.Color;
|
||||
|
||||
public class FeedlistAdapter extends ArrayAdapter<Feed> {
|
||||
private static final String TAG = "FeedlistAdapter";
|
||||
|
||||
|
||||
public FeedlistAdapter(Context context, int textViewResourceId,
|
||||
List<Feed> objects) {
|
||||
super(context, textViewResourceId, objects);
|
||||
@ -43,39 +43,34 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> {
|
||||
convertView = inflater.inflate(R.layout.feedlist_item, null);
|
||||
holder.title = (TextView) convertView
|
||||
.findViewById(R.id.txtvFeedname);
|
||||
|
||||
holder.newEpisodes = (TextView) convertView.findViewById(R.id.txtvNewEps);
|
||||
|
||||
holder.newEpisodes = (TextView) convertView
|
||||
.findViewById(R.id.txtvNewEps);
|
||||
holder.image = (ImageView) convertView
|
||||
.findViewById(R.id.imgvFeedimage);
|
||||
holder.lastUpdate = (TextView) convertView
|
||||
.findViewById(R.id.txtvLastUpdate);
|
||||
holder.numberOfEpisodes = (TextView) convertView.findViewById(R.id.txtvNumEpisodes);
|
||||
holder.numberOfEpisodes = (TextView) convertView
|
||||
.findViewById(R.id.txtvNumEpisodes);
|
||||
convertView.setTag(holder);
|
||||
holder.refreshing = (ImageView) convertView.findViewById(R.id.imgvRefreshing);
|
||||
} else {
|
||||
holder = (Holder) convertView.getTag();
|
||||
}
|
||||
|
||||
holder.title.setText(feed.getTitle());
|
||||
holder.lastUpdate.setText("Last Update: " + DateUtils.formatSameDayTime(feed
|
||||
.getLastUpdate().getTime(), System.currentTimeMillis(),
|
||||
DateFormat.SHORT, DateFormat.SHORT));
|
||||
holder.lastUpdate.setText("Last Update: "
|
||||
+ DateUtils.formatSameDayTime(feed.getLastUpdate().getTime(),
|
||||
System.currentTimeMillis(), DateFormat.SHORT,
|
||||
DateFormat.SHORT));
|
||||
holder.numberOfEpisodes.setText(feed.getItems().size() + " Episodes");
|
||||
|
||||
if (DownloadRequester.getInstance().downloads.contains(feed)) {
|
||||
Log.d(TAG, "Feed is downloading");
|
||||
holder.newEpisodes.setVisibility(View.GONE);
|
||||
holder.refreshing.setVisibility(View.VISIBLE);
|
||||
int newItems = feed.getNumOfNewItems();
|
||||
if (newItems > 0) {
|
||||
holder.newEpisodes.setText(Integer.toString(newItems));
|
||||
holder.newEpisodes.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
int newItems = feed.getNumOfNewItems();
|
||||
if (newItems > 0) {
|
||||
holder.newEpisodes.setText(Integer.toString(newItems));
|
||||
holder.newEpisodes.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.newEpisodes.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
holder.newEpisodes.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
|
||||
if (feed.getImage() != null) {
|
||||
holder.image.setImageBitmap(feed.getImage().getImageBitmap()); // TODO
|
||||
// select
|
||||
@ -96,7 +91,6 @@ public class FeedlistAdapter extends ArrayAdapter<Feed> {
|
||||
TextView numberOfEpisodes;
|
||||
TextView newEpisodes;
|
||||
ImageView image;
|
||||
ImageView refreshing;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,8 @@ public class DownloadService extends Service {
|
||||
private DownloadManager downloadManager;
|
||||
|
||||
private volatile boolean shutdownInitiated = false;
|
||||
/** True if service is running. */
|
||||
public static boolean isRunning = false;
|
||||
|
||||
private final IBinder mBinder = new LocalBinder();
|
||||
|
||||
@ -82,6 +84,7 @@ public class DownloadService extends Service {
|
||||
@Override
|
||||
public void onCreate() {
|
||||
Log.d(TAG, "Service started");
|
||||
isRunning = true;
|
||||
registerReceiver(downloadReceiver, createIntentFilter());
|
||||
syncExecutor = Executors.newSingleThreadExecutor();
|
||||
manager = FeedManager.getInstance();
|
||||
@ -99,6 +102,7 @@ public class DownloadService extends Service {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
Log.d(TAG, "Service shutting down");
|
||||
isRunning = false;
|
||||
sendBroadcast(new Intent(ACTION_FEED_SYNC_COMPLETED));
|
||||
mediaplayer.release();
|
||||
unregisterReceiver(downloadReceiver);
|
||||
|
@ -133,6 +133,16 @@ public class DownloadRequester {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Returns true if there is at least one Feed in the downloads queue. */
|
||||
public boolean isDownloadingFeeds() {
|
||||
for (FeedFile f : downloads) {
|
||||
if (f.getClass() == Feed.class) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Remove an object from the downloads-list of the requester. */
|
||||
public void removeDownload(FeedFile f) {
|
||||
|
Loading…
Reference in New Issue
Block a user