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:de.enlightened.peris.ProfileFragment.java
@Override public void onStart() { super.onStart(); final Bundle bundle = getArguments(); this.userId = bundle.getString("userid"); this.userName = bundle.getString("username"); this.setupElements(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { new DownloadProfileTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new String[] { this.userId, this.userName }); } else {/*from w w w .j av a 2 s .co m*/ new DownloadProfileTask().execute(new String[] { this.userId, this.userName }); } }
From source file:org.jboss.aerogear.android.cookbook.aerodoc.authentication.AeroDocAuthenticationModule.java
@Override public void login(final Map<String, String> loginData, final Callback<HeaderAndBody> callback) { AsyncTask<Void, Void, HeaderAndBody> task = new AsyncTask<Void, Void, HeaderAndBody>() { private Exception exception = null; @Override/*ww w. j av a2 s .c o m*/ protected HeaderAndBody doInBackground(Void... params) { try { URL loginURL = UrlUtils.appendToBaseURL(baseURL, getLoginEndpoint()); HttpProvider provider = new HttpRestProvider(loginURL); String loginRequest = new JSONObject(loginData).toString(); HeaderAndBody result = provider.post(loginRequest); isLoggedIn = true; return result; } catch (Exception e) { Log.e(TAG, e.getMessage(), e); exception = e; return null; } } @Override protected void onPostExecute(HeaderAndBody headerAndBody) { if (exception == null) { callback.onSuccess(headerAndBody); } else { callback.onFailure(exception); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.cooperok.socialuser.vk.VkAccount.java
@Override public void postImage(Bitmap image, PostImageCallback callback) { new PostImageLoader().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new ShareImageObject(image, callback)); }
From source file:com.giovanniterlingen.windesheim.view.Fragments.ChooseScheduleFragment.java
private void startTask() { if (componentFetcher != null) { if (componentFetcher.getStatus() == AsyncTask.Status.RUNNING || componentFetcher.getStatus() == AsyncTask.Status.PENDING) { componentFetcher.cancel(true); }/*from w ww . j ava 2s. c o m*/ } if (isMenuVisible()) { (componentFetcher = new ComponentFetcher()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { if (adapter != null) { adapter = null; } if (recyclerView != null) { recyclerView.setAdapter(null); } } }
From source file:com.fastbootmobile.encore.app.fragments.SongsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View root = inflater.inflate(R.layout.fragment_songs, container, false); assert root != null; mListView = (ListView) root.findViewById(R.id.songsList); mListView.setFastScrollEnabled(true); mSongsListAdapter = new SongsListAdapter(true); new GetAllSongsTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); mListView.setOnItemClickListener(mItemClickListener); return root;/* w w w.ja v a2 s.co m*/ }
From source file:fr.simon.marquis.preferencesmanager.ui.AppListActivity.java
private void checkRoot() { AsyncTask<Void, Void, Boolean> checking = new AsyncTask<Void, Void, Boolean>() { @Override/*ww w . j a va2 s.co m*/ protected Boolean doInBackground(Void... params) { return RootTools.isRootAvailable() && RootTools.isAccessGiven() && RootTools.isBusyboxAvailable(); } @Override protected void onPostExecute(Boolean hasRoot) { super.onPostExecute(hasRoot); isRootAccessGiven = hasRoot; if (!hasRoot) { Utils.displayNoRoot(getFragmentManager()); } } }; checking.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); }
From source file:com.example.android.leanback.PlaybackSeekAsyncDataProvider.java
@Override public void getThumbnail(int index, ResultCallback callback) { Integer key = index;/* w w w . ja va2 s. com*/ Bitmap bitmap = mCache.get(key); if (bitmap != null) { callback.onThumbnailLoaded(bitmap, index); } else { bitmap = mPrefetchCache.get(key); if (bitmap != null) { mCache.put(key, bitmap); mPrefetchCache.remove(key); callback.onThumbnailLoaded(bitmap, index); } else { LoadBitmapTask task = mRequests.get(index); if (task == null || task.isCancelled()) { // no normal task or prefetch for the position, create a new task task = new LoadBitmapTask(index, callback); mRequests.put(index, task); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { // update existing ResultCallback which might be normal task or prefetch task.mResultCallback = callback; } } } if (mLastRequestedIndex != index) { if (mLastRequestedIndex != -1) { prefetch(mLastRequestedIndex, index > mLastRequestedIndex); } mLastRequestedIndex = index; } }
From source file:com.gigathinking.simpleapplock.AppLaunchDetectorService.java
@Override public void onCreate() { super.onCreate(); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mAppListData = new AppListData(getApplicationContext()); mAppListData.init();//from ww w . j av a 2 s . c o m updateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (!mList.isEmpty()) { mList.clear(); } if (!mAppMap.isEmpty()) { mAppMap.clear(); } Cursor cursor = mAppListData.getAppListInfo(); int count = cursor.getCount(); for (int i = 0; i < count; ++i) { cursor.moveToPosition(i); mList.add(cursor.getString(2)); mAppMap.put(cursor.getString(2), Boolean.valueOf(cursor.getString(3))); mLastOpen.put(cursor.getString(2), cursor.getInt(4)); } } }; mList = new ArrayList<String>(); mAppMap = new HashMap<String, Boolean>(); mLastOpen = new HashMap<String, Integer>(); Cursor cursor = mAppListData.getAppListInfo(); int count = cursor.getCount(); for (int i = 0; i < count; ++i) { cursor.moveToPosition(i); mList.add(cursor.getString(2)); mAppMap.put(cursor.getString(2), Boolean.valueOf(cursor.getString(3))); mLastOpen.put(cursor.getString(2), cursor.getInt(4)); } cursor.close(); LocalBroadcastManager.getInstance(this).registerReceiver(updateReceiver, new IntentFilter(AppLockApplication.UPDATE_LIST)); new DetectAppLaunch().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.example.splashanimationtest.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(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 .j a v a2 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(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, data); } }
From source file:net.saga.aeroconf.app.ui.fragment.ScheduleFragment.java
@Override public void onResume() { super.onResume(); resolver.registerContentObserver(ConfContract.ScheduleContract.URI, false, observer); calendarLoaderTask = new AsyncTask<Void, Void, List<Schedule>>() { @Override//w w w . j a v a 2 s . c om protected synchronized List<Schedule> doInBackground(Void... params) { List<Schedule> toReturn = new ArrayList<Schedule>(); Cursor cursor = null; try { cursor = getActivity().getContentResolver().query(ConfContract.ScheduleContract.URI, null, null, null, null); while (cursor != null && cursor.moveToNext()) { toReturn.add(GsonUtils.GSON.fromJson(cursor.getString(0), Schedule.class)); } return toReturn; } finally { if (cursor != null) { cursor.close(); } } } @Override protected synchronized void onPostExecute(List<Schedule> userCalendars) { if (!super.isCancelled()) { dataUpdated(userCalendars); } } }; if (calendar == null || calendar.size() < 3) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) calendarLoaderTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); else calendarLoaderTask.execute(); } }