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:ch.gianulli.flashcards.ListsFragment.java
@Override public void onRefresh() { if (mListLoader != null) { mListLoader.cancel(true);//from ww w . j a v a 2 s . c o m mListLoader = null; } mListLoader = new AsyncTask<Void, Void, ArrayList<TrelloList>>() { @Override protected void onPreExecute() { super.onPreExecute(); if (mAdapter.isEmpty()) { setActivePage(Page.PROGRESS); mRefreshLayout.setRefreshing(false); } else { setActivePage(Page.LIST_LIST); mRefreshLayout.setRefreshing(true); } } @Override protected ArrayList<TrelloList> doInBackground(Void... params) { try { return mBoard.getAllLists(mTrelloApi); } catch (TrelloNotAuthorizedException e) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { mTrelloApi.requestAuthorization(getActivity().getSupportFragmentManager()); } }); } catch (TrelloNotAccessibleException e) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { setActivePage(Page.NO_CONNECTION); } }); } return null; } @Override protected void onPostExecute(ArrayList<TrelloList> lists) { mRefreshLayout.setRefreshing(false); mAdapter.setLists(lists); if (lists != null) { if (mAdapter.isEmpty()) { setActivePage(Page.NO_BOARDS); } else { setActivePage(Page.LIST_LIST); } } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.readystatesoftware.ghostlog.ServerlessLogScreen.java
private void startProcessMonitor() { mProcessMonitorTask = new ProcessMonitorAsyncTask(mContext) { @Override/*from w w w. jav a 2s . c o m*/ protected void onProgressUpdate(ForegroundProcessInfo... values) { mForegroundAppPid = values[0].pid; updateBuffer(); } }; mProcessMonitorTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); Log.i(TAG, "process monitor task started"); }
From source file:net.sarangnamu.scroll_capture.MainActivity.java
private void scrollCapture() { mProgress.setVisibility(View.VISIBLE); BkCfg.hideKeyboard(mUrl);/*from w w w .j a v a2 s. c o m*/ if (mLog.isDebugEnabled()) { String log = ""; log += "===================================================================\n"; log += "CAPTURE START\n"; log += "===================================================================\n"; mLog.debug(log); } new AsyncTask<Object, Integer, Boolean>() { Bitmap mBmp; @Override protected void onPreExecute() { int w, h; try { Picture pic = mWeb.capturePicture(); w = pic.getWidth(); h = pic.getHeight(); } catch (Exception e) { w = mWeb.getMeasuredWidth(); h = mWeb.getMeasuredHeight(); } mWeb.measure( View.MeasureSpec.makeMeasureSpec(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); mBmp = Bitmap.createBitmap(w, h, Bitmap.Config.RGB_565); Canvas canvas = new Canvas(mBmp); mWeb.draw(canvas); } @Override protected Boolean doInBackground(Object... objects) { Context context = (Context) objects[0]; File dnPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); File ssPath = new File(dnPath, "screenshot"); if (!ssPath.exists()) { ssPath.mkdirs(); } String fileName = "test.png"; // DateFormat.format("yyyyMMdd-HHmmss", new Date()) + ".png"; File ssFile = new File(ssPath, fileName); try { FileOutputStream os = new FileOutputStream(ssFile); mBmp.compress(Bitmap.CompressFormat.PNG, 90, os); os.flush(); os.close(); sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + ssFile.getAbsolutePath()))); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return true; } @Override protected void onPostExecute(Boolean result) { if (mBmp != null) { mBmp.recycle(); mBmp = null; } if (mLog.isDebugEnabled()) { String log = ""; log += "===================================================================\n"; log += "CAPTURE END\n"; log += "===================================================================\n"; mLog.debug(log); } mProgress.setVisibility(View.GONE); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, MainActivity.this); }
From source file:de.enlightened.peris.SocialFragment.java
private void submitPost() { this.newStatus.setEnabled(false); this.updateStatusButton.setEnabled(false); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new SocialPostTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {/* ww w. ja v a 2 s . c o m*/ new SocialPostTask().execute(); } }
From source file:com.bukanir.android.activities.MoviesListActivity.java
private void startMovieTask(boolean refresh) { if (Utils.isNetworkAvailable(this)) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); listCount = Integer.valueOf(prefs.getString("list_count", "30")); String force;//ww w . j a va2 s . c o m if (refresh) { force = "1"; } else { force = "0"; } moviesTask = new MoviesTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { moviesTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, category, force); } else { moviesTask.execute(null, category, force); } } else { Toast.makeText(this, getString(R.string.network_not_available), Toast.LENGTH_LONG).show(); } }
From source file:com.dmitrymalkovich.android.popularmoviesapp.details.MovieDetailFragment.java
private void fetchTrailers() { FetchTrailersTask task = new FetchTrailersTask(this); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mMovie.getId()); }
From source file:org.anoopam.main.anoopamvideo.VideoCatListActivity.java
private void getVideoCategoryFormCache() { SmartUtils.showProgressDialog(this, "Loading...", true); AsyncTask<Void, Void, ArrayList<ContentValues>> task = new AsyncTask<Void, Void, ArrayList<ContentValues>>() { @Override/*from w w w . ja va 2 s. c o m*/ protected ArrayList<ContentValues> doInBackground(Void... params) { if (IN_CATID != null && IN_CATID.length() > 0) { try { videoCat = smartCaching.getDataFromCache("videocategories", "SELECT * FROM videocategories WHERE mainCatID='" + IN_CATID + "' ORDER BY catName ASC"); } catch (Exception e) { e.printStackTrace(); } } else { try { videoCat = smartCaching.getDataFromCache("videocategories", "SELECT * FROM videocategories WHERE mainCatID='1' ORDER BY catName ASC"); } catch (Exception e) { e.printStackTrace(); } } return null; } @Override protected void onPostExecute(ArrayList<ContentValues> result) { super.onPostExecute(result); SmartUtils.hideProgressDialog(); if (videoCat != null && videoCat.size() > 0) { if (mAdapter == null) { mAdapter = new AudioCatAdapter(); mRecyclerView.setAdapter(mAdapter); } else { mAdapter.notifyDataSetChanged(); } showProgress = false; } else { showProgress = true; } if (IN_CATID == null || IN_CATID.length() <= 0 || IN_CATID.equals("1")) { getVideoCategories(); } } }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { task.execute(); } }
From source file:org.tomasdavid.vehicleroutingproblem.fragments.VrpFragment.java
/** * {@inheritDoc}/*from w w w . j a va2 s. c o m*/ */ @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_run) { // according to solver task status change play/ stop icon, start or stop solver vrpSolverTask.cancelToast(); if (vrpSolverTask.isRunning()) { vrpSolverTask.stopTask(); item.setIcon(R.drawable.ic_play_arrow_white_24dp); } else { item.setIcon(R.drawable.ic_stop_white_24dp); if (vrpSolverTask.getStatus() != Status.PENDING) { vrpSolverTask = new VrpSolverTask(this, timeLimitInSeconds, algorithm); } vrpSolverTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, vrs); if (progressBarTask.getStatus() != Status.PENDING) { progressBarTask = new ProgressBarTask(this); } progressBarTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, timeLimitInSeconds); } return true; } else if (id == R.id.action_about) { AboutAppDialog aad = new AboutAppDialog(); aad.show(getActivity().getSupportFragmentManager(), null); return true; } else if (id == R.id.action_legend) { LegendDialog aad = new LegendDialog(); aad.show(getActivity().getSupportFragmentManager(), null); return true; } return super.onOptionsItemSelected(item); }
From source file:de.enlightened.peris.ProfileFragment.java
public void finishUpSubmission() { this.application.getSession().setSessionListener(new Session.SessionListener() { @Override/*from ww w . j a va 2 s .com*/ public void onSessionConnectionFailed(final String reason) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new DownloadProfileTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new String[] { ProfileFragment.this.userId, ProfileFragment.this.userName }); } else { new DownloadProfileTask() .execute(new String[] { ProfileFragment.this.userId, ProfileFragment.this.userName }); } } @Override public void onSessionConnected() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new DownloadProfileTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new String[] { ProfileFragment.this.userId, ProfileFragment.this.userName }); } else { new DownloadProfileTask() .execute(new String[] { ProfileFragment.this.userId, ProfileFragment.this.userName }); } } }); this.application.getSession().refreshLogin(); }
From source file:at.flack.MainActivity.java
public void emailLogin(int save, int offset, int limit) { new EmailProfileTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, save, offset, limit); }