Example usage for android.os AsyncTask THREAD_POOL_EXECUTOR

List of usage examples for android.os AsyncTask THREAD_POOL_EXECUTOR

Introduction

In this page you can find the example usage for android.os AsyncTask THREAD_POOL_EXECUTOR.

Prototype

Executor THREAD_POOL_EXECUTOR

To view the source code for android.os AsyncTask THREAD_POOL_EXECUTOR.

Click Source Link

Document

An Executor that can be used to execute tasks in parallel.

Usage

From source file:com.lovejoy777sarootool.rootool.dialogs.UnpackDialog.java

@Override
public Dialog onCreateDialog(Bundle state) {
    final Activity a = getActivity();

    // Set an EditText view to get user input
    final EditText inputf = new EditText(a);
    inputf.setHint(R.string.enter_name);
    inputf.setText(BrowserActivity.getCurrentlyDisplayedFragment().mCurrentPath + "/");

    final AlertDialog.Builder b = new AlertDialog.Builder(a);
    b.setTitle(R.string.extractto);//from   w  w w .  j  a  va2s  .c  o  m
    b.setView(inputf);
    b.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            String newpath = inputf.getText().toString();

            dialog.dismiss();

            if (ext.equals("zip")) {
                final UnZipTask task = new UnZipTask(a);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath);
            } else if (ext.equals("rar")) {
                final UnRarTask task = new UnRarTask(a);
                task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, file.getPath(), newpath);
            }
        }
    });
    b.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    return b.create();
}

From source file:org.piwik.sdk.TrackerBulkURLProcessor.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static <T> void executeAsyncTask(AsyncTask<T, ?, ?> task, T... params) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, params);
    } else {//from  w  ww . ja va 2s . c  o m
        task.execute(params);
    }
}

From source file:com.intel.iotkitlib.http.HttpDeleteTask.java

public CloudResponse doAsync(final String url, final HttpTaskHandler taskHandler) {
    asyncTask = new AsyncTask<String, Void, CloudResponse>() {
        @Override//from  w  w  w. j  a v a  2s  .  c om
        protected CloudResponse doInBackground(String... urls) {
            return doSync(urls[0]);
        }

        protected void onPostExecute(CloudResponse response) {
            // Done on UI Thread
            if (response != null && taskHandler != null) {
                taskHandler.taskResponse(response.code, response.response);
            }
        }
    };
    asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, url);
    return new CloudResponse(true, "Successful execute " + url);
}

From source file:com.commonsware.android.fileseditor.EditorFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (!loaded) {
        loadTask = new LoadTextTask();
        loadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                (File) getArguments().getSerializable(KEY_FILE));
    }//from w  w w  .j  a v  a 2s  .c om
}

From source file:com.plusub.lib.service.BaseRequestService.java

/**<TaskId, RequestLink>,id*/
//   public static final Map<Integer, RequestEntity> RequestMap = new HashMap<Integer, RequestEntity>();
//   private RequestManager requestManager;

@SuppressLint("NewApi")
@Override/*from  www  .  j  a  v a 2s .  co m*/
public void onCreate() {
    // TODO Auto-generated method stub
    super.onCreate();
    isrun = true;
    //      requestManager = new RequestManager();
    //      addTaskToMap();

    if (Build.VERSION.SDK_INT >= 11) {
        new ServiceTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        new ServiceTask().execute();
    }

    if (BuildConfig.DEBUG) {
        Logger.init(getClass().getSimpleName()).setLogLevel(LogLevel.FULL).hideThreadInfo();
    } else {
        Logger.init(getClass().getSimpleName()).setLogLevel(LogLevel.NONE).hideThreadInfo();
    }
}

From source file:com.adityarathi.muo.services.BuildMusicLibraryService.java

@Override
public int onStartCommand(Intent intent, int startId, int flags) {

    //Create a persistent notification that keeps this service running and displays the scan progress.
    mBuilder = new NotificationCompat.Builder(mContext);
    mBuilder.setSmallIcon(R.mipmap.ic_launcher);
    mBuilder.setContentTitle(getResources().getString(R.string.building_music_library));
    mBuilder.setTicker(getResources().getString(R.string.building_music_library));
    mBuilder.setContentText("");
    mBuilder.setProgress(0, 0, true);/*from  w ww  .  j av  a 2  s.  com*/

    mNotifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotification = mBuilder.build();
    mNotification.flags |= Notification.FLAG_INSISTENT | Notification.FLAG_NO_CLEAR;

    startForeground(mNotificationId, mNotification);

    //Go crazy with a full-on scan.
    AsyncBuildLibraryTask task = new AsyncBuildLibraryTask(mContext, this);
    task.setOnBuildLibraryProgressUpdate(WelcomeActivity.mBuildingLibraryProgressFragment);
    task.setOnBuildLibraryProgressUpdate(this);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    return START_STICKY;
}

From source file:com.aniruddhc.acemusic.player.Services.BuildMusicLibraryService.java

@Override
public int onStartCommand(Intent intent, int startId, int flags) {

    //Create a persistent notification that keeps this service running and displays the scan progress.
    mBuilder = new NotificationCompat.Builder(mContext);
    mBuilder.setSmallIcon(R.drawable.notif_icon);
    mBuilder.setContentTitle(getResources().getString(R.string.building_music_library));
    mBuilder.setTicker(getResources().getString(R.string.building_music_library));
    mBuilder.setContentText("");
    mBuilder.setProgress(0, 0, true);//  ww w . j a  v a 2  s . c  o  m

    mNotifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
    mNotification = mBuilder.build();
    mNotification.flags |= Notification.FLAG_INSISTENT | Notification.FLAG_NO_CLEAR;

    startForeground(mNotificationId, mNotification);

    //Go crazy with a full-on scan.
    AsyncBuildLibraryTask task = new AsyncBuildLibraryTask(mContext, this);
    task.setOnBuildLibraryProgressUpdate(WelcomeActivity.mBuildingLibraryProgressFragment);
    task.setOnBuildLibraryProgressUpdate(this);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

    return START_STICKY;
}

From source file:paarmann.physikprofil.HomeworkUpdater.java

/**
 * Create a new {@code AsyncTask} for downloading the homework and returning it.
 *///from w w  w  . j av a 2  s . c  o m
public void downloadHomework() {
    Log.i(TAG, "Downloading homework");
    DownloadTask task = new DownloadTask();
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
}

From source file:com.swisscom.safeconnect.backend.PlumberTask.java

/**
 * Used to run the AsyncTasks in a ThreadPool. Otherwise all AsyncTasks will be exectued sequentially,
 * this sometimes resulted in problems when a previous task did not finish (in time).
 *
 * @param taskCallback/*  w  w  w  . ja  v  a  2 s  .  co m*/
 */
public void execute(InternalCallback taskCallback) {
    super.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, taskCallback);
}

From source file:it.feio.android.simplegallery.GalleryPagerFragment.java

@Override
@SuppressLint("NewApi")
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    TouchImageView rootView = new TouchImageView(getActivity());
    Point dimensions = Display.getUsableSize(getActivity());
    if (Build.VERSION.SDK_INT >= 11) {
        new ImageLoadTask(getActivity(), rootView, dimensions.x, dimensions.y)
                .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, mImagePath);
    } else {/*  www  . j ava 2 s  .com*/
        new ImageLoadTask(getActivity(), rootView, dimensions.x, dimensions.y).execute(mImagePath);
    }

    return rootView;
}