use of com.evernote.android.job.util.support.PersistableBundleCompat in project cw-omnibus by commonsguy.
the class MainActivity method manageUnified.
private void manageUnified(boolean start) {
if (start) {
final JobRequest.Builder b = new JobRequest.Builder(DemoUnifiedJob.JOB_TAG);
PersistableBundleCompat extras = new PersistableBundleCompat();
if (download.isChecked()) {
extras.putBoolean(KEY_DOWNLOAD, true);
b.setExtras(extras).setRequiredNetworkType(JobRequest.NetworkType.CONNECTED);
} else {
b.setRequiredNetworkType(JobRequest.NetworkType.ANY);
}
b.setPeriodic(getPeriod()).setPersisted(false).setRequiresCharging(false).setRequiresDeviceIdle(true);
unifiedJobId = b.build().schedule();
} else {
JobManager.instance().cancel(unifiedJobId);
}
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android by nextcloud.
the class ContactsPreferenceActivity method cancelPreviousContactBackupJobForAccount.
public static void cancelPreviousContactBackupJobForAccount(Context context, Account account) {
Log_OC.d(TAG, "disabling existing contacts backup job for account: " + account.name);
JobManager jobManager = JobManager.create(context);
Set<JobRequest> jobs = jobManager.getAllJobRequestsForTag(ContactsBackupJob.TAG);
for (JobRequest jobRequest : jobs) {
PersistableBundleCompat extras = jobRequest.getExtras();
if (extras.getString(ContactsBackupJob.ACCOUNT, "").equalsIgnoreCase(account.name) && jobRequest.isPeriodic()) {
jobManager.cancel(jobRequest.getJobId());
}
}
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android by nextcloud.
the class ContactsPreferenceActivity method startContactBackupJob.
public static void startContactBackupJob(Account account) {
Log_OC.d(TAG, "start daily contacts backup job");
PersistableBundleCompat bundle = new PersistableBundleCompat();
bundle.putString(ContactsBackupJob.ACCOUNT, account.name);
cancelPreviousContactBackupJobForAccount(MainApp.getAppContext(), account);
new JobRequest.Builder(ContactsBackupJob.TAG).setExtras(bundle).setPeriodic(24 * 60 * 60 * 1000).build().schedule();
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android by nextcloud.
the class ManageAccountsActivity method performAccountRemoval.
private void performAccountRemoval(Account account) {
// disable account in list view
for (int i = 0; i < mAccountListAdapter.getCount(); i++) {
AccountListItem item = mAccountListAdapter.getItem(i);
if (item != null && item.getAccount().equals(account)) {
item.setEnabled(false);
break;
}
mAccountListAdapter.notifyDataSetChanged();
}
// store pending account removal
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(getContentResolver());
arbitraryDataProvider.storeOrUpdateKeyValue(account.name, PENDING_FOR_REMOVAL, String.valueOf(true));
// Cancel transfers
if (mUploaderBinder != null) {
mUploaderBinder.cancel(account);
}
if (mDownloaderBinder != null) {
mDownloaderBinder.cancel(account);
}
// schedule job
PersistableBundleCompat bundle = new PersistableBundleCompat();
bundle.putString(AccountRemovalJob.ACCOUNT, account.name);
new JobRequest.Builder(AccountRemovalJob.TAG).startNow().setExtras(bundle).setUpdateCurrent(false).build().schedule();
// immediately select a new account
Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType());
String newAccountName = "";
for (Account acc : accounts) {
if (!account.name.equalsIgnoreCase(acc.name)) {
newAccountName = acc.name;
break;
}
}
if (newAccountName.isEmpty()) {
Log_OC.d(TAG, "new account set to null");
AccountUtils.resetOwnCloudAccount(this);
} else {
Log_OC.d(TAG, "new account set to: " + newAccountName);
AccountUtils.setCurrentOwnCloudAccount(this, newAccountName);
}
// only one to be (deleted) account remaining
if (accounts.length < 2) {
Intent resultIntent = new Intent();
resultIntent.putExtra(KEY_ACCOUNT_LIST_CHANGED, true);
resultIntent.putExtra(KEY_CURRENT_ACCOUNT_CHANGED, true);
setResult(RESULT_OK, resultIntent);
super.onBackPressed();
}
}
use of com.evernote.android.job.util.support.PersistableBundleCompat in project android by nextcloud.
the class ContactListAdapter method importContacts.
private void importContacts(ContactAccount account) {
PersistableBundleCompat bundle = new PersistableBundleCompat();
bundle.putString(ContactsImportJob.ACCOUNT_NAME, account.name);
bundle.putString(ContactsImportJob.ACCOUNT_TYPE, account.type);
bundle.putString(ContactsImportJob.VCARD_FILE_PATH, getFile().getStoragePath());
bundle.putIntArray(ContactsImportJob.CHECKED_ITEMS_ARRAY, contactListAdapter.getCheckedIntArray());
new JobRequest.Builder(ContactsImportJob.TAG).setExtras(bundle).startNow().setRequiresCharging(false).setUpdateCurrent(false).build().schedule();
Snackbar.make(recyclerView, R.string.contacts_preferences_import_scheduled, Snackbar.LENGTH_LONG).show();
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
if (getFragmentManager().getBackStackEntryCount() > 0) {
getFragmentManager().popBackStack();
} else {
getActivity().finish();
}
}
}, 1750);
}
Aggregations