do not show indeterminate progress bar when progress info is available
This commit is contained in:
parent
edbf27ffb8
commit
675749a608
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -132,8 +132,11 @@ public class OnlineActivity extends CommonActivity {
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
requestWindowFeature(Window.FEATURE_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) {
|
||||
|
Loading…
Reference in New Issue
Block a user