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.proninyaroslav.libretorrent.fragments.AddTorrentFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (activity == null) { activity = (AppCompatActivity) getActivity(); }/*from w w w. j a va2 s . c o m*/ adapter = new ViewPagerAdapter(activity.getSupportFragmentManager()); Utils.showColoredStatusBar_KitKat(activity); toolbar = (Toolbar) activity.findViewById(R.id.toolbar); if (toolbar != null) { toolbar.setTitle(R.string.add_torrent_title); } activity.setSupportActionBar(toolbar); setHasOptionsMenu(true); if (activity.getSupportActionBar() != null) { activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } if (savedInstanceState != null) { pathToTempTorrent = savedInstanceState.getString(TAG_PATH_TO_TEMP_TORRENT); saveTorrentFile = savedInstanceState.getBoolean(TAG_SAVE_TORRENT_FILE); hasTorrent = savedInstanceState.getBoolean(TAG_HAS_TORRENT); /* * No initialize fragments in the event of an decode error or * torrent decoding in process (after configuration changes) */ if (hasTorrent) { initFragments(); } } else { final StringBuilder progressDialogText = new StringBuilder(""); if (uri == null || uri.getScheme() == null) { progressDialogText.append(getString(R.string.decode_torrent_default_message)); } else { switch (uri.getScheme()) { case Utils.MAGNET_PREFIX: progressDialogText.append(getString(R.string.decode_torrent_fetch_magnet_message)); break; case Utils.HTTP_PREFIX: case Utils.HTTPS_PREFIX: progressDialogText.append(getString(R.string.decode_torrent_downloading_torrent_message)); break; default: progressDialogText.append(getString(R.string.decode_torrent_default_message)); break; } } /* * The AsyncTask class must be loaded on the UI thread. This is done automatically as of JELLY_BEAN. * http://developer.android.com/intl/ru/reference/android/os/AsyncTask.html */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { decodeTask = new TorrentDecodeTask(progressDialogText.toString()); decodeTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, uri); } else { Handler handler = new Handler(activity.getMainLooper()); Runnable r = new Runnable() { @Override public void run() { decodeTask = new TorrentDecodeTask(progressDialogText.toString()); decodeTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, uri); } }; handler.post(r); } } }
From source file:org.thoughtcrime.securesms.ShareActivity.java
private void initializeMedia() { final Context context = this; isPassingAlongMedia = false;/*from ww w. j a v a2 s . c om*/ Uri streamExtra = getIntent().getParcelableExtra(Intent.EXTRA_STREAM); mimeType = getMimeType(streamExtra); if (streamExtra != null && PartAuthority.isLocalUri(streamExtra)) { isPassingAlongMedia = true; resolvedExtra = streamExtra; handleResolvedMedia(getIntent(), false); } else { contactsFragment.getView().setVisibility(View.GONE); progressWheel.setVisibility(View.VISIBLE); new ResolveMediaTask(context).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, streamExtra); } }
From source file:com.iutiao.sdk.dialogs.VerifyCodeDialog.java
public void startCountDown() { // execute parallel countDownTask = new CountDownTask(resendCodeBtn); countDownTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java
@Override public void onConnectionLost() { if(!isDestroyed()){ mTask = new ReceiverAsyncTask(this); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }//w w w . ja v a2 s.c o m }
From source file:com.example.android.tvleanback2.ui.SearchFragment.java
private void loadRows() { // offload processing from the UI thread new AsyncTask<String, Void, ListRow>() { private final String query = mQuery; @Override/*www . j a va 2 s .co m*/ protected void onPreExecute() { mRowsAdapter.clear(); } @Override protected ListRow doInBackground(String... params) { final List<Movie> result = new ArrayList<>(); HashMap<String, List<Movie>> movies = VideoProvider.getMovieList(); for (Map.Entry<String, List<Movie>> entry : movies.entrySet()) { for (Movie movie : entry.getValue()) { if (movie.getTitle().toLowerCase().contains(query.toLowerCase()) || movie.getDescription().toLowerCase().contains(query.toLowerCase())) { result.add(movie); } } } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter()); listRowAdapter.addAll(0, result); HeaderItem header = new HeaderItem(getString(R.string.search_results, query)); return new ListRow(header, listRowAdapter); } @Override protected void onPostExecute(ListRow listRow) { mRowsAdapter.add(listRow); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.sgottard.tvdemoapp.ui.SearchFragment.java
private void loadRows() { // offload processing from the UI thread new AsyncTask<String, Void, ListRow>() { private final String query = mQuery; @Override/* w ww.ja v a 2s .c o m*/ protected void onPreExecute() { mRowsAdapter.clear(); } @Override protected ListRow doInBackground(String... params) { final List<Movie> result = new ArrayList<>(); HashMap<String, List<Movie>> movies = VideoProvider.getMovieList(); for (Map.Entry<String, List<Movie>> entry : movies.entrySet()) { for (Movie movie : entry.getValue()) { if (movie.getTitle().toLowerCase(Locale.ENGLISH).contains(query.toLowerCase(Locale.ENGLISH)) || movie.getDescription().toLowerCase(Locale.ENGLISH) .contains(query.toLowerCase(Locale.ENGLISH))) { result.add(movie); } } } ArrayObjectAdapter listRowAdapter = new ArrayObjectAdapter(new CardPresenter()); listRowAdapter.addAll(0, result); HeaderItem header = new HeaderItem(getString(R.string.search_results, query)); return new ListRow(header, listRowAdapter); } @Override protected void onPostExecute(ListRow listRow) { mRowsAdapter.add(listRow); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.rastating.droidbeard.net.SickbeardAsyncTask.java
public void start(Executor executor, Params... args) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { this.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args); } else {/*from w w w. j a v a2s .c o m*/ this.execute(args); } }
From source file:org.jboss.aerogear.android.sync.SyncService.java
private void connectAsync() { AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override/*from w ww . j av a2s . c o m*/ protected Void doInBackground(Void... params) { try { syncClient.connect(); } catch (Exception ex) { Log.e(TAG, ex.getMessage(), ex); throw new RuntimeException(ex); } return null; } @Override protected void onPostExecute(Void result) { super.onPostExecute(result); for (SyncServerConnectionListener listener : connectionListeners) { listener.onConnected(); } } }; task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null); }
From source file:com.readystatesoftware.ghostlog.ServerlessLogScreen.java
private void startLogReader() { mLogBuffer = new LinkedList<LogLine>(); mLogBufferFiltered = new LinkedList<LogLine>(); mLogReaderTask = new LogReaderAsyncTask() { @Override/*w ww. ja v a 2 s .co m*/ protected void onProgressUpdate(LogLine... values) { // process the latest logcat lines for (LogLine line : values) { updateBuffer(line); } } @Override protected void onPostExecute(Boolean ok) { if (!ok) { // not root - notify activity LocalBroadcastManager.getInstance(mContext).sendBroadcast(new Intent(ACTION_ROOT_FAILED)); // setEnabled integration mIntegrationEnabled = true; sendIntegrationBroadcast(true); updateBuffer(new LogLine("0 " + LOGCAT_TIME_FORMAT.format(new Date()) + " 0 0 " + getString(R.string.canned_integration_log_line))); } } }; mLogReaderTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); Log.i(TAG, "Log reader task started"); }
From source file:com.giovanniterlingen.windesheim.view.Fragments.ScheduleFragment.java
@Override public void onRefresh() { new ScheduleFetcher(true, false, true).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }