/** * 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; }
@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); } }
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(); } }
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); } } }
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); } }
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); } }
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)); } }
@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(); } }
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; }
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); }
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); }
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); }
@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); } }
/** * 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); } } }
/** * 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); }
private void showUpdateDialog() { if (updateDialog == null || !updateDialog.isShowing()) { if (loader != null && (loader.isCancelled() || loader.getStatus() == Status.PENDING) && Utils.isConnected(context)) { AlertDialog.Builder builder = new AlertDialog.Builder(this); updateDialog = builder .setMessage(getString(R.string.msg_updatemap)) .setPositiveButton(getString(R.string.msg_yes), MainActivity.this) .setNegativeButton(getString(R.string.msg_no), MainActivity.this).show(); } else { Log.wtf(TAG, "WTF!"); } } }
public void showRoadMap() { appState = ApplicationState.Road; findViewById(R.id.inMap).setVisibility(View.VISIBLE); ibPrev.setVisibility(View.GONE); ibNext.setVisibility(View.GONE); ibRefresh.setVisibility(View.VISIBLE); ibBack.setVisibility(View.GONE); nvMap.setVisibility(View.GONE); ivRoadsHelp.setVisibility(View.VISIBLE); spState.setVisibility(View.VISIBLE); if (loader == null || loader.isCancelled() || loader.getStatus() == Status.FINISHED) { loader = new DataLoader(this, tivMap, tvError); } loader.loadRoad(getState(), false); findViewById(R.id.ibTabRoad).setEnabled(false); tivMap.setBackgroundResource(R.drawable.shape_page_bg_white); checkLastUpdate(); }
/** * Method that request an asynchronous reload of the media store picture data. * * @param userRequest If the request was generated by the user * @param cb Asynchronous callback */ public synchronized void discover(boolean userRequest, OnMediaPictureDiscoveredListener cb) { if (mTask != null && mTask.getStatus().compareTo(Status.FINISHED) != 0 && !mTask.isCancelled()) { mTask.cancel(true); mTask = null; } if (AndroidHelper.hasReadExternalStoragePermissionGranted(mContext)) { mTask = new AsyncDiscoverTask(mContext.getContentResolver(), cb, userRequest); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { // Notify that we don't have any files cb.onEndMediaDiscovered(new File[0], userRequest); } }
private void fullScreenClickShowAndHide(boolean show) { LogInfo.log(RxBus.TAG, "全屏控制栏显示:" + show); if (show) { this.mTopBar.setVisibility(0); this.mBottomBar.setVisibility(0); if (LiveLunboUtils.isLunBoWeiShiType(this.pageIndex)) { this.mChannelBtn.setVisibility(0); } if (this.mLiveBarrageController == null || !this.mLiveBarrageController.getBarrageControl().isOpenBarrage()) { this.mBarrageInputBtn.setVisibility(4); } else { this.mBarrageInputBtn.setVisibility(0); } if (this.mCanWatchAndBuy) { this.mCartLayout.setVisibility(0); if (this.mCartShowingSubscription != null) { LogInfo.log(RxBus.TAG, "取消监听购物车按钮消失的通知"); this.mCartShowingSubscription.unsubscribe(); } } if (!(LiveLunboUtils.isLunBoWeiShiType(this.pageIndex) || this.mBaseBean == null || this.mBaseBean.branchType <= 0 || this.mBaseBean.isBranch != 1 || BaseTypeUtils.isListEmpty(this.mBaseBean.branches))) { this.mBtnMultiProgram.setVisibility(0); } } else { this.mTopBar.setVisibility(8); this.mBottomBar.setVisibility(8); if (LiveLunboUtils.isLunBoWeiShiType(this.pageIndex)) { this.mChannelBtn.setVisibility(8); } this.mBarrageInputBtn.setVisibility(4); hideFloatView(); setLevelTipVisible(false); if (this.mCartLayout.getVisibility() == 0 && !this.mWacthAndBuyFloatView.isShowing() && this.mWatchAndBuyCartListView.getVisibility() != 0 && ((this.mCartTask == null || this.mCartTask.getStatus() != Status.RUNNING) && this.mWatchAndBuyCartListView.getVisibility() != 0)) { this.mCartLayout.setVisibility(8); } this.mBtnMultiProgram.setVisibility(8); } RxBus.getInstance().send("rx_bus_live_home_action_update_system_ui"); }
@Override public boolean onOptionsItemSelected(MenuItem item) { //Log.v(APP_TAG, "Menu item is selected"); switch(item.getItemId()) { // case R.id.scan: // (new GetApps(this, false)).execute(); // return true; case R.id.full_scan: if (scanner != null && scanner.getStatus() == AsyncTask.Status.RUNNING) return true; scanner = new GetApps(this); scanner.execute(true); return true; case R.id.change_wallpaper: startActivity(new Intent(Intent.ACTION_SET_WALLPAPER)); return true; case R.id.options: startActivity(new Intent(this, Options.class)); return true; case R.id.access_hidden: categories.setCurCategory(CategoryManager.HIDDEN); findViewById(R.id.searchBar).setVisibility(View.GONE); findViewById(R.id.tabs).setVisibility(View.GONE); findViewById(R.id.quit_hidden_apps).setVisibility(View.VISIBLE); if (searchIsOpened) { closeSearch(); } loadFilteredApps(); return true; default: return false; } }
private void l() { if (this.y == null) { c(); } if (!(this.G == null || this.G.getStatus() == Status.FINISHED)) { this.G.cancel(true); } this.G = new y(this, this.y); this.G.execute(new Void[0]); }
/** * */ private void loadImage() { if (retrieveImageTask != null && retrieveImageTask.getStatus() == Status.RUNNING) { return; } retrieveImageTask = new RetrieveImageTask(this); Log.d(getClass().getName(), "showImage(" + imageUris.get(currentImageIndex) + ")"); retrieveImageTask.execute(imageUris.get(currentImageIndex)); }
@Override public void close() { super.close(); if (mLoadingTask != null && mLoadingTask.getStatus() != Status.FINISHED) { if(BuildConfig.DEBUG) Log.d(TAG, "Cursor is closed. Cancel the loading task " + mLoadingTask); // Interrupting the task is not a good choice as it's waiting for the Samba client thread // returning the result. Interrupting the task only frees the task from waiting for the // result, rather than freeing the Samba client thread doing the hard work. mLoadingTask.cancel(false); } }
public <T> void runTask(Uri uri, AsyncTask<T, ?, ?> task, T... args) { synchronized (mTasks) { if (!mTasks.containsKey(uri) || mTasks.get(uri).getStatus() == Status.FINISHED) { mTasks.put(uri, task); // TODO: Use different executor for different servers. task.executeOnExecutor(mExecutor, args); } else { Log.i(TAG, "Ignore this task for " + uri + " to avoid running multiple updates at the same time."); } } }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (passwordList == null) { if (thread.getStatus() == Status.FINISHED || thread.getStatus() == Status.RUNNING) thread = new KeygenThread(wifiNetwork); if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) { thread.execute(); } else { thread.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } } }
@Override public boolean onQueryTextSubmit(String query) { if ((mTask != null) && (mTask.getStatus() == Status.RUNNING)) { return false; } mQuery = query; mTask = new SearchTask(getActivity()); mTask.execute(query); return false; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); options = PreferenceManager.getDefaultSharedPreferences(this); prefListener = new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { //Log.v("TinyLaunch", "pref change detected"); if (key.equals(Options.PREF_DIRTY) && sharedPreferences.getBoolean(Options.PREF_DIRTY, false)) { if (scanner == null || scanner.getStatus() != AsyncTask.Status.RUNNING) { scanner = new GetApps(Apps.this); scanner.execute(false); } } } }; options.registerOnSharedPreferenceChangeListener(prefListener); if (options.getBoolean(Options.PREF_LIGHT, false)) setTheme(android.R.style.Theme_Light); setContentView(R.layout.apps); list = (ListView)findViewById(R.id.apps); res = getResources(); categories = null; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()) { // case R.id.scan: // (new GetApps(this, false)).execute(); // return true; case R.id.full_scan: if (scanner != null && scanner.getStatus() == AsyncTask.Status.RUNNING) return true; scanner = new GetApps(this); scanner.execute(true); return true; case R.id.options: startActivity(new Intent(this, Options.class)); return true; case R.id.new_category: newCategory(); return true; case R.id.rename_category: renameCategory(); return true; case R.id.delete_category: categories.removeCategory(); loadFilteredApps(); return true; default: return false; } }
public void onPause(org.exoplatform.base.BaseActivity act) { if (act == mContext) { // TODO implement correct behavior, current only dismissUI and cancel current task if (Log.LOGD) Log.d(TAG, "onPause cancel task"); setListener(null); if (mLoginTask != null && mLoginTask.getStatus() == Status.RUNNING) { mLoginTask.cancel(true); } dismissDialog(); } }
/** * Load <code>actNums</code> (default 100) newest activities and update the stream of this fragment. * @param actNums The number of activities to load. */ private void onLoad(int actNums) { if (ExoConnectionUtils.isNetworkAvailableExt(getActivity())) { if (mLoadTask == null || mLoadTask.getStatus() == Status.FINISHED) { int currentTab = getThisTabId(); mLoadTask = getThisLoadTask(); mLoadTask.execute(actNums, currentTab); firstIndex = 0; isLoadingMoreActivities = false; } } else { new ConnectionErrorDialog(getActivity()).show(); } }
/** * Load <code>numberOfActivities</code> (default 100) more activities from the end of the list. * @param numberOfActivities The number of activities to add to the current list. * @param currentPos The position of the 1st newly loaded activity. */ public void onLoadMore(int numberOfActivities, int currentPos, int firstVisible) { if (ExoConnectionUtils.isNetworkAvailableExt(getActivity())) { if (mLoadTask == null || mLoadTask.getStatus() == Status.FINISHED) { int currentTab = SocialTabsActivity.instance.mPager.getCurrentItem(); int lastActivity = 0; ArrayList<SocialActivityInfo> list = SocialServiceHelper.getInstance().getSocialListForTab(currentTab); mLoadTask = getThisLoadTask(); Log.d(TAG, "loading more data - flush image cache"); ((SocialTabsActivity) getActivity()).getGDApplication().getImageCache().flush(); System.gc(); if (list != null) { // if we can identify the last activity, we load the previous/older ones lastActivity = list.size()-1; isLoadingMoreActivities = true; currentPosition = currentPos; firstIndex = firstVisible; mLoadTask.execute(numberOfActivities, currentTab, lastActivity); } else { // otherwise we simply reload the current tab's activities and inform the user Toast.makeText(getActivity(), getActivity().getString(R.string.CannotLoadMoreActivities), Toast.LENGTH_LONG).show(); currentPosition = 0; mLoadTask.execute(numberOfActivities, currentTab); } } } else { new ConnectionErrorDialog(getActivity()).show(); } }
public void startCountDown() { if (mCountDownTask == null) { mCanStartCountDown = true; } else if (mCountDownTask.getStatus() == Status.PENDING) { mCountDownTask.execute(); } }
@Override public void onStop() { super.onStop(); //Stop any running tasks if(socialLoader != null) { if(socialLoader.getStatus() == Status.RUNNING) { socialLoader.cancel(true); } } }
@Override public void onStop() { super.onStop(); //Stop any running tasks if(mailDownloader != null) { if(mailDownloader.getStatus() == Status.RUNNING) { mailDownloader.cancel(true); } } }
private void endCurrentlyRunning() { //Stop any running tasks if(categoriesDownloader != null) { if(categoriesDownloader.getStatus() == Status.RUNNING) { categoriesDownloader.cancel(true); Log.i("Forum Fiend","Killed Currently Running"); } } }
private void endCurrentlyRunning() { //Stop any running tasks if(postsDownloader != null) { if(postsDownloader.getStatus() == Status.RUNNING) { postsDownloader.cancel(true); } } }
private void persistChanges() { if (saveTask == null || saveTask.getStatus() == Status.FINISHED) { saveTask = new SaveDataStoreTask(); saveTask.execute(); } else { JTApp.logMessage(TAG, JTApp.LOG_SEVERITY_ERROR, "SaveDataStore Task in invalid state"); } }
private void backupData(String fileName) { if (backupTask == null || backupTask.getStatus() == Status.FINISHED) { backupTask = new BackupTask(); backupTask.execute(fileName); } else { JTApp.logMessage(TAG, JTApp.LOG_SEVERITY_ERROR, "BackupTask in invalid state"); } }
private void persistChanges(boolean exitAfterSave) { if (saveTask == null || saveTask.getStatus() == Status.FINISHED) { saveTask = new SaveDataStoreTask(); saveTask.execute(exitAfterSave); } else { JTApp.logMessage(TAG, JTApp.LOG_SEVERITY_ERROR, "SaveDataStore Task in invalid state"); } }