do not show indeterminate progress bar when progress info is available

This commit is contained in:
Andrew Dolgov 2012-09-19 16:07:11 +04:00
parent edbf27ffb8
commit 675749a608
3 changed files with 16 additions and 3 deletions

View File

@ -52,6 +52,7 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
protected int m_responseCode = 0;
protected String m_responseMessage;
protected int m_apiStatusCode = 0;
protected boolean m_canUseProgress = false;
protected Context m_context;
private SharedPreferences m_prefs;
@ -182,6 +183,8 @@ public class ApiRequest extends AsyncTask<HashMap<String,String>, Integer, JsonE
int contentLength = conn.getHeaderFieldInt("Api-Content-Length", -1);
m_canUseProgress = (contentLength != -1);
while ((read = in.read(buf)) >= 0) {
response.append(buf, 0, read);
total += read;

View File

@ -17,6 +17,7 @@ public class GlobalState extends Application {
public boolean m_unreadArticlesOnly = true;
public String m_sessionId;
public int m_apiLevel;
public boolean m_canUseProgress;
public static GlobalState getInstance(){
return m_singleton;

View File

@ -132,8 +132,11 @@ public class OnlineActivity extends CommonActivity {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
if (canUseProgress()) {
requestWindowFeature(Window.FEATURE_PROGRESS);
} else {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
}
setProgressBarVisibility(false);
setProgressBarIndeterminateVisibility(false);
@ -166,6 +169,10 @@ public class OnlineActivity extends CommonActivity {
}
}
protected boolean canUseProgress() {
return GlobalState.getInstance().m_canUseProgress;
}
private void switchOffline() {
if (m_offlineModeStatus == 2) {
@ -1178,7 +1185,9 @@ public class OnlineActivity extends CommonActivity {
if (content != null) {
setSessionId(content.get("session_id").getAsString());
Log.d(TAG, "Authenticated!");
GlobalState.getInstance().m_canUseProgress = m_canUseProgress;
Log.d(TAG, "Authenticated! canUseProgress=" + m_canUseProgress);
ApiRequest req = new ApiRequest(m_context) {
protected void onPostExecute(JsonElement result) {