예제 #1
0
  // ****************************************************************
  // * Life Cycle
  // ****************************************************************
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    try {
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
      setSupportActionBar(toolbar);

      final ActionBar actionBar = getSupportActionBar();
      actionBar.setHomeAsUpIndicator(R.drawable.ic_menu);
      actionBar.setDisplayHomeAsUpEnabled(true);
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setElevation(0);

      mySohaAPI.setReceive(this);

      viewHolder =
          new MainViewHolder(
              this, this, findViewById(R.id.drawer_layout), getSupportFragmentManager());

      mySohaAPI.requestApi(RequestType.GIFT_POPUP, GiftPopupDTO.class, null, getTagId());

      Utils.showMessageNotify(findViewById(R.id.app_content), R.string.notify_user_login_success);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #2
0
 @Override
 public void receiveSocket(BaseWSDTO baseWSDTO) {
   super.receiveSocket(baseWSDTO);
   try {
     Logger.d(TAG, "receiveSocket data from MainActivity");
     runOnUiThread(new ReceiveSocket(baseWSDTO));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #3
0
 @Override
 protected void onStart() {
   super.onStart();
   try {
     //            if (mySohaAPI != null) {
     //                mySohaAPI.onStart();
     //            }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #4
0
 @Override
 public void error(String tag, RequestType actionType, String messenger) {
   super.error(tag, actionType, messenger);
   try {
     if (!TextUtils.isEmpty(messenger)) {
       Utils.showMessageNotify(findViewById(R.id.app_content), messenger);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
예제 #5
0
  // ****************************************************************
  // * Event
  // ****************************************************************
  @Override
  public void onClick(View v) {
    try {
      switch (v.getId()) {
        case R.id.back:
          try {
            ((BaseActivity) context).onBackPressed();
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;

        case R.id.btn_add_scoin_accept:
          setPrice(addScoinNumberEditScoin.getText().toString());
          break;
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
예제 #6
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();
   }
 }
예제 #7
0
 @Override
 public void onPostCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
   super.onPostCreate(savedInstanceState, persistentState);
 }
예제 #8
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();
    }
  }