Esempio n. 1
0
 @Override
 public void pushFragment(BaseFragment fragment, Bundle extras, int inAnimation, int outAnimation)
     throws Exception {
   String tag = fragment.getTagId();
   if (viewHolder.getExtendFragmentVisibility() == View.GONE) {
     tag = FIRST_POPOVER_FRAGMENT_FLAG;
     viewHolder.showHideExtendFragment(View.VISIBLE);
   }
   fragment.setArguments(extras);
   FragmentManager fm = getSupportFragmentManager();
   FragmentTransaction transaction = fm.beginTransaction();
   transaction.add(R.id.extend_fragment, fragment).addToBackStack(tag).show(fragment).commit();
   currentExtendFragmentTag = fragment.getTagId();
 }
Esempio n. 2
0
  @Override
  public void complete(final BaseWSDTO baseWSDTO) {
    super.complete(baseWSDTO);

    try {
      if (baseWSDTO instanceof WSResultDTO) {
        final WSResultDTO requestResult = (WSResultDTO) baseWSDTO;

        /* Show message error */
        int code = Integer.parseInt(requestResult.code);
        if (code == REQUEST_SUCCESS) {
          switch (requestResult.actionType) {
            case CARD_LIKE:
            case CARD_UNLIKE:
            case CARD_SHARE:
              if (!TextUtils.isEmpty(requestResult.messenger)) {
                Utils.showMessageNotifyWithDelay(
                    findViewById(R.id.app_content), requestResult.messenger, handler);
              }
              break;
          }
        } else {
          String msg = requestResult.messenger;
          Utils.showMessageNotify(findViewById(R.id.app_content), msg);
          //                    if (!TextUtils.isEmpty(msg)) {
          //                        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
          //                    }
        }

        /* Transfer data to fragment */
        final String tag = requestResult.tag;
        ArrayList<BaseFragment> fragments = getFragmentByTag(tag);
        if (fragments != null && fragments.size() > 0) {
          for (BaseFragment fragment : fragments) {
            Log.d(TAG, "Viewpager transfer complete data to fragment : " + fragment.getTagId());
            fragment.complete(requestResult);
          }
        }

        /* Catch special case */
        switch (requestResult.actionType) {
          case GET_USER_INFOMATION:
            if (viewHolder.isOpenUserInformation()) {
              viewHolder.loadUserInfo();
            }
            break;

          case GIFT_POPUP:
            GiftPopupDTO giftPopupDTO = (GiftPopupDTO) requestResult.object;
            if (giftPopupDTO != null
                && giftPopupDTO.result != null
                && giftPopupDTO.result.size() > 0) {
              GiftPopupEntity giftPopupEntity = giftPopupDTO.result.get(0);
              if (STATUS_CAN_RECEIVE_GIFTCODE_POPUP.equals(giftPopupEntity.status)) {
                viewHolder.showExitDialog(giftPopupEntity);
              }
            }
            break;

          case GIFT_AWARD:
            //                        mySohaAPI.requestApi(RequestType.GET_USER_INFOMATION,
            // UserDTO.class, null, getTagId());
            break;

          case CARD_ADD_NEW:
            if (isOpenCard) {
              isOpenCard = false;
              Logger.d(TAG, "COMPLETE ... CARD_ADD_NEW");
              UserDTO userDTO = (UserDTO) mySohaAPI.get(GetAction.GET_USER_DATA);
              String userID = userDTO.userId;
              String userName = userDTO.username;
              ChatEntity chatEntity = (ChatEntity) requestResult.object;
              Logger.d(
                  TAG,
                  chatEntity.id
                      + " - "
                      + chatEntity.Onwer.friendID
                      + " - "
                      + chatEntity.Onwer.userNameFriend
                      + " - "
                      + userID
                      + " - "
                      + " - "
                      + userName);
              String roomID = chatEntity.id;

              Intent intent = new Intent(this, ChatActivity.class);
              intent.putExtra(ChatActivity.PARAM_CARD_ID, roomID);
              intent.putExtra(ChatActivity.PARAM_USER_ID, userID);
              intent.putExtra(ChatActivity.PARAM_USER_NAME, userName);

              intent.putExtra(ChatActivity.PARAM_FRIENDS_ID, this.userIDs);
              intent.putExtra(ChatActivity.PARAM_CHAT_TITLE, this.title);
              intent.putExtra(ChatActivity.TYPE_CHAT_SEND_GAME, false);
              intent.putExtra(ChatActivity.TYPE_CHAT_GROUP, true);
              intent.putExtra(ChatActivity.TYPE_CHAT_SUGGEST_FRIEND, false);
              //                        intent.putExtra(ChatActivity.PARAM_FRIENDS_ID,
              // wsResultDTO.referenceData.toString());
              startActivity(intent);
            }
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }