本文整理汇总了Java中android.support.v4.os.AsyncTaskCompat类的典型用法代码示例。如果您正苦于以下问题:Java AsyncTaskCompat类的具体用法?Java AsyncTaskCompat怎么用?Java AsyncTaskCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AsyncTaskCompat类属于android.support.v4.os包,在下文中一共展示了AsyncTaskCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCapture
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
/**
* 开始截图. 获取 image 面板上的图片.
*/
private void startCapture() {
Image image = null;
try {
try {
finalize();
} catch (Throwable throwable) {
throwable.printStackTrace();
}
image = mImageReader.acquireLatestImage();
} catch (Exception e) {
e.printStackTrace();
}
if (image == null) {
L.e(" 获取 image 为空 结束..");
return;
} else {
SaveTask mSaveTask = new SaveTask();
AsyncTaskCompat.executeParallel(mSaveTask, image);
}
}
示例2: afterResponse
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
@Override
public void afterResponse(int code, boolean isSuccessful, String message) {
switch (code) {
case GET_MANAGER_ISSUES: {
if (mainActivity != null) {
mainActivity.isCashedValues = false;
if (!isSuccessful) {
mainActivity.showSpinner(false);
mainActivity.showMessage(message);
} else {
AsyncTaskCompat.executeParallel(new GetIssuesAdapter(mainActivity), (Void) null);
}
if (!isSuccessful && !TextUtils.isEmpty(message) && message.contains(
mainActivity.getResources().getString(R.string.no_connection_with_server)
)) {
mainActivity.isCashedValues = true;
AsyncTaskCompat.executeParallel(new GetIssuesAdapter(mainActivity), (Void) null);
}
break;
}
}
default:
break;
}
}
示例3: onReceive
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
@Override
public void onReceive(final Context context, final Intent intent) {
if ( intent.getAction().equals(DELIVERED_ACTION) ){
final PendingResult result = goAsync();
AsyncTaskCompat.executeParallel(new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
try {
// ... do some work here, for up to 10 seconds
processDispatch(context, intent);
} finally {
result.setResultCode(Activity.RESULT_OK);
result.finish();
}
return null;
}
});
} else if (intent.getAction().equals(DISPATCH_ACTION)){
processDelivered(context,intent);
}
}
示例4: run
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
@Override
public void run() {
if (locationHelper.isConnected()) {
location = locationHelper.getLastKnownLocation();
if (location != null) {
double distance = -1;
boolean firstTime = lastLocation == null;
if (!firstTime)
distance = LocationHelper.distance(location, lastLocation);
if (firstTime || distance > STATIONS_REFRESH_DISTANCE) {
lastLocation = location;
StationSearch task = new StationSearch(location.getLat(), location.getLng());
AsyncTaskCompat.executeParallel( task );
}
if (firstTime || distance > REQUEST_PLACE_REFRESH_DISTANCE) {
placesHelper.isAtGasStationAsync(new PlacesHelper.CurrentPlaceListener() {
@Override
public void OnIsAtGasStationResult(Station station) {
showSpentRequestDialog(station);
}
});
}
}
}
locationHandler.postDelayed(locationChecker, LOCATION_REFRESH_TIME);
}
示例5: persistHistoricalDataIfNeeded
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
/**
* Persists the history data to the backing file if the latter
* was provided. Calling this method before a call to {@link #readHistoricalDataIfNeeded()}
* throws an exception. Calling this method more than one without choosing an
* activity has not effect.
*
* @throws IllegalStateException If this method is called before a call to
* {@link #readHistoricalDataIfNeeded()}.
*/
private void persistHistoricalDataIfNeeded()
{
if (!mReadShareHistoryCalled)
{
throw new IllegalStateException("No preceding call to #readHistoricalData");
}
if (!mHistoricalRecordsChanged)
{
return;
}
mHistoricalRecordsChanged = false;
if (!TextUtils.isEmpty(mHistoryFileName))
{
AsyncTaskCompat.executeParallel(new PersistHistoryAsyncTask(), mHistoricalRecords, mHistoryFileName);
}
}
开发者ID:ludovicroland,项目名称:smartShareActionProvider-android,代码行数:26,代码来源:SmartActivityChooserModel.java
示例6: onActivityResult
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
@Override
public void onActivityResult(final int requestCode, final int resultCode, @Nullable final Intent data) {
switch (requestCode) {
case REQUEST_SELECT_IMAGE:
if (resultCode == Activity.RESULT_OK && data != null) {
if (mTask != null) {
mTask.cancel(true);
mTask = null;
}
mTask = new CopyContentUriTask();
AsyncTaskCompat.executeParallel(mTask, data.getData());
}
break;
default:
super.onActivityResult(requestCode, resultCode, data);
}
}
示例7: pay
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
public void pay(Activity activity,final String orderId, final String productName ,final String productDesc,
final String price, final String notifyUrl ,IZhifubaoPayCallback callback){
if(mProcessing.get()){
callback.onError("zhifubao pay is processing.");
return ;
}
mProcessing.set(true);
this.mWeakActivity = new WeakReference<>(activity);
this.mCallback = callback;
CheckTask task = new CheckTask(mTaskManager) {
@Override
protected void onZhifubaoExist() {
doPay(orderId, productName, productDesc, price, notifyUrl);
}
};
AsyncTaskCompat.executeParallel(task,activity);
}
示例8: persistHistoricalDataIfNeeded
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
private void persistHistoricalDataIfNeeded()
{
if (!mReadShareHistoryCalled)
{
throw new IllegalStateException("No preceding call to #readHistoricalData");
}
if (mHistoricalRecordsChanged)
{
mHistoricalRecordsChanged = false;
if (!TextUtils.isEmpty(mHistoryFileName))
{
AsyncTaskCompat.executeParallel(new PersistHistoryAsyncTask(), new Object[] {
new ArrayList(mHistoricalRecords), mHistoryFileName
});
return;
}
}
}
示例9: onStartClick
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
private void onStartClick() {
if (!checkCutRange()) {
toast("Inavailable cut range!");
return;
}
final Pair<Integer, Integer> size = retriveVideoSize(mSelectedVideo);
if (size == null) {
toast("Video file error!");
return;
}
getOutFileWithAudio().delete();
final long[] startMillis = new long[1];
AsyncTaskCompat.executeParallel(new AsyncTask<Object, Object, Boolean>() {
@Override
protected void onPreExecute() {
startMillis[0] = System.currentTimeMillis();
mProgressDialog.show();
}
@Override
protected Boolean doInBackground(Object... params) {
return new ParallelTranscodeTask(TranscodeActivity.this, new File(mSelectedVideo),
getOutFileWithAudio(), TRANSCODE_THREAD_COUNT, size.first, size.second,
1000000, mStartUsec, mEndUsec)
.transcode();
}
@Override
protected void onPostExecute(Boolean success) {
mProgressDialog.dismiss();
if (success) {
toast("Take " + (System.currentTimeMillis() - startMillis[0]) + " millis");
} else {
toast("Failed!");
}
}
});
}
示例10: showImageView
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
/**
* load image into image view
*
*/
private void showImageView(final String thumbernailPath, final String localFullSizePath,final EMMessage message) {
// first check if the thumbnail image already loaded into cache
Bitmap bitmap = EaseImageCache.getInstance().get(thumbernailPath);
if (bitmap != null) {
// thumbnail image is already loaded, reuse the drawable
imageView.setImageBitmap(bitmap);
} else {
AsyncTaskCompat.executeParallel( new AsyncTask<Object, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(Object... args) {
File file = new File(thumbernailPath);
if (file.exists()) {
return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
} else if (new File(imgBody.thumbnailLocalPath()).exists()) {
return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
}
else {
if (message.direct() == EMMessage.Direct.SEND) {
if (localFullSizePath != null && new File(localFullSizePath).exists()) {
return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
} else {
return null;
}
} else {
return null;
}
}
}
protected void onPostExecute(Bitmap image) {
if (image != null) {
imageView.setImageBitmap(image);
EaseImageCache.getInstance().put(thumbernailPath, image);
}
}
});
}
}
示例11: showImageView
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
/**
* load image into image view
*
*/
private void showImageView(final String thumbernailPath, final String localFullSizePath,final EMMessage message) {
// first check if the thumbnail image already loaded into cache
Bitmap bitmap = com.heybuluo.overseastribe.message.ui.easerelevant.model.EaseImageCache.getInstance().get(thumbernailPath);
if (bitmap != null) {
// thumbnail image is already loaded, reuse the drawable
imageView.setImageBitmap(bitmap);
} else {
AsyncTaskCompat.executeParallel( new AsyncTask<Object, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(Object... args) {
File file = new File(thumbernailPath);
if (file.exists()) {
return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
} else if (new File(imgBody.thumbnailLocalPath()).exists()) {
return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
}
else {
if (message.direct() == EMMessage.Direct.SEND) {
if (localFullSizePath != null && new File(localFullSizePath).exists()) {
return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
} else {
return null;
}
} else {
return null;
}
}
}
protected void onPostExecute(Bitmap image) {
if (image != null) {
imageView.setImageBitmap(image);
EaseImageCache.getInstance().put(thumbernailPath, image);
}
}
});
}
}
示例12: handleSearchIntent
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
private void handleSearchIntent(Intent intent) {
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
if (query != null && !query.isEmpty()) {
MenuItemCompat.collapseActionView(menuSearch);
AsyncTaskCompat.executeParallel(new SearchTask(), query);
}
}
}
示例13: onStartCommand
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
config = intent.getParcelableExtra(KEY_CONFIG);
startNotification();
AsyncTaskCompat.executeParallel(new DownloadTask());
return Service.START_STICKY;
}
示例14: persistHistoricalDataIfNeeded
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
private void persistHistoricalDataIfNeeded() {
if (!this.mReadShareHistoryCalled) {
throw new IllegalStateException("No preceding call to #readHistoricalData");
} else if (this.mHistoricalRecordsChanged) {
this.mHistoricalRecordsChanged = false;
if (!TextUtils.isEmpty(this.mHistoryFileName)) {
AsyncTaskCompat.executeParallel(new PersistHistoryAsyncTask(), new ArrayList(this.mHistoricalRecords), this.mHistoryFileName);
}
}
}
示例15: showImageView
import android.support.v4.os.AsyncTaskCompat; //导入依赖的package包/类
/**
* load image into image view
*
*/
private void showImageView(final String thumbernailPath, final String localFullSizePath,final EMMessage message) {
// first check if the thumbnail image already loaded into cache
Bitmap bitmap = EaseImageCache.getInstance().get(thumbernailPath);
if (bitmap != null) {
// thumbnail image is already loaded, reuse the drawable
imageView.setImageBitmap(bitmap);
} else {
AsyncTaskCompat.executeParallel(new AsyncTask<Object, Void, Bitmap>() {
@Override
protected Bitmap doInBackground(Object... args) {
File file = new File(thumbernailPath);
if (file.exists()) {
return EaseImageUtils.decodeScaleImage(thumbernailPath, 160, 160);
} else if (new File(imgBody.thumbnailLocalPath()).exists()) {
return EaseImageUtils.decodeScaleImage(imgBody.thumbnailLocalPath(), 160, 160);
}
else {
if (message.direct() == EMMessage.Direct.SEND) {
if (localFullSizePath != null && new File(localFullSizePath).exists()) {
return EaseImageUtils.decodeScaleImage(localFullSizePath, 160, 160);
} else {
return null;
}
} else {
return null;
}
}
}
protected void onPostExecute(Bitmap image) {
if (image != null) {
imageView.setImageBitmap(image);
EaseImageCache.getInstance().put(thumbernailPath, image);
}
}
});
}
}