diff options
| -rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java | 76 |
1 files changed, 17 insertions, 59 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java index 684514d8..adb6d28a 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/OnlineActivity.java @@ -1177,72 +1177,30 @@ public class OnlineActivity extends CommonActivity { if (apiLevel != null) { setApiLevel(apiLevel.getAsInt()); - Log.d(TAG, "Received API level: " + getApiLevel()); - - // get custom sort from configuration object - if (getApiLevel() >= 17) { - - // daemon_is_running, icons_dir, etc... - JsonObject config = content.get("config").getAsJsonObject(); - - Type hashType = new TypeToken<Map<String, String>>() { - }.getType(); - Map<String, String> customSortTypes = new Gson().fromJson(config.get("custom_sort_types"), hashType); - - setCustomSortModes(customSortTypes); - } - - if (m_listener != null) { - m_listener.OnLoginSuccess(); - } else { - loginSuccess(m_refreshAfterLogin); - } - } else { + // Very old tt-rss server without api_level in login response + setApiLevel(0); + } - ApiRequest req = new ApiRequest(OnlineActivity.this) { - 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 != ApiCommon.ApiError.API_UNKNOWN_METHOD) { - // Unknown method means old tt-rss, in that case we assume API 0 and continue - - setLoadingStatus(getErrorMessage()); - - if (m_lastErrorMessage != null) { - setLoadingStatus(getString(getErrorMessage()) + "\n\n" + m_lastErrorMessage); - } else { - setLoadingStatus(getErrorMessage()); - } - - if (m_listener != null) { - m_listener.OnLoginFailed(); - } else { - loginFailure(); - } - - return; - } + Log.d(TAG, "Received API level: " + getApiLevel()); - Log.d(TAG, "Received API level: " + getApiLevel()); + // get custom sort from configuration object + if (getApiLevel() >= 17) { - loginSuccess(m_refreshAfterLogin); - } - }; + // daemon_is_running, icons_dir, etc... + JsonObject config = content.get("config").getAsJsonObject(); - HashMap<String, String> map = new HashMap<>(); - map.put("sid", getSessionId()); - map.put("op", "getApiLevel"); + Type hashType = new TypeToken<Map<String, String>>() { + }.getType(); + Map<String, String> customSortTypes = new Gson().fromJson(config.get("custom_sort_types"), hashType); - req.execute(map); + setCustomSortModes(customSortTypes); + } - setLoadingStatus(R.string.loading_message); + if (m_listener != null) { + m_listener.OnLoginSuccess(); + } else { + loginSuccess(m_refreshAfterLogin); } return; |
