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