Java Code Examples for android.net.Uri

The following examples show how to use android.net.Uri. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: FireFiles   Source File: MediaDocumentsProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
        throws FileNotFoundException {

    if (!"r".equals(mode)) {
        throw new IllegalArgumentException("Media is read-only");
    }

    final Uri target = getUriForDocumentId(docId);

    // Delegate to real provider
    final long token = Binder.clearCallingIdentity();
    try {
        return getContext().getContentResolver().openFileDescriptor(target, mode);
    } finally {
        Binder.restoreCallingIdentity(token);
    }
}
 
Example 2
Source Project: sana.mobile   Source File: DBUtils.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Converts any Uri query string into a select statement by taking
 * every key value pair in the query into "key = 'value'".
 *
 * @param uri
 * @return
 */
public static String convertUriQueryToSelect(Uri uri) {
    String qString = uri.getQuery();
    // Shortcut out for null query
    if (TextUtils.isEmpty(qString))
        return null;
    StringBuilder select = new StringBuilder();
    String[] rawQuery = uri.getQuery().split(",");
    for (int index = 0; index < rawQuery.length; index++) {
        String[] kv = rawQuery[index].split("=");
        // append space after first key value pair
        if (index > 0) select.append(" ");
        select.append(String.format("%s LIKE '%s'", kv[0], kv[1]));
    }
    return select.toString();
}
 
Example 3
private void deleteContactFromPhoneBook(int uid) {
    if (!hasContactsPermission()) {
        return;
    }
    synchronized (observerLock) {
        ignoreChanges = true;
    }
    try {
        ContentResolver contentResolver = ApplicationLoader.applicationContext.getContentResolver();
        Uri rawContactUri = ContactsContract.RawContacts.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_NAME, systemAccount.name).appendQueryParameter(ContactsContract.RawContacts.ACCOUNT_TYPE, systemAccount.type).build();
        int value = contentResolver.delete(rawContactUri, ContactsContract.RawContacts.SYNC2 + " = " + uid, null);
    } catch (Exception e) {
        FileLog.e(e);
    }
    synchronized (observerLock) {
        ignoreChanges = false;
    }
}
 
Example 4
@Override
public void setGroupChatSubject(String subject) throws RemoteException {
    try {
        if (isGroupChatSession()) {
            ChatGroup group = (ChatGroup)mChatSession.getParticipant();
            getGroupManager().setGroupSubject(group, subject);

            //update the database
            ContentValues values1 = new ContentValues(1);
            values1.put(Imps.Contacts.NICKNAME,subject);
            ContentValues values = values1;

            Uri uriContact = ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, mContactId);
            mContentResolver.update(uriContact, values, null, null);

        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example 5
/**
 * Get the value of the data column for this Uri. This is useful for
 * MediaStore Uris, and other file-based ContentProviders.
 *
 * @param context The context.
 * @param uri The Uri to query.
 * @param selection (Optional) Filter used in the query.
 * @param selectionArgs (Optional) Selection arguments used in the query.
 * @return The value of the _data column, which is typically a file path.
 */
private static String getDataColumn(Context context, Uri uri, String selection,
                                    String[] selectionArgs) {

    Cursor cursor = null;
    final String column = "_data";
    final String[] projection = {
            column
    };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
                null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}
 
Example 6
Source Project: reader   Source File: Notification.java    License: MIT License 6 votes vote down vote up
/**
 * Beep plays the default notification ringtone.
 *
 * @param count     Number of times to play notification
 */
public void beep(final long count) {
    cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            Ringtone notification = RingtoneManager.getRingtone(cordova.getActivity().getBaseContext(), ringtone);

            // If phone is not set to silent mode
            if (notification != null) {
                for (long i = 0; i < count; ++i) {
                    notification.play();
                    long timeout = 5000;
                    while (notification.isPlaying() && (timeout > 0)) {
                        timeout = timeout - 100;
                        try {
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                        }
                    }
                }
            }
        }
    });
}
 
Example 7
Source Project: lrkFM   Source File: ContextMenuUtil.java    License: MIT License 6 votes vote down vote up
private void addOpenWithToMenu(FMFile f, ContextMenu menu) {
    menu.add(0, ID_OPEN_WITH, 0, activity.getString(R.string.open_with)).setOnMenuItemClickListener(item -> {
        Intent i = new Intent(Intent.ACTION_VIEW);
        String mimeType = FMFile.getMimeTypeFromFile(f);
        i.setDataAndType(Uri.fromFile(f.getFile()), mimeType);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        Intent chooser = Intent.createChooser(i, activity.getString(R.string.choose_application));

        if (i.resolveActivity(activity.getPackageManager()) != null) {
            if (activity.getPackageManager().queryIntentActivities(i, 0).size() == 1) {
                Toast.makeText(activity, R.string.only_one_app_to_handle_file, LENGTH_SHORT).show();
            }
            activity.startActivity(chooser);
        } else {
            Toast.makeText(activity, R.string.no_app_to_handle_file, LENGTH_SHORT).show();
        }

        return true;
    }).setVisible(!f.isDirectory());
}
 
Example 8
Source Project: OsmGo   Source File: Camera.java    License: MIT License 6 votes vote down vote up
/**
 * Save the modified image we've created to a temporary location, so we can
 * return a URI to it later
 * @param bitmap
 * @param contentUri
 * @param is
 * @return
 * @throws IOException
 */
private Uri saveTemporaryImage(Bitmap bitmap, Uri contentUri, InputStream is) throws IOException {
  String filename = contentUri.getLastPathSegment();
  if (!filename.contains(".jpg") && !filename.contains(".jpeg")) {
    filename += "." + (new java.util.Date()).getTime() + ".jpeg";
  }
  File cacheDir = getActivity().getCacheDir();
  File outFile = new File(cacheDir, filename);
  FileOutputStream fos = new FileOutputStream(outFile);
  byte[] buffer = new byte[1024];
  int len;
  while ((len = is.read(buffer)) != -1) {
    fos.write(buffer, 0, len);
  }
  fos.close();
  return Uri.fromFile(outFile);
}
 
Example 9
Source Project: JavaHTTPUpload   Source File: MainActivity.java    License: MIT License 6 votes vote down vote up
private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File

        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
            		Uri.fromFile(photoFile));
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
}
 
Example 10
Source Project: phonegapbootcampsite   Source File: Notification.java    License: MIT License 6 votes vote down vote up
/**
 * Beep plays the default notification ringtone.
 *
 * @param count     Number of times to play notification
 */
public void beep(long count) {
    Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    Ringtone notification = RingtoneManager.getRingtone(this.cordova.getActivity().getBaseContext(), ringtone);

    // If phone is not set to silent mode
    if (notification != null) {
        for (long i = 0; i < count; ++i) {
            notification.play();
            long timeout = 5000;
            while (notification.isPlaying() && (timeout > 0)) {
                timeout = timeout - 100;
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                }
            }
        }
    }
}
 
Example 11
/**
 * VLC authorize only "-._~" in Mrl format, android Uri authorize "_-!.~'()*".
 * Therefore, decode the characters authorized by Android Uri when creating an Uri from VLC.
 */
public static Uri UriFromMrl(String mrl) {
    final char array[] = mrl.toCharArray();
    final StringBuilder sb = new StringBuilder(array.length*2);
    for (int i = 0; i < array.length; ++i) {
        final char c = array[i];
        if (c == '%') {
            if (array.length - i >= 3) {
                try {
                    final int hex = Integer.parseInt(new String(array, i + 1, 2), 16);
                    if (URI_AUTHORIZED_CHARS.indexOf(hex) != -1) {
                        sb.append((char) hex);
                        i += 2;
                        continue;
                    }
                } catch (NumberFormatException ignored) {
                }
            }
        }
        sb.append(c);
    }

    return Uri.parse(sb.toString());
}
 
Example 12
Source Project: MultipleImageSelect   Source File: HelperActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showAppPermissionSettings() {
    Snackbar snackbar = Snackbar.make(
            view,
            getString(R.string.permission_force),
            Snackbar.LENGTH_INDEFINITE)
            .setAction(getString(R.string.permission_settings), new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Uri uri = Uri.fromParts(
                            getString(R.string.permission_package),
                            HelperActivity.this.getPackageName(),
                            null);

                    Intent intent = new Intent();
                    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    intent.setData(uri);
                    startActivityForResult(intent, Constants.PERMISSION_REQUEST_CODE);
                }
            });

    /*((TextView) snackbar.getView()
            .findViewById(android.support.design.R.id.snackbar_text)).setMaxLines(maxLines);*/
    snackbar.show();
}
 
Example 13
Source Project: BmapLite   Source File: AppUtils.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Get the value of the data column for this Uri. This is useful for
 * MediaStore Uris, and other file-based ContentProviders.
 *
 * @param context       The context.
 * @param uri           The Uri to query.
 * @param selection     (Optional) Filter used in the query.
 * @param selectionArgs (Optional) Selection arguments used in the query.
 * @return The value of the _data column, which is typically a file path.
 */
