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.reicast.emulator.debug.About.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about_fragment); handler = new Handler(); Bundle extras = getIntent().getExtras(); if (extras != null) { buildId = extras.getString("hashtag"); }//from w w w . j a va 2 s .com try { String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; int versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode; TextView version = (TextView) findViewById(R.id.revision_text); String revision = getString(R.string.revision_text, versionName, String.valueOf(versionCode)); if (!buildId.equals("")) { String ident = buildId.substring(0, 7); if (Config.isCustom) { ident = "LK-" + ident; } revision = getString(R.string.revision_text, versionName, ident); } version.setText(revision); } catch (NameNotFoundException e) { e.printStackTrace(); } slidingGithub = (SlidingDrawer) findViewById(R.id.slidingGithub); slidingGithub.setOnDrawerOpenListener(new OnDrawerOpenListener() { @TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onDrawerOpened() { retrieveGitTask queryGithub = new retrieveGitTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { queryGithub.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, Config.git_api); } else { queryGithub.execute(Config.git_api); } } }); slidingGithub.open(); }
From source file:com.prey.activities.InitActivity.java
public void onboardingCompleted() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) new OnboardingCompletedTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); else/*from www .j a va2s . c om*/ new OnboardingCompletedTask().execute(); }
From source file:eu.power_switch.gui.adapter.RoomRecyclerViewAdapter.java
@Override public void onBindViewHolder(final RoomRecyclerViewAdapter.ViewHolder holder, int position) { // Get the data model based on position final Room room = rooms.get(holder.getAdapterPosition()); // Set item views based on the data model holder.roomName.setText(room.getName()); final LinearLayout linearLayout = holder.linearLayoutOfReceivers; holder.roomName.setOnClickListener(new View.OnClickListener() { @Override//w w w . j a va 2 s .c o m public void onClick(View v) { if (linearLayout.getVisibility() == View.VISIBLE) { room.setCollapsed(true); linearLayout.setVisibility(View.GONE); } else { room.setCollapsed(false); linearLayout.setVisibility(View.VISIBLE); } } }); holder.roomName.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { EditRoomDialog editRoomDialog = EditRoomDialog.newInstance(room.getId()); editRoomDialog.setTargetFragment(recyclerViewFragment, 0); editRoomDialog.show(fragmentActivity.getSupportFragmentManager(), null); return true; } }); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) { VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration()); } android.widget.Button buttonView = (android.widget.Button) v; String buttonName = buttonView.getText().toString(); new AsyncTask<String, Void, Void>() { @Override protected Void doInBackground(String... buttonNames) { try { String buttonName = buttonNames[0]; // send signal ActionHandler.execute(fragmentActivity, room, buttonName); } catch (Exception e) { } return null; } @Override protected void onPostExecute(Void aVoid) { updateReceiverViews(holder, room); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, buttonName); } }; holder.buttonAllOn.setOnClickListener(onClickListener); holder.buttonAllOff.setOnClickListener(onClickListener); if (!SmartphonePreferencesHandler.getShowRoomAllOnOff()) { holder.buttonAllOn.setVisibility(View.GONE); holder.buttonAllOff.setVisibility(View.GONE); } else { holder.buttonAllOn.setVisibility(View.VISIBLE); holder.buttonAllOff.setVisibility(View.VISIBLE); } updateReceiverViews(holder, room); // collapse room if (room.isCollapsed()) { linearLayout.setVisibility(View.GONE); } else { linearLayout.setVisibility(View.VISIBLE); } if (holder.getAdapterPosition() == getItemCount() - 1) { holder.footer.setVisibility(View.VISIBLE); } else { holder.footer.setVisibility(View.GONE); } }
From source file:com.android.calculator2.BitmapTask.java
@SuppressLint("NewApi") public void executeAsync(Void... args) { boolean pullFromOnline = true; System.out.println("I'm in async with url: " + mURL); Bitmap bitmap = loadMemCache(mURL);//from www . j a va 2s. c om if (bitmap != null) { mImageView.setImageBitmap(bitmap); pullFromOnline = false; } else { bitmap = loadCache(mImageView.getContext(), mURL); if (bitmap != null) { mImageView.setImageBitmap(bitmap); System.out.println("I have loaded the bitmap"); Log.d(TAG, "Saving bitmap to memory."); LOADED_BITMAPS.put(mURL, bitmap); } } if (pullFromOnline) { if (android.os.Build.VERSION.SDK_INT < 11) { execute(args); } else { executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args); } } }
From source file:de.knufficast.ui.main.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_add_feed: addFeedClicked();/*from w w w . j a v a 2 s .c om*/ return true; case R.id.menu_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.menu_refresh_feeds: // hack to pass an unused argument... one null doesn't work :D new ToastRefresherTask(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null, null); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.gelakinetic.mtgfam.helpers.lruCache.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. *//*ww w . j a v a2 s.com*/ 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)) { //BEGIN_INCLUDE(execute_background_task) 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); //END_INCLUDE(execute_background_task) } }
From source file:org.dbhatt.d_deleted_contact.MainActivity.java
private void load_contacts() { contentResolver = getContentResolver(); if (!refreshing) new Update_lists().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.docd.purefm.ui.activities.SearchActivity.java
private void onSearchClicked() { final String text = mInput.getText().toString().trim(); if (text.isEmpty()) { return;/*from w ww . j av a2 s . c o m*/ } if (mSearchTask != null && mSearchTask.getStatus() == AsyncTask.Status.RUNNING) { mSearchTask.cancel(true); } mAdapter.updateData(new GenericFile[0]); mSearchTask = AbstractSearchTask.create(this, mStartDirectory, this); mSearchTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, text); }
From source file:com.example.gemswin.screencastrecevertest.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 .j ava 2 s. co m*/ mTextureView.invalidate(); mTextureView.setOpaque(false); logout = (Button) findViewById(R.id.logout); cast = (Button) findViewById(R.id.castAsmaster); doubtbutton = (Button) findViewById(R.id.doubt); viewbutton = (Button) findViewById(R.id.viewdoubt); pref = new PrefManager(getApplicationContext()); text.setText(ip); logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pref.logout(); Intent i = new Intent(MainActivity_Reciever.this, LoginActivity.class); startActivity(i); finish(); } }); cast.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new allowcast().execute(); } }); viewbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ new viewdoubttask().execute(); } }); doubtbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //pref.logout(); // LOOK HERE ASH /*Intent i = new Intent(MainActivity_Reciever.this,DoubtActivity.class); startActivity(i);*/ DoubtBox(); } }); mTask = new ReceiverAsyncTask(this); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); Intent intent1 = new Intent(this, MyBroadcastReceiver.class); intent1.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 234324243, intent1, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (10 * 1000), pendingIntent); }
From source file:be.kuleuven.noiseapp.auth.AbstractGetInfoTask.java
private void saveUserProfileServer(UserDetails userDetails) { new CreateUserProfileTask(mActivity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, userDetails); }