本文整理匯總了Java中android.os.AsyncTask.Status類的典型用法代碼示例。如果您正苦於以下問題:Java Status類的具體用法?Java Status怎麽用?Java Status使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Status類屬於android.os.AsyncTask包,在下文中一共展示了Status類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: startRecordingCellInfo
import android.os.AsyncTask.Status; //導入依賴的package包/類
/**
* cell recording을 위한 thread를 실행한다. <p/>
* cell recording task는 오직 한개만 실행 가능하고, 일정한 주기로 cell 정보를 수집하여 저장한다. <p/>
* @return cell recording task 실행결과.
*/
public boolean startRecordingCellInfo() {
if (mCellInfoTask == null) {
mCellInfoTask = new CellInfoTask();
}
mCellInfoTask.clearCellInfo();
Status status = mCellInfoTask.getStatus();
if (status == Status.PENDING) {
mCellInfoTask.execute();
return true;
} else if (status == Status.RUNNING) {
return true;
} else if (status == Status.FINISHED) {
mCellInfoTask = new CellInfoTask();
mCellInfoTask.execute();
return true;
}
return false;
}
示例2: onContextItemSelected
import android.os.AsyncTask.Status; //導入依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_download:
if (downloadTask == null || downloadTask.getStatus() == Status.FINISHED) {
downloadTask = new DownloadTask();
downloadTask.execute();
} else {
JTApp.logMessage(TAG, JTApp.LOG_SEVERITY_ERROR,
"Download Task in invalid state");
}
return true;
default:
return super.onContextItemSelected(item);
}
}
示例3: restoreProgressDialog
import android.os.AsyncTask.Status; //導入依賴的package包/類
private void restoreProgressDialog() {
if (restoreTask != null && restoreTask.getStatus() == AsyncTask.Status.RUNNING) {
progressDialog.setMessage(getString(R.string.dialog_message_restoring));
progressDialog.show();
}
if (saveTask != null && saveTask.getStatus() == AsyncTask.Status.RUNNING) {
progressDialog.setMessage(getString(R.string.dialog_message_saving));
progressDialog.show();
}
if (backupTask != null && backupTask.getStatus() == AsyncTask.Status.RUNNING) {
progressDialog.setMessage(getString(R.string.dialog_message_backup));
progressDialog.show();
}
}
示例4: lookupPatient
import android.os.AsyncTask.Status; //導入依賴的package包/類
private void lookupPatient(String patientId) {
logEvent(EventType.ENCOUNTER_LOOKUP_PATIENT_START, patientId);
if (lookupProgress == null) {
lookupProgress = new ProgressDialog(this);
lookupProgress.setMessage("Looking up patient \""+patientId +"\""); // TODO i18n
lookupProgress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
if(!isFinishing())
lookupProgress.show();
if(patientLookupTask == null ||
patientLookupTask.getStatus() == Status.FINISHED){
patientLookupTask = new PatientLookupTask(this);
patientLookupTask.setPatientLookupListener(this);
patientLookupTask.execute(patientId);
}
}
}
示例5: saveLocalTaskState
import android.os.AsyncTask.Status; //導入依賴的package包/類
private void saveLocalTaskState(Bundle outState){
final ProcedureLoaderTask task = procedureLoaderTask;
if (task != null && task.getStatus() != Status.FINISHED) {
task.cancel(true);
outState.putBoolean(STATE_LOAD_PROCEDURE, true);
outState.putParcelable(STATE_PROC_LOAD_BUNDLE, task.instance);
outState.putParcelable(STATE_PROC_LOAD_INTENT, task.intent);
}
final PatientLookupTask pTask = patientLookupTask;
if (pTask != null && pTask.getStatus() != Status.FINISHED) {
pTask.cancel(true);
outState.putBoolean(STATE_LOOKUP_PATIENT, true);
outState.putString(STATE_PATIENT_ID, pTask.patientId);
}
}
示例6: saveLocalTaskState
import android.os.AsyncTask.Status; //導入依賴的package包/類
private void saveLocalTaskState(Bundle outState){
final CheckCredentialsTask task = mCredentialsTask;
if (task != null && task.getStatus() != Status.FINISHED) {
task.cancel(true);
outState.putBoolean(STATE_CHECK_CREDENTIALS, true);
}
final MDSSyncTask mTask = mSyncTask;
if (mTask != null && mTask.getStatus() != Status.FINISHED) {
mTask.cancel(true);
outState.putBoolean(STATE_MDS_SYNC, true);
}
final ResetDatabaseTask rTask = mResetDatabaseTask;
if (rTask != null && rTask.getStatus() != Status.FINISHED) {
rTask.cancel(true);
outState.putBoolean(STATE_RESET_DB, true);
}
}
示例7: getDataSources
import android.os.AsyncTask.Status; //導入依賴的package包/類
public static void getDataSources(OnDataSourceResultListener listener,
boolean force) {
if (mDownloadTask == null
|| mDownloadTask.getStatus() != Status.FINISHED || force) {
mCurrentListeners.add(listener);
if (mDownloadTask == null
|| mDownloadTask.getStatus() == Status.FINISHED) {
mDownloadTask = new DownloadTask();
mDownloadTask.execute((Void) null);
}
} else {
listener.onDataSourceResult(new ArrayList<PluginDownloadHolder>(
mDownloadableDataSources));
}
}
示例8: onBackPressed
import android.os.AsyncTask.Status; //導入依賴的package包/類
@Override
public void onBackPressed() {
if (mFlashFirmwareTask != null && mFlashFirmwareTask.getStatus().equals(Status.RUNNING)) {
if (mDoubleBackToExitPressedOnce) {
super.onBackPressed();
return;
}
this.mDoubleBackToExitPressedOnce = true;
Toast.makeText(this, "Please click BACK again to cancel flashing and exit", Toast.LENGTH_SHORT).show();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
mDoubleBackToExitPressedOnce = false;
}
}, 2000);
} else {
super.onBackPressed();
}
}
示例9: canReport
import android.os.AsyncTask.Status; //導入依賴的package包/類
public Boolean canReport() {
Log.d("HarvestReporter", "canReport");
ConnectivityManager manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info == null || !info.isAvailable() || !info.isConnected()) {
Log.d("HarvestReporter", "canReport: not connected");
return false;
}
if ((settings.getRealNowSeconds() - lastAttempt) < HarvestSettings.ATTEMPT_INTERVAL) {
Log.d("HarvestReporter", "canReport: too soon to try");
return false;
}
if ((settings.getClockNowSeconds() - settings.getLastReported()) < HarvestSettings.REPORT_INTERVAL) {
Log.d("HarvestReporter", "canReport: too son to report");
return false;
}
if (previousTask != null && previousTask.getStatus() != Status.FINISHED){
Log.d("HarvestReporter", "canReport: previous task is still running");
return false;
}
return true;
}
示例10: handleTaskStatusChange
import android.os.AsyncTask.Status; //導入依賴的package包/類
public void handleTaskStatusChange(Uri task, org.sana.api.task.Status status, String now, ContentValues values){
if(now == null) now = timeStamp();
if(values == null)
values = new ContentValues();
Log.i(TAG, "Updating status: " + now + " --> " + status + " --> " + values.size() + " --> " + task);
// update in db
values.put(Tasks.Contract.STATUS, status.toString());
values.put(Tasks.Contract.MODIFIED, now);
// Convert to a Bundle so that we can pass it
Log.d(TAG, "FORM data");
Bundle form = new Bundle();
form.putString(Tasks.Contract.STATUS,String.valueOf(status.code));
form.putString(Tasks.Contract.MODIFIED,now);
getContentResolver().update(task,values,null,null);
// send to sync
Intent intent = new Intent(Intents.ACTION_UPDATE,task);
intent.putExtra("form", form);
startService(intent);
}
示例11: markTaskStatusInProgress
import android.os.AsyncTask.Status; //導入依賴的package包/類
public void markTaskStatusInProgress(Uri task){
Log.i(TAG, "markStatusInProgress(): " + task);
org.sana.api.task.Status status = org.sana.api.task.Status.IN_PROGRESS;
String now = timeStamp();
ContentValues values = new ContentValues();
values.put(Tasks.Contract.STATUS, "In Progress");
values.put(Tasks.Contract.MODIFIED, now);
values.put(Tasks.Contract.STARTED, now);
getContentResolver().update(task,values,null,null);
Bundle form = new Bundle();
form.putString(Tasks.Contract.STATUS, "In Progress");
form.putString(Tasks.Contract.MODIFIED,now);
form.putString(Tasks.Contract.STARTED,now);
// send to sync
Intent intent = new Intent(Intents.ACTION_UPDATE,task);
intent.putExtra("form", form);
startService(intent);
}
示例12: markTaskStatusCompleted
import android.os.AsyncTask.Status; //導入依賴的package包/類
public void markTaskStatusCompleted(Uri task, Uri encounter){
Log.i(TAG, "markStatusCompleted(): " + task);
org.sana.api.task.Status status = org.sana.api.task.Status.COMPLETED;
String now = timeStamp();
String uuid = ModelWrapper.getUuid(encounter,getContentResolver());
ContentValues values = new ContentValues();
values.put(Tasks.Contract.STATUS, status.toString());
values.put(Tasks.Contract.COMPLETED, now);
values.put(EncounterTasks.Contract.ENCOUNTER, uuid);
values.put(Tasks.Contract.MODIFIED, now);
Bundle form = new Bundle();
form.putString(Tasks.Contract.STATUS, status.toString());
form.putString(Tasks.Contract.MODIFIED,now);
form.putString(Tasks.Contract.COMPLETED,now);
form.putString(EncounterTasks.Contract.ENCOUNTER, uuid);
// send to sync
Intent intent = new Intent(Intents.ACTION_UPDATE,task);
intent.putExtra("form", form);
startService(intent);
}
示例13: checkDroneConnectivity
import android.os.AsyncTask.Status; //導入依賴的package包/類
@SuppressLint("NewApi")
private void checkDroneConnectivity()
{
if (checkDroneConnectionTask != null && checkDroneConnectionTask.getStatus() != Status.FINISHED) {
checkDroneConnectionTask.cancel(true);
}
checkDroneConnectionTask = new CheckDroneNetworkAvailabilityTask() {
@Override
protected void onPostExecute(Boolean result) {
onDroneAvailabilityChanged(result);
}
};
if (Build.VERSION.SDK_INT >= 11) {
checkDroneConnectionTask.executeOnExecutor(CheckDroneNetworkAvailabilityTask.THREAD_POOL_EXECUTOR, this);
} else {
checkDroneConnectionTask.execute(this);
}
}
示例14: inverseTask
import android.os.AsyncTask.Status; //導入依賴的package包/類
/**
* Permet de changer l'ordre de chargement des pages
* @param targetPageNumber
*/
private void inverseTask(int targetPageNumber)
{
// Si une t�che est en cours
if (preLoadingPostsAsyncTask != null && preLoadingPostsAsyncTask.getStatus() == Status.RUNNING)
{
// si la page pr�c�dente n'est en cours de chargement
if (preLoadingPostsAsyncTask.getPageNumber() != targetPageNumber)
{
// Sinon on force le chargement de la page pr�c�dente
int interruptedPageNumber = preLoadingPostsAsyncTask.getPageNumber();
preLoadingPostsAsyncTask.cancel(true);
preLoadingPostsAsyncTask = new PreLoadingPostsAsyncTask(PostsActivity.this, interruptedPageNumber);
preLoadingPostsAsyncTask.execute(targetPageNumber, topic);
}
}
}
示例15: testDownloadTitleAuthors
import android.os.AsyncTask.Status; //導入依賴的package包/類
/**
* This test downloads the list of title authors from the repo of stories.
* This data would be displayed in the online mode's list of stories to
* download or cache.
*/
public void testDownloadTitleAuthors() throws Throwable {
final SampleOViewClass sampleClass = new SampleOViewClass();
this.downloadTitleAuthors = new DownloadTitleAuthorsTask(context, sampleClass);
runTestOnUiThread(new Runnable() {
@Override
public void run() {
downloadTitleAuthors.execute(new String[] {});
}
});
if (!downloadTitleAuthors.get()) {
// Download failed
fail("Download failed");
}
// Wait til onPostExecute finishes and we get updated
while (downloadTitleAuthors.getStatus() != Status.FINISHED && !sampleClass.updated) {
if (downloadTitleAuthors.isCancelled())
fail("We were cancelled");
}
assertNotNull(sampleClass.titleAuthors);
assertTrue("There are no stories in the sampleClass",
sampleClass.titleAuthors.size() > 0);
}