示例#1
0
 /** Called when the user selects the Send button */
 public void sendMessage(View view) {
   Intent intent = new Intent(this, DisplayMessageActivity.class);
   EditText editText = (EditText) findViewById(R.id.edit_message);
   String message = editText.getText().toString();
   intent.putExtra(EXTRA_MESSAGE, message);
   startActivity(intent);
 }
示例#2
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
示例#3
0
 @Override
 public void onItemClick(AdapterView adapterView, View view, int position, long id) {
   Log.d(TAG, "onItemClick: position: " + position + ", id: " + id);
   String item = listAdapter.getItem(position).trim();
   if (item.endsWith(" =")) {
     item = item.substring(0, item.length() - 2);
   }
   if (!item.startsWith("no result")) {
     inputView.append(item);
   }
 }
 @Override
 public void onExprItemClick(String exprInfo, boolean isDel) {
   SpannableString ss;
   int textSize = (int) editText.getTextSize();
   if (isDel) {
     HashMap<String, Integer> mExprFilenameIdData =
         XWExpressionManager.getInstance().getmExprInfoIdValuesCN(getActivity());
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(),
             XWExpressionUtil.deleteOneWord(editText.getText().toString(), mExprFilenameIdData),
             textSize);
   } else {
     String content = editText.getText() + exprInfo;
     ss =
         XWExpressionUtil.generateSpanComment(
             getActivity().getApplicationContext(), content, textSize);
   }
   editText.setText(ss);
   editText.setSelection(ss.length());
 }
 /**
  * 控制表情区和软键盘的显示
  *
  * @param isShowKeyboard
  * @param isSwitch
  */
 private void controlKeyboardOrExpr(boolean isShowKeyboard, boolean isSwitch) {
   if (isSwitch) {
     if (!isShowKeyboard) {
       mIsExprShow = true;
       mIsSoftKeyboardShow = false;
       mImm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
       mUiHandler.postDelayed(
           new Runnable() {
             @Override
             public void run() {
               mExpressionWidgt.setVisibility(View.VISIBLE);
             }
           },
           100);
       mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_keyboard);
     } else {
       mIsExprShow = false;
       mIsSoftKeyboardShow = true;
       mExpressionWidgt.setVisibility(View.GONE);
       mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
       mImm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
     }
   } else {
     if (isShowKeyboard) {
       mIsExprShow = false;
       mIsSoftKeyboardShow = true;
       mExpressionWidgt.setVisibility(View.GONE);
       mImm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
     } else {
       if (mIsSoftKeyboardShow) {
         mIsSoftKeyboardShow = false;
         mImm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
       } else {
         mIsExprShow = false;
         mExpressionWidgt.setVisibility(View.GONE);
       }
     }
     mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
   }
 }
