コード例 #1
0
 public void retrieveDimPtn() {
   isCancelled = true;
   notifyDimFinish();
   isCancelled = false;
   ptn = null;
   carrier = null;
   errorMessage = null;
   token = null;
   destination = null;
   port = null;
   retryCount = 0;
   isRunning = true;
   ThreadPool threadPool = ThreadManager.getPool(ThreadManager.TYPE_APP_ACTION);
   threadPool.addJob(this);
 }
コード例 #2
0
  protected void syncStops() {
    boolean isSyncEnabled = MigrationExecutor.getInstance().isSyncEnabled();
    boolean isnetworkAvailable = NetworkStatusManager.getInstance().isConnected();
    if (isSyncEnabled && isnetworkAvailable) {
      final IUserProfileProvider userProfileProvider =
          (IUserProfileProvider) get(ICommonConstants.KEY_O_USER_PROFILE_PROVIDER);

      IJob syncJob =
          new IJob() {

            public void execute(int handlerID) {

              // don't do sync before migration succ.
              if (MigrationExecutor.getInstance().isInProgress()) {
                MigrationExecutor.getInstance().setListener(AbstractCommonNetworkModel.this);
                return;
              } else {
                boolean isMigrationSucc =
                    DaoManager.getInstance().getAddressDao().isMigrationSucc();

                // don't do normal sync before migration succ.
                if (isMigrationSucc) {
                  SyncStopsExecutor.getInstance()
                      .syncStop(AbstractCommonNetworkModel.this, userProfileProvider);
                  IServerProxyListener listener =
                      new IServerProxyListener() {
                        @Override
                        public void updateTransactionStatus(
                            AbstractServerProxy proxy, byte progress) {}

                        @Override
                        public void transactionFinished(AbstractServerProxy proxy, String jobId) {
                          String action = proxy.getRequestAction();
                          if (proxy instanceof IToolsProxy
                              && IServerProxyConstants.ACT_SYNC_PREFERENCE.equals(action)) {
                            SyncResExecutor.getInstance().handlePreferenceResp((IToolsProxy) proxy);
                          }
                        }

                        @Override
                        public void transactionError(AbstractServerProxy proxy) {}

                        @Override
                        public void networkError(
                            AbstractServerProxy proxy, byte statusCode, String jobId) {}

                        @Override
                        public boolean isAllowNetworkRequest(AbstractServerProxy proxy) {
                          return AbstractCommonNetworkModel.this.isAllowNetworkRequest(proxy);
                        }
                      };
                  SyncResExecutor.getInstance()
                      .syncPreference(null, IToolsProxy.SYNC_TYPE_DOWNLOAD, listener, null, -1);
                } else {
                  MigrationExecutor.getInstance().doMigration(AbstractCommonNetworkModel.this);
                }
              }
            }

            public void cancel() {}

            public boolean isCancelled() {
              return false;
            }

            public boolean isRunning() {
              return true;
            }
          };
      ThreadPool pool = ThreadManager.getPool(ThreadManager.TYPE_APP_ACTION);
      pool.addJob(syncJob);
    }
  }