Java Code Examples for android.os.AsyncTask#execute()

The following examples show how to use android.os.AsyncTask#execute() . 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 check out the related API usage on the sidebar.
Example 1
Source File: MiscUtil.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
public static String saveBitmapToFile(final Bitmap bitmap) {
    File dir = new File(filePath);
    if (!dir.exists()) {
        dir.mkdirs();
    }
    final String fileName = filePath + getCurrentDate() +
            "_" + System.currentTimeMillis() + ".jpg";
    Logger(TAG, "file : " + fileName, false);
    AsyncTask.execute(new Runnable() {
        @Override
        public void run() {
            try {
                File file = new File(fileName);
                FileOutputStream fos = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fos);
                fos.flush();
                fos.close();
                bitmap.recycle();
            } catch (IOException e) {
                Log.e(TAG, "saveBitmapToFile: ", e);
            }
        }
    });
    return fileName;
}
 
Example 2
Source File: ApiTestActivity.java    From NewXmPluginSDK with Apache License 2.0 6 votes vote down vote up
public void testBarcodeCodec(){
    AsyncTask<Void,Void,Boolean> task = new AsyncTask<Void, Void, Boolean>() {
        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            start("testBarcodeCodec");
        }

        @Override
        protected Boolean doInBackground(Void... params) {
            String barcode = "testBarcodeCodec";
            Bitmap bitmap = XmPluginHostApi.instance().encodeBarcode(barcode,300,300);
            String decodeBarcode = XmPluginHostApi.instance().decodeBarcode(bitmap);
            return barcode.equals(decodeBarcode);
        }

        @Override
        protected void onPostExecute(Boolean aVoid) {
            super.onPostExecute(aVoid);
            addInfo(aVoid, "testBarcodeCodec");
        }
    };
    task.execute();
}
 
Example 3
Source File: MainActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
private void doSometime() {
	AsyncTask<String, Void, String> task = new AsyncTask<String, Void, String>() {

		@Override
		protected String doInBackground(String... params) {
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			return "test";
		}

		protected void onPostExecute(String result) {
			findItem.collapseActionView();
			findItem.setActionView(null);
		};
	};
	task.execute("test");

}
 
Example 4
Source File: MiscUtil.java    From PLDroidShortVideo with Apache License 2.0 6 votes vote down vote up
public static String saveDataToFile(String fileName, String fileExtName, final byte[] data) {
    File dir = new File(filePath);
    if (!dir.exists()) {
        dir.mkdirs();
    }
    final String fileFullName = filePath + fileName + "." + fileExtName;
    AsyncTask.execute(new Runnable() {
        @Override
        public void run() {
            File file = new File(fileFullName);
            Logger(TAG, "saveDataToFile " + fileFullName, false);
            try {
                FileOutputStream fos = new FileOutputStream(file);
                fos.write(data);
                fos.flush();
                fos.close();
            } catch (IOException e) {
                Log.e(TAG, "saveDataToFile", e);
            }
        }
    });
    return fileFullName;
}
 
Example 5
Source File: ContentViewerActivity.java    From ankihelper with GNU General Public License v3.0 6 votes vote down vote up
private void refreshContent(int index) {
    @SuppressLint("StaticFieldLeak") AsyncTask<Integer, Void, ContentEntity> asyncTask = new AsyncTask<Integer, Void, ContentEntity>() {
        @Override
        protected ContentEntity doInBackground(Integer... integers) {
            return externalContent.getRandomContentAt(integers[0],
                    Settings.getInstance(ContentViewerActivity.this).getShowContentAlreadyRead());
        }

        @Override
        protected void onPostExecute(ContentEntity contentEntity){
            swipeRefreshLayout.setRefreshing(false);
            if(contentEntity != null){
                contentTextView.setText(
                        contentEntity.getText()
                );
                currentContent = contentEntity.getText();
                note = contentEntity.getNote();
            }else{
                Utils.showMessage(ContentViewerActivity.this, "刷新失败");
            }
        }
    };

    asyncTask.execute(index);
}
 