public static String getDataColumn(Context context, Uri uri, String selection,
                                   String[] selectionArgs) {

    Cursor cursor = null;
    final String column = "_data";
    final String[] projection = {column};

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs,
                null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }
    return null;
}
 
Example 14
Source Project: Ouroboros   Source File: ChanUrls.java    License: GNU General Public License v3.0 6 votes vote down vote up
public static String getImageUrl(String boardName, String tim, String ext){
    Uri.Builder builder = new Uri.Builder();

    if (isOldTim(tim)) {
        // Some older files use an old path including the board name.
        builder.scheme(SCHEME)
            .authority(DOMAIN_NAME)
            .appendPath(boardName)
            .appendPath(OLD_IMAGE_DIRECTORY)
            .appendPath(tim + ext)
            .build();
    } else {
        builder.scheme(SCHEME)
            .authority(DOMAIN_NAME)
            .appendPath(IMAGE_DIRECTORY)
            .appendPath(tim + ext)
            .build();
    }

    return builder.toString();
}
 
Example 15
Source Project: AndroidComponentPlugin   Source File: ContentResolver.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public final @Nullable AssetFileDescriptor openAssetFile(@NonNull Uri uri, @NonNull String mode,
        @Nullable CancellationSignal signal) throws FileNotFoundException {
    try {
        if (mWrapped != null) return mWrapped.openAssetFile(uri, mode, signal);
    } catch (RemoteException e) {
        return null;
    }

    return openAssetFileDescriptor(uri, mode, signal);
}
 
Example 16
Source Project: rpicheck   Source File: OverclockingWidgetView.java    License: MIT License 5 votes vote down vote up
private static PendingIntent getSelfPendingIntent(Context context, int appWidgetId, Uri uri, String action) {
    final Intent intent = new Intent(context, OverclockingWidget.class);
    intent.setAction(action);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(uri);
    return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
 
Example 17
Source Project: android_tv_metro   Source File: iDataORM.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean updateSetting(Context context, Uri settingUri, String name, String value) {
    boolean ret = false;
    String where = String.format(" name = \"%1$s\" ", name);
    ContentValues ct = new ContentValues();
    ct.put(SettingsCol.Value, value);
    ct.put(SettingsCol.ChangeDate, dateToString(new Date()));

    if(context.getContentResolver().update(settingUri, ct, where, null) > 0)
    {
        ret = true;
    }
    return ret;
}
 
Example 18
@Override
public void onClick(View v) {
    if(v.getTag() instanceof Integer){
        int settingID = (int)v.getTag();
        switch (settingID){
            case SETTING_APPS_UNDER_CTRL:{
                MsgDispatcher.get().dispatchSync(Messege.PUSH_WINDOW,
                        TrafficCtrlWindow.createWindow(getContext(), VpnConfig.CTRL_BITS.BASE));
                break;
            }
            case SETTING_DNS_SERVER:{
                showDnsConfigDialog();
                break;
            }
            case SETTING_PROXY_ADDR:{
                showProxyConfigDialog();
                break;
            }
            case SETTING_CRASH_RECORDS:{
                MsgDispatcher.get().dispatchSync(Messege.PUSH_WINDOW, new CrashRecordWindow(ContextMgr.getContext()));
                break;
            }case SETTING_ABOUT:{
                Toast.makeText(getContext(), ResTools.getString(R.string.app_name) + " " + SystemUtils.getLocalVersionName(getContext())
                        , Toast.LENGTH_SHORT).show();
                break;
            }case SETTING_ENHANCE_BACKGROUN_RUNNING:{
                final Intent doze = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
                doze.setData(Uri.parse("package:" + getContext().getPackageName()));
                if(getContext().getPackageManager().resolveActivity(doze, 0) != null){
                    getContext().startActivity(doze);
                }else{
                    Toast.makeText(getContext(), R.string.tips_devices_not_available, Toast.LENGTH_SHORT).show();
                }
                break;
            }
        }
    }
}
 
Example 19
Source Project: ucar-weex-core   Source File: TypefaceUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static void loadTypeface(final FontDO fontDo) {
  if (fontDo != null && fontDo.getTypeface() == null &&
          (fontDo.getState() == FontDO.STATE_FAILED || fontDo.getState() == FontDO.STATE_INIT)) {
    fontDo.setState(FontDO.STATE_LOADING);
    if (fontDo.getType() == FontDO.TYPE_LOCAL) {
      Uri uri = Uri.parse(fontDo.getUrl());
      loadFromAsset(fontDo,uri.getPath().substring(1));//exclude slash
    } else if (fontDo.getType() == FontDO.TYPE_NETWORK) {
      final String url = fontDo.getUrl();
      final String fontFamily = fontDo.getFontFamilyName();
      final String fileName = url.replace('/', '_').replace(':', '_');
      File dir = new File(getFontCacheDir());
      if(!dir.exists()){
        dir.mkdirs();
      }
      final String fullPath =  dir.getAbsolutePath()+ File.separator +fileName;
      if (!loadLocalFontFile(fullPath, fontFamily)) {
        downloadFontByNetwork(url, fullPath, fontFamily);
      }
    } else if (fontDo.getType() == FontDO.TYPE_FILE) {
      boolean result = loadLocalFontFile(fontDo.getUrl(), fontDo.getFontFamilyName());
      if (!result) {
        fontDo.setState(FontDO.STATE_FAILED);
      }
    }
  }
}
 
Example 20
Source Project: custom-tabs-client   Source File: LauncherActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the URL that the Trusted Web Activity should be launched to. By default this
 * implementation checks to see if the Activity was launched with an Intent with data, if so
 * attempt to launch to that URL. If not, read the
 * "android.support.customtabs.trusted.DEFAULT_URL" metadata from the manifest.
 *
 * Override this for special handling (such as ignoring or sanitising data from the Intent).
 */
protected Uri getLaunchingUrl() {
    Uri uri = getIntent().getData();
    if (uri != null) {
        Log.d(TAG, "Using URL from Intent (" + uri + ").");
        return uri;
    }

    if (mMetadata.defaultUrl != null) {
        Log.d(TAG, "Using URL from Manifest (" + mMetadata.defaultUrl + ").");
        return Uri.parse(mMetadata.defaultUrl);
    }

    return Uri.parse("https://www.example.com/");
}
 
Example 21
private void archiveConversation (long itemId)
{
    Uri chatUri = ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, itemId);
    ContentValues values = new ContentValues();
    values.put(Imps.Chats.CHAT_TYPE,Imps.Chats.CHAT_TYPE_ARCHIVED);
    getActivity().getContentResolver().update(chatUri,values,Imps.Chats.CONTACT_ID + "=" + itemId,null);

}
 
Example 22
public CurrentTrackOverlay(
        Context context,
        MapViewOverlays mapViewOverlays)
{
    super(context, mapViewOverlays);

    Activity parent = (Activity) context;

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setColor(ControlHelper.getColor(mContext, R.attr.colorAccent));
    mPaint.setStrokeWidth(4);

    mTrackpoints = new ArrayList<>();
    IGISApplication app = (IGISApplication) parent.getApplication();
    String authority = app.getAuthority();
    mContentUriTracks = Uri.parse("content://" + authority + "/" + TrackLayer.TABLE_TRACKS);
    mCursor = mContext.getContentResolver()
            .query(mContentUriTracks, mProjection, mSelection, null, null);

    if (mCursor == null)
        return;

    mCursor.setNotificationUri(mContext.getContentResolver(), mContentUriTracks);
    ContentObserver test = new TrackObserver(new Handler());
    mCursor.registerContentObserver(test);
}
 
Example 23
Source Project: medialibrary   Source File: LocalMergeAlbum.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Uri getContentUri() {
    String bucketId = String.valueOf(mBucketId);
    if (ApiHelper.HAS_MEDIA_PROVIDER_FILES_TABLE) {
        return MediaStore.Files.getContentUri("external").buildUpon()
                .appendQueryParameter(LocalSource.KEY_BUCKET_ID, bucketId)
                .build();
    } else {
        // We don't have a single URL for a merged image before ICS
        // So we used the image's URL as a substitute.
        return MediaStore.Images.Media.EXTERNAL_CONTENT_URI.buildUpon()
                .appendQueryParameter(LocalSource.KEY_BUCKET_ID, bucketId)
                .build();
    }
}
 
Example 24
Source Project: leanback-showcase   Source File: MusicMediaPlayerGlue.java    License: Apache License 2.0 5 votes vote down vote up
public void prepareAndPlay(Uri uri) {
    for (int i = 0; i < mMediaMetaDataList.size(); i++) {
        MediaMetaData mediaData = mMediaMetaDataList.get(i);
        if (mediaData.getMediaSourceUri().equals(uri)) {
            prepareAndPlay(mediaData);
            return;
        }
    }
}
 
Example 25
@Override
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
    if (request.getPath().contains(TestUtils.TEST_AUTHORIZATION_ENDPOINT)){
        return new MockResponse().setResponseCode(302).addHeader("Location",TestUtils.TEST_APP_REDIRECT_URI+"?code=valid_code&state=random_state").setBody("Test");
    } else if (request.getPath().contains(TestUtils.TEST_TOKEN_ENDPOINT)){
        String baseUrl = TestUtils.getBaseUrl(Uri.parse(request.getRequestUrl().toString()));
        return  new MockResponse().setResponseCode(200).setBody(TestUtils.getValidTokenResponse(baseUrl, nonce));
    }
    return new MockResponse().setResponseCode(404);
}
 
Example 26
Source Project: Flora   Source File: MainActivity.java    License: MIT License 5 votes vote down vote up
@OnClick(R.id.github)
void openGithub(View view) {
    Intent intent = new Intent();
    intent.setData(Uri.parse(com.jascal.flora.net.Config.GITHUB));
    intent.setAction(Intent.ACTION_VIEW);
    this.startActivity(intent);
}
 
Example 27
Source Project: LibreTasks   Source File: PhoneNumberViewItem.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public View buildUI(DataType initData) {
  if (initData != null) {
    editText.setText(initData.getValue());
  }
  
  ContentResolver cr = activity.getContentResolver();
  List<String> contacts = new ArrayList<String>();
  // Form an array specifying which columns to return.
  String[] projection = new String[] {People.NAME, People.NUMBER };
  // Get the base URI for the People table in the Contacts content provider.
  Uri contactsUri = People.CONTENT_URI;
  // Make the query.
  Cursor cursor = cr.query(contactsUri, 
      projection, // Which columns to return
      null, // Which rows to return (all rows)
      null, // Selection arguments (none)
      Contacts.People.DEFAULT_SORT_ORDER);
  if (cursor.moveToFirst()) {
    String name;
    String phoneNumber;
    int nameColumn = cursor.getColumnIndex(People.NAME);
    int phoneColumn = cursor.getColumnIndex(People.NUMBER);
    do {
      // Get the field values of contacts
      name = cursor.getString(nameColumn);
      phoneNumber = cursor.getString(phoneColumn);
      contacts.add(name + ": " + phoneNumber);
    } while (cursor.moveToNext());
  }
  cursor.close();
  
  String[] contactsStr = new String[]{};
  ArrayAdapter<String> adapter = new ArrayAdapter<String>(activity,
      android.R.layout.simple_dropdown_item_1line, contacts.toArray(contactsStr));
  
  editText.setAdapter(adapter);
  editText.setThreshold(1);
  return(editText);
}
 
Example 28
static GifInfoHandle openUri(ContentResolver resolver, Uri uri, boolean justDecodeMetaData) throws IOException {
    if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) //workaround for #128
    {
        return openFile(uri.getPath(), justDecodeMetaData);
    }
    return openAssetFileDescriptor(resolver.openAssetFileDescriptor(uri, "r"), justDecodeMetaData);
}
 
Example 29
private Completable saveData(ManageStoreViewModel storeModel) {
  return Single.fromCallable(() -> {
    if (storeModel.hasNewAvatar()) {
      return uriToPathResolver.getMediaStoragePath(Uri.parse(storeModel.getPictureUri()));
    }
    return "";
  })
      .flatMapCompletable(
          mediaStoragePath -> accountManager.createOrUpdate(storeModel.getStoreName(),
              storeModel.getStoreDescription(), mediaStoragePath, storeModel.hasNewAvatar(),
              storeModel.getStoreTheme()
                  .getThemeName(), storeModel.storeExists()));
}
 
Example 30
Source Project: mobile-manager-tool   Source File: TracksBrowser.java    License: MIT License 5 votes vote down vote up
/**
  * @return number of albums from Bundle
  */
 public String getNumSongs() {
 	String[] projection = {
             BaseColumns._ID, ArtistColumns.ARTIST, ArtistColumns.NUMBER_OF_TRACKS
     };
 	Uri uri = Audio.Artists.EXTERNAL_CONTENT_URI;
     Long id = ApolloUtils.getArtistId(getArtist(), ARTIST_ID, this);
     Cursor cursor = null;
     try{
     	cursor = this.getContentResolver().query(uri, projection, BaseColumns._ID+ "=" + DatabaseUtils.sqlEscapeString(String.valueOf(id)), null, null);
     }
     catch(Exception e){
     	e.printStackTrace();
     }
     if(cursor == null)
     	return String.valueOf(0);
     int mArtistNumAlbumsIndex = cursor.getColumnIndexOrThrow(ArtistColumns.NUMBER_OF_TRACKS);
     if(cursor.getCount()>0){
  	cursor.moveToFirst();
      String numAlbums = cursor.getString(mArtistNumAlbumsIndex);
cursor.close();
      if(numAlbums != null){
      	return numAlbums;
      }
     }
     return String.valueOf(0);
 }