handle api_level returned by login
This commit is contained in:
parent
fb7792125b
commit
695feaf0cd
@ -1264,50 +1264,62 @@ public class OnlineActivity extends CommonActivity {
|
|||||||
if (result != null) {
|
if (result != null) {
|
||||||
try {
|
try {
|
||||||
JsonObject content = result.getAsJsonObject();
|
JsonObject content = result.getAsJsonObject();
|
||||||
|
|
||||||
if (content != null) {
|
if (content != null) {
|
||||||
setSessionId(content.get("session_id").getAsString());
|
setSessionId(content.get("session_id").getAsString());
|
||||||
|
|
||||||
|
JsonElement apiLevel = content.get("api_level");
|
||||||
|
|
||||||
GlobalState.getInstance().m_canUseProgress = m_canUseProgress;
|
GlobalState.getInstance().m_canUseProgress = m_canUseProgress;
|
||||||
|
|
||||||
Log.d(TAG, "Authenticated! canUseProgress=" + m_canUseProgress);
|
Log.d(TAG, "Authenticated! canUseProgress=" + m_canUseProgress);
|
||||||
|
|
||||||
ApiRequest req = new ApiRequest(m_context) {
|
if (apiLevel != null) {
|
||||||
protected void onPostExecute(JsonElement result) {
|
setApiLevel(apiLevel.getAsInt());
|
||||||
setApiLevel(0);
|
Log.d(TAG, "Received API level: " + getApiLevel());
|
||||||
|
|
||||||
if (result != null) {
|
loginSuccess(m_refreshAfterLogin);
|
||||||
try {
|
|
||||||
setApiLevel(result.getAsJsonObject().get("level").getAsInt());
|
} else {
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
ApiRequest req = new ApiRequest(m_context) {
|
||||||
|
protected void onPostExecute(JsonElement result) {
|
||||||
|
setApiLevel(0);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
try {
|
||||||
|
setApiLevel(result.getAsJsonObject().get("level").getAsInt());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else if (m_lastError != ApiError.API_UNKNOWN_METHOD) {
|
||||||
|
// Unknown method means old tt-rss, in that case we assume API 0 and continue
|
||||||
|
|
||||||
|
setLoadingStatus(getErrorMessage(), false);
|
||||||
|
loginFailure();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if (m_lastError != ApiError.API_UNKNOWN_METHOD) {
|
|
||||||
// Unknown method means old tt-rss, in that case we assume API 0 and continue
|
|
||||||
|
|
||||||
setLoadingStatus(getErrorMessage(), false);
|
Log.d(TAG, "Received API level: " + getApiLevel());
|
||||||
loginFailure();
|
|
||||||
|
loginSuccess(m_refreshAfterLogin);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Log.d(TAG, "Received API level: " + getApiLevel());
|
@SuppressWarnings("serial")
|
||||||
|
HashMap<String, String> map = new HashMap<String, String>() {
|
||||||
|
{
|
||||||
|
put("sid", getSessionId());
|
||||||
|
put("op", "getApiLevel");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
loginSuccess(m_refreshAfterLogin);
|
req.execute(map);
|
||||||
|
|
||||||
return;
|
setLoadingStatus(R.string.loading_message, true);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
HashMap<String, String> map = new HashMap<String, String>() {
|
|
||||||
{
|
|
||||||
put("sid", getSessionId());
|
|
||||||
put("op", "getApiLevel");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
req.execute(map);
|
|
||||||
|
|
||||||
setLoadingStatus(R.string.loading_message, true);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user