List of usage examples for android.content ContentResolver update
public final int update(@RequiresPermission.Write @NonNull Uri uri, @Nullable ContentValues values, @Nullable String where, @Nullable String[] selectionArgs)
From source file:com.carlrice.reader.fragment.EntryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mEntriesIds != null) { Activity activity = getActivity(); switch (item.getItemId()) { case R.id.menu_star: { mFavorite = !mFavorite;//from ww w . j a va 2 s.co m if (mFavorite) { item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important); } else { item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important); } final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentValues values = new ContentValues(); values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0); ContentResolver cr = Application.context().getContentResolver(); cr.update(uri, values, null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }.start(); break; } case R.id.menu_share: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); if (cursor != null) { String link = cursor.getString(mLinkPos); if (link != null) { String title = cursor.getString(mTitlePos); startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } } break; } case R.id.menu_full_screen: { setImmersiveFullScreen(true); break; } case R.id.menu_copy_clipboard: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", link); clipboard.setPrimaryClip(clip); Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_SHORT).show(); break; } case R.id.menu_mark_as_unread: { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentResolver cr = Application.context().getContentResolver(); cr.update(uri, FeedData.getUnreadContentValues(), null, null); } }.start(); activity.finish(); break; } } } return true; }
From source file:com.viktorrudometkin.burramys.fragment.EditFeedsListFragment.java
private void moveItem(boolean fromIsGroup, boolean toIsGroup, boolean fromIsFeedWithoutGroup, long packedPosTo, int packedGroupPosTo, int flatPosFrom) { ContentValues values = new ContentValues(); ContentResolver cr = getActivity().getContentResolver(); if (fromIsGroup && toIsGroup) { values.put(FeedColumns.PRIORITY, packedGroupPosTo + 1); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); } else if (!fromIsGroup && toIsGroup) { values.put(FeedColumns.PRIORITY, packedGroupPosTo + 1); values.putNull(FeedColumns.GROUP_ID); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); } else if ((!fromIsGroup && !toIsGroup) || (fromIsFeedWithoutGroup && !toIsGroup)) { int groupPrio = ExpandableListView.getPackedPositionChild(packedPosTo) + 1; values.put(FeedColumns.PRIORITY, groupPrio); int flatGroupPosTo = mListView .getFlatListPosition(ExpandableListView.getPackedPositionForGroup(packedGroupPosTo)); values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatGroupPosTo)); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); }//from w ww .j a v a2 s . com }
From source file:net.etuldan.sparss.fragment.EditFeedsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_edit_feed_list, container, false); mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list); mListView.setFastScrollEnabled(true); mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override/*from w w w . j a v a 2 s .c o m*/ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id))); return true; } }); mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (v.findViewById(R.id.indicator).getVisibility() != View.VISIBLE) { // This is no a real group startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id))); return true; } return false; } }); mListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { ActionBarActivity activity = (ActionBarActivity) getActivity(); if (activity != null) { String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString(); Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title); if (m.matches()) { title = m.group(1); } long feedId = mListView.getItemIdAtPosition(position); ActionMode actionMode; if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group actionMode = activity.startSupportActionMode(mGroupActionModeCallback); } else { // This is a feed actionMode = activity.startSupportActionMode(mFeedActionModeCallback); } actionMode.setTag(new Pair<>(feedId, title)); mListView.setItemChecked(position, true); } return true; } }); mListView.setAdapter(new FeedsCursorAdapter(getActivity(), FeedColumns.GROUPS_CONTENT_URI)); mListView.setDragNDropListener(new DragNDropListener() { boolean fromHasGroupIndicator = false; @Override public void onStopDrag(View itemView) { } @Override public void onStartDrag(View itemView) { fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE; } @Override public void onDrop(final int flatPosFrom, final int flatPosTo) { final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator; View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition()); boolean toIsFeedWithoutGroup = toIsGroup && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE; final long packedPosTo = mListView.getExpandableListPosition(flatPosTo); final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo); if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) { new AlertDialog.Builder(getActivity()) // .setTitle(R.string.to_group_title) // .setMessage(R.string.to_group_message) // .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ContentValues values = new ContentValues(); values.put(FeedColumns.PRIORITY, 1); values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo)); ContentResolver cr = getActivity().getContentResolver(); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } }).show(); } else { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } } @Override public void onDrag(int x, int y, ListView listView) { } }); return rootView; }
From source file:com.viktorrudometkin.burramys.fragment.EditFeedsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_edit_feed_list, container, false); mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list); mListView.setFastScrollEnabled(true); mListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); mListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override/*from ww w .ja va 2s . co m*/ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id))); return true; } }); mListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (v.findViewById(R.id.indicator).getVisibility() != View.VISIBLE) { // This is no a real group startActivity(new Intent(Intent.ACTION_EDIT).setData(FeedColumns.CONTENT_URI(id))); return true; } return false; } }); mListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString(); Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title); if (m.matches()) { title = m.group(1); } long feedId = mListView.getItemIdAtPosition(position); ActionMode actionMode; if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group actionMode = activity.startSupportActionMode(mGroupActionModeCallback); } else { // This is a feed actionMode = activity.startSupportActionMode(mFeedActionModeCallback); } actionMode.setTag(new Pair<>(feedId, title)); mListView.setItemChecked(position, true); } return true; } }); mListView.setAdapter(new FeedsCursorAdapter(getActivity(), FeedColumns.GROUPS_CONTENT_URI)); mListView.setDragNDropListener(new DragNDropListener() { boolean fromHasGroupIndicator = false; @Override public void onStopDrag(View itemView) { } @Override public void onStartDrag(View itemView) { fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE; } @Override public void onDrop(final int flatPosFrom, final int flatPosTo) { final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator; View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition()); boolean toIsFeedWithoutGroup = toIsGroup && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE; final long packedPosTo = mListView.getExpandableListPosition(flatPosTo); final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo); if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) { new AlertDialog.Builder(getActivity()) // .setTitle(R.string.to_group_title) // .setMessage(R.string.to_group_message) // .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ContentValues values = new ContentValues(); values.put(FeedColumns.PRIORITY, 1); values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo)); ContentResolver cr = getActivity().getContentResolver(); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } }).show(); } else { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } } @Override public void onDrag(int x, int y, ListView listView) { } }); return rootView; }
From source file:net.news.inrss.fragment.EntryFragment.java
private void refreshUI(Cursor entryCursor) { if (entryCursor != null) { Log.d(TAG, "refreshUI() called with: " + "entryCursor = [" + entryCursor + "]"); String feedTitle = entryCursor.isNull(mFeedNamePos) ? entryCursor.getString(mFeedUrlPos) : entryCursor.getString(mFeedNamePos); BaseActivity activity = (BaseActivity) getActivity(); activity.setTitle(feedTitle);//ww w . ja v a 2 s . co m byte[] iconBytes = entryCursor.getBlob(mFeedIconPos); Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24); if (bitmap != null) { activity.getSupportActionBar().setIcon(new BitmapDrawable(getResources(), bitmap)); } else { activity.getSupportActionBar().setIcon(null); } mFavorite = entryCursor.getInt(mIsFavoritePos) == 1; activity.invalidateOptionsMenu(); // Listen the mobilizing task if (FetcherService.hasMobilizationTask(mEntriesIds[mCurrentPagerPos])) { // If the service is not started, start it here to avoid an infinite loading if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) { MainApplication.getContext() .startService(new Intent(MainApplication.getContext(), FetcherService.class) .setAction(FetcherService.ACTION_MOBILIZE_FEEDS)); } } // Mark the article as read if (entryCursor.getInt(mIsReadPos) != 1) { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread(new Runnable() { @Override public void run() { ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, FeedData.getReadContentValues(), null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }).start(); } } }
From source file:nl.privacybarometer.privacyvandaag.fragment.EntryFragment.java
private void refreshUI(Cursor entryCursor) { if (entryCursor != null) { String feedTitle = entryCursor.isNull(mFeedNamePos) ? entryCursor.getString(mFeedUrlPos) : entryCursor.getString(mFeedNamePos); BaseActivity activity = (BaseActivity) getActivity(); activity.setTitle(feedTitle);/*from ww w . ja v a 2 s.c o m*/ // ModPrivacyVandaag: Get icon from resource drawable instead of retrieved favicon blob in database int mIconResourceId = entryCursor.getInt(mIconIdPos); if (mIconResourceId > 0) { Drawable mDrawable = ContextCompat.getDrawable(MainApplication.getContext(), mIconResourceId); Bitmap bitmap = ((BitmapDrawable) mDrawable).getBitmap(); if (bitmap != null) { BitmapDrawable mIcon; mIcon = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, 36, 36, true)); activity.getSupportActionBar().setIcon(mIcon); } } else { activity.getSupportActionBar().setIcon(null); } /* Following code no longer needed byte[] iconBytes = entryCursor.getBlob(mFeedIconPos); Bitmap bitmap = UiUtils.getScaledBitmap(iconBytes, 24); if (bitmap != null) { activity.getSupportActionBar().setIcon(new BitmapDrawable(getResources(), bitmap)); } else { activity.getSupportActionBar().setIcon(null); } */ // End ModPrivacyVandaag mFavorite = entryCursor.getInt(mIsFavoritePos) == 1; activity.invalidateOptionsMenu(); // Listen the mobilizing task if (FetcherService.hasMobilizationTask(mEntriesIds[mCurrentPagerPos])) { showSwipeProgress(); // If the service is not started, start it here to avoid an infinite loading if (!PrefUtils.getBoolean(PrefUtils.IS_REFRESHING, false)) { MainApplication.getContext() .startService(new Intent(MainApplication.getContext(), FetcherService.class) .setAction(FetcherService.ACTION_MOBILIZE_FEEDS)); } } else { hideSwipeProgress(); } // Mark the article as read if (entryCursor.getInt(mIsReadPos) != 1) { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread(new Runnable() { @Override public void run() { ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, FeedData.getReadContentValues(), null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }).start(); } } }
From source file:myblog.richard.vewe.launcher3.LauncherApplication.java
public void setInstallDate() { ContentResolver resolver = getContentResolver(); ContentValues update = new ContentValues(); int installdate = EventRecords.getCurDate(); update.put(UsersContract.TableUsers.Column.INSTALL_DATE, installdate); int rowsUpdated; String selection = UsersContract.TableUsers.Column.NAME + "=" + UsersContract.TableUsers.CURRENT; rowsUpdated = resolver.update(UsersContract.TableUsers.CONTENT_URI, update, selection, null); if (rowsUpdated != 1) { Log.e(tag, "failed to update install date"); }// www . j a v a 2 s.c o m if (mUser != null) { mUser.getProperities().put(UsersContract.TableUsers.Column.INSTALL_DATE, installdate); } }
From source file:spit.matrix2017.Activities.EventDetails.java
@Override public void onResume() { super.onResume(); if (visitedCalendar) { if (getLastEventId(getContentResolver()) == mEventID) { ContentResolver contentResolver = getContentResolver(); Uri uri = Uri.parse("content://spit.matrix2017.provider"); String selection = "name = ?"; String[] selectionArgs = { getIntent().getStringExtra("name") + ", S.P.I.T." }; ContentValues cv = new ContentValues(); cv.put("reminder", 1); contentResolver.update(uri, cv, selection, selectionArgs); isReminderSet = true;//from w w w .ja va 2 s. c o m mi_reminder.setIcon(R.drawable.svg_alarm_on_white_48px); Toast.makeText(EventDetails.this, "Successfully added reminder", Toast.LENGTH_SHORT).show(); } else Toast.makeText(EventDetails.this, "Reminder not added", Toast.LENGTH_SHORT).show(); } }
From source file:co.nerdart.ourss.fragment.FeedsListFragment.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { setFeedSortEnabled(false);//from w w w . j a va2 s . com switch (item.getItemId()) { case R.id.menu_add_feed: { startActivity(new Intent(Intent.ACTION_INSERT).setData(FeedColumns.CONTENT_URI)); return true; } case R.id.menu_refresh: { if (!FetcherService.isRefreshingFeeds) { getActivity().startService( new Intent(getActivity(), FetcherService.class).setAction(Constants.ACTION_REFRESH_FEEDS)); } return true; } case R.id.menu_settings: { startActivity(new Intent(getActivity(), GeneralPrefsActivity.class)); return true; } case R.id.menu_all_read: { new Thread() { @Override public void run() { ContentResolver cr = getActivity().getContentResolver(); if (cr.update(EntryColumns.CONTENT_URI, FeedData.getReadContentValues(), EntryColumns.WHERE_UNREAD, null) > 0) { cr.notifyChange(FeedColumns.CONTENT_URI, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); cr.notifyChange(EntryColumns.FAVORITES_CONTENT_URI, null); } } }.start(); return true; } case R.id.menu_add_group: { final EditText input = new EditText(getActivity()); input.setSingleLine(true); new AlertDialog.Builder(getActivity()) // .setTitle(R.string.add_group_title) // .setView(input) // // .setMessage(R.string.add_group_sentence) // .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new Thread() { @Override public void run() { String groupName = input.getText().toString(); if (!groupName.isEmpty()) { ContentResolver cr = getActivity().getContentResolver(); ContentValues values = new ContentValues(); values.put(FeedColumns.IS_GROUP, true); values.put(FeedColumns.NAME, groupName); cr.insert(FeedColumns.GROUPS_CONTENT_URI, values); } } }.start(); } }).setNegativeButton(android.R.string.cancel, null).show(); return true; } case R.id.menu_import: { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.select_file); try { final String[] fileNames = Environment.getExternalStorageDirectory().list(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { return new File(dir, filename).isFile(); } }); builder.setItems(fileNames, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { new Thread(new Runnable() { // To not block the UI @Override public void run() { try { OPML.importFromFile(Environment.getExternalStorageDirectory().toString() + File.separator + fileNames[which]); } catch (Exception e) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { Crouton.makeText(getActivity(), R.string.error_feed_import, Style.INFO); } }); } } }).start(); } }); builder.show(); } catch (Exception e) { Crouton.makeText(getActivity(), R.string.error_feed_import, Style.INFO); } } else { Crouton.makeText(getActivity(), R.string.error_external_storage_not_available, Style.INFO); } return true; } case R.id.menu_export: { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) || Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED_READ_ONLY)) { new Thread(new Runnable() { // To not block the UI @Override public void run() { try { final String filename = Environment.getExternalStorageDirectory().toString() + "/OURSS_" + System.currentTimeMillis() + ".opml"; OPML.exportToFile(filename); getActivity().runOnUiThread(new Runnable() { @Override public void run() { //Toast.makeText(getActivity(), // String.format // (getString(R.string.message_exported_to), // filename),Toast.LENGTH_LONG).show(); Crouton.makeText(getActivity(), String.format(getString(R.string.message_exported_to), filename), Style.INFO); } }); } catch (Exception e) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { //Toast.makeText(getActivity(), // R.string.error_feed_export, // Toast.LENGTH_LONG).show(); Crouton.makeText(getActivity(), R.string.error_feed_export, Style.INFO); } }); } } }).start(); } else { //Toast.makeText(getActivity(), R.string.error_external_storage_not_available, // Toast.LENGTH_LONG).show(); Crouton.makeText(getActivity(), R.string.error_external_storage_not_available, Style.INFO); } break; } case R.id.menu_enable_feed_sort: { setFeedSortEnabled(true); return true; } case R.id.menu_disable_feed_sort: { // do nothing as the feed sort gets disabled anyway return true; } } return super.onOptionsItemSelected(item); }
From source file:cz.maresmar.sfm.view.credential.CredentialDetailFragment.java
@Nullable @Override//from w w w . j a v a 2s . c om public Uri saveData() { Timber.i("Saving credential data"); // Defines an object to contain the new values to insert ContentValues values = new ContentValues(); /* * Sets the values of each column and inserts the word. The arguments to the "put" * method are "column name" and "value" */ values.put(ProviderContract.Credentials.CREDENTIALS_GROUP_ID, mCredentialGroupSpinner.getSelectedItemId()); values.put(ProviderContract.Credentials.PORTAL_GROUP_ID, mPortalGroupId); // User will be added from user prefix values.put(ProviderContract.Credentials.USER_NAME, mNameText.getText().toString()); values.put(ProviderContract.Credentials.USER_PASS, mPasswordText.getText().toString()); values.put(ProviderContract.Credentials.EXTRA, getExtraData()); // Notifications @ProviderContract.CredentialFlags int flags = 0; if (!mCreditIncreaseNotificationCheckBox.isChecked()) { flags |= ProviderContract.CREDENTIAL_FLAG_DISABLE_CREDIT_INCREASE_NOTIFICATION; } if (!mLowCreditNotificationCheckBox.isChecked()) { flags |= ProviderContract.CREDENTIAL_FLAG_DISABLE_LOW_CREDIT_NOTIFICATION; } values.put(ProviderContract.Credentials.FLAGS, flags); values.put(ProviderContract.Credentials.LOW_CREDIT_THRESHOLD, mLowCreditText.getText().toString()); //noinspection ConstantConditions ContentResolver contentResolver = getContext().getContentResolver(); if (mCredentialUri == null) { Uri credentialUri = Uri.withAppendedPath(mUserPrefixUri, ProviderContract.CREDENTIALS_PATH); mCredentialTempUri = contentResolver.insert(credentialUri, values); mCredentialUri = mCredentialTempUri; } else { int updatedRows = contentResolver.update(mCredentialUri, values, null, null); if (BuildConfig.DEBUG) { Assert.isOne(updatedRows); } } return mCredentialUri; }