Example 6
Source File: MainActivity.java    From jam-collaboration-sample with Apache License 2.0 5 votes vote down vote up
public void beginOAuthLogin() {
    final OAuth10aService service = JamAuthConfig.instance().getOAuth10aService();

    AsyncTask network = new AsyncTask() {
        @Override
        protected Object doInBackground(Object[] params) {
            return service.getRequestToken();
        }

        @Override
        protected void onPostExecute(Object object) {
            super.onPostExecute(object);

            if (object != null) {
                final OAuth1RequestToken requestToken = (OAuth1RequestToken) object;
                String authUrl = service.getAuthorizationUrl(requestToken);

                JamOAuthDialog dialog = new JamOAuthDialog(MainActivity.this, authUrl);
                dialog.oauthListener = new JamOAuthDialog.ConfirmedOAuthAccessListener() {
                    @Override
                    public void onFinishOAuthAccess(String oauthToken, String oauthVerifier) {
                        processOAuthVerifier(requestToken, oauthVerifier);
                    }
                };
                dialog.show();
            }
        }
    };

    network.execute();
}
 
Example 7
Source File: WalletAPI.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
public static void getBalance(final String name, final String key, final Callback<Long> onComplete) {
    AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
        private DecentWalletManager decent_ = null;
        private BigInteger res_ = BigInteger.valueOf(0);
        @Override
        protected Void doInBackground(Void... voids) {
            final Semaphore waiter = new Semaphore(1);
            waiter.acquireUninterruptibly();
            res_ = BigInteger.valueOf(0);
            decent_ = new DecentWalletManager(CONNECTION_ADDRESS, new DecentAdapter() {
                @Override public void onWalletImported() {decent_.finishRequest();decent_.getBalance();Log.d("flint", "getBalance.onWalletImported");}
                @Override public void onBalanceGot(BigInteger balance) {res_ = balance;decent_.finishRequest();waiter.release();Log.d("flint", "getBalance.onBalanceGot " + res_);}
                @Override public void onError(Exception e) {waiter.release();Log.d("flint", "getBalance.onError: " + e.toString());}
            }, WalletWords.getWords(GuardaApp.context_s));
            Log.d("flint", "getBalance.importWallet... ");
            decent_.importWallet(name, key);
            try {waiter.tryAcquire(TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);} catch (InterruptedException e) {}
            return null;
        }
        @Override
        protected void onPostExecute(Void result) {
            if (onComplete != null)
                onComplete.onResponse(res_.longValue());
        }
    };

    task.execute();
}
 
Example 8
Source File: ListFriendCursorAdapter.java    From PADListener with GNU General Public License v2.0 5 votes vote down vote up
private void onFavouriteClicked(View v, Context context, CapturedFriendFullInfoModel model) {
	MyLog.entry();

	final boolean newValue = !model.getFriendModel().isFavourite();
	model.getFriendModel().setFavourite(newValue);

	final int drawableResId = newValue ? R.drawable.ic_action_favourite : R.drawable.ic_action_not_favourite;
	((ImageView) v).setImageDrawable(context.getResources().getDrawable(drawableResId));
	final AsyncTask<CapturedFriendModel, Void, Void> task = new FavouriteUpdateAsyncTask(context);
	task.execute(model.getFriendModel());

	MyLog.exit();
}
 
Example 9
Source File: SaiyTextToSpeech.java    From Saiy-PS with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Method to check if synthesis exists in the {@link DBSpeech} for the pending utterance.
 *
 * @param utterance the pending utterance
 * @param voiceName the name of the current Text to Speech Voice
 * @return true if the audio data is available to stream. False otherwise.
 */
private boolean synthesisAvailable(@NonNull final String utterance, @NonNull final String voiceName) {

    final DBSpeech dbSpeech = new DBSpeech(mContext);
    final SpeechCacheResult speechCacheResult = dbSpeech.getBytes(getInitialisedEngine(),
            voiceName, utterance);

    if (speechCacheResult.isSuccess()) {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "synthesisAvailable: true");
        }
        return true;
    } else {
        if (DEBUG) {
            MyLog.i(CLS_NAME, "synthesisAvailable: getBytes failed or speech does not exist");
        }

        if (speechCacheResult.getRowId() > -1) {
            if (DEBUG) {
                MyLog.i(CLS_NAME, "synthesisAvailable: speech does not exist");
            }
            AsyncTask.execute(new Runnable() {
                @Override
                public void run() {
                    Process.setThreadPriority(Process.THREAD_PRIORITY_LOWEST);
                    dbSpeech.deleteEntry(speechCacheResult.getRowId());
                }
            });
        }
    }

    return false;
}
 
