Java Code Examples for android.os.AsyncTask#isCancelled()
The following examples show how to use
android.os.AsyncTask#isCancelled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectZoomLevelsDialog.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
private long getTilesCount(AsyncTask task, MapBase map, int leftThumbIndex, int rightThumbIndex) { TMSLayer layer = (TMSLayer) map.getLayerById(getLayerId()); GeoEnvelope envelope = getEnvelope(); long total = 0; for (int zoom = leftThumbIndex; zoom <= rightThumbIndex; zoom++) { if (task != null && task.isCancelled()) return total; total += MapUtil.getTileCount(task, envelope, zoom, layer.getTMSType()); } return total; }
Example 2
Source File: BaseActivity.java From qingyang with Apache License 2.0 | 5 votes |
/** * 清除所有的异步任务 */ protected void clearAsyncTask() { Iterator<AsyncTask<Void, Void, Boolean>> iterator = myAsyncTasks .iterator(); while (iterator.hasNext()) { AsyncTask<Void, Void, Boolean> asyncTask = iterator.next(); if (asyncTask != null && !asyncTask.isCancelled()) { asyncTask.cancel(true); } } myAsyncTasks.clear(); }
Example 3
Source File: BaseActivity.java From WifiChat with GNU General Public License v2.0 | 5 votes |
/** 清理异步处理事件 */ protected void clearAsyncTask() { Iterator<AsyncTask<Void, Void, Boolean>> iterator = mAsyncTasks.iterator(); while (iterator.hasNext()) { AsyncTask<Void, Void, Boolean> asyncTask = iterator.next(); if (asyncTask != null && !asyncTask.isCancelled()) { asyncTask.cancel(true); } } mAsyncTasks.clear(); }
Example 4
Source File: BaseFragment.java From WifiChat with GNU General Public License v2.0 | 5 votes |
public void clearAsyncTask() { Iterator<AsyncTask<Void, Void, Boolean>> iterator = mAsyncTasks.iterator(); while (iterator.hasNext()) { AsyncTask<Void, Void, Boolean> asyncTask = iterator.next(); if (asyncTask != null && !asyncTask.isCancelled()) { asyncTask.cancel(true); } } mAsyncTasks.clear(); }
Example 5
Source File: YTutils.java From YTPlayer with GNU General Public License v3.0 | 4 votes |
static boolean killAsync(AsyncTask asyncTask) { return asyncTask != null && !asyncTask.isCancelled() && asyncTask.cancel(true); }
Example 6
Source File: Util.java From FFmpeg-Android with MIT License | 4 votes |
static boolean killAsync(AsyncTask asyncTask) { return asyncTask != null && !asyncTask.isCancelled() && asyncTask.cancel(true); }
Example 7
Source File: Utils.java From android-discourse with Apache License 2.0 | 4 votes |
public static final void cancelTask(@SuppressWarnings("rawtypes") AsyncTask task) { if (task != null && task.isCancelled()) { task.cancel(true); } }
Example 8
Source File: MapUtil.java From android_maplib with GNU Lesser General Public License v3.0 | 4 votes |
public static long getTileCount(AsyncTask task, GeoEnvelope bounds, double zoom, int tmsType) { int decimalZoom = (int) zoom; int tilesInMapOneDimension = 1 << decimalZoom; double halfTilesInMapOneDimension = tilesInMapOneDimension * 0.5; double tilesSizeOneDimension = GeoConstants.MERCATOR_MAX / halfTilesInMapOneDimension; int begX = (int) Math.floor(bounds.getMinX() / tilesSizeOneDimension + halfTilesInMapOneDimension); int begY = (int) Math.floor(bounds.getMinY() / tilesSizeOneDimension + halfTilesInMapOneDimension); int endX = (int) Math.ceil(bounds.getMaxX() / tilesSizeOneDimension + halfTilesInMapOneDimension); int endY = (int) Math.ceil(bounds.getMaxY() / tilesSizeOneDimension + halfTilesInMapOneDimension); if (begY == endY) endY++; if (begX == endX) endX++; if (begY < 0) begY = 0; if (endY > tilesInMapOneDimension) endY = tilesInMapOneDimension; // normal fill from left bottom corner long total = 0; int realY; for (int x = begX; x < endX; x++) { if (task != null && task.isCancelled()) return total; for (int y = begY; y < endY; y++) { realY = y; if (tmsType == GeoConstants.TMSTYPE_OSM) realY = tilesInMapOneDimension - y - 1; if (realY < 0 || realY >= tilesInMapOneDimension) continue; total++; } } return total; }