示例#6
0
  @Override
  public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
    Log.d(TAG, "onEditorAction: actionId: " + actionId + ", keyEvent: " + keyEvent);

    if ((actionId == EditorInfo.IME_ACTION_DONE)
        || ((keyEvent != null) && (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
      Log.d(TAG, "onEditorAction: IME_ACTION_DONE || KEYCODE_ENTER");
      String input = textView.getText().toString().trim();

      if (input.length() > 0) {
        String result = "";

        try {
          result += calculator.calculate(input);
        } catch (Exception e) {
          result = "no result (" + e.getMessage() + ")";
        }

        if (listAdapter.getCount() > 0) {
          listAdapter.add("");
        }

        listAdapter.add(input + " =");
        if (input.indexOf("@") > -1) {
          listAdapter.add(calculator.getEquation() + " =");
        }
        listAdapter.add(result);
        listAdapter.notifyDataSetChanged();

        inputView.endBatchEdit();
        inputView.setText("");
        hideKeyboard();
      }
    }

    return false;
  }
 @Override
 public void onClick(View inButton) {
   boolean isErr = false;
   if (mTitle.getText().toString().length() == 0) {
     mTitle.setError("Required");
     mTitle.setEms(10);
     isErr = true;
   }
   if (mDesc.getText().toString().length() == 0) {
     mDesc.setActivated(true);
     mDesc.setError("Required");
     isErr = true;
   }
   if (inButton.getId() == openWeb.getId()) web.setVisibility(View.VISIBLE);
   else if (inButton.getId() == mAvail.getId())
     startActivity(new Intent(this, CheckActivity.class));
   else if (inButton.getId() == mBack.getId()) finish();
   else if (inButton.getId() == mSub.getId()) {
     AlertDialog.Builder al = new AlertDialog.Builder(this);
     if (isErr) return;
     else
       al.setTitle("Continue?")
           .setIcon(R.drawable.ornament)
           .setMessage("Your listing is going to be submitted to your chosen category.")
           .setPositiveButton(
               "OK",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {
                   payment = new ArrayList<String>();
                   if (mCard.isChecked()) payment.add("Card");
                   if (mCheck.isChecked()) payment.add("Check");
                   if (mOnline.isChecked()) payment.add("Online");
                   if (mCash.isChecked()) payment.add("Cash");
                   //			Toast.makeText(getApplicationContext(), payment.toString(),
                   // Toast.LENGTH_LONG).show();
                   Intent intent = new Intent(getApplicationContext(), StartActivity.class);
                   intent.putExtra("Payment", payment);
                   intent.putExtra("Category", mChosenCategory);
                   intent.putExtra("Title", mTitle.getText().toString());
                   intent.putExtra("Price", mPrice.getText().toString());
                   intent.putExtra("Description", mDesc.getText().toString());
                   intent.putExtra("Location", mLocation.getText().toString());
                   intent.putExtra("Photo", jpegData);
                   startActivity(intent);
                 }
               })
           .setNegativeButton(
               "Cancel",
               new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface d, int x) {}
               })
           .show();
   } else
     startActivityForResult(
         new Intent(this, com.lightbox.android.camera.activities.Camera.class), REQ);
 }
示例#8
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    Thread.currentThread().setUncaughtExceptionHandler(this);
    setContentView(R.layout.main);

    inputView = (EditText) findViewById(R.id.input_view);
    inputView.setOnEditorActionListener(this);

    listAdapter = new ArrayAdapter<String>(this, R.layout.row);
    listAdapter.setNotifyOnChange(true);

    resultsView = (ListView) this.findViewById(R.id.results_view);
    resultsView.setAdapter(listAdapter);
    resultsView.setOnItemClickListener(this);
  }
  @OnClick(R.id.comment_sendbtn)
  public void senAction() {
    String infoid = getArguments().getString("infoid");
    String userid = getArguments().getString("userid");
    String commentid = getArguments().getString("commentid");
    String content = editText.getText().toString().trim();
    if (TextUtils.isEmpty(content)) {
      showToast("请输入内容");
      return;
    }
    KeyboardUtil.hideSoftInput(getActivity());

    if (isCompanyCircle) {
      companyZoneCommentSub(infoid, userid, commentid, content);
    } else {
      String infouserid = getArguments().getString("infouserid");
      friendZoneCommentSub(infoid, userid, commentid, content, infouserid);
    }
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.request_location);

    findViewById(R.id.edit)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                findViewById(R.id.request_location_message_edit).setVisibility(View.VISIBLE);
                findViewById(R.id.request_location_message).setVisibility(View.GONE);
              }
            });
    final ImageButton save = (ImageButton) findViewById(R.id.save);
    save.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            findViewById(R.id.request_location_message_edit).setVisibility(View.GONE);
            findViewById(R.id.request_location_message).setVisibility(View.VISIBLE);
          }
        });

    msgView = (TextView) findViewById(R.id.request_location_message_text);
    editmsgView = (EditText) findViewById(R.id.request_location_message_edittext);
    editmsgView.setOnKeyListener(
        new View.OnKeyListener() {
          public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
              msgView.setText(editmsgView.getText());
            }
            return false;
          }
        });
    editmsgView.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          public void onFocusChange(View view, boolean b) {
            if (!b) {
              save.performClick();
            }
          }
        });

    requestLocationView = findViewById(R.id.request_location);
    requestLocationView.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View view) {
            // Send SMS to each tracker, and sets up the location database
            showDialog(SETUP_ALL);
          }
        });
    findViewById(R.id.main_menu)
        .setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View view) {
                // Go to select trackers screen
                Intent intent = new Intent("com.androidworks.navsys.wuffit.ACTION_MAIN_MENU");
                intent.addCategory(Intent.CATEGORY_DEFAULT);
                startActivity(intent);
              }
            });
    View footer =
        ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.footer_view, null);
    footerCountText = (TextView) footer.findViewById(R.id.text2);
    getListView().addFooterView(footer);

    // Establish a connection with the service.  We use an explicit
    // class name because we want a specific service implementation that
    // we know will be running in our own process (and thus won't be
    // supporting component replacement by other applications).
    bindService(
        new Intent(RequestLocation.this, SMSHandler.class),
        smsHandlerConnection,
        Context.BIND_AUTO_CREATE);
    isBound = true;
  }
示例#11
0
  private void promptForAddEdit(final MessageEntry messageEntry) {
    final boolean isEdit = messageEntry != null;
    String message = messageEntry == null ? "" : messageEntry.getMessage();

    final EditText text = new EditText(ExampleActivity.this);
    text.setText(message);
    String promptText = isEdit ? "Edit" : "Add";
    new AlertDialog.Builder(ExampleActivity.this)
        .setTitle(promptText + " a message")
        .setMessage(promptText + " text:")
        .setView(text)
        .setNeutralButton(
            "Cancel",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
              }
            })
        .setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(final DialogInterface dialogInterface, int i) {
                String value = text.getText().toString().trim();
                if (StringUtils.isNotEmpty(value)) {
                  new AsyncTask() {
                    @Override
                    protected Object doInBackground(Object... objects) {
                      try {
                        String messString = text.getText().toString();

                        MessageEntry localEntry = messageEntry;
                        if (localEntry == null) {
                          localEntry =
                              new MessageEntry(null, null, System.currentTimeMillis(), messString);
                        }
                        localEntry.setMessage(messString);
                        callUpdate(localEntry);
                      } catch (StorageException e) {
                        throw new RuntimeException(e);
                      }
                      return null;
                    }

                    @Override
                    protected void onPostExecute(Object o) {
                      dialogInterface.dismiss();
                    }
                  }.execute();
                }
              }
            })
        .setNegativeButton(
            "Delete",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {
                new AsyncTask() {
                  @Override
                  protected Object doInBackground(Object... objects) {

                    try {

                      MessageEntry localEntry = messageEntry;

                      localEntry.setPosted(-1l);

                      callUpdate(localEntry);

                    } catch (StorageException e) {
                      e.printStackTrace(); // To change body of catch statement use File |
                      // Settings | File Templates.
                    }
                    return null;
                  }
                }.execute();
              }
            })
        .show();
  }
 @Override
 public void onShowInputView() {
   editText.setHint("");
 }
示例#13
0
 public void clear() {
   inputView.setText("");
   listAdapter.clear();
   listAdapter.notifyDataSetChanged();
 }
示例#14
0
  @Override
  public void onClick(View v) {
    TextView txtManageLabel, txtBrowseLabel, txtRefreshLabel, txtSearchLabel;
    txtManageLabel = (TextView) findViewById(R.id.txt_manage_label);
    txtBrowseLabel = (TextView) findViewById(R.id.txt_browse_label);
    txtRefreshLabel = (TextView) findViewById(R.id.txt_refresh_label);
    txtSearchLabel = (TextView) findViewById(R.id.txt_search_label);
    txtSearch.addTextChangedListener(
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            new AsyncTask<String, Void, ArrayList<RssItem>>() {
              @Override
              protected ArrayList<RssItem> doInBackground(String... params) {
                return dbQuery.searchRssItem(params[0]);
              }

              @Override
              protected void onPostExecute(ArrayList<RssItem> result) {
                rssList.clear();
                rssList.addAll(result);
                rssAdapter.config().notifyDataSetChanged();
              }
            }.execute(s.toString());
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {}
        });
    txtSearch.setOnKeyListener(
        new OnKeyListener() {
          @Override
          public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) return true;
            return false;
          }
        });
    switch (v.getId()) {
      case R.id.btn_manage:
        startActivityForResult(
            new Intent(RssReaderActivity.this, RssManageActivity.class), REQ_RSS_MANAGE);
        break;

      case R.id.btn_browse:
        rssProvider = dbQuery.getRssProviderList(null);
        int length = rssProvider.getProviderNames().length;
        if (length == 0) break;

        String[] providers = new String[length + 1];
        providers[0] = "All";
        for (int i = 0; i < length; i++) providers[i + 1] = rssProvider.getProviderNames()[i];
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder
            .setTitle(R.string.rss_choose_provider)
            .setItems(
                providers,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                      loadData(null, true, false, false);
                      return;
                    }
                    loadData(rssProvider.getProviderNames()[item - 1], false, false, false);
                    curProvider = item - 1;
                    updateListView();
                  }
                });
        builder.create().show();
        break;

      case R.id.btn_refresh:
        if (curProvider == -1) loadData(null, true, true, true);
        else
          loadData(
              dbQuery.getRssProviderList(null).getProviderNames()[curProvider], false, true, true);
        break;

      case R.id.btn_search:
        if (txtSearchLabel.getText().toString().equals(getString(R.string.btn_search_text))) {
          btnManage.setVisibility(View.GONE);
          txtManageLabel.setVisibility(View.GONE);
          btnBrowse.setVisibility(View.GONE);
          txtBrowseLabel.setVisibility(View.GONE);
          btnRefresh.setVisibility(View.GONE);
          txtRefreshLabel.setVisibility(View.GONE);
          btnSearch.setBackgroundResource(R.drawable.btn_done_background);
          txtSearchLabel.setText(R.string.btn_done_text);
          txtSearch.setVisibility(View.VISIBLE);
          txtSearch.requestFocus();
        } else {
          btnManage.setVisibility(View.VISIBLE);
          txtManageLabel.setVisibility(View.VISIBLE);
          btnBrowse.setVisibility(View.VISIBLE);
          txtBrowseLabel.setVisibility(View.VISIBLE);
          btnRefresh.setVisibility(View.VISIBLE);
          txtRefreshLabel.setVisibility(View.VISIBLE);
          btnSearch.setBackgroundResource(R.drawable.btn_search_background);
          txtSearchLabel.setText(R.string.btn_search_text);
          txtSearch.setVisibility(View.GONE);
          txtSearch.setText("");
          loadData(null, true, false, false);
        }
        break;
      default:
        break;
    }
  }
