@Override public void onResume() { displayActivateDialog(); if (receiver == null) { IntentFilter intentFilter = new IntentFilter(IntentIntegrator.ACTION_SYNC_SCAN_COMPLETED); intentFilter.addAction(IntentIntegrator.ACTION_UPDATE_COMPLETED); intentFilter.addAction(IntentIntegrator.ACTION_DECRYPT_COMPLETED); intentFilter.addAction(IntentIntegrator.ACTION_ENCRYPT_COMPLETED); receiver = new FavoriteSyncReceiver(); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, intentFilter); } if (getMode() != MODE_PROGRESS) { hasSynchroActive = GeneralPreferences.hasActivateSync(getActivity(), acc); } else { hasSynchroActive = true; } int titleId = R.string.menu_favorites; if (hasSynchroActive) { titleId = R.string.synced_documents; } if (getFolderName() != null) { UIUtils.displayTitle(getActivity(), getFolderName()); } else { UIUtils.displayTitle(getActivity(), getString(titleId)); } super.onResume(); }
// ///////////////////////////////////////////////////////////// // UTILS // //////////////////////////////////////////////////////////// private void displayActivateDialog() { if (!GeneralPreferences.hasDisplayedActivateSync(getActivity()) && getMode() != MODE_PROGRESS) { ActivateSyncDialogFragment.newInstance( new OnSyncChangeListener() { @Override public void onPositive() { GeneralPreferences.setActivateSync(getActivity(), true); hasSynchroActive = true; refresh(); } @Override public void onNegative() { hasSynchroActive = false; GeneralPreferences.setActivateSync(getActivity(), false); refresh(); } }) .show(getActivity().getFragmentManager(), ActivateSyncDialogFragment.TAG); GeneralPreferences.setDisplayActivateSync(getActivity(), true); } }
public void displayFavoriteStatut() { Cursor statutCursor = null; Drawable icon = getActivity().getResources().getDrawable(R.drawable.ic_favorite); Drawable statut = null; try { Account acc = SessionUtils.getAccount(getActivity()); Boolean hasSynchroActive = GeneralPreferences.hasActivateSync(getActivity(), acc); if (hasSynchroActive && acc != null) { statutCursor = getActivity() .getContentResolver() .query( SynchroProvider.CONTENT_URI, SynchroSchema.COLUMN_ALL, SynchroProvider.getAccountFilter(acc) + " AND " + SynchroSchema.COLUMN_STATUS + " == " + SyncOperation.STATUS_REQUEST_USER, null, null); if (statutCursor.getCount() > 0) { statut = getActivity().getResources().getDrawable(R.drawable.ic_warning_light); } statutCursor.close(); if (menuSlidingFavorites != null) { menuSlidingFavorites.setCompoundDrawablesWithIntrinsicBounds(icon, null, statut, null); } menuFavorites.setCompoundDrawablesWithIntrinsicBounds(icon, null, statut, null); } } catch (Exception e) { } finally { if (statutCursor != null) { statutCursor.close(); } } }