Пример #1
0
  private void startTrack() {
    Common.log(TAG, "startTrack()");
    mDbHelper.setMessageToStarted(mMessageId);

    Intent intent = new Intent(this, LoggerMap.class);
    intent.putExtra(LoggerMap.PARTNER_RUN_KEY, true);
    startActivity(intent);
  }
Пример #2
0
  public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null)
      convertView =
          LayoutInflater.from(mContext).inflate(R.layout.achievementcatitem, parent, false);

    TextView title = (TextView) convertView.findViewById(R.id.achievementcat_name);
    if (mSection == 0) {
      switch (position) {
        case 0:
          title.setText(Categories.getNameForCat(Categories.DIFF_EASY));
          break;
        case 1:
          title.setText(Categories.getNameForCat(Categories.DIFF_MED));
          break;
        case 2:
          title.setText(Categories.getNameForCat(Categories.DIFF_HARD));
          break;
        default:
          break;
      }
    } else if (mSection == 1) {
      switch (position) {
        case 0:
          title.setText(Categories.getNameForCat(Categories.TYPE_SPEED));
          break;
        case 1:
          title.setText(Categories.getNameForCat(Categories.TYPE_ENDURANCE));
          break;
        case 2:
          title.setText(Categories.getNameForCat(Categories.TYPE_DETERMINATION));
          break;
        case 3:
          title.setText(Categories.getNameForCat(Categories.TYPE_CHARISMA));
          break;
        default:
          break;
      }
    }

    TextView fraction = (TextView) convertView.findViewById(R.id.achievementcat_fraction);
    if (mSection == 0) {
      switch (position) {
        case 0:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.DIFF_EASY, Categories.DIFF_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(
                      Categories.DIFF_EASY, Categories.DIFF_MASK));
          break;
        case 1:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.DIFF_MED, Categories.DIFF_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(Categories.DIFF_MED, Categories.DIFF_MASK));
          break;
        case 2:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.DIFF_HARD, Categories.DIFF_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(
                      Categories.DIFF_HARD, Categories.DIFF_MASK));
          break;
        default:
          break;
      }
    } else if (mSection == 1) {
      switch (position) {
        case 0:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.TYPE_SPEED, Categories.TYPE_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(
                      Categories.TYPE_SPEED, Categories.TYPE_MASK));
          break;
        case 1:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.TYPE_ENDURANCE, Categories.TYPE_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(
                      Categories.TYPE_ENDURANCE, Categories.TYPE_MASK));
          break;
        case 2:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.TYPE_DETERMINATION, Categories.TYPE_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(
                      Categories.TYPE_DETERMINATION, Categories.TYPE_MASK));
          break;
        case 3:
          fraction.setText(
              mDbHelper.getCompletedAchievementCountForCat(
                      Categories.TYPE_CHARISMA, Categories.TYPE_MASK)
                  + "/"
                  + mDbHelper.getAchievementCountForCat(
                      Categories.TYPE_CHARISMA, Categories.TYPE_MASK));
          break;
        default:
          break;
      }
    }

    return convertView;
  }
Пример #3
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Common.log(TAG, "onCreate()");
    this.setContentView(R.layout.gamemessagedetail);

    mMessageId = savedInstanceState != null ? savedInstanceState.getLong(GameMessages.TABLE) : 0;
    if (mMessageId == 0) {
      Bundle extras = getIntent().getExtras();
      mMessageId = extras != null ? extras.getLong(GameMessages.TABLE) : 0;
    }

    mDbHelper = new DatabaseHelper(this);
    mDbHelper.openAndGetDb();

    mMessage = mDbHelper.getMessageWithId(mMessageId);
    startManagingCursor(mMessage);
    mMessage.moveToFirst();
    mPeople = mDbHelper.getUsersForMessage(mMessageId, mMessage.getLong(1));
    startManagingCursor(mPeople);

    mMsgObject =
        new MessageObject(
            mMessage.getInt(2),
            mMessage.getLong(5),
            mMessage.getLong(4),
            mMessage.getString(6),
            mMessage.getString(7));

    mDidStart = mMessage.getInt(9);

    mPeople.moveToPosition(-1);
    ArrayList<Long> recipients = new ArrayList<Long>(mPeople.getCount());
    while (mPeople.moveToNext())
      if (mPeople.getLong(1) != Common.getRegisteredUser(this).id)
        recipients.add(mPeople.getLong(1));

    mReplyRecipientIds = new long[recipients.size()];
    for (int i = 0; i < mReplyRecipientIds.length; i++) mReplyRecipientIds[i] = recipients.get(i);

    // Common.log(TAG, Arrays.toString(mReplyRecipientIds));

    mPeople.moveToFirst();

    mStartButton = (Button) findViewById(R.id.startbutton);
    mStartButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startTrack();
          }
        });
    mStartButton.setVisibility(View.GONE);

    mReplyButton = (Button) findViewById(R.id.replybutton);
    mReplyButton.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            startMessageSender();
          }
        });

    if (!(mPeople.getCount() == 1 && mPeople.getInt(1) == Common.getRegisteredUser(this).id)) {
      if ((mMsgObject.mType == GameMessages.TYPE_INVITE
              || mMsgObject.mType == GameMessages.TYPE_CHALLENGE)
          && mDidStart == 0) mStartButton.setVisibility(View.VISIBLE);
      if (!(mPeople.getCount() > 1)) mReplyButton.setText("Reply");
    }
    setTitle("Message");
    fillData();
  }
Пример #4
0
 @Override
 protected void onDestroy() {
   mDbHelper.close();
   super.onDestroy();
 }
Пример #5
0
 @Override
 protected void onRestart() {
   Common.log(TAG, "onRestart()");
   mDbHelper.openAndGetDb();
   super.onRestart();
 }