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 int m_responseCode = 0;
|
||||||
protected String m_responseMessage;
|
protected String m_responseMessage;
|
||||||
protected int m_apiStatusCode = 0;
|
protected int m_apiStatusCode = 0;
|
||||||
|
protected boolean m_canUseProgress = false;
|
||||||
protected Context m_context;
|
protected Context m_context;
|
||||||
private SharedPreferences m_prefs;
|
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);
|
int contentLength = conn.getHeaderFieldInt("Api-Content-Length", -1);
|
||||||
|
|
||||||
|
m_canUseProgress = (contentLength != -1);
|
||||||
|
|
||||||
while ((read = in.read(buf)) >= 0) {
|
while ((read = in.read(buf)) >= 0) {
|
||||||
response.append(buf, 0, read);
|
response.append(buf, 0, read);
|
||||||
total += read;
|
total += read;
|
||||||
|
@ -17,6 +17,7 @@ public class GlobalState extends Application {
|
|||||||
public boolean m_unreadArticlesOnly = true;
|
public boolean m_unreadArticlesOnly = true;
|
||||||
public String m_sessionId;
|
public String m_sessionId;
|
||||||
public int m_apiLevel;
|
public int m_apiLevel;
|
||||||
|
public boolean m_canUseProgress;
|
||||||
|
|
||||||
public static GlobalState getInstance(){
|
public static GlobalState getInstance(){
|
||||||
return m_singleton;
|
return m_singleton;
|
||||||
|
@ -132,8 +132,11 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
if (canUseProgress()) {
|
||||||
requestWindowFeature(Window.FEATURE_PROGRESS);
|
requestWindowFeature(Window.FEATURE_PROGRESS);
|
||||||
|
} else {
|
||||||
|
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||||
|
}
|
||||||
|
|
||||||
setProgressBarVisibility(false);
|
setProgressBarVisibility(false);
|
||||||
setProgressBarIndeterminateVisibility(false);
|
setProgressBarIndeterminateVisibility(false);
|
||||||
@ -166,6 +169,10 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean canUseProgress() {
|
||||||
|
return GlobalState.getInstance().m_canUseProgress;
|
||||||
|
}
|
||||||
|
|
||||||
private void switchOffline() {
|
private void switchOffline() {
|
||||||
if (m_offlineModeStatus == 2) {
|
if (m_offlineModeStatus == 2) {
|
||||||
|
|
||||||
@ -1178,7 +1185,9 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
if (content != null) {
|
if (content != null) {
|
||||||
setSessionId(content.get("session_id").getAsString());
|
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) {
|
ApiRequest req = new ApiRequest(m_context) {
|
||||||
protected void onPostExecute(JsonElement result) {
|
protected void onPostExecute(JsonElement result) {
|
||||||
|
Loading…
Reference in New Issue
Block a user