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:com.wulian.icam.view.album.utils.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and * disk cache will be used if an {@link ImageCache} has been added using * {@link ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask} * will be created to asynchronously load the bitmap. * * @param data The URL of the image to download. * @param imageView The ImageView to bind the downloaded image to. *///from w w w. ja va 2 s . c o m public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }
From source file:com.example.gemswin.screancasttest.MainActivity_Reciever.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_reciever); WifiManager wm = (WifiManager) getSystemService(WIFI_SERVICE); String ip = Formatter.formatIpAddress(wm.getConnectionInfo().getIpAddress()); TextView text = (TextView) findViewById(R.id.textView); planetList = new ArrayList<String>(); mTextureView = (TextureView) findViewById(R.id.textureView); mTextureView.setSurfaceTextureListener(this); mTextureView.requestLayout();//from w w w . jav a 2 s . c o m mTextureView.invalidate(); mTextureView.setOpaque(false); pref = new PrefManager(getApplicationContext()); text.setText(ip); mTask = new ReceiverAsyncTask(getApplicationContext(), this); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:io.imoji.sdk.editor.fragment.CreateTaskFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true);/*from w ww.ja v a2 s . com*/ mTags = getArguments().getStringArrayList(TAGS_BUNDLE_ARG_KEY); mImojiSession = ImojiSDK.getInstance().createSession(getActivity().getApplicationContext()); Bitmap b = EditorBitmapCache.getInstance().get(EditorBitmapCache.Keys.TRIMMED_BITMAP); if (b == null) { notifyFailure(getActivity()); return; } boolean createOutlinedBitmap = getArguments().getBoolean(CREATE_OUTLINE_BITMAP_BUNDLE_ARG_KEY); //start the task if (createOutlinedBitmap) { OutlineAsyncTask task = new OutlineAsyncTask(b, IMOJI_WIDTH_BOUND, IMOJI_HEIGHT_BOUND, this); if (Build.VERSION.SDK_INT >= 11) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { task.execute(); } } else { Bitmap outlined = EditorBitmapCache.getInstance().get(EditorBitmapCache.Keys.TRIMMED_BITMAP); if (outlined == null) { notifyFailure(getActivity()); return; } createImoji(outlined); } }
From source file:cn.huaxingtan.util.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not used. * Kept private at the moment as its interest is not clear. *///from w ww . j a v a 2 s . c o m private void forceDownload(String url, ImageView imageView) { // State sanity: url is guaranteed to never be null in DownloadedDrawable and cache keys. if (url == null) { imageView.setImageDrawable(null); return; } if (cancelPotentialDownload(url, imageView)) { switch (mode) { case NO_ASYNC_TASK: Bitmap bitmap = downloadBitmap(url); addBitmapToCache(url, bitmap); imageView.setImageBitmap(bitmap); break; case NO_DOWNLOADED_DRAWABLE: imageView.setMinimumHeight(156); BitmapDownloaderTask task = new BitmapDownloaderTask(imageView); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url); break; case CORRECT: task = new BitmapDownloaderTask(imageView); DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task); imageView.setImageDrawable(downloadedDrawable); imageView.setMinimumHeight(156); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url); break; } } }
From source file:cn.edu.wyu.documentviewer.RootsCache.java
/** * Gather roots from storage providers belonging to given package name. *///from w w w . j a v a 2s . c om public void updatePackageAsync(String packageName) { // Need at least first load, since we're going to be using previously // cached values for non-matching packages. waitForFirstLoad(); new UpdateTask(packageName).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:ru.freshartapp.automarka.utils.ImageDetailFragment.java
private void addToFavorites() { Log.d("addToFavorites", "start"); final FavotitesTask task = new FavotitesTask(this.FAVORITES_ADD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, this.mModelId); } else {/*from w w w . ja v a 2 s . c o m*/ task.execute(this.mModelId); } }
From source file:com.dm.wallpaper.board.fragments.CategoriesFragment.java
public void getCategories() { if (mAsyncTask != null) { mAsyncTask.cancel(true);//from ww w .ja v a 2s.c o m } if (Database.get(getActivity()).getWallpapersCount() > 0) { mAsyncTask = new CategoriesLoader().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return; } mAsyncTask = new CategoriesLoader().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
From source file:ar.uba.fi.splitapp.MockServer.java
public static void sendFriendMessage(String message, String friendId, String friendName) { if (mSession == null) { return;/*www . j a va2s .co m*/ } mSession.addResponse(message, Profile.getCurrentProfile().getId()); AddResponseTask task = new AddResponseTask(friendId, friendName); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.kytse.aria2remote.DownloadListFragment.java
@Override public void onResume() { super.onResume(); mAria2.addListener(this); mSwipeRefreshLayout.post(new Runnable() { @Override/*from w w w . j ava 2 s. com*/ public void run() { mSwipeRefreshLayout.setRefreshing(true); onRefresh(); } }); mGetDownloadListAsyncTask = new GetDownloadListAsyncTask(); mGetDownloadListAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:org.strongswan.android.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); super.onCreate(savedInstanceState); setContentView(R.layout.main);/*w w w .java 2 s . co m*/ ActionBar bar = getSupportActionBar(); bar.setDisplayShowHomeEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setIcon(R.drawable.ic_launcher); this.bindService(new Intent(this, VpnStateService.class), mServiceConnection, Service.BIND_AUTO_CREATE); /* load CA certificates in a background task */ new LoadCertificatesTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }