List of usage examples for android.content SyncResult SyncResult
public SyncResult()
From source file:org.ohmage.sync.StreamSyncAdapterTest.java
@Override public void setUp() throws Exception { super.setUp(); fakeContext = mock(Context.class); fakeContentProviderClient = mock(ContentProviderClient.class); fakeAccount = spy(new Account("name", AuthUtil.AUTHTOKEN_TYPE)); fakeWriter = mock(StreamWriterOutput.class); fakeSyncResult = new SyncResult(); mSyncAdapter = new StreamSyncAdapter(fakeContext, false, false); }
From source file:com.trellmor.berrymotes.sync.SubredditEmoteDownloader.java
public SubredditEmoteDownloader(Context context, EmoteDownloader emoteDownloader, String subreddit) { mContext = context;// w ww. j a va 2 s . c om mEmoteDownloader = emoteDownloader; mSubreddit = subreddit; SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); mDownloadNSFW = settings.getBoolean(SettingsActivity.KEY_SYNC_NSFW, false); mLastModified = new Date(settings.getLong(SettingsActivity.KEY_SYNC_LAST_MODIFIED + mSubreddit, 0)); mBaseDir = mContext.getExternalFilesDir(null); mContentResolver = mContext.getContentResolver(); mSyncResult = new SyncResult(); }
From source file:org.voidsink.anewjkuapp.update.ImportExamTask.java
public ImportExamTask(Account account, Context context) { this(account, null, null, null, null, context); this.mProvider = context.getContentResolver() .acquireContentProviderClient(KusssContentContract.Exam.CONTENT_URI); this.mSyncResult = new SyncResult(); this.mShowProgress = true; }
From source file:org.voidsink.anewjkuapp.update.ImportCalendarTask.java
public ImportCalendarTask(Account account, Context context, String getTypeID, CalendarBuilder calendarBuilder) { this(account, null, null, null, new SyncResult(), context, getTypeID, calendarBuilder); if (ContextCompat.checkSelfPermission(context, Manifest.permission.WRITE_CALENDAR) == PackageManager.PERMISSION_GRANTED) { this.mProvider = context.getContentResolver() .acquireContentProviderClient(CalendarContractWrapper.Events.CONTENT_URI()); }/*from w w w . j a v a 2 s.co m*/ this.mReleaseProvider = true; this.mShowProgress = true; }
From source file:org.anhonesteffort.flock.UnsubscribedFragment.java
private void handleRefreshSubscriptionStore() { asyncTask = new AsyncTask<String, Void, Bundle>() { @Override/*from w w w. j av a2 s . c o m*/ protected void onPreExecute() { Log.d(TAG, "handleRefreshSubscriptionStore()"); subscriptionActivity.setProgressBarIndeterminateVisibility(true); subscriptionActivity.setProgressBarVisibility(true); } @Override protected Bundle doInBackground(String... params) { Bundle result = new Bundle(); new AccountSyncWorker(subscriptionActivity, subscriptionActivity.davAccount, null, new SyncResult()) .run(); result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SUCCESS); return result; } @Override protected void onPostExecute(Bundle result) { asyncTask = null; subscriptionActivity.setProgressBarIndeterminateVisibility(false); subscriptionActivity.setProgressBarVisibility(false); if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS) handleUpdateUi(); else ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result); } }.execute(); }
From source file:com.odoo.core.service.OSyncAdapter.java
private void syncData(OModel model, OUser user, ODomain domain_filter, SyncResult result, Boolean checkForDataLimit, Boolean createRelationRecords) { Log.v(TAG, "Sync for (" + model.getModelName() + ") Started at " + ODateUtils.getDate()); model.onSyncStarted();/*from ww w . j a v a2 s.c om*/ try { ODomain domain = new ODomain(); domain.append(model.defaultDomain()); if (domain_filter != null) { domain.append(domain_filter); } if (checkForWriteCreateDate) { List<Integer> serverIds = model.getServerIds(); // Model Create date domain filters if (model.checkForCreateDate() && checkForDataLimit) { if (serverIds.size() > 0) { if (model.checkForWriteDate() && !model.isEmptyTable()) { domain.add("|"); } if (model.checkForWriteDate() && !model.isEmptyTable() && createRelationRecords && model.getLastSyncDateTime() != null) domain.add("&"); } int data_limit = preferenceManager.getInt("sync_data_limit", 60); domain.add("create_date", ">=", ODateUtils.getDateBefore(data_limit)); if (serverIds.size() > 0) { domain.add("id", "not in", new JSONArray(serverIds.toString())); } } // Model write date domain filters if (model.checkForWriteDate() && !model.isEmptyTable() && createRelationRecords) { String last_sync_date = model.getLastSyncDateTime(); if (last_sync_date != null) { domain.add("write_date", ">", last_sync_date); } } } // Getting data JSONObject response = mOdoo.search_read(model.getModelName(), getFields(model), domain.get(), 0, mSyncDataLimit, "create_date", "DESC"); OSyncDataUtils dataUtils = new OSyncDataUtils(mContext, mOdoo, model, user, response, result, createRelationRecords); // Updating records on server if local are latest updated. // if model allowed update record to server if (model.allowUpdateRecordOnServer()) { dataUtils.updateRecordsOnServer(this); } // Creating or updating relation records handleRelationRecords(user, dataUtils.getRelationRecordsHashMap(), result); // If model allowed to create record on server if (model.allowCreateRecordOnServer()) { createRecordsOnServer(model); } // If model allowed to delete record on server if (model.allowDeleteRecordOnServer()) { removeRecordOnServer(model); } // If model allowed to delete server removed record from local database if (model.allowDeleteRecordInLocal()) { removeNonExistRecordFromLocal(model); } Log.v(TAG, "Sync for (" + model.getModelName() + ") finished at " + ODateUtils.getDate()); if (createRelationRecords) { IrModel irModel = new IrModel(mContext, user); irModel.setLastSyncDateTimeToNow(model); } model.onSyncFinished(); } catch (OdooSessionExpiredException odooSession) { app.setOdoo(null, user); if (user.isOAauthLogin()) { // FIXME: Saas not working with multi login. Facing issue of session expired. } else { showSignInErrorNotification(user); } } catch (Exception e) { e.printStackTrace(); } // Performing next sync if any in service if (mSyncFinishListeners.containsKey(model.getModelName())) { OSyncAdapter adapter = mSyncFinishListeners.get(model.getModelName()).performNextSync(user, result); mSyncFinishListeners.remove(model.getModelName()); if (adapter != null) { SyncResult syncResult = new SyncResult(); OModel syncModel = model.createInstance(adapter.getModelClass()); ContentProviderClient contentProviderClient = mContext.getContentResolver() .acquireContentProviderClient(syncModel.authority()); adapter.onPerformSync(user.getAccount(), null, syncModel.authority(), contentProviderClient, syncResult); } } model.close(); }
From source file:com.nextgis.mobile.activity.MainActivity.java
void testSync() { IGISApplication application = (IGISApplication) getApplication(); MapBase map = application.getMap();//w w w.j av a2 s . com NGWVectorLayer ngwVectorLayer; for (int i = 0; i < map.getLayerCount(); i++) { ILayer layer = map.getLayer(i); if (layer instanceof NGWVectorLayer) { ngwVectorLayer = (NGWVectorLayer) layer; Pair<Integer, Integer> ver = NGWUtil.getNgwVersion(this, ngwVectorLayer.getAccountName()); ngwVectorLayer.sync(application.getAuthority(), ver, new SyncResult()); } } }
From source file:com.nextgis.ngm_clink_monitoring.activities.MainActivity.java
void testSync() { IGISApplication application = (IGISApplication) getApplication(); sync(application.getMap(), application.getAuthority(), new SyncResult()); }
From source file:com.odoo.core.orm.OModel.java
public void quickSyncRecords(ODomain domain) { OSyncAdapter syncAdapter = new OSyncAdapter(mContext, getClass(), null, true); syncAdapter.setModel(this); syncAdapter.setDomain(domain);//from www . ja v a2s . co m syncAdapter.checkForWriteCreateDate(false); syncAdapter.onPerformSync(getUser().getAccount(), null, authority(), null, new SyncResult()); }
From source file:com.odoo.core.orm.OModel.java
public ODataRow quickCreateRecord(ODataRow record) { OSyncAdapter syncAdapter = new OSyncAdapter(mContext, getClass(), null, true); syncAdapter.setModel(this); ODomain domain = new ODomain(); domain.add("id", "=", record.getInt("id")); syncAdapter.setDomain(domain);/*from w w w. ja va2s . co m*/ syncAdapter.checkForWriteCreateDate(false); syncAdapter.onPerformSync(getUser().getAccount(), null, authority(), null, new SyncResult()); return browse(null, "id = ?", new String[] { record.getString("id") }); }