Example #1
0
  @Override
  protected void onPrepareDialog(int id, Dialog dialog) {

    AlertDialog alertDialog = (AlertDialog) dialog;
    ArrayAdapter<CharSequence> adapter;
    switch (id) {
      case DIALOG_XODIT:
      case DIALOG_XODIT_EDIT:
      case DIALOG_SORT_BY_XODIL:
        mCurentDialogList = utils.getSortXodilList();
        adapter =
            new ArrayAdapter<CharSequence>(
                this,
                android.R.layout.select_dialog_item,
                android.R.id.text1,
                utils.getString(mCurentDialogList));
        alertDialog.getListView().setAdapter(adapter);
        break;

      case DIALOG_PODTVERDIL:
        int xodit = utils.getAllList().get(0).getPlayerXodit();
        mCurentDialogList = utils.getPodtverdilList(xodit);
        adapter =
            new ArrayAdapter<CharSequence>(
                this,
                android.R.layout.select_dialog_item,
                android.R.id.text1,
                utils.getString(mCurentDialogList));
        alertDialog.getListView().setAdapter(adapter);
        break;

      case DIALOG_SORT_BY_PODTVERDIL:
        mCurentDialogList = utils.getSortPodtverdilList();
        adapter =
            new ArrayAdapter<CharSequence>(
                this,
                android.R.layout.select_dialog_item,
                android.R.id.text1,
                utils.getString(mCurentDialogList));
        alertDialog.getListView().setAdapter(adapter);
        break;
      default:
        super.onPrepareDialog(id, dialog);
    }
  }
Example #2
0
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_XODIT:
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.logs_btnxodit)
            .setItems(
                utils.getString(mCurentDialogList),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, final int which) {
                    sendBroadcast(new Intent(CConstants.ACTION_UPDATE_DATA));
                    // http://code.google.com/p/k9mail/source/detail?r=3132
                    // https://github.com/k9mail/k-9/blob/master/src/com/fsck/k9/activity/ChooseFolder.java
                    // https://github.com/sunlightlabs/congress
                    int num = mCurentDialogList.get(which).getNumber();
                    PMovePOJO item = new PMovePOJO(num);
                    utils.getAllList().add(0, item);
                    mBtnPodtverdil.setEnabled(false);
                    mBtnXodit.setEnabled(false);

                    mSlyx.setText("");
                    mTitle.setText(mCurentDialogList.get(which).getLabel());
                    mTitle.setOnClickListener(
                        new OnClickListener() {
                          public void onClick(View view) {
                            showDialog(DIALOG_XODIT_EDIT);
                          }
                        });

                    mAdapter.notifyDataSetChanged();
                    mCurentDialogList.removeAll(mCurentDialogList);
                  }
                })
            .create();
      case DIALOG_XODIT_EDIT:
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.logs_btnxodit)
            .setItems(
                utils.getString(mCurentDialogList),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, final int which) {

                    // No need to remove current row, only update
                    int num = mCurentDialogList.get(which).getNumber();
                    utils.getAllList().get(0).setPlayerXodit(num);
                    sendBroadcast(new Intent(CConstants.ACTION_UPDATE_DATA));

                    mSlyx.setText("");
                    mTitle.setText(mCurentDialogList.get(which).getLabel());
                    mAdapter.notifyDataSetChanged();
                    mCurentDialogList.removeAll(mCurentDialogList);
                  }
                })
            .create();
      case DIALOG_PODTVERDIL:
        int xodit = utils.getAllList().get(0).getPlayerXodit();
        mCurentDialogList = utils.getPodtverdilList(xodit);

        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.logs_btnpodtverdil)
            .setItems(
                utils.getString(mCurentDialogList),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    mBtnXodit.setEnabled(true);
                    if (which == 0) {
                      which = nc;
                    } else {
                      which = mCurentDialogList.get(which).getNumber();
                    }
                    utils.getAllList().get(0).setPlayerPodtverdil(which);
                    mAdapter.notifyDataSetChanged();
                    mCurentDialogList.removeAll(mCurentDialogList);
                    // removeDialog(DIALOG_PODTVERDIL);
                  }
                })
            .create();
      case DIALOG_PEOPLE:
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.title_people)
            .setItems(
                game.mPeople,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    utils.getAllList().get(0).setSlyxPerson(which);
                    mAdapter.notifyDataSetChanged();
                  }
                })
            .create();
      case DIALOG_PLACE:
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.title_place)
            .setItems(
                game.mPlace,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    utils.getAllList().get(0).setSlyxPlace(which);
                    mAdapter.notifyDataSetChanged();
                  }
                })
            .create();
      case DIALOG_WEAPON:
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.title_weapon)
            .setItems(
                game.mWeapon,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    utils.getAllList().get(0).setSlyxWeapon(which);
                    mAdapter.notifyDataSetChanged();
                  }
                })
            .create();
      case DIALOG_SORT_BY_XODIL:
        mCurentDialogList = utils.getSortXodilList();
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.logs_alert_title_sort_xodil)
            .setItems(
                utils.getString(mCurentDialogList),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    mViewMode = ShowModeType.XODIT;
                    mPerson = mCurentDialogList.get(which).getNumber();
                    ;
                    mAdapter.notifyDataSetChanged();
                    mCurentDialogList.removeAll(mCurentDialogList);
                    // removeDialog(DIALOG_SORT_BY_XODIL);
                  }
                })
            .create();
      case DIALOG_SORT_BY_PODTVERDIL:
        mCurentDialogList = utils.getSortPodtverdilList();
        return new AlertDialog.Builder(LogsActivity.this)
            .setTitle(R.string.logs_alert_title_sort_podtverdil)
            .setItems(
                utils.getString(mCurentDialogList),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    if (which == 0) {
                      which = nc;
                    } else {
                      which = mCurentDialogList.get(which).getNumber();
                    }
                    mViewMode = ShowModeType.PODTVERDIL;
                    mAdapter.notifyDataSetChanged();
                    mCurentDialogList.removeAll(mCurentDialogList);
                    // removeDialog(DIALOG_SORT_BY_PODTVERDIL);
                  }
                })
            .create();
    }
    return null;
  }