示例#15
0
        public void onClick(View v) {
          ContentResolver cr = getContentResolver();
          switch (v.getId()) {
              // 전부 읽기
            case R.id.readall:
              Cursor cursor = cr.query(Uri.parse(WORDURI), null, null, null, null);

              String Result = "";
              while (cursor.moveToNext()) {
                String eng = cursor.getString(0);
                String han = cursor.getString(1);
                Result += (eng + " = " + han + "\n");
              }

              if (Result.length() == 0) {
                mText.setText("Empyt Set");
              } else {
                mText.setText(Result);
              }
              cursor.close();
              break;
              // 하나만 읽기
            case R.id.readone:
              Cursor cursor2 = cr.query(Uri.parse(WORDURI + "/boy"), null, null, null, null);

              String Result2 = "";
              if (cursor2.moveToFirst()) {
                String eng = cursor2.getString(0);
                String han = cursor2.getString(1);
                Result2 += (eng + " = " + han + "\n");
              }

              if (Result2.length() == 0) {
                mText.setText("Empyt Set");
              } else {
                mText.setText(Result2);
              }
              cursor2.close();
              break;
              // 삽입
            case R.id.insert:
              ContentValues row = new ContentValues();
              row.put("eng", "school");
              row.put("han", "학교");

              cr.insert(Uri.parse(WORDURI), row);
              mText.setText("Insert Success");
              break;
              // 삭제
            case R.id.delete:
              cr.delete(Uri.parse(WORDURI), null, null);
              mText.setText("Delete Success");
              break;
              // 수정
            case R.id.update:
              ContentValues row2 = new ContentValues();
              row2.put("han", "핵교");
              cr.update(Uri.parse(WORDURI + "/school"), row2, null, null);
              mText.setText("Update Success");
              break;
          }
        }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.search);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      getWindow().setStatusBarColor(getResources().getColor(R.color.holo_blue_bright));
    }
    listmain = new ArrayList<ConRecItem>();
    tm = (EditText) findViewById(R.id.setext);
    final RecycleItemClickListener itemClickListener =
        new RecycleItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            switch (position) {
              default:
                Intent intent = new Intent(searchActivity.this, conActivity.class);
                Data data = new Data();
                File fl = new File("/storage/sdcard0/M++/data/slist.txt");
                String spos = data.getData(fl, position + 1);
                int pos = Integer.valueOf(spos);
                intent.putExtra("pos", pos);
                startActivity(intent);
                break;
            }
          }
        };
    int displayWidth = 0;
    int displayHeight = 0;
    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    displayWidth = displayMetrics.widthPixels;
    displayHeight = displayMetrics.heightPixels;
    final int rpos = displayWidth / 320;
    listmain = new ArrayList<ConRecItem>();
    ConRecAdapter adapter = new ConRecAdapter(listmain, itemClickListener);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
    recyclerView.setLayoutManager(
        new StaggeredGridLayoutManager(rpos, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setAdapter(adapter);
    tm.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void beforeTextChanged(CharSequence p1, int p2, int p3, int p4) {
            // TODO: Implement this method
          }

          @Override
          public void onTextChanged(CharSequence p1, int p2, int p3, int p4) {
            // TODO: Implement this method
          }

          @Override
          public void afterTextChanged(Editable edit) {

            // TODO
            listmain = new ArrayList<ConRecItem>();
            System.out.println("okokok");
            File fs = new File("/storage/sdcard0/M++/data/fs_con.txt");
            File fl = new File("/storage/sdcard0/M++/data/slist.txt");
            String text = tm.getText().toString();
            if (fs.exists()) {
              listmain = new ArrayList<ConRecItem>();
              if (fl.exists()) {
                fl.delete();
              }

              try {
                fl.createNewFile();

                String reg = ".*" + text + ".*";

                FileReader fr = new FileReader(fs);

                BufferedReader br = new BufferedReader(fr);

                String temp = null;
                String s = "";

                while ((temp = br.readLine()) != null) {
                  s += temp + "\n";
                }

                String[] ss = s.split("\n");
                for (int i = 0; i <= ss.length; i++) {
                  try {
                    if (ss[10 * i].matches(reg)) {
                      ConRecItem p = new ConRecItem(ss[10 * i + 1], ss[10 * i]);
                      listmain.add(p);
                      String spos = String.valueOf(i);
                      Data data = new Data();
                      data.writeData(fl, spos + "\n", false);
                    }
                  } catch (ArrayIndexOutOfBoundsException e) {
                  }
                }
                ConRecAdapter adapter = new ConRecAdapter(listmain, itemClickListener);
                RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler);
                recyclerView.setLayoutManager(
                    new StaggeredGridLayoutManager(rpos, StaggeredGridLayoutManager.VERTICAL));
                recyclerView.setAdapter(adapter);

              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          };
        });
  }
示例#17
0
 public void hideKeyboard() {
   InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
   imm.hideSoftInputFromWindow(inputView.getWindowToken(), 0);
 }
