public void displayWarning() { if (info != null && info.hasWarning()) { SyncErrorDialogFragment.newInstance() .show(getActivity().getFragmentManager(), SyncErrorDialogFragment.TAG); return; } }
public void getMenu(Menu menu) { info = SyncScanInfo.getLastSyncScanData(getActivity(), acc); if (info != null && (info.hasWarning() && !info.hasResponse())) { mi = menu.add( Menu.NONE, MenuActionItem.MENU_SYNC_WARNING, Menu.FIRST + MenuActionItem.MENU_SYNC_WARNING, R.string.sync_warning); mi.setIcon(R.drawable.ic_warning); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } mi = menu.add( Menu.NONE, MenuActionItem.MENU_REFRESH, MenuActionItem.MENU_SYNC_WARNING + MenuActionItem.MENU_REFRESH, R.string.refresh); mi.setIcon(R.drawable.ic_refresh); mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); }
@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, intent.getAction()); if (intent.getAction() == null) { return; } if (mi != null && getActivity() != null && intent.getAction().equals(IntentIntegrator.ACTION_SYNC_SCAN_COMPLETED)) { // Hide spinning wheel mi.setActionView(null); info = SyncScanInfo.getLastSyncScanData(context, acc); getActivity().invalidateOptionsMenu(); if (info.hasWarning()) { SyncErrorDialogFragment.newInstance() .show(getActivity().getFragmentManager(), SyncErrorDialogFragment.TAG); return; } } if (acc == null) { return; } if (intent.getAction().equals(IntentIntegrator.ACTION_UPDATE_COMPLETED)) { Bundle b = intent.getExtras().getParcelable(IntentIntegrator.EXTRA_DATA); Node updatedNode = (Node) b.getParcelable(IntentIntegrator.EXTRA_UPDATED_NODE); if (updatedNode == null) { return; } Cursor favoriteCursor = context .getContentResolver() .query( SynchroProvider.CONTENT_URI, SynchroSchema.COLUMN_ALL, SynchroProvider.getAccountFilter(acc) + " AND " + SynchroSchema.COLUMN_NODE_ID + " LIKE '" + NodeRefUtils.getCleanIdentifier(updatedNode.getIdentifier()) + "%'", null, null); boolean hasFavorite = (favoriteCursor.getCount() == 1); if (hasFavorite && !hasSynchroActive) { favoriteCursor.moveToFirst(); ContentValues cValues = new ContentValues(); cValues.put(SynchroSchema.COLUMN_NODE_ID, updatedNode.getIdentifier()); cValues.put( SynchroSchema.COLUMN_SERVER_MODIFICATION_TIMESTAMP, updatedNode.getModifiedAt().getTimeInMillis()); context .getContentResolver() .update( SynchroManager.getUri(favoriteCursor.getLong(SynchroSchema.COLUMN_ID_ID)), cValues, null, null); } favoriteCursor.close(); } }