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.cn21.speedtest.service.LogService.java
private void startLogReader() { mLogBuffer = new LinkedList<LogLine>(); mLogBufferFiltered = new LinkedList<LogLine>(); mLogReaderTask = new LogReaderAsyncTask() { @Override/*from ww w. j ava2s. c om*/ 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(LogService.this) .sendBroadcast(new Intent(ACTION_ROOT_FAILED)); // enable 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.dmitrymalkovich.android.popularmoviesapp.details.MovieDetailFragment.java
private void fetchReviews() { FetchReviewsTask task = new FetchReviewsTask(this); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mMovie.getId()); }
From source file:com.dm.material.dashboard.candybar.fragments.ApplyFragment.java
private void getLaunchers() { mGetLaunchers = new AsyncTask<Void, Void, Boolean>() { List<Icon> launchers; @Override// ww w .ja v a2 s. c o m protected void onPreExecute() { super.onPreExecute(); launchers = new ArrayList<>(); } @Override protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); String[] launcherNames = getActivity().getResources() .getStringArray(R.array.launcher_names); TypedArray launcherIcons = getActivity().getResources() .obtainTypedArray(R.array.launcher_icons); String[] launcherPackages1 = getActivity().getResources() .getStringArray(R.array.launcher_packages_1); String[] launcherPackages2 = getActivity().getResources() .getStringArray(R.array.launcher_packages_2); String[] launcherPackages3 = getActivity().getResources() .getStringArray(R.array.launcher_packages_3); List<Icon> installed = new ArrayList<>(); List<Icon> supported = new ArrayList<>(); for (int i = 0; i < launcherNames.length; i++) { boolean isInstalled = isLauncherInstalled(launcherPackages1[i], launcherPackages2[i], launcherPackages3[i]); int icon = R.drawable.ic_app_default; if (i < launcherIcons.length()) icon = launcherIcons.getResourceId(i, icon); String launcherPackage = launcherPackages1[i]; if (launcherPackages1[i].equals("com.lge.launcher2")) { boolean lghome3 = isPackageInstalled(launcherPackages2[i]); if (lghome3) launcherPackage = launcherPackages2[i]; } Icon launcher = new Icon(launcherNames[i], icon, launcherPackage); if (isInstalled) installed.add(launcher); else supported.add(launcher); } try { Collections.sort(installed, new AlphanumComparator() { @Override public int compare(Object o1, Object o2) { String s1 = ((Icon) o1).getTitle(); String s2 = ((Icon) o2).getTitle(); return super.compare(s1, s2); } }); } catch (Exception ignored) { } try { Collections.sort(supported, new AlphanumComparator() { @Override public int compare(Object o1, Object o2) { String s1 = ((Icon) o1).getTitle(); String s2 = ((Icon) o2).getTitle(); return super.compare(s1, s2); } }); } catch (Exception ignored) { } if (installed.size() > 0) { launchers.add(new Icon(getActivity().getResources().getString(R.string.apply_installed), -1, null)); } launchers.addAll(installed); launchers.add(new Icon(getActivity().getResources().getString(R.string.apply_supported), -2, null)); launchers.addAll(supported); launcherIcons.recycle(); return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); if (aBoolean) { mRecyclerView.setAdapter(new LauncherAdapter(getActivity(), launchers)); resetSpanSizeLookUp(); } mGetLaunchers = null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.tagaugmentedreality.utilties.LocationRetriever.java
@SuppressLint("NewApi") @Override//from www .ja v a2s . com public void onLocationChanged(Location mCurrentLocation) { // TODO Auto-generated method stub latitude = mCurrentLocation.getLatitude(); longitude = mCurrentLocation.getLongitude(); //Toast.makeText(this.context,"updated "+latitude.toString()+" "+longitude.toString()+" "+mCurrentLocation.getAccuracy(), 1000).show(); Log.e("updated", latitude.toString() + " " + longitude.toString() + " " + mCurrentLocation.getProvider() + " " + mCurrentLocation.getAccuracy()); int numberOfInstaces = listenerInstance.size(), k = 0; for (k = 0; k < numberOfInstaces; k++) { if (instanceIdentifier.get(k).equalsIgnoreCase("TL")) {//the tags list has been downloaded, so send it to the TagsList class Log.e("tagAR", "TL"); listenerInstance.get(k).latitudeLongitudeReady(latitude, longitude); } //end if else { Log.e("tagAR ", "not TL"); } //end else } //end for if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { new GetAddressTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } //end if else { new GetAddressTask().execute(); } //end else }
From source file:at.flack.MainActivity.java
public void emailLogin(int save) { new EmailProfileTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, save, 0, 12); }
From source file:com.orbar.pxdemo.ImageView.FivePXImageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "onCreateView"); final View rootView = inflater.inflate(R.layout.fragment_five_px_image, container, false); getReusableViews(rootView);/*from w w w .j a v a2 s. c om*/ // Set the attributes for the custom ActionBar actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowCustomEnabled(true); actionBar.setDisplayShowTitleEnabled(false); // Set the placeholder until download finishes. actionBar.setIcon(R.drawable.ic_launcher); // get the ImageBean that was clicked Bundle bundle = this.getArguments(); mFiveZeroZeroImageBean = (FiveZeroZeroImageBean) bundle.getParcelable(ARG_IMAGE_BEAN); // Inflate the custom action bar layout LayoutInflater inflator = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View actionView = inflator.inflate(R.layout.actionbar_five_px_image, null); // set the title and user name in the action bar TextView imageTitle = (TextView) actionView.findViewById(R.id.image_title); TextView imageuserName = (TextView) actionView.findViewById(R.id.image_username); imageTitle.setText(mFiveZeroZeroImageBean.getName()); imageuserName.setText(mFiveZeroZeroImageBean.getUserBean().getUserName()); actionBar.setCustomView(actionView); // get reference to userAccountLayout in the action bar userAccountLayout = (RelativeLayout) actionView.findViewById(R.id.image_account_layout); // Download the user image in Extra Small size. No Picasso for this image. mDownloadUserImage = new DownloadUserImage(); mDownloadUserImage.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mFiveZeroZeroImageBean.getUserBean().getUserpicURL(USER_IMAGE_SIZE.LARGE)); // Setup the Sliding Panel layout mSlidingPaneLayout.setShadowDrawable(getResources().getDrawable(R.drawable.above_shadow)); mSlidingPaneLayout.setAnchorPoint(0.2f); mSlidingPaneLayout.setDragView(imageControlsLayout); mSlidingPaneLayout.setEnableDragViewTouchEvents(true); // Download the Image and put it into a zoom-able and pan-able imageview. ImageView mImageView = (ImageView) rootView.findViewById(R.id.image); // The MAGIC happens here! mAttacher = new PhotoViewAttacher(mImageView); Picasso.with(getActivity()) // .load(mFiveZeroZeroImageBean.getImageUrl(IMAGE_SIZE.ORIGINAL)) //.placeholder(image.getDrawable()) // Use the smaller image while downloading the higher resolution image .error(android.R.drawable.stat_notify_error) // The error image .into(mImageView, new Callback() { @Override public void onError() { } // When finished loading, update the attacher @Override public void onSuccess() { mAttacher.update(); } }); //mAttacher.setOnPhotoTapListener(new PhotoTapListener()); // Setup the comments ListView mCommentsAdapter = new CommentsAdapter(getActivity(), mFiveZeroZeroImageBean.getCommentBeans()); commentsListView.setAdapter(mCommentsAdapter); // set the comment count imageComments.setText(Integer.toString(mFiveZeroZeroImageBean.getCommentsCount())); imageLikes.setText(Integer.toString(mFiveZeroZeroImageBean.getVotesCount())); imageFavorites.setText(Integer.toString(mFiveZeroZeroImageBean.getFavoritesCount())); // get the last page number (we want to add pages in reverse order (newest first) pageNumber.set((int) Math.ceil(mFiveZeroZeroImageBean.getCommentsCount() / 20.0)); mFiveZeroZeroImageAPIBuilder = new FiveZeroZeroImageAPIBuilder().setPageNum(pageNumber.get()); mLoadCommentsList = new LoadCommentsList(getActivity(), mFiveZeroZeroImageAPIBuilder, mLoginManager, mFiveZeroZeroImageBean, loadingMore, stopLoadingData, pageNumber); mLoadCommentsList.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); mLoadImageDetailsList = new LoadImageDetailsList(getActivity(), mFiveZeroZeroImageAPIBuilder, mLoginManager, mFiveZeroZeroImageBean); mLoadImageDetailsList.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); return rootView; }
From source file:com.dm.wallpaper.board.fragments.CategoryWallpapersFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { getActivity().finish();/*from w w w .j av a 2s.co m*/ getActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); return true; } else if (id == R.id.menu_sort) { View menuSort = mToolbar.findViewById(R.id.menu_sort); if (menuSort == null) return false; Popup.Builder(getActivity()).to(menuSort).list(PopupItem.getSortItems(getActivity(), false)) .callback((popup, position) -> { popup.dismiss(); mSearchView.clearFocus(); if (mAsyncTask != null) return; mAsyncTask = new WallpapersSortLoader(popup.getItems().get(position).getType()) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }).show(); return true; } return super.onOptionsItemSelected(item); }
From source file:passenger.view.activity.LoginActivity.java
protected void loginDaChe() { new LoadNickName().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, paidanyuan); }
From source file:com.purdue.CampusFeed.Utils.ImageLoader.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageLoader#processBitmap(Object)} to define the processing logic). 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. */// ww w . java 2s .c o m public void loadImage(Object data, ImageView imageView) { if (data == null) { imageView.setImageBitmap(mLoadingBitmap); return; } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache imageView.setImageBitmap(bitmap); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, data); } }
From source file:joshuatee.wx.LocationFragment.java
public void refresh_dynamic_content() { tv_sunrise.setText(""); tv_sunrise.setVisibility(View.GONE); seven_day_ext_shown = false;/*from w w w.ja v a 2 s .c o m*/ new GetForecast().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); if (loc_display_img_current.startsWith("t") && simple_mode_current.startsWith("f")) { new GetRadar().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } long current_time = System.currentTimeMillis(); last_refresh = current_time / 1000; editor.putLong("LOC_LAST_UPDATE", last_refresh); editor.commit(); }