コード例 #1
0
ファイル: EmpirSubstDialog.java プロジェクト: vasekp/sifry
 public View getView(int position, View convertView, ViewGroup parent) {
   TextView tv;
   if (convertView == null)
     tv = (TextView) App.getInflater().inflate(R.layout.gen_letter_item, null);
   else tv = (TextView) convertView;
   String chr = getItem(position);
   tv.setText(chr);
   if (position < cnt)
     tv.setTextColor(chr.equals(orig) ? colOK : (used.containsKey(chr) ? colColl : colPrimary));
   else if (position == cnt)
     tv.setTextColor(orig != null && abc.ord(orig) < 0 ? colOK : colPrimary);
   else tv.setTextColor(colPrimary);
   return tv;
 }
コード例 #2
0
ファイル: EmpirSubstDialog.java プロジェクト: vasekp/sifry
  @SuppressWarnings("unchecked")
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    Builder bld = new Builder(getActivity());
    bld.setCancelable(true);

    final SubsItem item = (SubsItem) getArguments().getSerializable(App.SPEC);
    abc = Alphabet.getPreferentialFullInstance();
    used = (HashMap<String, Integer>) getArguments().getSerializable(App.DATA);

    layout = App.getInflater().inflate(R.layout.esubs_dialog, null);
    ((TextView) layout.findViewById(R.id.tvESDPuv))
        .setText(item.ord >= 0 ? item.orig : Utils.getCharDesc(item.orig.charAt(0), mezera));
    GridView grid = (GridView) layout.findViewById(R.id.gvESDialog);
    grid.setAdapter(new AlphabetLA(item.repl));

    bld.setView(layout);
    final AlertDialog dlg = bld.create();

    grid.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          public void onItemClick(
              AdapterView<?> parentView, View childView, int position, long id) {
            if (position < abc.count()) {
              if (onSelectedListener != null)
                onSelectedListener.onSelected(item.orig, abc.chr(position));
              dlg.dismiss();
            } else if (position == abc.count() + 1) {
              if (onSelectedListener != null) onSelectedListener.onSelected(item.orig, null);
              dlg.dismiss();
            } else {
              setExpand(true);
            }
          }
        });

    if (item.repl != null) ((EditText) layout.findViewById(R.id.etESDJine)).setText(item.repl);
    layout
        .findViewById(R.id.tvESDBack)
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                setExpand(false);
              }
            });
    layout
        .findViewById(R.id.tvESDOK)
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                if (onSelectedListener != null) {
                  String str =
                      ((EditText) layout.findViewById(R.id.etESDJine)).getText().toString();
                  if (str.equals("")) str = null;
                  onSelectedListener.onSelected(item.orig, str);
                }
                dlg.dismiss();
              }
            });

    if (savedInstanceState != null) setExpand(savedInstanceState.getBoolean(App.VSTUP1));
    else setExpand(item.repl != null && abc.ord(item.repl) < 0);

    return dlg;
  }