Пример #1
1
 @Override
 public void onClick(View v) {
   Intent intent = null;
   switch (v.getId()) {
     case R.id.btn_back:
       activity.finish();
       break;
     case R.id.btn_home:
       intent = new Intent(activity, MainActivity.class);
       activity.startActivity(intent);
       activity.finish();
       break;
     case R.id.l_count_followers:
       intent = new Intent(activity, FollowersActivity.class);
       intent.putExtra("user_id", user.getUser_id());
       intent.putExtra("nick", user.getNick());
       activity.startActivity(intent);
       break;
     case R.id.l_count_friends:
       intent = new Intent(activity, FriendsActivity.class);
       intent.putExtra("user_id", user.getUser_id());
       intent.putExtra("nick", user.getNick());
       activity.startActivity(intent);
       break;
     case R.id.l_count_status:
       intent = new Intent(activity, User_TimelineActivity.class);
       intent.putExtra("nick", user.getNick());
       intent.putExtra("user_id", user.getUser_id());
       activity.startActivity(intent);
       break;
     default:
       break;
   }
 }
Пример #2
0
    @Override
    protected void onPostExecute(String s) {
      if (state) {
        try {
          distritos = XMLParser.getItem(s, "District");

          List<String> e = new ArrayList<>();
          for (Item item : distritos) {
            e.add(item.getName());
          }
          ArrayAdapter<String> adapter =
              new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, e);
          district.setAdapter(adapter);
          district.setSelection(adapter.getPosition(reg.getString("SELECT" + district.getId())));
        } catch (Exception e) {
          Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
          esta.finish();
        }
      } else {
        Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
        esta.finish();
      }

      if (progressDialog.isShowing()) {
        progressDialog.dismiss();
      }
    }
Пример #3
0
  private static void startActivityOrFinish(
      final int finishType,
      final Activity thisActivity,
      final Intent intent,
      final Integer requestCode,
      final Bundle bundle) {
    if (requestCode == null) thisActivity.startActivity(intent);
    else if (bundle == null) thisActivity.startActivityForResult(intent, requestCode);
    else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      // TODO 注意:低于api16 时
      thisActivity.startActivityForResult(intent, requestCode, bundle);
    } else thisActivity.startActivityForResult(intent, requestCode);

    switch (finishType) {
      case FINISH_SINGLE:
        // finish当前activity
        thisActivity.finish();
        break;
      case FINISH_ALL:
        // finish目标activity外的所有activity
        // TODO 注意:低于api16 使用 finish() 代替 finishAffinity()
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
          thisActivity.finishAffinity();
        } else thisActivity.finish();
        break;
    }
  }
 @Override
 public void finish() {
   if (mFrom == DLConstants.FROM_INTERNAL) {
     super.finish();
   } else {
     mProxyActivity.finish();
   }
 }
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
      case R.id.adialogOkButton:
        if (Settings.frmSettingflag == true) {
          try {
            DatabaseHelper db = new DatabaseHelper(mActivity);
            String strQuery = "Select OfflineFlag from CS_OfflineCount";
            Cursor cur = db.getData(strQuery);
            int cnt = cur.getCount();

            if (cur.getCount() > 0) {
              if (Utility.isNetworkAvailable(mActivity)) {
                for (int l = 0; l < cnt; l++) {
                  cur.moveToNext();
                  oflcnt = Integer.parseInt(cur.getString(0).toString());
                  try {
                    new SoapAccessTask_SaveFeedback().execute();

                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }
              }
              cur.close();
              db.CloseDB();
            }
          } catch (Exception e) {
            e.printStackTrace();
          }
          // mActivity.finish();
          // dismiss();
        } else if (SplashActivity.deviceIsActive == 0) {
          if (offlineCount > 0) {
            // go to settings class
            fromAlert = true;
            Settings.offlinExpiredflag = true;
            mActivity.finish();
            Intent myIntent = new Intent(mActivity, Settings.class);
            mActivity.startActivity(myIntent);
            dismiss();
          } else {
            mActivity.finish();
            break;
          }
        } else {
          mActivity.finish();
          break;
        }

      default:
        break;
    }
    dismiss();
  }
 /** ����ǰActivity����ջ�����һ��ѹ��ģ� */
 public void finishActivity() {
   Activity activity = activityStack.lastElement();
   if (activity != null) {
     activity.finish();
     activity = null;
   }
 }
