Permalink
Browse files

Progress indicator is shown on the title bar

  • Loading branch information...
1 parent 6fe7c8a commit 821613ccca2e4814def3ea024b6ee307a57c966c @tindandelion committed Oct 4, 2012
@@ -25,14 +25,18 @@ public static Intent createIntent(Context context, String title, String showName
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.podcast_screen);
- StartParams params = StartParams.fromIntent(getIntent());
- setTitle(params.title());
+ }
+ @Override
+ protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
progress = ProgressIndicator.create(this);
- PodcastListAdapter listAdapter = new PodcastListAdapter(this);
- initListView(listAdapter);
- attachToLoader(params.showName(), listAdapter);
+ StartParams params = StartParams.fromIntent(getIntent());
+ setTitle(params.title());
+ PodcastListAdapter pa = new PodcastListAdapter(this);
+ initListView(pa);
+ attachToLoader(params.showName(), pa, progress);
}
private void initListView(PodcastListAdapter adapter) {
@@ -51,10 +55,10 @@ private PodcastSelectionHandler createSelectionHandler() {
app.createDownloader(), new DialogErrorDisplayer(this));
}
- protected void attachToLoader(String showName, PodcastListAdapter listAdapter) {
+ protected void attachToLoader(String show, PodcastListAdapter la, ProgressIndicator pi) {
PodcastsApp app = PodcastsApp.getInstance();
- loader = app.createLoaderForShow(showName);
- loader.attach(progress, listAdapter);
+ loader = app.createLoaderForShow(show);
+ loader.attach(pi, la);
}
@Override
@@ -81,7 +85,7 @@ protected void onDestroy() {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.podcast_list, menu);
- progress.setRefreshItem(menu.findItem(R.id.refresh));
+ progress.setActionItem(menu.findItem(R.id.refresh));
return super.onCreateOptionsMenu(menu);
}
@@ -1,9 +1,7 @@
package org.dandelion.radiot.podcasts.ui;
import android.app.Activity;
-import android.app.ProgressDialog;
import android.content.Context;
-import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
@@ -18,58 +16,50 @@ public ProgressIndicator(Context context) {
public static ProgressIndicator create(Activity activity) {
if (ActivityHelper.supportsActionBar()) {
- return new ActionBarProgressIndicator(activity);
+ return new ActionItemIndicator(activity);
} else {
- return new DialogProgressIndicator(activity);
+ return new SimpleProgressIndicator(activity);
}
}
- public abstract void setRefreshItem(MenuItem item);
+ public abstract void setActionItem(MenuItem item);
- private static class DialogProgressIndicator extends ProgressIndicator {
- private Activity activity;
- private ProgressDialog progress;
+ private static class SimpleProgressIndicator extends ProgressIndicator {
+ private View indicator;
- DialogProgressIndicator(Activity activity) {
+ public SimpleProgressIndicator(Activity activity) {
super(activity);
- this.activity = activity;
+ this.indicator = activity.findViewById(R.id.titlebar_progress);
}
@Override
- public void onStarted() {
- progress = ProgressDialog.show(activity, null,
- activity.getString(R.string.loading_message), true, true,
- new DialogInterface.OnCancelListener() {
- public void onCancel(DialogInterface dialog) {
- activity.finish();
- }
- });
+ public void setActionItem(MenuItem item) {
}
@Override
- public void onFinished() {
- progress.dismiss();
+ public void onStarted() {
+ indicator.setVisibility(View.VISIBLE);
}
@Override
- public void setRefreshItem(MenuItem item) {
-
+ public void onFinished() {
+ indicator.setVisibility(View.INVISIBLE);
}
}
- private static class ActionBarProgressIndicator extends ProgressIndicator {
+ private static class ActionItemIndicator extends ProgressIndicator {
private boolean inProgress = false;
private MenuItem refreshItem;
private final View progressView;
- public ActionBarProgressIndicator(Activity context) {
+ public ActionItemIndicator(Activity context) {
super(context);
LayoutInflater inflater = context.getLayoutInflater();
progressView = inflater.inflate(R.layout.progress_view, null);
}
@Override
- public void setRefreshItem(MenuItem item) {
+ public void setActionItem(MenuItem item) {
this.refreshItem = item;
updateItem();
}

0 comments on commit 821613c

Please sign in to comment.