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:joshuatee.wx.StormReportsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    preferences = PreferenceManager.getDefaultSharedPreferences(this);
    theme_blue_current = preferences.getString("THEME_BLUE", "");
    if (theme_blue_current.contains("white")) {
        highlight_color = Color.BLUE;
        background_color = Color.BLACK;
        highlight_color_str = "blue";
        background_color_str = "black";

    }/*  ww w .  j  a  v a 2 s.  c  o m*/
    setTheme(Utility.Theme(theme_blue_current));
    setContentView(R.layout.activity_storm_reports);

    //padding = (int)res.getDimension(R.dimen.padding);
    //padding_vertical = (int)res.getDimension(R.dimen.padding_vertical);

    Resources res = getResources();
    padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            (float) res.getDimension(R.dimen.padding), getResources().getDisplayMetrics());
    padding_vertical = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            (float) res.getDimension(R.dimen.padding_vertical), getResources().getDisplayMetrics());
    text_size = res.getDimension(R.dimen.listitem_text);

    iv = new TouchImageView2(getBaseContext());
    no = getIntent().getStringExtra(NO);
    dm = new DisplayMetrics();
    this.getWindowManager().getDefaultDisplay().getMetrics(dm);

    final Calendar cal = Calendar.getInstance();
    pYear = cal.get(Calendar.YEAR);
    pMonth = cal.get(Calendar.MONTH);
    pDay = cal.get(Calendar.DAY_OF_MONTH);

    // FIXME, handle first of the month
    if (no.equals("yesterday"))
        pDay--;

    cYear = pYear;
    cMonth = pMonth;
    cDay = pDay;

    UpdateIowaMesoData();

    img_url = "http://www.spc.noaa.gov/climo/reports/" + no + ".gif";
    text_url = "http://www.spc.noaa.gov/climo/reports/" + no + ".csv";

    comma = Pattern.compile(",");
    br = Pattern.compile("<br>");

    output = new StringBuilder(200);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerList = (ListView) findViewById(R.id.left_drawer);
    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, state_array));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.drawer, R.string.drawer_open,
            R.string.drawer_close) {
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);

        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    new GetContent().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

}

From source file:de.enlightened.peris.IntroScreen.java

@SuppressLint("NewApi")
public final void onCreate(final Bundle savedInstanceState) {
    this.dbHelper = new PerisDBHelper(this);
    final Bundle bundle = getIntent().getExtras();
    if (bundle != null) {
        if (bundle.containsKey("server_id")) {
            if (bundle.getString("server_id") != null) {

                this.incomingShortcut = true;
                this.shortcutServerId = bundle.getString("server_id");
            }//from  www.j av a 2s  .c  o m
        }
    }

    final PerisApp app = (PerisApp) getApplication();
    app.initSession();

    startService(new Intent(this, MailService.class));
    this.initDatabase();

    final SharedPreferences appPreferences = getSharedPreferences("prefs", 0);

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    final SharedPreferences.Editor editor = appPreferences.edit();
    editor.putString("server_address", getString(R.string.server_location));
    editor.commit();

    final String backgroundColor = app.getSession().getServer().serverColor;

    ThemeSetter.setTheme(this, backgroundColor);

    super.onCreate(savedInstanceState);

    ThemeSetter.setActionBar(this, backgroundColor);

    //Track app analytics
    this.ah = ((PerisApp) getApplication()).getAnalyticsHelper();
    this.ah.trackScreen(getString(R.string.app_name) + " v" + getString(R.string.app_version) + " for Android",
            true);

    setContentView(R.layout.intro_screen);

    this.serverInputter = (EditText) findViewById(R.id.intro_screen_add_server_box);

    final Button serverAdder = (Button) findViewById(R.id.intro_screen_submit_new_server);

    serverAdder.setOnClickListener(new View.OnClickListener() {

        @SuppressWarnings("checkstyle:requirethis")
        public void onClick(final View v) {

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                new ServerValidationTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                        serverInputter.getText().toString().trim());
            } else {
                new ServerValidationTask().execute(serverInputter.getText().toString().trim());
            }

        }
    });

    this.lvServers = (ListView) findViewById(R.id.intro_screen_server_list);
    this.gvServers = (GridView) findViewById(R.id.intro_screen_server_grid);

    if (this.lvServers == null) {
        registerForContextMenu(this.gvServers);
        this.gvServers.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("checkstyle:requirethis")
            public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                final Server server = serverList.get(position);
                connectToServer(server);
            }
        });
    } else {
        this.lvServers.setDivider(null);
        registerForContextMenu(this.lvServers);

        this.lvServers.setOnItemClickListener(new OnItemClickListener() {
            @SuppressWarnings("checkstyle:requirethis")
            public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                    final long id) {
                final Server server = serverList.get(position);
                connectToServer(server);
            }
        });
    }

    final TextView tvTapaShoutout = (TextView) findViewById(R.id.intro_screen_app_title);
    tvTapaShoutout.setOnClickListener(new View.OnClickListener() {

        public void onClick(final View v) {
            final Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/McNetic/peris"));
            startActivity(browserIntent);
        }
    });

    //Check for incoming link from tapatalk :-)
    String host = "";

    final Uri data = getIntent().getData();

    if (data != null) {
        host = data.getHost();
        this.stealingType = data.getQueryParameter("location");

        if (this.stealingType == null) {
            this.stealingType = "0";
        } else {
            if (this.stealingType.contentEquals("forum")) {
                final String forumId = data.getQueryParameter("fid");

                if (forumId == null) {
                    this.stealingLocation = "0";
                } else {
                    this.stealingLocation = forumId;
                }
            }

            if (this.stealingType.contentEquals("topic")) {
                final String topicId = data.getQueryParameter("tid");

                if (topicId == null) {
                    this.stealingLocation = "0";
                } else {
                    this.stealingLocation = topicId;
                }
            }
        }

    }

    if (host.length() > 0) {
        this.linkToSteal = host;
        this.stealingLink = true;
        return;
    }

}

