Example #1
0
  @Override
  protected void onActivityResult(int arg0, int arg1, Intent arg2) {
    // TODO Auto-generated method stub
    if (arg0 == Const.TO_USER_SET && arg1 == Const.TO_EXITS_USER) {
      new ToastUtils(MainActivity.this, "退出账户成功!");
      mIndex = 0;
      setOnTabselected();
    }
    if (mInformationFragment != null) {
      mInformationFragment.onActivityResult(arg0, arg1, arg2);
    }
    if (mToolFragment != null) {
      mToolFragment.onActivityResult(arg0, arg1, arg2);
    }
    if (mMyFragment != null) {
      mMyFragment.onActivityResult(arg0, arg1, arg2);
    }
    super.onActivityResult(arg0, arg1, arg2);

    if (arg1 == RESULT_CANCELED) {
      disshowPhoto();
      return;
    }
    if (arg0 == Const.TO_LOGIN && arg1 == RESULT_OK) { // 登陆成功
      mIndex = 3;
      setOnTabselected();
      EventBus.getDefault().post(new MyEvent(0, null));
    }
    if (arg0 == Const.TO_SEND_IDENTIY && arg1 == RESULT_OK) { // 发布成功
    }
    if (arg0 == ImageUtils.GET_IMAGE_BY_CAMERA && arg1 == RESULT_OK) { // 我的页面,获取照片地址获取到图片(相机)
      if (imageUtils.PICPATH != null) {
        imageUtils.crop(Uri.fromFile((new File(imageUtils.PICPATH))));
      }
    }
    if (arg0 == ImageUtils.GET_IMAGE_FROM_PHONE
        && arg1 == Activity.RESULT_OK) { // 我的页面,获取照片地址获取到图片(相册)
      if (arg2 != null && arg2.getData() != null) {
        imageUtils.crop(arg2.getData());
      }
    }
    if (arg0 == ImageUtils.GET_IMAGE_FROM_PHONE_KITKAT
        && arg1 == RESULT_OK) { // 我的页面,获取照片地址获取到图片(相册)4.4系统,用谷歌的相册
      if (arg2 != null && arg2.getData() != null) {
        imageUtils.doPhotoKIKAT(arg2);
        imageUtils.crop(Uri.fromFile(new File(imageUtils.PICPATH)));
      }
    }
    if (arg0 == ImageUtils.PHOTO_REQUEST_CUT && arg1 == RESULT_OK) { // 获取剪切好的人物头像
      if (arg2 != null) {

        uploadLogo(FileUtils.getInstance().getLogoPath().getAbsolutePath());
      }
    }
    disshowPhoto();
  }
Example #2
0
  @Override
  public void onTabSelected(int index) {
    if (index == 3) {
      // 我的页面
      if (ItApplication.getcurrnUser() == null) {
        mIndex = 0;
        Intent intent = new Intent(MainActivity.this, LoginAcitivity.class);
        startActivityForResult(intent, Const.TO_LOGIN);
        overridePendingTransition(R.anim.toast_in, R.anim.hold);
        return;
      }
    }
    FragmentTransaction transaction = mFragmentManager.beginTransaction();
    hideFragments(transaction);
    switch (index) {
      case 0:
        if (null == mNewHomeFragment) {
          mNewHomeFragment = new NewHomeFragment();
          transaction.add(R.id.center_layout, mNewHomeFragment);
        } else {
          transaction.show(mNewHomeFragment);
        }
        mNewHomeFragment.lazyLoad();

        break;
      case 1:
        EventBus.getDefault().post(new InfoEvent(0, null));
        if (null == mInformationFragment) {
          mInformationFragment = new InformationFragment();
          transaction.add(R.id.center_layout, mInformationFragment);
        } else {
          transaction.show(mInformationFragment);
        }
        break;
      case 2:
        EventBus.getDefault().post(new InfoEvent(0, null));
        if (null == mToolFragment) {
          mToolFragment = new ToolFragment();
          transaction.add(R.id.center_layout, mToolFragment);
        } else {
          transaction.show(mToolFragment);
        }
        break;
      case 3:
        if (null == mMyFragment) {
          mMyFragment = new MyFragment();
          mMyFragment.setLogoListener(
              new OnClickListener() {

                @Override
                public void onClick(View v) {
                  if (photodialog == null) {
                    photodialog = new SelectPhotoDialog(MainActivity.this, ImageListner);
                  }
                  if (!photodialog.isShowing()) {
                    photodialog.show();
                  }
                }
              });
          transaction.add(R.id.center_layout, mMyFragment);
        } else {
          transaction.show(mMyFragment);
        }
        EventBus.getDefault().post(new MyEvent(1, null));
        break;

      default:
        break;
    }
    mIndex = index;
    transaction.commitAllowingStateLoss();
  }