Exemple #1
0
 public void findView() {
   mNameTextView = (TextView) findViewById(R.id.nameTextView);
   mNameTextView.setText(mCurrentFriend.getName());
   mSceneListView = (HorizontalListView) findViewById(R.id.sceneListView);
   mSceneListView.setAdapter(mSceneHorizonAdapter);
   mSetBombTimeDialog = new SetBombTimeDialog(this);
   mHistoryListView = (ListView) findViewById(R.id.historyListView);
   mHistoryListView.setAdapter(mHistoryAdapter);
   mBackImageView = (ImageView) findViewById(R.id.backImageView);
   mBackTextView = (TextView) findViewById(R.id.backTextView);
 }
Exemple #2
0
  private void setListener() {
    mBackImageView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(HistoryActivity.this, MenuActivity.class);
            intent.putExtra(
                IntentExtraParams.FRAGMENT_NAME, FragmentFactory.FragmentName.FriendBomb);
            startActivity(intent);
            finish();
          }
        });

    mBackTextView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(HistoryActivity.this, MenuActivity.class);
            intent.putExtra(
                IntentExtraParams.FRAGMENT_NAME, FragmentFactory.FragmentName.FriendBomb);
            startActivity(intent);
            finish();
          }
        });

    mSetBombTimeDialog.setDialogListener(
        new DialogListener() {
          @Override
          public void closeDialog() {
            mSetBombTimeDialog.dismiss();
          }
        });

    mSetBombTimeDialog.setAddHistoryListener(
        new AddHistoryListener() {
          @Override
          public void addHistory(int sceneId, String time) {
            LogUtil.d(TAG, "Time is: " + time);
            ClientUser clientUser = UserCache.getInstance().getClientUser();
            History history =
                new History(
                    SceneCache.getInstance(HistoryActivity.this).getScene(sceneId),
                    time,
                    0,
                    clientUser.getUserId(),
                    clientUser.getUserName());
            mHistoryList.add(history);
            mHistoryAdapter.notifyDataSetChanged();
            ConversationCache.getInstance()
                .updateConversation(
                    new Conversation(
                        mCurrentFriend.getUserId(),
                        String.format(getString(R.string.send_bomb_message), history.getTime())));
            mSetBombTimeDialog.dismiss();

            IMChattingHelper.getInstance(HistoryActivity.this).sendMessage(mCurrentFriend, history);
          }
        });

    mOnMessageReportCallback =
        new OnMessageReportCallback() {
          @Override
          public void onMessageReport(ECError error, ECMessage message) {}

          @Override
          public void onPushMessage() {
            mHistoryAdapter.notifyDataSetChanged();
          }
        };

    mGetScenesNetworkHelper.setUiDataListener(
        new UIDataListener<Bean>() {
          @Override
          public void onDataChanged(Bean data) {
            try {
              JSONObject result = new JSONObject(data.getResult());
              String sceneListStr = result.getString("scene.list");
              JSONArray sceneList = new JSONArray(sceneListStr);
              initializeSceneList();
              String sceneStr;
              for (int i = 0; i < sceneList.length(); i++) {
                sceneStr = sceneList.getString(i);
                JSONObject scene = new JSONObject(sceneStr);
                mSceneList.add(
                    new Scene(
                        scene.getInt("id"),
                        scene.getString("Name"),
                        scene.getString("Logo"),
                        scene.getString("Picture"),
                        scene.getString("Audio")));
              }
              mSceneHorizonAdapter.notifyDataSetChanged();
              SceneCache.getInstance(HistoryActivity.this).setList(mSceneList);
            } catch (JSONException e) {
              this.onErrorHappened(CodeParams.ERROR_SAVE_SESSION_TOKEN, e.toString());
            }
          }

          @Override
          public void onErrorHappened(int errorCode, String errorMessage) {}
        });

    mSceneListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mSetBombTimeDialog.setSceneInfo(mSceneList.get(position).getSceneId());
            mSetBombTimeDialog.show();
          }
        });
  }