Example 10
Source File: ChangeEventActivity.java    From mage-android with Apache License 2.0 5 votes vote down vote up
private void finishEvent(final Event event) {
	// Send chosen event to the server
	List<String> userRecentEventInfo = new ArrayList<>();
	userRecentEventInfo.add(event.getRemoteId());
	new RecentEventTask(new AccountDelegate() {
		@Override
		public void finishAccount(AccountStatus accountStatus) {
			// no-op, don't care if server didn't get event selection
		}
	}, getApplicationContext()).execute(userRecentEventInfo.toArray(new String[userRecentEventInfo.size()]));

	try {
		UserHelper userHelper = UserHelper.getInstance(getApplicationContext());
		User user = userHelper.readCurrentUser();
		userHelper.setCurrentEvent(user, event);
	} catch (UserException e) {
		Log.e(LOG_NAME, "Could not set current event.", e);
	}

	// disable pushing locations
	if (!UserHelper.getInstance(getApplicationContext()).isCurrentUserPartOfEvent(event)) {
		SharedPreferences.Editor sp = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).edit();
		sp.putBoolean(getString(R.string.reportLocationKey), false).apply();
	}


	AsyncTask.execute(new Runnable() {
		@Override
		public void run() {
			new ObservationServerFetch(getApplicationContext()).fetch(false);
		}
	});

	setResult(RESULT_OK);
	finish();
}
 
Example 11
Source File: PrefFileManager.java    From MinMinGuard with GNU General Public License v3.0 5 votes vote down vote up
public void fixFolderPermissionsAsync()
{
    AsyncTask.execute(new Runnable() {
        @SuppressLint("SetWorldReadable")
        @SuppressWarnings("ResultOfMethodCallIgnored")
        @Override
        public void run() {
            File pkgFolder = mContext.getFilesDir().getParentFile();
            if (pkgFolder.exists())
            {
                pkgFolder.setExecutable(true, false);
                pkgFolder.setReadable(true, false);
            }
            File cacheFolder = mContext.getCacheDir();
            if (cacheFolder.exists())
            {
                cacheFolder.setExecutable(true, false);
                cacheFolder.setReadable(true, false);
            }
            File filesFolder = mContext.getFilesDir();
            if (filesFolder.exists())
            {
                filesFolder.setExecutable(true, false);
                filesFolder.setReadable(true, false);
                for (File f : filesFolder.listFiles())
                {
                    f.setExecutable(true, false);
                    f.setReadable(true, false);
                }
            }
        }
    });
}
 
Example 12
Source File: SettingsManager.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public void fixFolderPermissionsAsync() {
    AsyncTask.execute(new Runnable() {
        @Override
        public void run() {
            mContext.getFilesDir().setExecutable(true, false);
            mContext.getFilesDir().setReadable(true, false);
            File sharedPrefsFolder = new File(mContext.getFilesDir().getAbsolutePath()
                    + "/../shared_prefs");
            sharedPrefsFolder.setExecutable(true, false);
            sharedPrefsFolder.setReadable(true, false);
        }
    });
}
 
Example 13
Source File: BookListPresenter.java    From MyBookshelf with GNU General Public License v3.0 5 votes vote down vote up
private void downloadAll(int downloadNum, boolean onlyNew) {
    if (bookShelfBeans == null || mView.getContext() == null) {
        return;
    }
    AsyncTask.execute(() -> {
        for (BookShelfBean bookShelfBean : new ArrayList<>(bookShelfBeans)) {
            if (!bookShelfBean.getTag().equals(BookShelfBean.LOCAL_TAG) && (!onlyNew || bookShelfBean.getHasUpdate())) {
                List<BookChapterBean> chapterBeanList = BookshelfHelp.getChapterList(bookShelfBean.getNoteUrl());
                if (chapterBeanList.size() >= bookShelfBean.getDurChapter()) {
                    for (int start = bookShelfBean.getDurChapter(); start < chapterBeanList.size(); start++) {
                        if (!chapterBeanList.get(start).getHasCache(bookShelfBean.getBookInfoBean())) {
                            DownloadBookBean downloadBook = new DownloadBookBean();
                            downloadBook.setName(bookShelfBean.getBookInfoBean().getName());
                            downloadBook.setNoteUrl(bookShelfBean.getNoteUrl());
                            downloadBook.setCoverUrl(bookShelfBean.getBookInfoBean().getCoverUrl());
                            downloadBook.setStart(start);
                            downloadBook.setEnd(downloadNum > 0 ? Math.min(chapterBeanList.size() - 1, start + downloadNum - 1) : chapterBeanList.size() - 1);
                            downloadBook.setFinalDate(System.currentTimeMillis());
                            DownloadService.addDownload(mView.getContext(), downloadBook);
                            break;
                        }
                    }
                }
            }
        }
    });
}
 
Example 14
Source File: FragmentAboutHelper.java    From Saiy-PS with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Update the parent fragment with the UI components
 */
public void finaliseUI() {

    AsyncTask.execute(new Runnable() {
        @Override
        public void run() {
            final ArrayList<ContainerUI> tempArray = FragmentAboutHelper.this.getUIComponents();

            try {
                Thread.sleep(FragmentHome.DRAWER_CLOSE_DELAY);
            } catch (final InterruptedException e) {
                if (DEBUG) {
                    MyLog.w(CLS_NAME, "finaliseUI InterruptedException");
                    e.printStackTrace();
                }
            }

            if (FragmentAboutHelper.this.getParent().isActive()) {

                FragmentAboutHelper.this.getParentActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {

                        FragmentAboutHelper.this.getParent().getObjects().addAll(tempArray);
                        FragmentAboutHelper.this.getParent().getAdapter().notifyItemRangeInserted(0, FragmentAboutHelper.this.getParent().getObjects().size());
                    }
                });

            } else {
                if (DEBUG) {
                    MyLog.w(CLS_NAME, "finaliseUI Fragment detached");
                }
            }
        }
    });
}
 
Example 15
Source File: RestoreFromBackupActivity.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
@OnClick(R.id.btn_restore)
public void restore(View btn) {
    switch (spinnerKey.getSelectedItemPosition()) {
        case 0:
            if (!TextUtils.isEmpty(etBackupPhrase.getText().toString().trim())) {
                if (KeyUtils.isValidPrivateKey(etBackupPhrase.getText().toString())) {
                    btnRestore.setEnabled(false);
                    showProgress();
                    AsyncTask.execute(new Runnable() {
                        @Override
                        public void run() {
                            walletManager.restoreFromBlock2(etBackupPhrase.getText().toString(), new Runnable() {
                                @Override
                                public void run() {
                                    runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            if (!"".equals(Coders.decodeBase64(sharedManager.getLastSyncedBlock()))) {
                                                goToMainActivity();
                                                btnRestore.setEnabled(false);
                                            } else {
                                                showError(etBackupPhrase, getString(R.string.et_error_wrong_private_key));
                                                btnRestore.setEnabled(true);
                                            }
                                            closeProgress();
                                        }
                                    });
                                }
                            });
                        }
                    });
                } else {
                    showError(etBackupPhrase, getString(R.string.et_error_wrong_private_key));
                }
            } else {
                showError(etBackupPhrase, getString(R.string.et_error_private_key_is_empty));
            }
            break;
        case 1:
            if (selectedFilePath != null) {
                if (!etJsonPwd.getText().toString().isEmpty()) {
                    btnRestore.setEnabled(false);
                    showProgress();
                    AsyncTask.execute(new Runnable() {
                        @Override
                        public void run() {
                            walletManager.restoreFromBlock2Json(selectedFilePath, etJsonPwd.getText().toString(), new Runnable() {
                                @Override
                                public void run() {
                                    runOnUiThread(new Runnable() {
                                        @Override
                                        public void run() {
                                            if ("JsonParseException".equals(sharedManager.getJsonExcep())) {
                                                showCustomToast(getString(R.string.restore_backup_wrong_rest_file), R.drawable.err_json_doc);
                                                btnRestore.setEnabled(true);
                                            } else if ("CipherException".equals(sharedManager.getJsonExcep())) {
                                                showCustomToast(getString(R.string.restore_backup_wrong_rest_file), R.drawable.err_json_doc);
                                                btnRestore.setEnabled(true);
                                            } else if ("WrongPassword".equals(sharedManager.getJsonExcep())) {
                                                showCustomToast(getString(R.string.restore_backup_wrong_json_password), R.drawable.err_json_doc);
                                                btnRestore.setEnabled(true);
                                            } else if (!"".equals(Coders.decodeBase64(sharedManager.getLastSyncedBlock()))) {
                                                goToMainActivity();
                                                btnRestore.setEnabled(false);
                                            }
                                            closeProgress();
                                        }
                                    });
                                }
                            });
                        }
                    });
                } else {
                    showCustomToast(getString(R.string.restore_backup_json_password_empty), R.drawable.err_json_doc);
                }
            }
            break;
    }
}
 
Example 16
Source File: RestoreFromBackupActivity.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
@OnClick(R.id.btn_restore)
public void restore(View btn) {
    if (!TextUtils.isEmpty(etBackupPhrase.getText().toString().trim())) {
        String clearKey = etBackupPhrase.getText().toString().trim();
        if (clearKey.length() > 4 && clearKey.substring(0, 4).equalsIgnoreCase("xprv")) {
            btnRestore.setEnabled(false);
            showProgress();
            AsyncTask.execute(new Runnable() {
                @Override
                public void run() {
                    walletManager.restoreFromBlockByXPRV2(etBackupPhrase.getText().toString(), new Runnable() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (!"".equals(Coders.decodeBase64(sharedManager.getLastSyncedBlock()))) {
                                        goToMainActivity(etBackupPhrase.getText().toString());
                                        btnRestore.setEnabled(false);
                                    } else {
                                        showError(etBackupPhrase, getString(R.string.et_error_wrong_private_key));
                                        btnRestore.setEnabled(true);
                                    }
                                    closeProgress();
                                }
                            });
                        }
                    });
                }
            });
        } else if ((etBackupPhrase.getText().toString().trim().length() == 51 ||
                etBackupPhrase.getText().toString().trim().length() == 52) &&
                !etBackupPhrase.getText().toString().trim().contains(" ")) {
            btnRestore.setEnabled(false);
            showProgress();
            AsyncTask.execute(new Runnable() {
                @Override
                public void run() {
                    walletManager.restoreFromBlockByWif2(etBackupPhrase.getText().toString(), new Runnable() {
                        @Override
                        public void run() {
                            runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    if (!"".equals(Coders.decodeBase64(sharedManager.getLastSyncedBlock()))) {
                                        goToMainActivity(etBackupPhrase.getText().toString());
                                        btnRestore.setEnabled(false);
                                    } else {
                                        showError(etBackupPhrase, getString(R.string.et_error_wrong_private_key));
                                        btnRestore.setEnabled(true);
                                    }
                                    closeProgress();
                                }
                            });
                        }
                    });
                }
            });
        } else {
            if (walletManager.isValidPrivateKey(etBackupPhrase.getText().toString())) {
                btnRestore.setEnabled(false);
                showProgress();
                AsyncTask.execute(new Runnable() {
                    @Override
                    public void run() {
                        walletManager.restoreFromBlock2(etBackupPhrase.getText().toString(), new Runnable() {
                            @Override
                            public void run() {
                                runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (!"".equals(Coders.decodeBase64(sharedManager.getLastSyncedBlock()))) {
                                            goToMainActivity(etBackupPhrase.getText().toString());
                                            btnRestore.setEnabled(false);
                                        } else {
                                            showError(etBackupPhrase, getString(R.string.et_error_wrong_private_key));
                                            btnRestore.setEnabled(true);
                                        }
                                        closeProgress();
                                    }
                                });
                            }
                        });
                    }
                });
            } else {
                showError(etBackupPhrase, getString(R.string.et_error_wrong_private_key));
            }
        }

    } else {
        showError(etBackupPhrase, getString(R.string.et_error_private_key_is_empty));
    }
}
 
