Fix #374
This commit is contained in:
parent
6d30164bce
commit
fe89751e71
3 changed files with 46 additions and 1 deletions
|
@ -38,6 +38,7 @@ import de.luhmer.owncloudnewsreader.events.podcast.PodcastCompletedEvent;
|
|||
import de.luhmer.owncloudnewsreader.events.podcast.RegisterVideoOutput;
|
||||
import de.luhmer.owncloudnewsreader.events.podcast.UpdatePodcastStatusEvent;
|
||||
import de.luhmer.owncloudnewsreader.helper.SizeAnimator;
|
||||
import de.luhmer.owncloudnewsreader.helper.TeslaUnreadManager;
|
||||
import de.luhmer.owncloudnewsreader.interfaces.IPlayPausePodcastClicked;
|
||||
import de.luhmer.owncloudnewsreader.model.MediaItem;
|
||||
import de.luhmer.owncloudnewsreader.model.PodcastItem;
|
||||
|
@ -147,6 +148,8 @@ public class PodcastFragmentActivity extends AppCompatActivity implements IPlayP
|
|||
eventBus.unregister(this);
|
||||
eventBus.post(new RegisterVideoOutput(null, null));
|
||||
|
||||
TeslaUnreadManager.PublishUnreadCount(this);
|
||||
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package de.luhmer.owncloudnewsreader.helper;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import de.luhmer.owncloudnewsreader.ListView.SubscriptionExpandableListAdapter;
|
||||
import de.luhmer.owncloudnewsreader.database.DatabaseConnectionOrm;
|
||||
|
||||
/**
|
||||
* Created by David on 14.01.2016.
|
||||
*/
|
||||
public class TeslaUnreadManager {
|
||||
public static void PublishUnreadCount(Context context) {
|
||||
try {
|
||||
//Check if TeslaUnread is installed before doing some expensive database query
|
||||
ContentValues cv = new ContentValues();
|
||||
cv.put("tag", "de.luhmer.owncloudnewsreader/de.luhmer.owncloudnewsreader");
|
||||
cv.put("count", 0);
|
||||
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
|
||||
|
||||
//If we get here.. TeslaUnread is installed
|
||||
DatabaseConnectionOrm dbConn = new DatabaseConnectionOrm(context);
|
||||
int count = Integer.parseInt(dbConn.getUnreadItemsCountForSpecificFolder(SubscriptionExpandableListAdapter.SPECIAL_FOLDERS.ALL_UNREAD_ITEMS));
|
||||
|
||||
cv.put("count", count);
|
||||
context.getContentResolver().insert(Uri.parse("content://com.teslacoilsw.notifier/unread_count"), cv);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
/* Fine, TeslaUnread is not installed. */
|
||||
} catch (Exception ex) {
|
||||
/* Some other error, possibly because the format of the ContentValues are incorrect.
|
||||
Log but do not crash over this. */
|
||||
|
||||
ex.printStackTrace();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -48,6 +48,7 @@ import de.luhmer.owncloudnewsreader.R;
|
|||
import de.luhmer.owncloudnewsreader.SettingsActivity;
|
||||
import de.luhmer.owncloudnewsreader.helper.AidlException;
|
||||
import de.luhmer.owncloudnewsreader.helper.NotificationManagerNewsReader;
|
||||
import de.luhmer.owncloudnewsreader.helper.TeslaUnreadManager;
|
||||
import de.luhmer.owncloudnewsreader.reader.FeedItemTags;
|
||||
import de.luhmer.owncloudnewsreader.reader.OnAsyncTaskCompletedListener;
|
||||
import de.luhmer.owncloudnewsreader.reader.owncloud.OwnCloud_Reader;
|
||||
|
@ -189,6 +190,8 @@ public class OwnCloudSyncService extends Service {
|
|||
}
|
||||
|
||||
private void finishedSync() {
|
||||
TeslaUnreadManager.PublishUnreadCount(this);
|
||||
|
||||
syncRunning = false;
|
||||
syncStopWatch.stop();
|
||||
Log.v(TAG, "Time needed (synchronization): " + syncStopWatch.toString());
|
||||
|
@ -217,7 +220,7 @@ public class OwnCloudSyncService extends Service {
|
|||
try {
|
||||
icb.finishedSync();
|
||||
//icb.finishedSyncOfItems();
|
||||
} catch (RemoteException e) {
|
||||
} catch (RemoteException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue