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.dm.material.dashboard.candybar.activities.CandyBarSplashActivity.java
private void prepareIconsList() { mPrepareIconsList = new AsyncTask<Void, Void, Boolean>() { @Override/*from w w w . j a v a2s . c o m*/ protected Boolean doInBackground(Void... voids) { while (!isCancelled()) { try { Thread.sleep(1); CandyBarMainActivity.sSections = IconsHelper.getIconsList(CandyBarSplashActivity.this); int count = 0; for (Icon section : CandyBarMainActivity.sSections) { count += section.getIcons().size(); } CandyBarMainActivity.sIconsCount = count; return true; } catch (Exception e) { LogUtil.e(Log.getStackTraceString(e)); return false; } } return false; } @Override protected void onPostExecute(Boolean aBoolean) { super.onPostExecute(aBoolean); mPrepareIconsList = null; startActivity(new Intent(CandyBarSplashActivity.this, mMainActivity)); overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); finish(); } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:com.jrummyapps.busybox.fragments.ScriptsFragment.java
public void onRestoreInstanceState(@Nullable Bundle savedInstanceState) { if (savedInstanceState == null || !savedInstanceState.containsKey("scripts")) { new ScriptLoader().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {/*from www.j a v a2 s. c o m*/ ArrayList<ShellScript> scripts = savedInstanceState.getParcelableArrayList("scripts"); adapter = new Adapter(scripts); listView.setAdapter(adapter); } }
From source file:me.willowcheng.makerthings.util.MjpegStreamer.java
private DownloadImageTask startTask(MjpegStreamer cam, int id, boolean useParallelExecution, Handler h) { DownloadImageTask task = new DownloadImageTask(cam, id); if (useParallelExecution) { task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {// w w w . ja va 2 s . c o m task.execute(h); } return task; }
From source file:eu.musesproject.client.connectionmanager.ConnectionManager.java
/** * Disconnects session from the server /* w w w . jav a2 s.co m*/ * @return void */ @Override public void disconnect() { // FIXME What if the server is not online, How should we stop polling from here // As we are disconnecting we need to stop the polling Log.d(TAG, "Disconnecting .."); if (NetworkChecker.isInternetConnected) { Log.d(APP_TAG, "ConnManager=> disconnecting session to server"); HttpClientAsyncThread httpClientAsyncThread = new HttpClientAsyncThread(); httpClientAsyncThread.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, DISCONNECT, URL, Integer.toString(AlarmReceiver.DEFAULT_POLL_INTERVAL), ""); HttpConnectionsHelper.cookie = null; alarmReceiver.cancelAlarm(context); callBacks.statusCb(Statuses.DISCONNECTED, Statuses.DISCONNECTED); } else { Log.d(APP_TAG, "ConnManager=> can't disconnect no intenet connection"); callBacks.statusCb(Statuses.DISCONNECTED, Statuses.DISCONNECTED); } }
From source file:com.cw.litenote.util.video.UtilVideo.java
public static void setVideoViewLayout(String picStr) { System.out.println("UtilVideo / _setVideoViewLayout"); // set video view mVideoView = (VideoViewCustom) mCurrentPagerView.findViewById(R.id.video_view); ProgressBar spinner = (ProgressBar) mCurrentPagerView.findViewById(R.id.loading); mVideoView.setPlayPauseListener(new VideoViewCustom.PlayPauseListener() { @Override//from w w w.j a v a 2 s. c o m public void onPlay() { setVideoState(VIDEO_AT_PLAY); System.out.println("UtilVideo / _setVideoViewLayout / setPlayPauseListener / Play!"); } @Override public void onPause() { setVideoState(VIDEO_AT_PAUSE); System.out.println("UtilVideo / _setVideoViewLayout / setPlayPauseListener / Pause!"); } }); mVideoView.setVisibility(View.VISIBLE); // System.out.println("UtilVideo / _setVideoViewLayout / video view h = " + mVideoView.getHeight()); // System.out.println("UtilVideo / _setVideoViewLayout / video view w = " + mVideoView.getWidth()); // get bitmap by path mBitmapDrawable = getBitmapDrawableByPath(mAct, picStr); // if bitmap drawable is null, start an Async task if (mBitmapDrawable.getBitmap() == null) { System.out.println("UtilVideo / _setVideoViewLayout / mBitmapDrawable.getBitmap() == null"); AsyncTaskVideoBitmapPager mPagerVideoAsyncTask; mPagerVideoAsyncTask = new AsyncTaskVideoBitmapPager(mAct, mPictureString, mVideoView, spinner); mPagerVideoAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, "Searching media ..."); } else // if bitmap is not null, set bitmap drawable to video view directly { AsyncTaskVideoBitmapPager.mVideoUrl = null; System.out.println("UtilVideo / _setVideoViewLayout / mBitmapDrawable.getBitmap() != null"); setVideoViewDimensions(mBitmapDrawable); if (!hasMediaControlWidget) { // set bitmap drawable to video view if (UtilVideo.mVideoView.getCurrentPosition() == 0) setBitmapDrawableToVideoView(mBitmapDrawable, mVideoView); } } // if(mVideoView != null) // { // System.out.println("UtilVideo / _setVideoViewLayout / mVideoView != null"); // mVideoView.getViewTreeObserver().addOnGlobalLayoutListener(onGlobalLayoutListener); // } }
From source file:org.jboss.aerogear.android.cookbook.agreddit.authentication.RedditAuthenticationModule.java
public void login(final String username, final String password, final Callback<HeaderAndBody> callback) { COOKIE_MANAGER = new CookieManager(null, CookiePolicy.ACCEPT_NONE); CookieHandler.setDefault(COOKIE_MANAGER); AsyncTask<Void, Void, HeaderAndBody> task = new AsyncTask<Void, Void, HeaderAndBody>() { private Exception exception; @Override//from w w w . j a va2 s . co m protected HeaderAndBody doInBackground(Void... params) { HeaderAndBody result; try { HttpProvider provider = new HttpRestProvider(getLoginURL(username)); provider.setDefaultHeader("User-Agent", "AeroGear StoryList Demo /u/secondsun"); provider.setDefaultHeader("Content-Type", "application/x-www-form-urlencoded"); String loginData = buildLoginData(username, password); result = provider.post(loginData); Log.d("Auth", new String(result.getBody())); String json = new String(result.getBody()); JsonObject obj = new JsonParser().parse(json).getAsJsonObject().get("json").getAsJsonObject(); modHash = obj.get("data").getAsJsonObject().get("modhash").getAsString(); authToken = obj.get("data").getAsJsonObject().get("cookie").getAsString(); isLoggedIn = true; } catch (Exception e) { Log.e(RedditAuthenticationModule.class.getSimpleName(), "Error with Login", e); exception = e; return null; } return result; } @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
private void loadUserInfo() { new InfoLoader().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, null); }
From source file:joshuatee.wx.SPCCompmapActivity.java
private void selectItem(int position) { mDrawerList.setItemChecked(position, false); mDrawerLayout.closeDrawer(mDrawerList); String position_str = url_index[position]; if (model_params_labels[position].contains("(on)")) { model_params_labels[position] = model_params_labels[position].replaceAll("\\(on\\) ", ""); layer_str = layer_str.replaceAll("a" + position_str + ":", ""); new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else {// w w w.ja v a 2 s . c o m model_params_labels[position] = "(on) " + model_params_labels[position]; layer_str = layer_str + "a" + position_str + ":"; new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }
From source file:com.cw.litenote.operation.import_export.Import_webAct.java
void doCreate() { setContentView(R.layout.import_web); // web view/*from w ww.j a v a2 s. c o m*/ webView = (WebView) findViewById(R.id.webView); // cancel button Button btn_cancel = (Button) findViewById(R.id.import_web_cancel); btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_CANCELED); if (webView.canGoBack()) { webView.goBack(); content = null; } else finish(); } }); // import button btn_import = (Button) findViewById(R.id.import_web_import); btn_import.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); // import // save text in a file String dirName = "Download"; String fileName = "temp.xml"; String dirPath = Environment.getExternalStorageDirectory().toString() + "/" + dirName; File file = new File(dirPath, fileName); try { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } FileOutputStream fOut = new FileOutputStream(file); OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut); if (content != null) { content = content.replaceAll("(?m)^[ \t]*\r?\n", ""); } myOutWriter.append(content); myOutWriter.close(); fOut.flush(); fOut.close(); } catch (IOException e) { Log.e("Exception", "File write failed: " + e.toString()); } // import file content to DB Import_webAct_asyncTask task = new Import_webAct_asyncTask(Import_webAct.this, file.getPath()); task.enableSaveDB(true);// view task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }); webView.getSettings().setJavaScriptEnabled(true); // create instance final ImportInterface import_interface = new ImportInterface(webView); // load web content webView.addJavascriptInterface(import_interface, "INTERFACE"); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); btn_import.setVisibility(View.INVISIBLE); } @Override public void onPageFinished(WebView view, String url) { System.out.println("Import_webAct / _setWebViewClient / url = " + url); view.loadUrl( "javascript:window.INTERFACE.processContent(document.getElementsByTagName('body')[0].innerText);"); if (!url.contains(homeUrl)) btn_import.setVisibility(View.VISIBLE); } }); // show toast webView.addJavascriptInterface(import_interface, "LiteNote"); // load content to web view webView.loadUrl(homeUrl); }
From source file:com.example.gemswin.screancasttest.MainActivity_Reciever.java
@Override public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) { Log.i(LOG_TAG, "onSurfaceTextureAvailable (" + width + "/" + height + ")"); try {/*from www .ja v a2 s .co m*/ final Surface surface = new Surface(surfaceTexture); mDecoderAsyncTask = new DecoderAsyncTask(mMediaCodecFactory, surface, this); mDecoderAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } catch (IOException e) { e.printStackTrace(); } }