Example 17
Source File: RulesManagerServiceHelperImpl.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void execute(Runnable runnable) {
    AsyncTask.execute(runnable);
}
 
Example 18
Source File: BookSourcePresenter.java    From MyBookshelf with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void saveData(BookSourceBean bookSourceBean) {
    AsyncTask.execute(() -> DbHelper.getDaoSession().getBookSourceBeanDao().insertOrReplace(bookSourceBean));
}
 
Example 19
Source File: GoogleSignUpActivity.java    From socialmediasignup with MIT License 4 votes vote down vote up
private void handleSignInResult(GoogleSignInResult result) {
    if (result == null) {
        handCancel(SocialMediaSignUp.SocialMediaType.GOOGLE_PLUS);
        return;
    }
    if (result.isSuccess() && result.getSignInAccount() != null) {
        final GoogleSignInAccount acct = result.getSignInAccount();
        final SocialMediaUser user = new SocialMediaUser();
        user.setUserId(acct.getId());
        user.setAccessToken(acct.getIdToken());
        user.setProfilePictureUrl(acct.getPhotoUrl() != null ? acct.getPhotoUrl().toString() : "");
        user.setEmail(acct.getEmail());
        user.setFullName(acct.getDisplayName());
        AsyncTask.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    if (acct.getAccount() == null) {
                        handleError(new RuntimeException("Account is null"));
                    } else {
                        String accessToken = GoogleAuthUtil.getToken(getApplicationContext(), acct.getAccount(), getAccessTokenScope());
                        user.setAccessToken(accessToken);
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                handleSuccess(SocialMediaSignUp.SocialMediaType.GOOGLE_PLUS, user);
                            }
                        });
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    handleError(e);
                }
            }
        });
    } else {
        String errorMsg = result.getStatus().getStatusMessage();
        if (errorMsg == null) {
            handCancel(SocialMediaSignUp.SocialMediaType.GOOGLE_PLUS);
        } else {
            handleError(new Throwable(result.getStatus().getStatusMessage()));
        }
    }
}
 
Example 20
Source File: RadioItem.java    From uPods-android with Apache License 2.0 4 votes vote down vote up
/**
 * Fixes current RadioItem link (formail, isAlive) if needed.
 *
 * @param operationFinishSecsuessCallback
 * @param operationFinishFailCallback
 */
public void fixAudeoLinks(final IOperationFinishCallback operationFinishSecsuessCallback, final IOperationFinishCallback operationFinishFailCallback) {
    AsyncTask.execute(new Runnable() {
        @Override
        public void run() {
            boolean hasAtleastOneUrl = false;
            if (selectedStreamUrl != null) {
                if (!GlobalUtils.isUrlReachable(selectedStreamUrl.getUrl())) {
                    selectedStreamUrl = null;
                } else {
                    operationFinishSecsuessCallback.operationFinished();
                    return;
                }
            }
            for (StreamUrl streamUrl : streamUrls) {
                final String currentUrl = streamUrl.getUrl();
                if (GlobalUtils.isUrlReachable(currentUrl)) {
                    if (currentUrl.matches("(.+\\.m3u$)|(.+\\.pls$)")) {
                        try {
                            String newUrl = MediaUtils.extractMp3FromFile(currentUrl);
                            StreamUrl.replaceUrl(streamUrls, newUrl, currentUrl);
                        } catch (Exception e) {
                            Logger.printInfo(RADIO_LOG, "Error with fetching radio url from file");
                            e.printStackTrace();
                            continue;
                        }
                    }
                    hasAtleastOneUrl = true;
                    streamUrl.isAlive = true;
                } else {
                    streamUrl.isAlive = false;
                }
            }
            if (hasAtleastOneUrl) {
                operationFinishSecsuessCallback.operationFinished();
            } else {
                operationFinishFailCallback.operationFinished();
            }
        }
    });
}