use activity progress indicator

This commit is contained in:
Andrew Dolgov 2012-06-20 00:44:37 +04:00
parent be0f5fe64a
commit e1afe38ef3
14 changed files with 47 additions and 92 deletions

View File

@ -11,12 +11,6 @@
android:gravity="center" android:gravity="center"
android:orientation="vertical" > android:orientation="vertical" >
<ProgressBar
android:id="@+id/loading_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/loading_message" android:id="@+id/loading_message"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -11,12 +11,6 @@
android:gravity="center" android:gravity="center"
android:orientation="vertical" > android:orientation="vertical" >
<ProgressBar
android:id="@+id/loading_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView <TextView
android:id="@+id/loading_message" android:id="@+id/loading_message"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -5,7 +5,6 @@
android:layout_height="fill_parent" > android:layout_height="fill_parent" >
<LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent"> <LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent">
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView> <TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView>
</LinearLayout> </LinearLayout>
<ListView android:id="@+id/feeds" android:layout_height="match_parent" android:layout_width="match_parent"></ListView> <ListView android:id="@+id/feeds" android:layout_height="match_parent" android:layout_width="match_parent"></ListView>

View File

@ -3,7 +3,6 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent" android:layout_width="match_parent" android:id="@+id/feeds_fragment"> android:layout_height="fill_parent" android:layout_width="match_parent" android:id="@+id/feeds_fragment">
<LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent"> <LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent">
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView> <TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView>
</LinearLayout> </LinearLayout>
<ListView android:id="@+id/feeds" android:layout_height="match_parent" android:layout_width="match_parent"></ListView> <ListView android:id="@+id/feeds" android:layout_height="match_parent" android:layout_width="match_parent"></ListView>

View File

@ -5,7 +5,6 @@
android:layout_height="fill_parent" android:id="@+id/headlines_fragment"> android:layout_height="fill_parent" android:id="@+id/headlines_fragment">
<ListView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/headlines"></ListView> <ListView android:layout_height="match_parent" android:layout_width="match_parent" android:id="@+id/headlines"></ListView>
<LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent"> <LinearLayout android:id="@+id/loading_container" android:gravity="center" android:layout_height="match_parent" android:layout_width="match_parent">
<ProgressBar android:layout_width="wrap_content" style="?android:attr/progressBarStyleLarge" android:id="@+id/loading_progress" android:layout_height="wrap_content"></ProgressBar>
<TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView> <TextView android:layout_width="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:id="@+id/loading_message" android:layout_height="wrap_content" ></TextView>
</LinearLayout> </LinearLayout>
<TextView android:id="@+id/no_headlines" <TextView android:id="@+id/no_headlines"

View File

@ -16,11 +16,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="@string/loading_message" /> android:text="@string/loading_message" />
<ProgressBar
android:id="@+id/loading_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout> </LinearLayout>
<FrameLayout <FrameLayout

View File

@ -164,7 +164,7 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
context.setAttribute(ClientContext.CREDS_PROVIDER, cp); context.setAttribute(ClientContext.CREDS_PROVIDER, cp);
} }
httpPost.setEntity(new StringEntity(requestStr, "utf-8")); httpPost.setEntity(new StringEntity(requestStr, "utf-8"));
HttpResponse execute = client.execute(httpPost, context); HttpResponse execute = client.execute(httpPost, context);

View File