Пример #7
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (DEBUG) Log.e(TAG, "onCreate");
    setHasOptionsMenu(true);
    setRetainInstance(false);
    mThreadLoaderCallback = new ThreadDataCallback();

    final Activity activity = getActivity();
    mContentResolver = activity.getContentResolver();
    Intent intent = activity.getIntent();

    mReplyType = intent.getIntExtra(Constants.EDITING, -999);
    mPostId = intent.getIntExtra(Constants.REPLY_POST_ID, 0);
    mThreadId = intent.getIntExtra(Constants.REPLY_THREAD_ID, 0);

    boolean badRequest = false;
    if (mReplyType < 0 || mThreadId == 0) {
      // we always need a valid type and thread ID
      badRequest = true;
    } else if (mPostId == 0
        && (mReplyType == AwfulMessage.TYPE_EDIT || mReplyType == AwfulMessage.TYPE_QUOTE)) {
      // edits and quotes always need a post ID too
      badRequest = true;
    }

    if (badRequest) {
      activity.finish();
    } else {
      loadReply(mReplyType, mThreadId, mPostId);
    }
  }
  @Override
  public void finish() {
    ListActivity.info("finish mapping.");
    finishing.set(true);

    super.finish();
  }
      /** If the update was successful restart the MainActivity */
      @Override
      protected void onPostExecute(String result) {
        super.onPostExecute(result);

        progr_dlg.dismiss();

        // After all the update is (succesfully) done we have to restart
        // the main activity

        if (DONE.equals(result)) {
          // either we were started tru intent (return to main)
          if (context instanceof PreferencesActivity) {
            Activity a = (Activity) context;
            a.setResult(PreferencesActivity.RESULT_DATA_UPDATED);
            // this will call on activity result
            a.finish();
          }

          // or directly by passing context: restart directly
          if (context instanceof MainActivity) {
            MainActivity mainActivity = (MainActivity) context;
            mainActivity.restartActivity(0);
          }
        }
      }
Пример #10
0
 @Override
 public void finish() {
   if (handler != null && payMent.getMessage() != null) {
     handler.sendMessageDelayed(payMent.getMessage(), 800);
   }
   super.finish();
 }
Пример #11
0
 public void HandleResult(int inCode) {
   if (inCode == resTerminate) {
     // Log.v("VIEW","Terminate Request.");
     mActivity.finish();
     return;
   }
   double wake = NME.getNextWake();
   final MainView me = this;
   if (wake <= 0)
     queueEvent(
         new Runnable() {
           public void run() {
             me.onPoll();
           }
         });
   else {
     final int tid = ++mTimerID;
     Date end = new Date();
     end.setTime(end.getTime() + (int) (wake * 1000));
     mTimer.schedule(
         new java.util.TimerTask() {
           public void run() {
             if (tid == me.mTimerID) me.queuePoll();
           }
         },
         end);
   }
 }
