use of android.app.backup.BackupManager in project android_frameworks_base by ParanoidAndroid.
the class HugeBackupActivity method onCreate.
/** Set up the activity and populate its UI from the persistent data. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** Establish the activity's UI */
setContentView(R.layout.backup_restore);
/** Once the UI has been inflated, cache the controls for later */
mFillingGroup = (RadioGroup) findViewById(R.id.filling_group);
mAddMayoCheckbox = (CheckBox) findViewById(R.id.mayo);
mAddTomatoCheckbox = (CheckBox) findViewById(R.id.tomato);
/** Set up our file bookkeeping */
mDataFile = new File(getFilesDir(), HugeBackupActivity.DATA_FILE_NAME);
/** It is handy to keep a BackupManager cached */
mBackupManager = new BackupManager(this);
/**
* Finally, build the UI from the persistent store
*/
populateUI();
}
use of android.app.backup.BackupManager in project platform_frameworks_base by android.
the class HugeBackupActivity method onCreate.
/** Set up the activity and populate its UI from the persistent data. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** Establish the activity's UI */
setContentView(R.layout.backup_restore);
/** Once the UI has been inflated, cache the controls for later */
mFillingGroup = (RadioGroup) findViewById(R.id.filling_group);
mAddMayoCheckbox = (CheckBox) findViewById(R.id.mayo);
mAddTomatoCheckbox = (CheckBox) findViewById(R.id.tomato);
/** Set up our file bookkeeping */
mDataFile = new File(getFilesDir(), HugeBackupActivity.DATA_FILE_NAME);
/** It is handy to keep a BackupManager cached */
mBackupManager = new BackupManager(this);
/**
* Finally, build the UI from the persistent store
*/
populateUI();
}
use of android.app.backup.BackupManager in project AntennaPod by AntennaPod.
the class DBWriter method addNewFeed.
static Future<?> addNewFeed(final Context context, final Feed... feeds) {
return dbExec.submit(() -> {
final PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
adapter.setCompleteFeed(feeds);
adapter.close();
if (ClientConfig.gpodnetCallbacks.gpodnetEnabled()) {
for (Feed feed : feeds) {
GpodnetPreferences.addAddedFeed(feed.getDownload_url());
}
}
BackupManager backupManager = new BackupManager(context);
backupManager.dataChanged();
});
}
use of android.app.backup.BackupManager in project AntennaPod by AntennaPod.
the class DBWriter method deleteFeed.
/**
* Deletes a Feed and all downloaded files of its components like images and downloaded episodes.
*
* @param context A context that is used for opening a database connection.
* @param feedId ID of the Feed that should be deleted.
*/
public static Future<?> deleteFeed(final Context context, final long feedId) {
return dbExec.submit(() -> {
DownloadRequester requester = DownloadRequester.getInstance();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
final Feed feed = DBReader.getFeed(feedId);
if (feed != null) {
if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA && PlaybackPreferences.getLastPlayedFeedId() == feed.getId()) {
context.sendBroadcast(new Intent(PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID, -1);
editor.commit();
}
// delete image file
if (feed.getImage() != null) {
if (feed.getImage().isDownloaded() && feed.getImage().getFile_url() != null) {
File imageFile = new File(feed.getImage().getFile_url());
imageFile.delete();
} else if (requester.isDownloadingFile(feed.getImage())) {
requester.cancelDownload(context, feed.getImage());
}
}
// delete stored media files and mark them as read
List<FeedItem> queue = DBReader.getQueue();
List<FeedItem> removed = new ArrayList<>();
if (feed.getItems() == null) {
DBReader.getFeedItemList(feed);
}
for (FeedItem item : feed.getItems()) {
if (queue.remove(item)) {
removed.add(item);
}
if (item.getMedia() != null && item.getMedia().isDownloaded()) {
File mediaFile = new File(item.getMedia().getFile_url());
mediaFile.delete();
} else if (item.getMedia() != null && requester.isDownloadingFile(item.getMedia())) {
requester.cancelDownload(context, item.getMedia());
}
if (item.hasItemImage()) {
FeedImage image = item.getImage();
if (image.isDownloaded() && image.getFile_url() != null) {
File imgFile = new File(image.getFile_url());
imgFile.delete();
} else if (requester.isDownloadingFile(image)) {
requester.cancelDownload(context, item.getImage());
}
}
}
PodDBAdapter adapter = PodDBAdapter.getInstance();
adapter.open();
if (removed.size() > 0) {
adapter.setQueue(queue);
for (FeedItem item : removed) {
EventBus.getDefault().post(QueueEvent.irreversibleRemoved(item));
}
}
adapter.removeFeed(feed);
adapter.close();
if (ClientConfig.gpodnetCallbacks.gpodnetEnabled()) {
GpodnetPreferences.addRemovedFeed(feed.getDownload_url());
}
EventDistributor.getInstance().sendFeedUpdateBroadcast();
// we assume we also removed download log entries for the feed or its media files.
// especially important if download or refresh failed, as the user should not be able
// to retry these
EventDistributor.getInstance().sendDownloadLogUpdateBroadcast();
BackupManager backupManager = new BackupManager(context);
backupManager.dataChanged();
}
});
}
use of android.app.backup.BackupManager in project android_frameworks_base by crdroidandroid.
the class HugeBackupActivity method onCreate.
/** Set up the activity and populate its UI from the persistent data. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/** Establish the activity's UI */
setContentView(R.layout.backup_restore);
/** Once the UI has been inflated, cache the controls for later */
mFillingGroup = (RadioGroup) findViewById(R.id.filling_group);
mAddMayoCheckbox = (CheckBox) findViewById(R.id.mayo);
mAddTomatoCheckbox = (CheckBox) findViewById(R.id.tomato);
/** Set up our file bookkeeping */
mDataFile = new File(getFilesDir(), HugeBackupActivity.DATA_FILE_NAME);
/** It is handy to keep a BackupManager cached */
mBackupManager = new BackupManager(this);
/**
* Finally, build the UI from the persistent store
*/
populateUI();
}
Aggregations