@ -17,11 +17,13 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
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 android.view.Window;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
@ -120,7 +122,7 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
if (m_cats == null || m_cats.size() == 0) if (m_cats == null || m_cats.size() == 0)
refresh(false); refresh(false);
else else
view.findViewById(R.id.loading_progress).setVisibility(View.GONE); getActivity().setProgressBarIndeterminateVisibility(false);
return view; return view;
} }
@ -151,13 +153,9 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = getView().findViewById(R.id.loading_progress);
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
} }
getActivity().setProgressBarIndeterminateVisibility(showProgress);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -169,14 +167,12 @@ public class FeedCategoriesFragment extends Fragment implements OnItemClickListe
if (sessionId != null) { if (sessionId != null) {
if (!background) { getActivity().runOnUiThread(new Runnable() {
getActivity().runOnUiThread(new Runnable() { @Override
@Override public void run() {
public void run() { setLoadingStatus(R.string.blank, true);
setLoadingStatus(R.string.blank, true); }
} });
});
}
@SuppressWarnings("serial") @SuppressWarnings("serial")
HashMap<String,String> map = new HashMap<String,String>() { HashMap<String,String> map = new HashMap<String,String>() {

View File

@ -162,7 +162,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (m_feeds == null || m_feeds.size() == 0) if (m_feeds == null || m_feeds.size() == 0)
refresh(false); refresh(false);
else else
view.findViewById(R.id.loading_progress).setVisibility(View.GONE); getActivity().setProgressBarIndeterminateVisibility(false);
return view; return view;
} }
@ -219,14 +219,12 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (sessionId != null) { if (sessionId != null) {
if (!background) { getActivity().runOnUiThread(new Runnable() {
getActivity().runOnUiThread(new Runnable() { @Override
@Override public void run() {
public void run() { setLoadingStatus(R.string.blank, true);
setLoadingStatus(R.string.blank, true); }
} });
});
}
HashMap<String,String> map = new HashMap<String,String>() { HashMap<String,String> map = new HashMap<String,String>() {
{ {
@ -251,13 +249,9 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = getView().findViewById(R.id.loading_progress);
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
} }
getActivity().setProgressBarIndeterminateVisibility(showProgress);
} }
@SuppressWarnings({ "unchecked", "serial" }) @SuppressWarnings({ "unchecked", "serial" })

View File

@ -148,7 +148,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (m_feed != null && (m_articles == null || m_articles.size() == 0)) if (m_feed != null && (m_articles == null || m_articles.size() == 0))
refresh(false); refresh(false);
else else
view.findViewById(R.id.loading_progress).setVisibility(View.GONE); getActivity().setProgressBarIndeterminateVisibility(false);
return view; return view;
} }
@ -254,13 +254,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = getView().findViewById(R.id.loading_progress);
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
} }
getActivity().setProgressBarIndeterminateVisibility(showProgress);
} }
private class HeadlinesRequest extends ApiRequest { private class HeadlinesRequest extends ApiRequest {

View File

@ -48,6 +48,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText; import android.widget.EditText;
@ -451,7 +452,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
m_themeName = m_prefs.getString("theme", "THEME_DARK"); m_themeName = m_prefs.getString("theme", "THEME_DARK");
if (savedInstanceState != null) { if (savedInstanceState != null) {
@ -623,12 +626,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = findViewById(R.id.loading_progress); setProgressBarIndeterminateVisibility(showProgress);
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
} }
@Override @Override
@ -1325,6 +1324,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
private void loginSuccess() { private void loginSuccess() {
findViewById(R.id.loading_container).setVisibility(View.GONE); findViewById(R.id.loading_container).setVisibility(View.GONE);
setProgressBarIndeterminateVisibility(false);
m_isOffline = false; m_isOffline = false;
@ -1629,8 +1629,6 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
if (tv != null) { if (tv != null) {
tv.setText(R.string.login_ready); tv.setText(R.string.login_ready);
} }
findViewById(R.id.loading_progress).setVisibility(View.GONE);
initMainMenu(); initMainMenu();
} }

View File

@ -35,6 +35,7 @@ import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.AnimationUtils; import android.view.animation.AnimationUtils;
import android.widget.AdapterView.AdapterContextMenuInfo; import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.EditText; import android.widget.EditText;
@ -119,6 +120,8 @@ public class OfflineActivity extends FragmentActivity implements
} }
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
NotificationManager nmgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationManager nmgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nmgr.cancel(OfflineDownloadService.NOTIFY_DOWNLOADING); nmgr.cancel(OfflineDownloadService.NOTIFY_DOWNLOADING);
@ -205,19 +208,15 @@ public class OfflineActivity extends FragmentActivity implements
return m_activeFeedId; return m_activeFeedId;
} }
private void setLoadingStatus(int status, boolean showProgress) { /* private void setLoadingStatus(int status, boolean showProgress) {
TextView tv = (TextView) findViewById(R.id.loading_message); TextView tv = (TextView) findViewById(R.id.loading_message);
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = findViewById(R.id.loading_progress); setProgressBarIndeterminateVisibility(showProgress);
} */
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
}
@Override @Override
public void onSaveInstanceState(Bundle out) { public void onSaveInstanceState(Bundle out) {

View File

@ -153,21 +153,17 @@ public class OfflineFeedsFragment extends Fragment implements OnItemClickListene
} }
} }
public void setLoadingStatus(int status, boolean showProgress) { /* public void setLoadingStatus(int status, boolean showProgress) {
if (getView() != null) { if (getView() != null) {
TextView tv = (TextView)getView().findViewById(R.id.loading_message); TextView tv = (TextView)getView().findViewById(R.id.loading_message);
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = getView().findViewById(R.id.loading_progress);
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
} }
}
getActivity().setProgressBarIndeterminateVisibility(showProgress);
} */
private class FeedListAdapter extends SimpleCursorAdapter { private class FeedListAdapter extends SimpleCursorAdapter {

View File

@ -151,7 +151,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
list.setEmptyView(view.findViewById(R.id.no_headlines)); list.setEmptyView(view.findViewById(R.id.no_headlines));
registerForContextMenu(list); registerForContextMenu(list);
view.findViewById(R.id.loading_progress).setVisibility(View.GONE); getActivity().setProgressBarIndeterminateVisibility(false);
return view; return view;
} }
@ -213,21 +213,17 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis
out.putCharSequence("searchQuery", m_searchQuery); out.putCharSequence("searchQuery", m_searchQuery);
} }
public void setLoadingStatus(int status, boolean showProgress) { /* public void setLoadingStatus(int status, boolean showProgress) {
if (getView() != null) { if (getView() != null) {
TextView tv = (TextView)getView().findViewById(R.id.loading_message); TextView tv = (TextView)getView().findViewById(R.id.loading_message);
if (tv != null) { if (tv != null) {
tv.setText(status); tv.setText(status);
} }
View pb = getView().findViewById(R.id.loading_progress);
if (pb != null) {
pb.setVisibility(showProgress ? View.VISIBLE : View.GONE);
}
} }
}
getActivity().setProgressBarIndeterminateVisibility(showProgress);
} */
private class ArticleListAdapter extends SimpleCursorAdapter { private class ArticleListAdapter extends SimpleCursorAdapter {
public ArticleListAdapter(Context context, int layout, Cursor c, public ArticleListAdapter(Context context, int layout, Cursor c,