From source file:org.chromium.chrome.browser.download.DownloadManagerDelegate.java

/**
 * Query the Android DownloadManager for download status.
 * @param downloadItem Download item to query.
 * @param showNotifications Whether to show status notifications.
 * @param callback Callback to be notified when query completes.
 *//*from w  w  w  .  ja  v a2 s . com*/
void queryDownloadResult(DownloadItem downloadItem, boolean showNotifications, DownloadQueryCallback callback) {
    DownloadQueryTask task = new DownloadQueryTask(downloadItem, showNotifications, callback);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:com.example.gemswin.screencastrecevertest.MainActivity_Reciever.java

 @Override
public void onDestroy() {
   Log.i(LOG_TAG, "onSurfaceTextureAvailable (" + width + "/" + height + ")");
   try {//w w w.ja va 2 s. c  om
      final Surface surface = new Surface(surfaceTexture);
      mDecoderAsyncTask = new DecoderAsyncTask(mMediaCodecFactory, surface, this);
      mDecoderAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
   } catch (IOException e) {
      e.printStackTrace();
   }

}

From source file:com.sonymobile.androidapp.gridcomputing.fragments.ReportChartFragment.java

private void setChartValues() {
    mChart.resetTracking();/*from  w ww. j a v a  2  s. co  m*/
    new AsyncTask<Void, Void, LineData>() {

        @Override
        protected LineData doInBackground(Void... params) {
            return getData();
        }

        @Override
        protected void onPostExecute(final LineData data) {
            try {
                mChart.setData(data);
                mChart.invalidate();
                setLegends();
                updateContributedTimeTitle();

                mChartsLayout.setVisibility(View.VISIBLE);
                mProgressBar.setVisibility(View.INVISIBLE);
            } catch (Exception e) {
                e.printStackTrace();
                Log.e("Could not update the chart: " + e.getMessage());
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

}

From source file:com.kytse.aria2remote.DownloadListFragment.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.fab) {
        final EditText editText = new EditText(v.getContext());

        AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
        builder.setTitle(R.string.add_url_tittle).setView(editText)
                .setPositiveButton(R.string.add, new DialogInterface.OnClickListener() {
                    @Override//from  w w w .j av  a  2  s  .  c  o  m
                    public void onClick(DialogInterface dialog, int which) {
                        String url = editText.getEditableText().toString();
                        new AddDownloadAsyncTask(url).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                    }
                }).setNegativeButton(R.string.cancel, null).show();
    }
}

From source file:com.dycody.android.idealnote.NavigationDrawerFragment.java

private void buildCategoriesMenu() {
    CategoryMenuTask task = new CategoryMenuTask(this);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:com.rodrigopontes.androidbubbles.BubblesManager.java

/**
 * Adds new Bubble to BubblesManager/*from w  w  w.  j  a  va2 s.c o m*/
 */
public void addBubble(Bubble bubble) {
    if (windowManager != null) {
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.TOP | Gravity.START;
        params.y = screenHeight / BubblesProperties.BUBBLE_ENTER_Y_POSITION;
        BubbleController bubbleController = new BubbleController(bubble, params);
        bubble.getFrameLayout().setOnTouchListener(bubbleController.new BubbleTouchListener());
        bubblesList.add(bubbleController);
        windowManager.addView(bubble.getFrameLayout(), params);
        bubbleController.createdAnimation = new SpringAnimation(
                new AnimationPosition(BubblesProperties.MODE_STATIC_POSITION,
                        screenWidth + BubblesProperties.BUBBLE_ENTER_SPEED),
                new AnimationPosition(BubblesProperties.MODE_STATIC_POSITION, screenWidth
                        - (int) (bubbleController.bubbleWidth * BubblesProperties.BUBBLE_EDGE_OFFSET_RIGHT)),
                params, BubblesProperties.AXIS_X, BubblesProperties.SPRING_ANIMATION_LONG_DURATION, bubble)
                        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        throw new NullPointerException("BubblesManager has not yet been created! Use .create() first.");
    }
}

From source file:com.dycody.android.idealnote.NavigationDrawerFragment.java

private void buildMainMenu() {
    MainMenuTask task = new MainMenuTask(this);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:com.giovanniterlingen.windesheim.view.Fragments.ScheduleFragment.java

private void alertConnectionProblem() {
    if (!isMenuVisible()) {
        return;/*from  w  w  w  .  j av a  2 s.  c o m*/
    }
    ApplicationLoader.runOnUIThread(new Runnable() {
        @Override
        public void run() {
            new AlertDialog.Builder(getActivity())
                    .setTitle(getResources().getString(R.string.alert_connection_title))
                    .setMessage(getResources().getString(R.string.alert_connection_description))
                    .setPositiveButton(getResources().getString(R.string.connect),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                    new ScheduleFetcher(true, false, true)
                                            .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                                    dialog.cancel();
                                }
                            })
                    .setNegativeButton(getResources().getString(R.string.cancel),
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                    dialog.cancel();
                                }
                            })
                    .show();
        }
    });
}