Пример #12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFirst) {
      processBA =
          new BA(this.getApplicationContext(), null, null, "b4a.example", "b4a.example.main");
      processBA.loadHtSubs(this.getClass());
      float deviceScale = getApplicationContext().getResources().getDisplayMetrics().density;
      BALayout.setDeviceScale(deviceScale);

    } else if (previousOne != null) {
      Activity p = previousOne.get();
      if (p != null && p != this) {
        BA.LogInfo("Killing previous instance (main).");
        p.finish();
      }
    }
    processBA.runHook("oncreate", this, null);
    if (!includeTitle) {
      this.getWindow().requestFeature(android.view.Window.FEATURE_NO_TITLE);
    }
    if (fullScreen) {
      getWindow()
          .setFlags(
              android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN,
              android.view.WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    mostCurrent = this;
    processBA.sharedProcessBA.activityBA = null;
    layout = new BALayout(this);
    setContentView(layout);
    afterFirstLayout = false;
    BA.handler.postDelayed(new WaitForLayout(), 5);
  }
  /** Wipe out the stored authentication credentials (remove account) and restart the app. */
  public void logout(Activity frontActivity) {
    // Finish front activity if specified
    if (frontActivity != null) {
      frontActivity.finish();
    }

    // Reset smartstore
    if (hasSmartStore()) {
      getSmartStore().dropAllSoups();
    }

    // Reset passcode if any
    getPasscodeManager().reset(this);

    // Remove account if any
    ClientManager clientMgr =
        new ClientManager(this, getAccountType(), null /* we are not doing any login*/);
    clientMgr.removeAccountAsync(
        new AccountManagerCallback<Boolean>() {

          @Override
          public void run(AccountManagerFuture<Boolean> arg0) {
            // Clear cookies
            CookieSyncManager.createInstance(ForceApp.this);
            CookieManager.getInstance().removeAllCookie();

            // Restart application
            Intent i = new Intent(ForceApp.this, getMainActivityClass());
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(i);
          }
        });
  }
Пример #14
0
 @OnClick(R.id.find_sqqz_add)
 private void find_sqqz_add(View v) {
   Intent intent = new Intent(mActivity, NeiFbGroupActivity.class);
   intent.setFlags(3);
   HView.gotoActivity(mActivity, intent);
   mActivity.finish();
 }
Пример #15
0
 /** 结束指定的Activity */
 public void finishActivity(Activity activity) {
   if (activity != null && !activity.isFinishing()) {
     activityStack.remove(activity);
     activity.finish();
     activity = null;
   }
 }
Пример #16
0
 private void closeApplicationAnyway(final Activity activity, boolean disableService) {
   activity.finish();
   Intent newIntent = new Intent(activity, ExitActivity.class);
   newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
   newIntent.putExtra(ExitActivity.DISABLE_SERVICE, disableService);
   startActivity(newIntent);
 }
Пример #17
0
  public void closeApplicationAnywayImpl(final Activity activity, boolean disableService) {
    if (appInitializer.isAppInitializing()) {
      resourceManager.close();
    }
    activity.finish();
    if (getNavigationService() == null) {
      fullExit();
    } else if (disableService) {
      final Intent serviceIntent = new Intent(this, NavigationService.class);
      stopService(serviceIntent);

      new Thread(
              new Runnable() {
                public void run() {
                  // wait until the service has fully stopped
                  while (getNavigationService() != null) {
                    try {
                      Thread.sleep(100);
                    } catch (InterruptedException e) {
                    }
                  }

                  fullExit();
                }
              })
          .start();
    }
  }
Пример #18
0
 public static void refreshActivity(Activity activity) {
   activity.finish();
   Intent intent = new Intent(activity, activity.getClass());
   intent.putExtra(WAS_REFRESHED, true);
   activity.startActivity(intent);
   activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
 }
Пример #19
0
  @Override
  protected void onPostExecute(Comment result) {
    super.onPostExecute(result);

    if (isShowDialog && dialog != null) {
      try {
        dialog.dismiss();
      } catch (Exception e) {
      }
    }

    if (newComment != null) {
      if (isShowDialog) {
        Toast.makeText(context, R.string.msg_comment_success, Toast.LENGTH_LONG).show();
        Intent intent = new Intent();
        intent.putExtra("RESULT_COMMENT", newComment);
        ((Activity) context).setResult(Constants.RESULT_CODE_SUCCESS, intent);
        ((Activity) context).finish();
      }
    } else {
      if (isShowDialog) {
        Button btnSend = (Button) ((Activity) context).findViewById(R.id.btnOperate);
        btnSend.setEnabled(true);
      }
      Toast.makeText(context, resultMsg, Toast.LENGTH_LONG).show();
    }
  }
 protected void onSignOut(Activity currentActivity) {
   if (currentActivity == null) {
     Log.e(TAGERROR, "Activity can not be null");
   } else {
     changeCurrentState(StatusFacebookConn.DISCONNECTED);
     Log.i(TAGINFO, "Disconnected");
     LoginManager.getInstance().logOut();
     activityWeakReference
         .get()
         .getSharedPreferences("FacebookSession", Context.MODE_PRIVATE)
         .edit()
         .putBoolean("FacebookLogged", false)
         .commit();
     activityWeakReference
         .get()
         .getSharedPreferences("FacebookSession", Context.MODE_PRIVATE)
         .edit()
         .putString("FacebookEmail", null)
         .commit();
     currentActivity.startActivity(new Intent(currentActivity, LoginActivity.class));
     activityWeakReference.get().finish();
     currentActivity.finish();
     clearInstanceReference();
   }
 }
Пример #21
0
 /** 进入应用 */
 public void intoApplication() {
   // 判断是否进入向导界面
   SharedPreferences sp_guide =
       context.getSharedPreferences(MarketApp.GUIDESP, Context.MODE_PRIVATE);
   int versionCodeInSP = sp_guide.getInt(MarketApp.VERSION_CODE, -1);
   if (localVersionCode != versionCodeInSP) {
     sp_guide.edit().putBoolean(MarketApp.IS_GUIDED, false).commit();
   }
   boolean guided = sp_guide.getBoolean(MarketApp.IS_GUIDED, false);
   final Intent intent = new Intent();
   if (!guided) {
     intent.setClass(context, GuideActivity.class);
   } else {
     intent.setClass(context, LoginActivity.class);
     SharedPreferences sp_lenovo =
         context.getSharedPreferences(MarketApp.SHARED_PREFERENCES_LENOVO, Context.MODE_PRIVATE);
     String account = sp_lenovo.getString(MarketApp.LOGIN_ACCOUNT, "");
     if (!TextUtils.isEmpty(account)) {
       UserDBHelper userDb = new UserDBHelper();
       UserVo userVo = userDb.getUserInfo(account);
       if (userVo != null) {
         String user_account = userVo.getAccount();
         String password = userVo.getPassword();
         LoginUtils.login(context, user_account, password);
         return;
       }
     }
   }
   context.startActivity(intent);
   ((Activity) context).finish();
 }
Пример #22
0
 /**
  * <退出栈顶Activity> <功能详细描述>
  *
  * @param activity
  * @see [类、类#方法、类#成员]
  */
 public static void popActivity(Activity activity) {
   if (activity != null) {
     activity.finish();
     activityList.remove(activity);
     activity = null;
   }
 }
Пример #23
0
 public static void finishAll() {
   for (Activity activity : activities) {
     if (!activity.isFinishing()) {
       activity.finish();
     }
   }
 }
  /**
   * Logout the current user.
   *
   * @param activity the caller activity
   */
  public static void logout(Activity activity) {
    stopEventStream(activity);

    try {
      ShortcutBadger.setBadge(activity, 0);
    } catch (Exception e) {
    }

    // warn that the user logs out
    Collection<MXSession> sessions = Matrix.getMXSessions(activity);
    for (MXSession session : sessions) {
      // Publish to the server that we're now offline
      MyPresenceManager.getInstance(activity, session).advertiseOffline();
      MyPresenceManager.remove(session);
    }

    // clear the preferences
    PreferenceManager.getDefaultSharedPreferences(activity).edit().clear().commit();

    // clear credentials
    Matrix.getInstance(activity).clearSessions(activity, true);

    // reset the GCM
    Matrix.getInstance(activity).getSharedGcmRegistrationManager().reset();

    // reset the contacts
    PIDsRetriever.getIntance().reset();
    ContactsManager.reset();

    MXMediasCache.clearThumbnailsCache(activity);

    // go to login page
    activity.startActivity(new Intent(activity, LoginActivity.class));
    activity.finish();
  }
Пример #25
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.reset_btn:
        if (reset_password1.getText().toString().trim().length() < 8) {
          Toast.makeText(this, "密码须大于8位", Toast.LENGTH_SHORT).show();
        } else if (!reset_password1
            .getText()
            .toString()
            .equals(reset_password2.getText().toString())) {
          Toast.makeText(this, "输入的两次密码不相等", Toast.LENGTH_SHORT).show();
        } else {
          HttpUtils.resetPassword(
              res,
              phone.replaceAll(" ", ""),
              reset_password2.getText().toString().replaceAll(" ", ""));
        }
        break;
      case R.id.register_back:
        super.finish();
        overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
        break;
      case R.id.policy:
        Intent intent = new Intent(E8_ResetPwdActivity.this, E13_User_policy_Activity.class);
        startActivity(intent);
        this.overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
        break;

      default:
        break;
    }
  }
  @Override
  public void uncaughtException(Thread thread, Throwable exception) {
    final StringWriter stackTrace = new StringWriter();
    exception.printStackTrace(new PrintWriter(stackTrace));
    System.err.println(stackTrace);

    // 发送错误到FixBooksDirectoryActivity;开启一个activity用于处理和显示页面
    Intent intent =
        new Intent(
            FBReaderIntents.Action.CRASH,
            new Uri.Builder().scheme(exception.getClass().getSimpleName()).build());

    intent.setPackage(FBReaderIntents.DEFAULT_PACKAGE);
    try {
      myContext.startActivity(intent);
    } catch (ActivityNotFoundException e) {
      // 如果进不去,则跳转到手动提交bug页面
      intent = new Intent(myContext, BugReportActivity.class);
      intent.putExtra(BugReportActivity.STACKTRACE, stackTrace.toString());
      myContext.startActivity(intent);
    }

    if (myContext instanceof Activity) {
      ((Activity) myContext).finish();
    }

    Process.killProcess(Process.myPid());
    System.exit(10);
  }
    @Override
    protected void onPostExecute(Boolean result) {

      if (result) {
        mActivity.finish();
      }
    }
 @Override
 public void finish() {
   if (isSave) {
     saveNote();
   }
   super.finish();
 }
 /** ����ָ����Activity */
 public void finishActivity(Activity activity) {
   if (activity != null) {
     activityStack.remove(activity);
     activity.finish();
     activity = null;
   }
 }
Пример #30
0
 public void finish(int id) {
   Activity activity = get(id);
   if (activity != null) {
     remove(activity);
     activity.finish();
   }
 }