示例#18
0
  private String nameDialog(String dialogTitle, String nameTxt) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(this);
    final EditText nameInput = new EditText(this);
    final Long id2;
    //        String nameTxt;

    //        nameInput.setInputType(0x00080000 | 0x00000002);
    nameInput.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

    if (nameTxt == null) {
      nameTxt = "";
      nameInput.setHint("Enter filename");
    }

    nameInput.setText(nameTxt);
    alert.setTitle(dialogTitle);
    alert.setView(nameInput);

    alert.setPositiveButton(
        "Ok",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            String value = nameInput.getText().toString().trim();
            Toast.makeText(getApplicationContext(), value, Toast.LENGTH_SHORT).show();
            try {
              int x = mItem;
              boolean xb = (value != null);
              xb = !(value.equals(""));
              if ((value != null) && !(value.equals(""))) {
                fileNameIn = value;
                // getDir(sdcard);
                switch (mItem) {
                  case mCopy:
                    fileName = root + value; // TODO: Check for dir
                    cpDb(fileName);
                    finish();
                    break;
                  case mDelete:
                    deleteDatabase(CreateShopDatabase.DATABASE_NAME);

                    finish();
                    break;

                  case mExport:
                    fileName = selectFile + "/" + value + ".abb"; // TODO: Check for dir
                    cpDb(fileName);
                    finish();
                    break;
                }
                // do something with value
              }
            } catch (Exception ignored) {
            }
          }
        });

    alert.setNegativeButton(
        "Cancel",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
          }
        });
    alert.show();
    return nameTxt;
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    editText.setHint(getArguments().getString("hint"));
    isCompanyCircle = getArguments().getBoolean("isCompanyCircle");
    mImm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    getView()
        .findViewById(R.id.ly_other)
        .setOnTouchListener(
            new View.OnTouchListener() {
              @Override
              public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_UP) {
                  //                    finish();
                  KeyboardUtil.hideSoftInput(getActivity());
                  if (mComLis != null) {
                    mComLis.onHideCommunityCommentary();
                  }
                  getFragmentManager()
                      .beginTransaction()
                      .remove(CommunityCommentaryFragment.this)
                      .commit();
                  return true;
                }
                return false;
              }
            });
    mRootContainer.setOnInputViewListener(this);

    editText.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              if (mIsExprShow) {
                mIsExprShow = false;
                mIsSoftKeyboardShow = true;
                mExpressionWidgt.setVisibility(View.GONE);
                mExprBtn.setBackgroundResource(R.drawable.selector_s_chat_expressions);
              }
            }
            return false;
          }
        });
    mSoftKeyboardHeight = PreferencesManager.getSoftKeyboardHeight(getActivity());
    if (mSoftKeyboardHeight > 0) {
      resizeExprArea(Constants.screenWidth);
    } else {
      mSoftKeyboardHeight = Constants.screenHeight / 3;
    }

    /** 测量软键盘所占区域高度 */
    mRootContainer
        .getViewTreeObserver()
        .addOnGlobalLayoutListener(
            new ViewTreeObserver.OnGlobalLayoutListener() {
              @Override
              public void onGlobalLayout() {
                Rect r = new Rect();
                if (mRootContainer != null) {
                  mRootContainer.getWindowVisibleDisplayFrame(r);
                  int screenHeight = mRootContainer.getHeight();
                  final int screenWidth = mRootContainer.getWidth();
                  if (mOriginalHeight == 0) {
                    mOriginalHeight = screenHeight;
                  } else {
                    if (screenHeight != mOriginalHeight && !isExprAreaResized) {
                      mSoftKeyboardHeight = Math.abs(screenHeight - mOriginalHeight);
                      PreferencesManager.saveSoftKeyboardHeight(getActivity(), mSoftKeyboardHeight);
                      isExprAreaResized = true;
                      mUiHandler.post(
                          new Runnable() {
                            @Override
                            public void run() {
                              resizeExprArea(screenWidth);
                            }
                          });
                    }
                  }
                }
              }
            });
    mExpressionWidgt.setmOnExprItemClickListener(this);
    resizeExprArea(Constants.screenWidth);
    KeyboardUtil.showSoftInput(editText);
  }