List of usage examples for android.os AsyncTask THREAD_POOL_EXECUTOR
Executor THREAD_POOL_EXECUTOR
To view the source code for android.os AsyncTask THREAD_POOL_EXECUTOR.
Click Source Link
From source file:org.anoopam.main.anoopamaudio.AudioListActivity.java
private void getAudioListFromCache() { SmartUtils.showProgressDialog(this, "Loading...", true); AsyncTask<Void, Void, ArrayList<ContentValues>> task = new AsyncTask<Void, Void, ArrayList<ContentValues>>() { @Override// w w w. j a va 2 s. c om protected ArrayList<ContentValues> doInBackground(Void... params) { try { audioList = smartCaching.getDataFromCache("audios", "SELECT * FROM audios WHERE catID='" + audioDetails.getAsString("catID") + "' ORDER BY audioTitle ASC"); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(ArrayList<ContentValues> result) { super.onPostExecute(result); SmartUtils.hideProgressDialog(); if (audioList != null && audioList.size() > 0) { if (mAdapter == null) { mAdapter = new AudioListAdapter(); mRecyclerView.setAdapter(mAdapter); } else { mAdapter.notifyDataSetChanged(); } } } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { task.execute(); } }
From source file:com.eeshana.icstories.activities.UploadVideoActivity.java
@SuppressLint("NewApi") @Override/* www. j a v a 2 s .c om*/ public void onClick(View v) { if (v.getId() == uploadButton.getId()) { if (connectionDetector.isConnectedToInternet()) { title = titleEditText.getText().toString(); description = descriptionEditText.getText().toString(); flag = isAssignment; my_location = locationEditText.getText().toString(); if (title.equalsIgnoreCase("") || description.equalsIgnoreCase("")) { showCustomToast.showToast(UploadVideoActivity.this, "Title and Description both are required"); } else { Log.e("location2", my_location); //new UplodTask(getApplicationContext()).execute(); if (title.length() <= 30 && title.length() >= 4 && description.length() >= 4 && description.length() <= 150 && my_location.length() <= 30) {//&& my_location.matches(pattern) && title.matches(pattern) && description.matches(pattern)){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { new UplodTask(getApplicationContext()) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { new UplodTask(getApplicationContext()).execute(); } } else { // if(!title.matches(pattern)){ // titleEditText.setError("Title contains one or more invalid characters. Please check."); // } // if(!description.matches(pattern)){ // descriptionEditText.setError("Description contains one or more invalid characters. Please check"); // } // if(!my_location.matches(pattern)){ // locationEditText.setError("Location contains one or more invalid characters. Please check"); // } if (title.length() < 4) { titleEditText.setError("Title must be min 4 characters."); } if (description.length() < 4) { descriptionEditText.setError("Description must be min 4 characters."); } if (title.length() > 30) { titleEditText.setError("Title must be max 30 characters."); } if (description.length() > 150) { descriptionEditText.setError("Description must be max 150 characters."); } if (my_location.length() > 30) { descriptionEditText.setError("Location must be max 30 characters."); } } } } else { showCustomToast.showToast(UploadVideoActivity.this, "Please check your internet connection."); } } else if (v.getId() == isAssignmentButton.getId()) { if (isAssignment.equalsIgnoreCase("NO")) { isAssignment = "YES"; isAssignmentButton.setText("YES"); } else { isAssignment = "NO"; isAssignmentButton.setText("NO"); } } else if (v.getId() == wallRelativeLayout.getId()) { Intent i = new Intent(UploadVideoActivity.this, WallActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i); finish(); } else if (v.getId() == settingsRelativeLayout.getId()) { Intent i = new Intent(UploadVideoActivity.this, SettingsActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(i); finish(); } else if (v.getId() == okButton.getId()) { //go to settings page to enable GPS Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivityForResult(intent, REQUEST_CODE); locationDialog.dismiss(); } else if (v.getId() == cancelButton.getId()) { locationDialog.dismiss(); } }
From source file:com.android.camera.v2.uimanager.ThumbnailManager.java
private void getLastThumbnailUncached() { LogHelper.d(TAG, "[getLastThumbnailUncached]..."); cancelLoadThumbnail();//from ww w . j a v a 2s .com mLoadThumbnailTask = new LoadThumbnailTask(false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:org.dharmaseed.android.NavigationActivity.java
public void fetchNewDataFromServer() { // Fetch new data from the server Log.i("navigationActivity", "fetchNewDataFromServer()"); if (teacherFetcherTask == null || teacherFetcherTask.getStatus() == AsyncTask.Status.FINISHED) { refreshLayout.setRefreshing(true); teacherFetcherTask = new TeacherFetcherTask(dbManager, this, this); teacherFetcherTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }// www .j av a 2 s.co m if (centerFetcherTask == null || centerFetcherTask.getStatus() == AsyncTask.Status.FINISHED) { refreshLayout.setRefreshing(true); centerFetcherTask = new CenterFetcherTask(dbManager, this); centerFetcherTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } if (talkFetcherTask == null || talkFetcherTask.getStatus() == AsyncTask.Status.FINISHED) { refreshLayout.setRefreshing(true); talkFetcherTask = new TalkFetcherTask(dbManager, this); talkFetcherTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }
From source file:com.concentricsky.android.khanacademy.data.KADataService.java
private void updateDownloadStatus(Intent intent, final PendingIntent pendingIntent, final int startId) { final long id = intent.getLongExtra(EXTRA_ID, -1); final DownloadManager mgr = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); final DownloadManager.Query q = new DownloadManager.Query(); q.setFilterById(id);/* w w w . jav a2 s . c o m*/ new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... arg) { Cursor cursor = mgr.query(q); String youtubeId = null; int status = -1; if (cursor.moveToFirst()) { String filename = cursor .getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME)); youtubeId = OfflineVideoManager.youtubeIdFromFilename(filename); status = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)); } cursor.close(); if (status == DownloadManager.STATUS_SUCCESSFUL && youtubeId != null) { try { Dao<Video, String> videoDao = helper.getVideoDao(); UpdateBuilder<Video, String> q = videoDao.updateBuilder(); q.where().eq("youtube_id", youtubeId); q.updateColumnValue("download_status", Video.DL_STATUS_COMPLETE); q.update(); return true; } catch (SQLException e) { e.printStackTrace(); } } return false; } @Override protected void onPostExecute(Boolean successful) { if (successful) { broadcastOfflineVideoSetChanged(); finish(startId, pendingIntent, RESULT_SUCCESS); } else { finish(startId, pendingIntent, RESULT_ERROR); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:de.enlightened.peris.ProfileFragment.java
private void submitpic() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new UploadImageTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {/*w ww . jav a2s .c om*/ new UploadImageTask().execute(); } }
From source file:com.android.leanlauncher.WidgetPreviewLoader.java
public static void removePackageFromDb(final CacheDb cacheDb, final String packageName) { synchronized (sInvalidPackages) { sInvalidPackages.add(packageName); }//from www. j av a2s . c om new AsyncTask<Void, Void, Void>() { public Void doInBackground(Void... args) { SQLiteDatabase db = cacheDb.getWritableDatabase(); try { db.delete(CacheDb.TABLE_NAME, CacheDb.COLUMN_NAME + " LIKE ? OR " + CacheDb.COLUMN_NAME + " LIKE ?", // SELECT query new String[] { WIDGET_PREFIX + packageName + "/%" } // args to SELECT query ); } catch (SQLiteDiskIOException ignored) { } synchronized (sInvalidPackages) { sInvalidPackages.remove(packageName); } return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); }
From source file:org.akop.crosswords.fragment.SubscriptionDetailFragment.java
private void download(DateTime dateTime) { hideMessageBar();/*from ww w . ja v a2 s. c om*/ if (mSource == null) { showMessage(getString(R.string.error_no_source_selected)); return; } String url = mSource.createDateUrl(dateTime); final long puzzleId = Storage.getInstance().findBySourceUrl(url); // Check storage for an existing download if (puzzleId != Storage.ID_NOT_FOUND) { showMessage(getString(R.string.puzzle_already_downloaded), R.string.open, new Runnable() { @Override public void run() { CrosswordActivity.launch(getActivity(), puzzleId); } }); return; } // Check the list of items already downloaded (but not yet saved) final PuzzleWrapper downloaded = mAdapter.findItemByUrl(url); if (downloaded != null) { showMessage(getString(R.string.puzzle_already_downloaded), R.string.open, new Runnable() { @Override public void run() { saveAndOpen(downloaded); } }); return; } CrosswordFetchRunnable.Request request = new CrosswordFetchRunnable.Request(mSource, dateTime); FetcherTask task = new FetcherTask(); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, request); }
From source file:org.thoughtcrime.securesms.MediaPreviewActivity.java
@SuppressWarnings("CodeBlock2Expr") @SuppressLint("InlinedApi") private void saveToDisk() { MediaItem mediaItem = getCurrentMediaItem(); if (mediaItem != null) { SaveAttachmentTask.showWarningDialog(this, (dialogInterface, i) -> { Permissions.with(this) .request(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE) .ifNecessary()//from www . j a va2s .c o m .withPermanentDenialDialog(getString( R.string.MediaPreviewActivity_signal_needs_the_storage_permission_in_order_to_write_to_external_storage_but_it_has_been_permanently_denied)) .onAnyDenied(() -> Toast.makeText(this, R.string.MediaPreviewActivity_unable_to_write_to_external_storage_without_permission, Toast.LENGTH_LONG).show()) .onAllGranted(() -> { SaveAttachmentTask saveTask = new SaveAttachmentTask(MediaPreviewActivity.this); long saveDate = (mediaItem.date > 0) ? mediaItem.date : System.currentTimeMillis(); saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Attachment(mediaItem.uri, mediaItem.type, saveDate, null)); }).execute(); }); } }
From source file:com.marianhello.bgloc.LocationService.java
public void postLocationAsync(BackgroundLocation location) { PostLocationTask task = new LocationService.PostLocationTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, location); } else {/* w w w . j a v a2s .com*/ task.execute(location); } }