	public Bitmap doInBackground(Object... params) {
		listener = (KKImageRequestListener) params[0];
		Bitmap bitmap;
		try {
			int readLength;
			cachePath = KKImageManager.getTempImagePath(context, url);
			File cacheFile = new File(cachePath);
			File localFile = null;
			String tempFilePath = context.getCacheDir().getAbsolutePath() + File.separator + "image" + File.separator + hashCode();
			if (localPath != null) {
				localFile = new File(localPath);
			}
			try {
				if (cacheFile.exists()) {
					if (actionType == KKImageManager.ActionType.DOWNLOAD) {
						if (localFile == null || !localFile.exists()) {
							cryptToFile(cachePath, localPath);
						}
						return null;
					} else {
						bitmap = decodeBitmap(cachePath);
						if (bitmap != null) {
							if (localPath != null && saveToLocal && (localFile == null || !localFile.exists())) {
								cryptToFile(cachePath, localPath);
							}
							return bitmap;
						} else {
							removeCacheFile();
						}
					}
				}
				if (localFile != null && localFile.exists()) {
					if (actionType == KKImageManager.ActionType.DOWNLOAD) {
						return null;
					} else {
						cryptToFile(localPath, tempFilePath);
						moveFileTo(tempFilePath, cachePath);
						bitmap = decodeBitmap(cachePath);
						if (bitmap != null) {
							return bitmap;
						} else {
							removeCacheFile();
						}
					}
				}
			} catch (Exception e) {}
			final HttpGet httpget = new HttpGet(url);
			response = httpclient.execute(httpget);
			final InputStream is = response.getEntity().getContent();
			publishProgress(response.getAllHeaders());
			removeCacheFile();
			if (actionType == KKImageManager.ActionType.DOWNLOAD) {
				RandomAccessFile tempFile = new RandomAccessFile(tempFilePath, "rw");
				while ((readLength = is.read(buffer, 0, buffer.length)) != -1) {
					if (cipher != null) {
						buffer = cipher.doFinal(buffer);
					}
					tempFile.write(buffer, 0, readLength);
				}
				tempFile.close();
				moveFileTo(tempFilePath, localPath);
				return null;
			} else {
				RandomAccessFile tempFile;
				try {
					tempFile = new RandomAccessFile(tempFilePath, "rw");
				} catch (IOException e) {
					return BitmapFactory.decodeStream(is);
				}
				try {
					while ((readLength = is.read(buffer, 0, buffer.length)) != -1) {
						tempFile.write(buffer, 0, readLength);
					}
				} catch (IOException e) {
					tempFile.close();
					return null;
				}
				tempFile.close();
				moveFileTo(tempFilePath, cachePath);
				bitmap = decodeBitmap(cachePath);
				if (bitmap != null) {
					if (saveToLocal && localPath != null) {
						cryptToFile(cachePath, localPath);
					}
					return bitmap;
				}
			}
		} catch (final Exception e) {
			isNetworkError = true;
			removeInvalidImageFiles();
		}
		return null;
	}

	public Bitmap doInBackground(Object... params) {
		listener = (KKImageRequestListener) params[0];
		Bitmap bitmap;
		try {
			int readLength;
			cachePath = KKImageManager.getTempImagePath(context, url);
			File cacheFile = new File(cachePath);
			File localFile = null;
			String tempFilePath = context.getCacheDir().getAbsolutePath() + File.separator + "image" + File.separator + hashCode();
			if (localPath != null) {
				localFile = new File(localPath);
			}
			try {
				if (cacheFile.exists()) {
					if (actionType == KKImageManager.ActionType.DOWNLOAD) {
						if (localFile == null || !localFile.exists()) {
							cryptToFile(cachePath, localPath);
						}
						return null;
					} else {
						bitmap = decodeBitmap(cachePath);
						if (bitmap != null) {
							if (localPath != null && saveToLocal && (localFile == null || !localFile.exists())) {
								cryptToFile(cachePath, localPath);
							}
							return bitmap;
						} else {
							removeCacheFile();
						}
					}
				}
				if (localFile != null && localFile.exists()) {
					if (actionType == KKImageManager.ActionType.DOWNLOAD) {
						return null;
					} else {
						cryptToFile(localPath, tempFilePath);
						moveFileTo(tempFilePath, cachePath);
						bitmap = decodeBitmap(cachePath);
						if (bitmap != null) {
							return bitmap;
						} else {
							removeCacheFile();
						}
					}
				}
			} catch (Exception e) {}
			final HttpGet httpget = new HttpGet(url);
			response = httpclient.execute(httpget);
			final InputStream is = response.getEntity().getContent();
			publishProgress(response.getAllHeaders());
			removeInvalidImageFiles();
			if (actionType == KKImageManager.ActionType.DOWNLOAD) {
				RandomAccessFile tempFile = new RandomAccessFile(tempFilePath, "rw");
				while ((readLength = is.read(buffer, 0, buffer.length)) != -1) {
					if (cipher != null) {
						buffer = cipher.doFinal(buffer);
					}
					tempFile.write(buffer, 0, readLength);
				}
				tempFile.close();
				moveFileTo(tempFilePath, localPath);
				return null;
			} else {
				RandomAccessFile tempFile;
				try {
					tempFile = new RandomAccessFile(tempFilePath, "rw");
				} catch (IOException e) {
					return BitmapFactory.decodeStream(is);
				}
				try {
					while ((readLength = is.read(buffer, 0, buffer.length)) != -1) {
						tempFile.write(buffer, 0, readLength);
					}
				} catch (IOException e) {
					tempFile.close();
					return null;
				}
				tempFile.close();
				moveFileTo(tempFilePath, cachePath);
				bitmap = decodeBitmap(cachePath);
				if (bitmap != null) {
					if (saveToLocal && localPath != null) {
						cryptToFile(cachePath, localPath);
					}
					return bitmap;
				}
			}
		} catch (final Exception e) {
			isNetworkError = true;
			removeInvalidImageFiles();
		}
		return null;
	}
