コード例 #1
0
  @Override
  public void onLoginFinished(Intent errorIntent) {
    AuthenticatorHelper helper = App.get(this).getAuthenticatorHelper();
    boolean result = helper.hasAccount();
    boolean premiumMember = helper.getRestrictions().isPremiumMember();

    if (result) {
      //noinspection ConstantConditions
      Crashlytics.setUserName(helper.getAccount().name);
    }

    AnalyticsUtil.actionLogin(result, premiumMember);

    setResult(result ? RESULT_OK : RESULT_CANCELED);

    if (errorIntent != null) {
      startActivity(errorIntent);
      finish();
      return;
    }

    if (premiumMember) {
      finish();
      return;
    }

    BasicMembershipWarningDialogFragment.newInstance()
        .show(getFragmentManager(), BasicMembershipWarningDialogFragment.FRAGMENT_TAG);
  }
コード例 #2
0
  @Override
  protected void preparePreference() {
    final Preference accountPreference = findPreference(ACCOUNT, Preference.class);
    final AuthenticatorHelper authenticatorHelper = App.get(getActivity()).getAuthenticatorHelper();

    accountPreference.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            if (authenticatorHelper.hasAccount()) {
              authenticatorHelper.removeAccount();
              accountPreference.setTitle(R.string.pref_account_login);
              accountPreference.setSummary(R.string.pref_account_login_summary);
            } else {
              authenticatorHelper.requestSignOn(getActivity(), 0);
            }

            return true;
          }
        });

    if (authenticatorHelper.hasAccount()) {
      accountPreference.setTitle(R.string.pref_account_logout);
      //noinspection ConstantConditions
      accountPreference.setSummary(prepareAccountSummary(authenticatorHelper.getAccount().name));
    } else {
      accountPreference.setTitle(R.string.pref_account_login);
      accountPreference.setSummary(R.string.pref_account_login_summary);
    }

    final Preference geocachingLivePreference =
        findPreference(ACCOUNT_GEOCACHING_LIVE, Preference.class);
    geocachingLivePreference.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            IntentUtil.showWebPage(getActivity(), AppConstants.GEOCACHING_LIVE_URI);
            return true;
          }
        });
  }