diff --git a/org.fox.ttrss/src/main/AndroidManifest.xml b/org.fox.ttrss/src/main/AndroidManifest.xml
index 66cd88ba..8dc79938 100755
--- a/org.fox.ttrss/src/main/AndroidManifest.xml
+++ b/org.fox.ttrss/src/main/AndroidManifest.xml
@@ -219,6 +219,7 @@
+
umap = new HashMap() {
- {
- put("op", "getUnread");
- put("feed_id", String.valueOf(feedId));
- put("sid", fSessionId);
- }
- };
+ SimpleLoginManager loginManager = new SimpleLoginManager() {
- aru.execute(umap);
- }
-
- @Override
- protected void onLoginFailed(int requestId, ApiRequest ar) {
-
- view.setTextViewText(R.id.counter, "?");
- manager.updateAppWidget(thisWidget, view);
- }
-
- @Override
- protected void onLoggingIn(int requestId) {
-
-
- }
- };
+ @Override
+ protected void onLoginSuccess(int requestId, String sessionId, int apiLevel) {
- String login = m_prefs.getString("login", "").trim();
- String password = m_prefs.getString("password", "").trim();
-
- loginManager.logIn(getApplicationContext(), 1, login, password);
- }
- } catch (Exception e) {
- e.printStackTrace();
-
- view.setTextViewText(R.id.counter, "?");
- manager.updateAppWidget(thisWidget, view);
-
- }
+ ApiRequest aru = new ApiRequest(getApplicationContext()) {
+ @Override
+ protected void onPostExecute(JsonElement result) {
+ if (result != null) {
+ try {
+ JsonObject content = result.getAsJsonObject();
+
+ if (content != null) {
+ int unread = content.get("unread").getAsInt();
+ sendResultIntent(unread, UPDATE_RESULT_OK);
+
+ return;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ sendResultIntent(-1, UPDATE_RESULT_ERROR_OTHER);
+ }
+ };
+
+ final String fSessionId = sessionId;
+
+ HashMap umap = new HashMap() {
+ {
+ put("op", "getUnread");
+ put("feed_id", String.valueOf(feedId));
+ put("sid", fSessionId);
+ }
+ };
+
+ aru.execute(umap);
+ }
+
+ @Override
+ protected void onLoginFailed(int requestId, ApiRequest ar) {
+ sendResultIntent(-1, UPDATE_RESULT_ERROR_LOGIN);
+ }
+
+ @Override
+ protected void onLoggingIn(int requestId) {
+
+
+ }
+ };
+
+ String login = m_prefs.getString("login", "").trim();
+ String password = m_prefs.getString("password", "").trim();
+
+ loginManager.logIn(getApplicationContext(), 1, login, password);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+
+ sendResultIntent(-1, UPDATE_RESULT_ERROR_OTHER);
+ }
+
+ stopSelf();
+
+ super.onStart(intent, startId);
}
+
+ public void sendResultIntent(int unread, int resultCode) {
+ Intent intent = new Intent();
+ intent.setAction(SmallWidgetProvider.ACTION_UPDATE_RESULT);
+ intent.putExtra("resultCode", resultCode);
+ intent.putExtra("unread", unread);
+
+ sendBroadcast(intent);
+
+ if (resultCode != UPDATE_IN_PROGRESS) stopSelf();
+ }
}
diff --git a/org.fox.ttrss/src/main/res/layout/widget_small.xml b/org.fox.ttrss/src/main/res/layout/widget_small.xml
old mode 100644
new mode 100755
index c40ead6b..f1a90491
--- a/org.fox.ttrss/src/main/res/layout/widget_small.xml
+++ b/org.fox.ttrss/src/main/res/layout/widget_small.xml
@@ -19,13 +19,13 @@
android:src="@drawable/ic_launcher" />