isCancelled ( )源码实例Demo

android.os.AsyncTask#isCancelled ( )源码实例Demo

下面列出了android.os.AsyncTask#isCancelled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_maplibui   文件: SelectZoomLevelsDialog.java
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;
}
 
源代码2 项目: qingyang   文件: BaseActivity.java
/**
 * 清除所有的异步任务
 */
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();
}
 
源代码3 项目: WifiChat   文件: BaseActivity.java
/** 清理异步处理事件 */
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();
}
 
源代码4 项目: WifiChat   文件: BaseFragment.java
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();
}
 
源代码5 项目: YTPlayer   文件: YTutils.java
static boolean killAsync(AsyncTask asyncTask) {
    return asyncTask != null && !asyncTask.isCancelled() && asyncTask.cancel(true);
}
 
源代码6 项目: FFmpeg-Android   文件: Util.java
static boolean killAsync(AsyncTask asyncTask) {
    return asyncTask != null && !asyncTask.isCancelled() && asyncTask.cancel(true);
}
 
源代码7 项目: android-discourse   文件: Utils.java
public static final void cancelTask(@SuppressWarnings("rawtypes") AsyncTask task) {
    if (task != null && task.isCancelled()) {
        task.cancel(true);
    }
}
 
源代码8 项目: android_maplib   文件: MapUtil.java
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;
}