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:fr.simon.marquis.preferencesmanager.ui.PreferencesFragment.java
private void launchTask() { ParsingTask task = new ParsingTask(mFile); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:joshuatee.wx.SPCMesoActivity.java
protected void onRestart() { new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); super.onRestart(); }
From source file:org.jboss.aerogear.android.cookbook.aerodoc.authentication.AeroDocAuthenticationModule.java
@Override public void logout(final Callback<Void> callback) { AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { private Exception exception = null; @Override//from www .j a va 2 s .c o m protected Void doInBackground(Void... params) { try { URL logoutURL = UrlUtils.appendToBaseURL(baseURL, getLogoutEndpoint()); HttpProvider provider = new HttpRestProvider(logoutURL); provider.post(""); isLoggedIn = false; } catch (Exception e) { Log.e(TAG, e.getMessage(), e); exception = e; } return null; } @Override protected void onPostExecute(Void ignore) { if (exception == null) { callback.onSuccess(null); } else { callback.onFailure(exception); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:net.yolosec.upckeygen.ui.NetworkFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (passwordList == null) { if (thread.getStatus() == Status.FINISHED || thread.getStatus() == Status.RUNNING) thread = new KeygenThread(wifiNetwork); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { thread.execute();// w w w . j a v a2 s . c om } else { thread.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } }
From source file:fr.simon.marquis.preferencesmanager.ui.AppListActivity.java
/** * @return true if a new task is started *//*from ww w . ja va 2s.c o m*/ private boolean startTask() { if (task == null || task.isCancelled()) { task = new GetApplicationsTask(this); task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null); return true; } return false; }
From source file:com.dm.wallpaper.board.activities.WallpaperBoardSplashActivity.java
private void checkRszIo() { mCheckRszIo = new AsyncTask<Void, Void, Boolean>() { final String rszio = "https://rsz.io/"; @Override//from ww w.j ava2s. c om protected Boolean doInBackground(Void... voids) { while ((!isCancelled())) { try { Thread.sleep(1); URL url = new URL(rszio); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setReadTimeout(6000); connection.setConnectTimeout(6000); int code = connection.getResponseCode(); return code == 200; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); mCheckRszIo = null; WallpaperBoardActivity.sRszIoAvailable = aBoolean; LogUtil.e("rsz.io availability: " + WallpaperBoardActivity.sRszIoAvailable); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.bt.heliniumstudentapp.LoginActivity.java
private void refresh() { if (MainActivity.isOnline()) { if (usernameET.length() != 0 || passwordET.length() != 0) { ((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)) .hideSoftInputFromWindow(getWindow().getDecorView().getRootView().getWindowToken(), 0); PreferenceManager.getDefaultSharedPreferences(LoginActivity.this).edit() .putString("username", usernameET.getEditableText().toString()).apply(); PreferenceManager.getDefaultSharedPreferences(LoginActivity.this).edit() .putString("password", passwordET.getEditableText().toString()).apply(); authenticationProgressDialog = new ProgressDialog( new ContextThemeWrapper(LoginActivity.this, MainActivity.themeDialog)); authenticationProgressDialog.setCancelable(false); authenticationProgressDialog.setMessage(getString(R.string.authenticating)); authenticationProgressDialog.show(); new MainActivity.GetLoginCookie().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, HeliniumStudentApp.VIEW_LOGIN); }/*from ww w.jav a 2s.c o m*/ } else { if (!MainActivity.displayingSnackbar) { final Snackbar noConnectionSB = Snackbar .make(findViewById(R.id.cl_snackbar_al), R.string.error_conn_no, Snackbar.LENGTH_LONG) .setAction(R.string.retry, new View.OnClickListener() { @Override public void onClick(View v) { refresh(); } }); noConnectionSB.getView().addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { MainActivity.displayingSnackbar = true; } @Override public void onViewDetachedFromWindow(View v) { MainActivity.displayingSnackbar = false; } }); noConnectionSB.show(); } } }
From source file:eu.power_switch.gui.adapter.SceneRecyclerViewAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final Scene scene = scenes.get(holder.getAdapterPosition()); String inflaterString = Context.LAYOUT_INFLATER_SERVICE; LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString); holder.sceneName.setText(scene.getName()); holder.sceneName.setOnClickListener(new View.OnClickListener() { @Override//from w ww .j a v a2 s.c o m public void onClick(View v) { if (holder.linearLayoutSceneItems.getVisibility() == View.VISIBLE) { holder.linearLayoutSceneItems.setVisibility(View.GONE); } else { holder.linearLayoutSceneItems.setVisibility(View.VISIBLE); } } }); holder.sceneName.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (onItemLongClickListener != null) { onItemLongClickListener.onItemLongClick(v, holder.getAdapterPosition()); } return true; } }); holder.buttonActivateScene.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) { VibrationHandler.vibrate(fragmentActivity, SmartphonePreferencesHandler.getVibrationDuration()); } new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { ActionHandler.execute(fragmentActivity, scene); return null; } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); // clear previous items holder.linearLayoutSceneItems.removeAllViews(); // hide setup by default holder.linearLayoutSceneItems.setVisibility(View.GONE); // add current setup for (final SceneItem sceneItem : scene.getSceneItems()) { // create a new receiverRow for our current receiver and add it // to our table of all devices of our current room // the row will contain the device name and all buttons LinearLayout receiverRow = new LinearLayout(fragmentActivity); receiverRow.setOrientation(LinearLayout.HORIZONTAL); holder.linearLayoutSceneItems.addView(receiverRow); // setup TextView to display receiver name AppCompatTextView receiverName = new AppCompatTextView(fragmentActivity); receiverName.setText(sceneItem.getReceiver().getName()); receiverName.setTextSize(18); receiverName .setTextColor(ThemeHelper.getThemeAttrColor(fragmentActivity, android.R.attr.textColorPrimary)); receiverName.setGravity(Gravity.CENTER_VERTICAL); receiverRow.addView(receiverName, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1.0f)); TableLayout buttonLayout = new TableLayout(fragmentActivity); receiverRow.addView(buttonLayout, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); int buttonsPerRow; if (sceneItem.getReceiver().getButtons().size() % 3 == 0) { buttonsPerRow = 3; } else { buttonsPerRow = 2; } int i = 0; TableRow buttonRow = null; for (final Button button : sceneItem.getReceiver().getButtons()) { final android.widget.Button buttonView = (android.widget.Button) inflater .inflate(R.layout.simple_button, buttonRow, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { buttonView.setElevation(0); buttonView.setStateListAnimator(null); } buttonView.setText(button.getName()); buttonView.setEnabled(false); final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent); final int inactiveColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.textColorInactive); if (sceneItem.getActiveButton().equals(button)) { buttonView.setTextColor(accentColor); } else { buttonView.setTextColor(inactiveColor); } if (i == 0 || i % buttonsPerRow == 0) { buttonRow = new TableRow(fragmentActivity); buttonRow.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); buttonRow.addView(buttonView); buttonLayout.addView(buttonRow); } else { buttonRow.addView(buttonView); } i++; } } if (holder.getAdapterPosition() == getItemCount() - 1) { holder.footer.setVisibility(View.VISIBLE); } else { holder.footer.setVisibility(View.GONE); } }
From source file:com.appsimobile.paintjob.PaintJob.java
private void loadBitmap(final BitmapSource bitmapSource) { mLoadTask = new AsyncTask<BitmapSource, Void, Bitmap>() { @Override//from w w w. ja va 2s . c o m protected Bitmap doInBackground(BitmapSource... params) { BitmapSource bitmapSource = params[0]; return bitmapSource.loadBitmapAsync(); } @Override protected void onPostExecute(Bitmap bitmap) { onBitmapLoaded(bitmap, false /* immediate */); } }; mLoadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new BitmapSource[] { bitmapSource }); }
From source file:com.giovanniterlingen.windesheim.view.Fragments.ScheduleFragment.java
@Override public void setUserVisibleHint(boolean isVisibleToUser) { if (isVisible()) { if (!DatabaseController.getInstance().isFetched(date)) { new ScheduleFetcher(true, true, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {//ww w . ja va 2 s. co m new ScheduleFetcher(false, false, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } }