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
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   try {
     Logger.d(
         "requestCode MainActivity:" + requestCode + "--resultCode MainActivity:" + resultCode);
     switch (requestCode) {
       case AppConstants.ActivityRequestCode.MULTIPLE_IMAGE_PICKER:
         String tag = MultipleImagePickerActivity.getFragmentTag(data);
         BaseFragment fragment = getFirstFragmentByTag(tag);
         if (fragment != null) {
           fragment.onActivityResult(requestCode, resultCode, data);
         }
         //                    ArrayList<BaseFragment> fragments = getFragmentByTag(tag);
         //                    for (BaseFragment fragment :
         //                            fragments) {
         //                        fragment.onActivityResult(requestCode, resultCode, data);
         //                    }
         break;
       case AppConstants.ActivityRequestCode.CREATE_CARD:
         //                    Toast.makeText(this, "Bắt kết quả trả về của CardCreateActivity",
         // Toast.LENGTH_SHORT).show();
         if (resultCode == RESULT_OK) {
           Utils.showMessageNotify(
               viewHolder.getViewRoot(),
               getString(R.string.card_create_complete),
               Snackbar.LENGTH_LONG,
               null);
         }
         tag = CardCreateActivity.getFragmentTag(data);
         fragment = getFirstFragmentByTag(tag);
         if (fragment != null) {
           fragment.onActivityResult(requestCode, resultCode, data);
         }
         break;
       case AppConstants.ActivityRequestCode.FRIEND_PICKER:
         String ids = FriendPickerActivity.getSelectedFriendIds(data);
         String names = FriendPickerActivity.getSelectedFriendName(data);
         Logger.d(getTagId(), "Friends picker:\nID: " + ids + "\nName: " + names);
         isOpenCard = true;
         createRoomChat(ids, names);
         break;
       default:
         Logger.d(getTagId(), "onActivityResult: Chưa bắt requestCode(" + requestCode + ")");
         break;
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Esempio n. 3
0
  @Override
  public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);
    try {
      // View holder

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 4
0
 @Override
 public void onBackPressed() {
   try {
     if (viewHolder.getExtendFragmentVisibility() == View.VISIBLE) {
       BaseFragment currentExtendFragment = getFirstFragmentByTag(currentExtendFragmentTag);
       if (!currentExtendFragment.onBackPressed()) {
         popFragment();
       }
     } else {
       BaseFragment currentFragment = getFirstFragmentByTag(currentFragmentTag);
       if (!currentFragment.onBackPressed()) {
         if (viewHolder.isOpenUserInformation()) {
           viewHolder.closeDrawer();
         } else {
           viewHolder.showExitDialog();
           //                        android.os.Process.killProcess(android.os.Process.myPid());
         }
       }
     }
   } catch (Exception e) {
     super.onBackPressed();
   }
 }
Esempio n. 5
0
 @Override
 public void onViewCreated(View view, Bundle savedInstanceState) {
   super.onViewCreated(view, savedInstanceState);
 }
Esempio n. 6
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();
    }
  }