private void startCameraSource() {
   try {
     mPreview.start(mCameraSource, mGraphicOverlay);
     boolean startAsyncTask = sp.getBoolean("vision_continuous_test", false);
     if (!startAsyncTask) {
       if (asyncTask != null) {
         // Check if there is an Async Task running. If so, cancel it
         switch (asyncTask.getStatus()) {
           case RUNNING:
             asyncTask.cancel(true);
             asyncTask = null;
             break;
           case PENDING:
             asyncTask.cancel(true);
             asyncTask = null;
             break;
           case FINISHED:
             asyncTask = null;
             break;
         }
       }
       asyncTask =
           new AsyncTaskWaitForBarcode(
                   this, Integer.parseInt(sp.getString("vision_sleep", "1500")))
               .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
     }
   } catch (IOException e) {
     mCameraSource.release();
     mCameraSource = null;
   }
 }
 @Override
 protected void onPause() {
   super.onPause();
   if (followInvoiceTask != null) {
     followInvoiceTask.cancel(true);
   }
   if (updateTimerTask != null) {
     updateTimerTask.cancel(true);
   }
 }
예제 #3
0
파일: Server.java 프로젝트: wenchr/DidiCol
 public void cleanup() {
   serverWorking = false;
   if (clientPoll != null)
     for (int i = 0; i < clientPoll.size(); i++) {
       AsyncTask<Integer, Object, Void> async = clientPoll.get(i);
       if (async != null) async.cancel(true);
     }
   if (serverStart != null) serverStart.cancel(true);
   serverStart = null;
   clientPoll = null;
   asyncClean();
 }
  protected void generateAsyncListMetadata() {
    synchronized (mObjectList) {
      if (mCurrentMetadataTask != null) {
        mCurrentMetadataTask.cancel(true);
      }

      final StickyHeaderListViewArrayAdapterBase<T, D> that = this;

      this.mCurrentMetadataTask =
          new AsyncTask<Void, Void, Void>() {
            private MetadataDTO metadata;

            @Override
            protected Void doInBackground(Void... params) {
              this.metadata = generateListMetadata();
              return null;
            }

            protected void onPostExecute(Void result) {
              mNotifiyng = true;
              that.mPrevHeadersPositionByIndex = metadata.getPrevHeadersPositionByIndex();
              that.mNextHeadersPositionByIndex = metadata.getNextHeadersPositionByIndex();
              that.mViewTypesByPosition = metadata.getViewTypesByPosition();
              that.mTotalItems = metadata.getTotalItems();

              StickyHeaderListViewArrayAdapterBase.super.notifyDataSetChanged();
            };
          };
      mCurrentMetadataTask.execute();
    }
  }
예제 #5
0
  /**
   * start or stop recording
   *
   * @param start true start recording, false stop recording
   */
  private void onRecord(boolean start) {
    if (start) {
      onPlay(STOP_PLAYING);
      mPlayPause.setImageResource(R.drawable.ic_play);

      startRecordingAsync();

      startAnimate();

    } else {

      if (!mIsRecording) {
        recordingAsync.cancel(true);
      }

      stopRecording();

      stopAnimating();

      try {
        long size = 0;
        File forSize = new File(mFilePath);
        if (forSize.exists()) {
          size = forSize.length();
          String text = getString(R.string.OK) + ", " + Tools.readableFileSize(size);
          okButton.setText(text);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
      ;
    }
  }
 @Override
 public void onDestroy() {
   super.onDestroy();
   if (mLicenseLoader != null) {
     mLicenseLoader.cancel(true);
   }
 }
 @Override
 public void onDismiss(DialogInterface dialog) {
   if (loadApps != null && loadApps.getStatus() == AsyncTask.Status.RUNNING) {
     loadApps.cancel(true);
     loadApps = null;
   }
 }
 @Override
 public Object onRetainNonConfigurationInstance() {
   if (mSignupTask != null) {
     mSignupTask.cancel(true);
   }
   return mSignupTask;
 }
예제 #9
0
 /** Gently killing AsyncTask */
 public static void stopTaskGracefully(AsyncTask<?, ?, ?> t) {
   if (t != null) {
     if (t.getStatus() == Status.RUNNING) {
       t.cancel(true);
     }
   }
 }
    void calculateProgress(
        final String name,
        final long fileBytes,
        final int id,
        final long size,
        final boolean move) {
      if (asyncTask != null && asyncTask.getStatus() == AsyncTask.Status.RUNNING)
        asyncTask.cancel(true);
      asyncTask =
          new AsyncTask<Void, Void, Void>() {
            int p1, p2;

            @Override
            protected Void doInBackground(Void... voids) {
              p1 = (int) ((copiedBytes / (float) totalBytes) * 100);
              p2 = (int) ((fileBytes / (float) size) * 100);
              lastpercent = (int) copiedBytes;
              return null;
            }

            @Override
            public void onPostExecute(Void v) {
              publishResults(name, p1, p2, id, totalBytes, copiedBytes, false, move);
            }
          }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
예제 #11
0
 private synchronized void cancel() {
   AsyncTask<?, ?, ?> task = inactivityTask;
   if (task != null) {
     task.cancel(true);
     inactivityTask = null;
   }
 }
예제 #12
0
  public void atualizarDados(final int position) {
    if (mTask != null) {
      mTask.cancel(true);
    }
    if (!mGoogleApiClient.isConnected()) return; // Se não estiver conectado, saia...
    mTask =
        new AsyncTask<Void, Void, PutDataMapRequest>() {
          @Override
          protected PutDataMapRequest doInBackground(Void... voids) {
            PutDataMapRequest putDataMapRequest =
                PutDataMapRequest.create(Constantes.CAMINHO_DADOS);
            mUriDados = putDataMapRequest.getUri();
            DataMap map = putDataMapRequest.getDataMap();
            map.putInt(Constantes.EXTRA_POSICAO_ATUAL, position);
            map.putInt(Constantes.EXTRA_TOTAL_IMAGENS, Constantes.TOTAL_IMAGENS);
            Bitmap miniatura =
                ImagemUtil.imagem(mContext, "foto" + (position + 1) + ".jpg", 160, 160);
            if (miniatura != null) {
              final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
              miniatura.compress(Bitmap.CompressFormat.JPEG, 80, byteStream);
              Asset asset = Asset.createFromBytes(byteStream.toByteArray());
              map.putAsset(Constantes.EXTRA_IMAGEM, asset);
            }
            return putDataMapRequest;
          }

          @Override
          protected void onPostExecute(PutDataMapRequest dataMapRequest) {
            super.onPostExecute(dataMapRequest);
            Wearable.DataApi.putDataItem(mGoogleApiClient, dataMapRequest.asPutDataRequest());
          }
        }.execute();
  }
예제 #13
0
 @Override
 protected void onDestroy() {
   if (getUsersTask != null) {
     getUsersTask.cancel(true);
   }
   super.onDestroy();
 }
예제 #14
0
 @Override
 protected void onPause() {
   super.onPause();
   if (operationTask != null) {
     operationTask.cancel(true);
   }
 }
예제 #15
0
 @Override
 public void onDestroyView() {
   if (mCurrentTask != null) {
     mCurrentTask.cancel(true);
   }
   mCurrentTask = null;
   super.onDestroyView();
 }
예제 #16
0
  public void stop() {

    Log.d("SyncTask", "Requested stop");
    this.stopped = true;
    if (task != null) {
      task.cancel(true);
    }
  }
예제 #17
0
 @Override
 public void onDestroy() {
   super.onDestroy();
   OpenHelperManager.releaseHelper();
   if (mAsyncTask != null) {
     mAsyncTask.cancel(true);
   }
 }
예제 #18
0
 private void unInit() {
   if (null != mInitTask) {
     if (!mInitTask.isCancelled()) {
       mInitTask.cancel(true);
     }
     mInitTask = null;
   }
 }
 @Override
 public void onBackPressed() {
   super.onBackPressed();
   if (asyncTask != null) {
     asyncTask.cancel(true);
     asyncTask = null;
   }
 }
예제 #20
0
 @Override
 public void onDestroy() {
   if (mTask != null) {
     mTask.cancel(true);
     mTask = null;
   }
   super.onDestroy();
 }
예제 #21
0
 private synchronized void cancelOutstandingTask() {
   if (outstandingTask != null) {
     if (outstandingTask.getStatus() != AsyncTask.Status.FINISHED) {
       outstandingTask.cancel(true);
     }
     outstandingTask = null;
   }
 }
예제 #22
0
 private void cancelPrevRegisterTask() {
   synchronized (mSyncObj) {
     if (null != mRegistrationAsyncTask) {
       mRegistrationAsyncTask.cancel(true);
     }
     mRegistrationAsyncTask = null;
   }
 }
예제 #23
0
 @JavascriptInterface
 public void cancel() {
   Log.d(TAG, "cancel");
   super.cancel(false);
   if (currentUsbRequest != null) {
     currentUsbRequest.cancel();
   }
   errorMessage = "cancel";
 }
예제 #24
0
 @Override
 public void onStopWithNative() {
   super.onStopWithNative();
   mCleanupTask.cancel(true);
   if (getActivityTab() != null) getActivityTab().saveState(getActivityDirectory());
   if (getFullscreenManager() != null) {
     getFullscreenManager().setPersistentFullscreenMode(false);
   }
 }
 @Override
 protected void onPause() {
   AsyncTask<?, ?, ?> oldTask = networkTask;
   if (oldTask != null) {
     oldTask.cancel(true);
     networkTask = null;
   }
   super.onPause();
 }
예제 #26
0
 @Override
 protected void onDestroy() {
   if (mRegisterTask != null) {
     mRegisterTask.cancel(true);
   }
   unregisterReceiver(mHandleMessageReceiver);
   GCMRegistrar.onDestroy(this);
   super.onDestroy();
 }
예제 #27
0
파일: MainMenu.java 프로젝트: farizijan/MEC
 // GCM
 @Override
 protected void onDestroy() {
   // TODO Auto-generated method stub
   if (mRegisterTask != null) {
     mRegisterTask.cancel(true);
   }
   unregisterReceiver(mHandleMessageReceiver);
   GCMRegistrar.onDestroy(getApplicationContext());
   super.onDestroy();
 }
예제 #28
0
  @Override
  protected void onStop() {
    Log.d(TAG, "onStop");
    super.onStop();

    if (mLoadPictureTask != null && mLoadPictureTask.getStatus() != AsyncTask.Status.FINISHED) {
      mLoadPictureTask.cancel(false);
    }

    unregisterReceiver(mReceiver);
  }
예제 #29
0
 public void cancel() {
   super.cancel(true);
   isCanceled = true;
   if (mAjax != null) {
     HttpRequest mHttpRequest = mAjax.getHttpRequest();
     if (mHttpRequest != null) {
       mHttpRequest.cancel();
       mHttpRequest = null;
     }
   }
 }
예제 #30
0
  @Override
  protected void onPause() {
    active = false;
    rescanWifiTask.cancel(true);

    if (nfcAvailable) {
      nfcAdapter.disableForegroundDispatch(this);
    }

    super.onPause();
  }