コード例 #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tt_activity_detail_portrait);

    Intent intent = getIntent();
    if (intent == null) {
      logger.e("detailPortrait#displayimage#null intent");
      return;
    }

    String resUri = intent.getStringExtra(IntentConstant.KEY_AVATAR_URL);
    imageUri = resUri;
    logger.d("detailPortrait#displayimage#resUri:%s", resUri);

    boolean isContactAvatar =
        intent.getBooleanExtra(IntentConstant.KEY_IS_IMAGE_CONTACT_AVATAR, false);
    logger.d("displayimage#isContactAvatar:%s", isContactAvatar);

    final ZoomableImageView portraitView = (ZoomableImageView) findViewById(R.id.detail_portrait);

    if (portraitView == null) {
      logger.e("detailPortrait#displayimage#portraitView is null");
      return;
    }

    logger.d("detailPortrait#displayimage#going to load the detail portrait");

    if (isContactAvatar) {
      IMUIHelper.setEntityImageViewAvatarNoDefaultPortrait(
          portraitView, resUri, DBConstant.SESSION_TYPE_SINGLE, 0);
    } else {
      IMUIHelper.displayImageNoOptions(portraitView, resUri, -1, 0);
    }

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                portraitView.setFinishActivity(
                    new finishActivity() {
                      @Override
                      public void finish() {
                        if (DetailPortraitActivity.this != null) {
                          DetailPortraitActivity.this.finish();
                          overridePendingTransition(R.anim.tt_stay, R.anim.tt_image_exit);
                        }
                      }
                    });
              }
            },
            500);
  }
コード例 #2
0
ファイル: LoginActivity.java プロジェクト: Carbs0126/TeamTalk
 // 为什么会有两个这个
 // 可能是 兼容性的问题 导致两种方法onBackPressed
 @Override
 public void onBackPressed() {
   logger.d("login#onBackPressed");
   // imLoginMgr.cancel();
   // TODO Auto-generated method stub
   super.onBackPressed();
 }
コード例 #3
0
ファイル: LoginActivity.java プロジェクト: Carbs0126/TeamTalk
 private void onSocketFailure(SocketEvent event) {
   logger.e("login#onLoginError -> errorCode:%s,", event.name());
   showLoginPage();
   String errorTip = getString(IMUIHelper.getSocketErrorTip(event));
   logger.d("login#errorTip:%s", errorTip);
   mLoginStatusView.setVisibility(View.GONE);
   Toast.makeText(this, errorTip, Toast.LENGTH_SHORT).show();
 }
コード例 #4
0
ファイル: LoginActivity.java プロジェクト: Carbs0126/TeamTalk
 // 主动退出的时候, 这个地方会有值,更具pwd来判断
 private boolean shouldAutoLogin() {
   Intent intent = getIntent();
   if (intent != null) {
     boolean notAutoLogin = intent.getBooleanExtra(IntentConstant.KEY_LOGIN_NOT_AUTO, false);
     logger.d("login#notAutoLogin:%s", notAutoLogin);
     if (notAutoLogin) {
       return false;
     }
   }
   return true;
 }
コード例 #5
0
ファイル: LoginActivity.java プロジェクト: Carbs0126/TeamTalk
        @Override
        public void onIMServiceConnected() {
          logger.d("login#onIMServiceConnected");
          imService = imServiceConnector.getIMService();
          try {
            do {
              if (imService == null) {
                // 后台服务启动链接失败
                break;
              }
              IMLoginManager loginManager = imService.getLoginManager();
              LoginSp loginSp = imService.getLoginSp();
              if (loginManager == null || loginSp == null) {
                // 无法获取登陆控制器
                break;
              }

              LoginSp.SpLoginIdentity loginIdentity = loginSp.getLoginIdentity();
              if (loginIdentity == null) {
                // 之前没有保存任何登陆相关的,跳转到登陆页面
                break;
              }

              mNameView.setText(loginIdentity.getLoginName());
              if (TextUtils.isEmpty(loginIdentity.getPwd())) {
                // 密码为空,可能是loginOut
                break;
              }
              mPasswordView.setText(loginIdentity.getPwd());

              if (autoLogin == false) {
                break;
              }

              handleGotLoginIdentity(loginIdentity);
              return;
            } while (false);

            // 异常分支都会执行这个
            handleNoLoginIdentity();
          } catch (Exception e) {
            // 任何未知的异常
            logger.w("loadIdentity failed");
            handleNoLoginIdentity();
          }
        }
コード例 #6
0
ファイル: LoginActivity.java プロジェクト: Carbs0126/TeamTalk
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    intputManager = (InputMethodManager) getSystemService(this.INPUT_METHOD_SERVICE);
    logger.d("login#onCreate");

    SystemConfigSp.instance().init(getApplicationContext());
    if (TextUtils.isEmpty(
        SystemConfigSp.instance().getStrConfig(SystemConfigSp.SysCfgDimension.LOGINSERVER))) {
      SystemConfigSp.instance()
          .setStrConfig(SystemConfigSp.SysCfgDimension.LOGINSERVER, UrlConstant.ACCESS_MSG_ADDRESS);
    }

    imServiceConnector.connect(LoginActivity.this);
    EventBus.getDefault().register(this);

    setContentView(R.layout.tt_activity_login);
    mSwitchLoginServer = (TextView) findViewById(R.id.sign_switch_login_server);
    mSwitchLoginServer.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            AlertDialog.Builder builder =
                new AlertDialog.Builder(
                    new ContextThemeWrapper(
                        LoginActivity.this, android.R.style.Theme_Holo_Light_Dialog));
            LayoutInflater inflater =
                (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View dialog_view = inflater.inflate(R.layout.tt_custom_dialog, null);
            final EditText editText = (EditText) dialog_view.findViewById(R.id.dialog_edit_content);
            editText.setText(
                SystemConfigSp.instance().getStrConfig(SystemConfigSp.SysCfgDimension.LOGINSERVER));
            TextView textText = (TextView) dialog_view.findViewById(R.id.dialog_title);
            textText.setText(R.string.switch_login_server_title);
            builder.setView(dialog_view);
            builder.setPositiveButton(
                getString(R.string.tt_ok),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {

                    if (!TextUtils.isEmpty(editText.getText().toString().trim())) {
                      SystemConfigSp.instance()
                          .setStrConfig(
                              SystemConfigSp.SysCfgDimension.LOGINSERVER,
                              editText.getText().toString().trim());
                      dialog.dismiss();
                    }
                  }
                });
            builder.setNegativeButton(
                getString(R.string.tt_cancel),
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.dismiss();
                  }
                });
            builder.show();
          }
        });

    mNameView = (EditText) findViewById(R.id.name);
    mPasswordView = (EditText) findViewById(R.id.password);
    mPasswordView.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {

            if (id == R.id.login || id == EditorInfo.IME_NULL) {
              attemptLogin();
              return true;
            }
            return false;
          }
        });
    mLoginStatusView = findViewById(R.id.login_status);
    findViewById(R.id.sign_in_button)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                intputManager.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0);
                attemptLogin();
              }
            });
    initAutoLogin();
  }