List of usage examples for android.text Editable toString
public String toString();
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void editFileFilterDlg(final ArrayList<String> file_filter, final NotifyEvent p_ntfy) { ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>(); final AdapterFilterList filterAdapter; // ??/*from w ww .j a va2 s .c om*/ final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn); dirbtn.setVisibility(Button.GONE); filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList); ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview); for (int i = 0; i < file_filter.size(); i++) { String inc = file_filter.get(i).substring(0, 1); String filter = file_filter.get(i).substring(1, file_filter.get(i).length()); boolean b_inc = false; if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE)) b_inc = true; filterAdapter.add(new FilterListItem(filter, b_inc)); } if (filterAdapter.getCount() == 0) filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false)); lv.setAdapter(filterAdapter); // filterAdapter.getFileFilter().filter("D"); // lv.setTextFilterEnabled(false); // lv.setDivider(new ColorDrawable(Color.WHITE)); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_file_filter)); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg); CommonDialog.setDlgBoxSizeLimit(dialog, true); // CommonDialog.setDlgBoxSizeCompact(dialog); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter); final Button addBtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { FilterListItem fli = filterAdapter.getItem(idx); if (fli.getFilter().startsWith("---") || fli.isDeleted()) return; // ???????? editDirFilter(idx, filterAdapter, fli, fli.getFilter()); } }); // Add? addBtn.setEnabled(false); et_filter.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() != 0) { if (isFilterExists(s.toString().trim(), filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, s.toString().trim())); addBtn.setEnabled(false); btn_ok.setEnabled(true); } else { dlg_msg.setText(""); addBtn.setEnabled(true); btn_ok.setEnabled(false); } } else { addBtn.setEnabled(false); btn_ok.setEnabled(true); } // et_filter.setText(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); addBtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dlg_msg.setText(""); String newfilter = et_filter.getText().toString().trim(); et_filter.setText(""); if (filterAdapter.getItem(0).getFilter().startsWith("---")) filterAdapter.remove(filterAdapter.getItem(0)); filterAdapter.add(new FilterListItem(newfilter, true)); filterAdapter.setNotifyOnChange(true); filterAdapter.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); btn_ok.setEnabled(true); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); file_filter.clear(); if (filterAdapter.getCount() > 0) { for (int i = 0; i < filterAdapter.getCount(); i++) { if (!filterAdapter.getItem(i).isDeleted() && !filterAdapter.getItem(i).getFilter().startsWith("---")) { String inc = SMBSYNC_PROF_FILTER_EXCLUDE; if (filterAdapter.getItem(i).getInc()) inc = SMBSYNC_PROF_FILTER_INCLUDE; file_filter.add(inc + filterAdapter.getItem(i).getFilter()); } } } p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBSync2.SyncTaskUtility.java
public void editDirFilterDlg(final SyncTaskItem sti, final String prof_master, final ArrayList<String> dir_filter, final NotifyEvent p_ntfy) { ArrayList<FilterListItem> filterList = new ArrayList<FilterListItem>(); final AdapterFilterList filterAdapter; // ??//from w w w .j a v a2 s. co m final Dialog dialog = new Dialog(mContext); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.filter_list_dlg); LinearLayout ll_dlg_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_view); ll_dlg_view.setBackgroundColor(mGp.themeColorList.dialog_msg_background_color); final LinearLayout title_view = (LinearLayout) dialog.findViewById(R.id.filter_select_edit_title_view); final TextView title = (TextView) dialog.findViewById(R.id.filter_select_edit_title); title_view.setBackgroundColor(mGp.themeColorList.dialog_title_background_color); title.setTextColor(mGp.themeColorList.text_color_dialog_title); filterAdapter = new AdapterFilterList(mContext, R.layout.filter_list_item_view, filterList); final ListView lv = (ListView) dialog.findViewById(R.id.filter_select_edit_listview); for (int i = 0; i < dir_filter.size(); i++) { String inc = dir_filter.get(i).substring(0, 1); String filter = dir_filter.get(i).substring(1, dir_filter.get(i).length()); boolean b_inc = false; if (inc.equals(SMBSYNC_PROF_FILTER_INCLUDE)) b_inc = true; filterAdapter.add(new FilterListItem(filter, b_inc)); } if (filterAdapter.getCount() == 0) filterAdapter.add(new FilterListItem(mContext.getString(R.string.msgs_filter_list_no_filter), false)); lv.setAdapter(filterAdapter); lv.setScrollingCacheEnabled(false); lv.setScrollbarFadingEnabled(false); title.setText(mContext.getString(R.string.msgs_filter_list_dlg_dir_filter)); final TextView dlg_msg = (TextView) dialog.findViewById(R.id.filter_select_edit_msg); final Button dirbtn = (Button) dialog.findViewById(R.id.filter_select_edit_dir_btn); CommonDialog.setDlgBoxSizeLimit(dialog, true); final EditText et_filter = (EditText) dialog.findViewById(R.id.filter_select_edit_new_filter); final Button addbtn = (Button) dialog.findViewById(R.id.filter_select_edit_add_btn); final Button btn_cancel = (Button) dialog.findViewById(R.id.filter_select_edit_cancel_btn); final Button btn_ok = (Button) dialog.findViewById(R.id.filter_select_edit_ok_btn); lv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> items, View view, int idx, long id) { FilterListItem fli = filterAdapter.getItem(idx); if (fli.getFilter().startsWith("---") || fli.isDeleted()) return; // ???????? editDirFilter(idx, filterAdapter, fli, fli.getFilter()); } }); // Add? et_filter.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.length() != 0) { if (isFilterExists(s.toString().trim(), filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, s.toString().trim())); addbtn.setEnabled(false); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } else { dlg_msg.setText(""); addbtn.setEnabled(true); dirbtn.setEnabled(false); btn_ok.setEnabled(false); } } else { addbtn.setEnabled(false); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } // et_filter.setText(s); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); addbtn.setEnabled(false); addbtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dlg_msg.setText(""); String newfilter = et_filter.getText().toString(); if (isFilterExists(newfilter, filterAdapter)) { String mtxt = mContext.getString(R.string.msgs_filter_list_duplicate_filter_specified); dlg_msg.setText(String.format(mtxt, newfilter)); return; } dlg_msg.setText(""); et_filter.setText(""); if (filterAdapter.getItem(0).getFilter().startsWith("---")) filterAdapter.remove(filterAdapter.getItem(0)); filterAdapter.add(new FilterListItem(newfilter, true)); filterAdapter.setNotifyOnChange(true); filterAdapter.sort(new Comparator<FilterListItem>() { @Override public int compare(FilterListItem lhs, FilterListItem rhs) { return lhs.getFilter().compareToIgnoreCase(rhs.getFilter()); }; }); dirbtn.setEnabled(true); btn_ok.setEnabled(true); } }); // Directory? // if (getProfileType(prof_master,prof_dapter).equals("L")) { // if (!mGp.externalStorageIsMounted) dirbtn.setEnabled(false); // } else if (getProfileType(prof_master,prof_dapter).equals("R")) { // if (util.isRemoteDisable()) dirbtn.setEnabled(false); // } else dirbtn.setEnabled(false); dirbtn.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { NotifyEvent ntfy = new NotifyEvent(mContext); //Listen setRemoteShare response ntfy.setListener(new NotifyEventListener() { @Override public void positiveResponse(Context arg0, Object[] arg1) { dlg_msg.setText(""); } @Override public void negativeResponse(Context arg0, Object[] arg1) { if (arg1 != null) dlg_msg.setText((String) arg1[0]); else dlg_msg.setText(""); } }); listDirFilter(sti, prof_master, dir_filter, filterAdapter, ntfy); } }); // CANCEL? btn_cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // glblParms.profileListView.setSelectionFromTop(currentViewPosX,currentViewPosY); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btn_cancel.performClick(); } }); // OK? btn_ok.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); dir_filter.clear(); if (filterAdapter.getCount() > 0) { for (int i = 0; i < filterAdapter.getCount(); i++) { if (!filterAdapter.getItem(i).isDeleted() && !filterAdapter.getItem(i).getFilter().startsWith("---")) { String inc = SMBSYNC_PROF_FILTER_EXCLUDE; if (filterAdapter.getItem(i).getInc()) inc = SMBSYNC_PROF_FILTER_INCLUDE; dir_filter.add(inc + filterAdapter.getItem(i).getFilter()); } } } p_ntfy.notifyToListener(true, null); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(context)); // dialog.setCancelable(false); dialog.show(); }
From source file:org.anurag.file.quest.TaskerActivity.java
/** * THIS FUNCTION CONTAINS ALL THE ACTION THAT HAS TO BE PERFORMED WHEN * SEARCH IS IN PROGRESS//from ww w. ja v a 2 s.c o m */ public void search() { searchList = new ArrayList<File>(); try { LinearLayout a = (LinearLayout) findViewById(R.id.applyBtn); a.setVisibility(View.GONE); //Search Flipper is loaded mVFlipper.setAnimation(nextAnim()); mVFlipper.showNext(); mVFlipper.showNext(); SEARCH_FLAG = true; // PREVIOUS COMMANDS ARE OVERWRITTEN COPY_COMMAND = CUT_COMMAND = RENAME_COMMAND = CREATE_FILE = false; editBox.setTextColor(Color.WHITE); editBox.setText(null); editBox.setHint("Enter Name To Filter Out"); editBox.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { searchList.clear(); // TODO Auto-generated method stub } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { searchList.clear(); // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable text) { // TODO Auto-generated method stub searchList.clear(); File f = new File(PATH); if (CURRENT_ITEM == 2) f = new File(RFileManager.getCurrentDirectory()); else if (CURRENT_ITEM == 1) f = new File(SFileManager.getCurrentDirectory()); final File[] list = f.listFiles(); final String search = text.toString(); final String[] fList = f.list(); new AsyncTask<String[], Void, Void>() { @Override protected void onPostExecute(Void result) { if (SEARCH_FLAG) { if (CURRENT_ITEM == 2) { root.setAdapter( new RootAdapter(getBaseContext(), R.layout.row_list_1, searchList)); } else if (CURRENT_ITEM == 1) { simple.setAdapter( new SimpleAdapter(getBaseContext(), R.layout.row_list_1, searchList)); } else LIST_VIEW_3D.setAdapter(new MediaElementAdapter(getBaseContext(), R.layout.row_list_1, searchList)); } } protected void onPreExecute() { if (SEARCH_FLAG) { if (CURRENT_ITEM == 2) root.setAdapter(null); else if (CURRENT_ITEM == 1) simple.setAdapter(null); else LIST_VIEW_3D.setAdapter(null); } super.onPreExecute(); } @Override protected Void doInBackground(String[]... arg0) { if (SEARCH_FLAG) { // SEARCH IS PERFORMED FOR CURRENT ITEM 0 if (CURRENT_ITEM == 0) { int len = mediaFileList.size(); for (int i = 0; i < len; ++i) { File file = mediaFileList.get(i); if (file.canRead()) if (file.getName().toLowerCase().contains(search)) searchList.add(file); } } // SEARCH IS PERFORMED FOR CURRENT ITEM = 1,2 else for (int i = 0; i < fList.length; ++i) { if (CURRENT_ITEM == 2) { if (list[i].canRead()) { if ((fList[i].toLowerCase()).contains(search.toLowerCase())) searchList.add(list[i]); } } else if (CURRENT_ITEM == 1) { if ((fList[i].toLowerCase()).contains(search.toLowerCase())) searchList.add(list[i]); } } } return null; } }.execute(); } }); } catch (IllegalStateException e) { } catch (RuntimeException e) { } catch (Exception e) { } }
From source file:org.mozilla.focus.widget.InlineAutocompleteEditText.java
/** * Add autocomplete text based on the result URI. * * @param result Result URI to be turned into autocomplete text *//*www. ja v a 2 s .c o m*/ public final void onAutocomplete(final String result) { // If mDiscardAutoCompleteResult is true, we temporarily disabled // autocomplete (due to backspacing, etc.) and we should bail early. if (mDiscardAutoCompleteResult) { return; } if (!isEnabled() || result == null) { mAutoCompleteResult = ""; return; } final Editable text = getText(); final int textLength = text.length(); final int resultLength = result.length(); final int autoCompleteStart = text.getSpanStart(AUTOCOMPLETE_SPAN); mAutoCompleteResult = result; if (autoCompleteStart > -1) { // Autocomplete text already exists; we should replace existing autocomplete text. // If the result and the current text don't have the same prefixes, // the result is stale and we should wait for the another result to come in. if (!TextUtils.regionMatches(result, 0, text, 0, autoCompleteStart)) { return; } beginSettingAutocomplete(); // Replace the existing autocomplete text with new one. // replace() preserves the autocomplete spans that we set before. text.replace(autoCompleteStart, textLength, result, autoCompleteStart, resultLength); // Reshow the cursor if there is no longer any autocomplete text. if (autoCompleteStart == resultLength) { setCursorVisible(true); } endSettingAutocomplete(); } else { // No autocomplete text yet; we should add autocomplete text // If the result prefix doesn't match the current text, // the result is stale and we should wait for the another result to come in. if (resultLength <= textLength || !TextUtils.regionMatches(result, 0, text, 0, textLength)) { return; } final Object[] spans = text.getSpans(textLength, textLength, Object.class); final int[] spanStarts = new int[spans.length]; final int[] spanEnds = new int[spans.length]; final int[] spanFlags = new int[spans.length]; // Save selection/composing span bounds so we can restore them later. for (int i = 0; i < spans.length; i++) { final Object span = spans[i]; final int spanFlag = text.getSpanFlags(span); // We don't care about spans that are not selection or composing spans. // For those spans, spanFlag[i] will be 0 and we don't restore them. if ((spanFlag & Spanned.SPAN_COMPOSING) == 0 && (span != Selection.SELECTION_START) && (span != Selection.SELECTION_END)) { continue; } spanStarts[i] = text.getSpanStart(span); spanEnds[i] = text.getSpanEnd(span); spanFlags[i] = spanFlag; } beginSettingAutocomplete(); // First add trailing text. text.append(result, textLength, resultLength); // Restore selection/composing spans. for (int i = 0; i < spans.length; i++) { final int spanFlag = spanFlags[i]; if (spanFlag == 0) { // Skip if the span was ignored before. continue; } text.setSpan(spans[i], spanStarts[i], spanEnds[i], spanFlag); } // Mark added text as autocomplete text. for (final Object span : mAutoCompleteSpans) { text.setSpan(span, textLength, resultLength, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } // Hide the cursor. setCursorVisible(false); // Make sure the autocomplete text is visible. If the autocomplete text is too // long, it would appear the cursor will be scrolled out of view. However, this // is not the case in practice, because EditText still makes sure the cursor is // still in view. bringPointIntoView(resultLength); endSettingAutocomplete(); } announceForAccessibility(text.toString()); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void createItem(final FileListAdapter fla, final String item_optyp, final String base_dir) { sendDebugLogMsg(1, "I", "createItem entered."); // ??/*from w w w . j av a 2 s .c o m*/ final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.file_rename_create_dlg); final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname); final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn); final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn); CommonDialog.setDlgBoxSizeCompact(dialog); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Create directory"); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name"); // newName.setText(item_name); btnOk.setEnabled(false); // btnCancel.setEnabled(false); newName.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().length() < 1) btnOk.setEnabled(false); else btnOk.setEnabled(true); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); if (!checkDuplicateDir(fla, newName.getText().toString())) { commonDlg.showCommonDialog(false, "E", "Create", "Duplicate directory name specified", null); } else { int cmd = 0; if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "", newName.getText().toString(), "", smbUser, smbPass, true); cmd = FILEIO_PARM_LOCAL_CREATE; } else { cmd = FILEIO_PARM_REMOTE_CREATE; fileioLinkParm = buildFileioLinkParm(fileioLinkParm, base_dir, "", newName.getText().toString(), "", smbUser, smbPass, true); } sendDebugLogMsg(1, "I", "createItem FILEIO task invoked."); startFileioTask(fla, cmd, fileioLinkParm, newName.getText().toString(), null, null); } } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); sendDebugLogMsg(1, "W", "createItem cancelled."); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // setFixedOrientation(true); // dialog.setCancelable(false); dialog.show(); }
From source file:com.sentaroh.android.SMBExplorer.SMBExplorerMain.java
private void renameItem(final FileListAdapter fla, final String item_optyp, final String item_name, final boolean item_isdir, final int item_num) { sendDebugLogMsg(1, "I", "renameItem entered."); // ??//w ww . j a v a 2 s. co m final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(R.layout.file_rename_create_dlg); final EditText newName = (EditText) dialog.findViewById(R.id.file_rename_create_dlg_newname); final Button btnOk = (Button) dialog.findViewById(R.id.file_rename_create_dlg_ok_btn); final Button btnCancel = (Button) dialog.findViewById(R.id.file_rename_create_dlg_cancel_btn); CommonDialog.setDlgBoxSizeCompact(dialog); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_title)).setText("Rename"); ((TextView) dialog.findViewById(R.id.file_rename_create_dlg_subtitle)).setText("Enter new name"); newName.setText(item_name); btnOk.setEnabled(false); newName.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { if (s.toString().length() < 1 || item_name.equals(s.toString())) btnOk.setEnabled(false); else btnOk.setEnabled(true); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); // OK? btnOk.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // setFixedOrientation(false); if (item_name.equals(newName.getText().toString())) { commonDlg.showCommonDialog(false, "E", "Rename", "Duplicate file name specified", null); } else { int cmd = 0; if (currentTabName.equals(SMBEXPLORER_TAB_LOCAL)) { fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(), fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), "", "", true); cmd = FILEIO_PARM_LOCAL_RENAME; } else { cmd = FILEIO_PARM_REMOTE_RENAME; if (item_isdir) fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(), fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), smbUser, smbPass, true); else fileioLinkParm = buildFileioLinkParm(fileioLinkParm, fla.getItem(item_num).getPath(), fla.getItem(item_num).getPath(), item_name, newName.getText().toString(), smbUser, smbPass, true); } sendDebugLogMsg(1, "I", "renameItem FILEIO task invoked."); startFileioTask(fla, cmd, fileioLinkParm, item_name, null, null); } } }); // CANCEL? btnCancel.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { dialog.dismiss(); // setFixedOrientation(false); sendDebugLogMsg(1, "W", "renameItem cancelled."); } }); // Cancel? dialog.setOnCancelListener(new Dialog.OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { btnCancel.performClick(); } }); // dialog.setOnKeyListener(new DialogOnKeyListener(currentContext)); // setFixedOrientation(true); // dialog.setCancelable(false); dialog.show(); }
From source file:com.example.libwidgettv.bak.AbsListView.java
@Override public Parcelable onSaveInstanceState() { /*// ww w . j a va2s . co m * This doesn't really make sense as the place to dismiss the popups, * but there don't seem to be any other useful hooks that happen early * enough to keep from getting complaints about having leaked the * window. */ dismissPopup(); Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); boolean haveChildren = getChildCount() > 0 && mItemCount > 0; long selectedId = getSelectedItemId(); ss.selectedId = selectedId; ss.height = getHeight(); if (selectedId >= 0) { // Remember the selection ss.viewTop = mSelectedTop; ss.position = getSelectedItemPosition(); ss.firstId = INVALID_POSITION; } else { if (haveChildren && mFirstPosition > 0) { // Remember the position of the first child. // We only do this if we are not currently at the top of // the list, for two reasons: // (1) The list may be in the process of becoming empty, in // which case mItemCount may not be 0, but if we try to // ask for any information about position 0 we will crash. // (2) Being "at the top" seems like a special case, anyway, // and the user wouldn't expect to end up somewhere else when // they revisit the list even if its content has changed. View v = getChildAt(0); ss.viewTop = v.getTop(); int firstPos = mFirstPosition; if (firstPos >= mItemCount) { firstPos = mItemCount - 1; } ss.position = firstPos; ss.firstId = mAdapter.getItemId(firstPos); } else { ss.viewTop = 0; ss.firstId = INVALID_POSITION; ss.position = 0; } } ss.filter = null; if (mFiltered) { final EditText textFilter = mTextFilter; if (textFilter != null) { Editable filterText = textFilter.getText(); if (filterText != null) { ss.filter = filterText.toString(); } } } ss.inActionMode = mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode != null; if (mCheckStates != null) { ss.checkState = mCheckStates.clone(); } if (mCheckedIdStates != null) { final LongSparseArray<Integer> idState = new LongSparseArray<Integer>(); final int count = mCheckedIdStates.size(); for (int i = 0; i < count; i++) { idState.put(mCheckedIdStates.keyAt(i), mCheckedIdStates.valueAt(i)); } ss.checkIdState = idState; } ss.checkedItemCount = mCheckedItemCount; return ss; }
From source file:com.common.widget.hzlib.AbsHorizontalListView.java
@Override public Parcelable onSaveInstanceState() { /*//www . j a v a 2 s .c om * This doesn't really make sense as the place to dismiss the * popups, but there don't seem to be any other useful hooks * that happen early enough to keep from getting complaints * about having leaked the window. */ dismissPopup(); Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); if (mPendingSync != null) { // Just keep what we last restored. ss.selectedId = mPendingSync.selectedId; ss.firstId = mPendingSync.firstId; ss.viewLeft = mPendingSync.viewLeft; ss.position = mPendingSync.position; ss.width = mPendingSync.width; ss.filter = mPendingSync.filter; ss.inActionMode = mPendingSync.inActionMode; ss.checkedItemCount = mPendingSync.checkedItemCount; ss.checkState = mPendingSync.checkState; ss.checkIdState = mPendingSync.checkIdState; return ss; } boolean haveChildren = getChildCount() > 0 && mItemCount > 0; long selectedId = getSelectedItemId(); ss.selectedId = selectedId; ss.width = getWidth(); if (selectedId >= 0) { // Remember the selection ss.viewLeft = mSelectedLeft; ss.position = getSelectedItemPosition(); ss.firstId = INVALID_POSITION; } else { if (haveChildren && mFirstPosition > 0) { // Remember the position of the first child. // We only do this if we are not currently at the top of // the list, for two reasons: // (1) The list may be in the process of becoming empty, in // which case mItemCount may not be 0, but if we try to // ask for any information about position 0 we will crash. // (2) Being "at the top" seems like a special case, anyway, // and the user wouldn't expect to end up somewhere else when // they revisit the list even if its content has changed. View v = getChildAt(0); ss.viewLeft = v.getLeft(); int firstPos = mFirstPosition; if (firstPos >= mItemCount) { firstPos = mItemCount - 1; } ss.position = firstPos; ss.firstId = mAdapter.getItemId(firstPos); } else { ss.viewLeft = 0; ss.firstId = INVALID_POSITION; ss.position = 0; } } ss.filter = null; if (mFiltered) { final EditText textFilter = mTextFilter; if (textFilter != null) { Editable filterText = textFilter.getText(); if (filterText != null) { ss.filter = filterText.toString(); } } } if (mCheckStates != null) { ss.checkState = mCheckStates.clone(); } if (mCheckedIdStates != null) { final LongSparseArray<Integer> idState = new LongSparseArray<Integer>(); final int count = mCheckedIdStates.size(); for (int i = 0; i < count; i++) { idState.put(mCheckedIdStates.keyAt(i), mCheckedIdStates.valueAt(i)); } ss.checkIdState = idState; } ss.checkedItemCount = mCheckedItemCount; return ss; }
From source file:com.irccloud.android.activity.MainActivity.java
@SuppressLint("NewApi") @SuppressWarnings({ "deprecation", "unchecked" }) @Override//from w w w . j a v a2s . c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); suggestionsTimer = new Timer("suggestions-timer"); countdownTimer = new Timer("messsage-countdown-timer"); IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON); filter.addAction(Intent.ACTION_SCREEN_OFF); registerReceiver(screenReceiver, filter); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); if (cloud != null) { setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC)); cloud.recycle(); } } setContentView(R.layout.activity_message); try { setSupportActionBar((Toolbar) findViewById(R.id.toolbar)); } catch (Throwable t) { } suggestionsAdapter = new SuggestionsAdapter(); progressBar = (ProgressBar) findViewById(R.id.progress); errorMsg = (TextView) findViewById(R.id.errorMsg); buffersListView = findViewById(R.id.BuffersList); messageContainer = (LinearLayout) findViewById(R.id.messageContainer); drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); redColor = getResources().getColor(R.color.highlight_red); blueColor = getResources().getColor(R.color.dark_blue); messageTxt = (ActionEditText) findViewById(R.id.messageTxt); messageTxt.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } else if (keyCode == KeyEvent.KEYCODE_TAB) { if (event.getAction() == KeyEvent.ACTION_DOWN) nextSuggestion(); return true; } return false; } }); messageTxt.setOnFocusChangeListener(new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (drawerLayout != null && v == messageTxt && hasFocus) { drawerLayout.closeDrawers(); update_suggestions(false); } else if (!hasFocus) { runOnUiThread(new Runnable() { @Override public void run() { suggestionsContainer.setVisibility(View.INVISIBLE); } }); } } }); messageTxt.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (drawerLayout != null) { drawerLayout.closeDrawers(); } } }); messageTxt.setOnEditorActionListener(new OnEditorActionListener() { public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (sendBtn.isEnabled() && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED && actionId == EditorInfo.IME_ACTION_SEND && messageTxt.getText() != null && messageTxt.getText().length() > 0) { sendBtn.setEnabled(false); new SendTask().execute((Void) null); } return true; } }); textWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { Object[] spans = s.getSpans(0, s.length(), Object.class); for (Object o : spans) { if (((s.getSpanFlags(o) & Spanned.SPAN_COMPOSING) != Spanned.SPAN_COMPOSING) && (o.getClass() == StyleSpan.class || o.getClass() == ForegroundColorSpan.class || o.getClass() == BackgroundColorSpan.class || o.getClass() == UnderlineSpan.class || o.getClass() == URLSpan.class)) { s.removeSpan(o); } } if (s.length() > 0 && NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) { sendBtn.setEnabled(true); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(1); } else { sendBtn.setEnabled(false); if (Build.VERSION.SDK_INT >= 11) sendBtn.setAlpha(0.5f); } String text = s.toString(); if (text.endsWith("\t")) { //Workaround for Swype text = text.substring(0, text.length() - 1); messageTxt.setText(text); nextSuggestion(); } else if (suggestionsContainer != null && suggestionsContainer.getVisibility() == View.VISIBLE) { runOnUiThread(new Runnable() { @Override public void run() { update_suggestions(false); } }); } else { if (suggestionsTimer != null) { if (suggestionsTimerTask != null) suggestionsTimerTask.cancel(); suggestionsTimerTask = new TimerTask() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); update_suggestions(false); } }; suggestionsTimer.schedule(suggestionsTimerTask, 250); } } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }; messageTxt.addTextChangedListener(textWatcher); sendBtn = findViewById(R.id.sendBtn); sendBtn.setFocusable(false); sendBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (NetworkConnection.getInstance().getState() == NetworkConnection.STATE_CONNECTED) new SendTask().execute((Void) null); } }); photoBtn = findViewById(R.id.photoBtn); if (photoBtn != null) { photoBtn.setFocusable(false); photoBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertPhoto(); } }); } userListView = findViewById(R.id.usersListFragment); View v = getLayoutInflater().inflate(R.layout.actionbar_messageview, null); v.findViewById(R.id.actionTitleArea).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { show_topic_popup(); } }); if (drawerLayout != null) { if (findViewById(R.id.usersListFragment2) == null) { upDrawable = new DrawerArrowDrawable(this); greyColor = upDrawable.getColor(); ((Toolbar) findViewById(R.id.toolbar)).setNavigationIcon(upDrawable); ((Toolbar) findViewById(R.id.toolbar)).setNavigationContentDescription("Show navigation drawer"); drawerLayout.setDrawerListener(mDrawerListener); if (refreshUpIndicatorTask != null) refreshUpIndicatorTask.cancel(true); refreshUpIndicatorTask = new RefreshUpIndicatorTask(); refreshUpIndicatorTask.execute((Void) null); } } messageTxt.setDrawerLayout(drawerLayout); title = (TextView) v.findViewById(R.id.title); subtitle = (TextView) v.findViewById(R.id.subtitle); key = (ImageView) v.findViewById(R.id.key); getSupportActionBar().setCustomView(v); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid")); buffer = BuffersDataSource.getInstance().getBuffer(savedInstanceState.getInt("bid")); backStack = (ArrayList<Integer>) savedInstanceState.getSerializable("backStack"); } if (savedInstanceState != null && savedInstanceState.containsKey("imagecaptureuri")) imageCaptureURI = Uri.parse(savedInstanceState.getString("imagecaptureuri")); else imageCaptureURI = null; ConfigInstance config = (ConfigInstance) getLastCustomNonConfigurationInstance(); if (config != null) { imgurTask = config.imgurUploadTask; fileUploadTask = config.fileUploadTask; } drawerLayout.setScrimColor(0); drawerLayout.closeDrawers(); getSupportActionBar().setElevation(0); }
From source file:com.common.widget.hzlib.AbsListView.java
@Override public Parcelable onSaveInstanceState() { /*//from www . j ava 2s .com * This doesn't really make sense as the place to dismiss the * popups, but there don't seem to be any other useful hooks * that happen early enough to keep from getting complaints * about having leaked the window. */ dismissPopup(); Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); if (mPendingSync != null) { // Just keep what we last restored. ss.selectedId = mPendingSync.selectedId; ss.firstId = mPendingSync.firstId; ss.viewTop = mPendingSync.viewTop; ss.position = mPendingSync.position; ss.height = mPendingSync.height; ss.filter = mPendingSync.filter; ss.inActionMode = mPendingSync.inActionMode; ss.checkedItemCount = mPendingSync.checkedItemCount; ss.checkState = mPendingSync.checkState; ss.checkIdState = mPendingSync.checkIdState; return ss; } boolean haveChildren = getChildCount() > 0 && mItemCount > 0; long selectedId = getSelectedItemId(); ss.selectedId = selectedId; ss.height = getHeight(); if (selectedId >= 0) { // Remember the selection ss.viewTop = mSelectedTop; ss.position = getSelectedItemPosition(); ss.firstId = INVALID_POSITION; } else { if (haveChildren && mFirstPosition >= 0) { // Remember the position of the first child. // We only do this if we are not currently at the top of // the list, for two reasons: // (1) The list may be in the process of becoming empty, in // which case mItemCount may not be 0, but if we try to // ask for any information about position 0 we will crash. // (2) Being "at the top" seems like a special case, anyway, // and the user wouldn't expect to end up somewhere else when // they revisit the list even if its content has changed. View v = getChildAt(0); ss.viewTop = v.getTop(); int firstPos = mFirstPosition; if (firstPos >= mItemCount) { firstPos = mItemCount - 1; } ss.position = firstPos; ss.firstId = mAdapter.getItemId(firstPos); } else { ss.viewTop = 0; ss.firstId = INVALID_POSITION; ss.position = 0; } } ss.filter = null; if (mFiltered) { final EditText textFilter = mTextFilter; if (textFilter != null) { Editable filterText = textFilter.getText(); if (filterText != null) { ss.filter = filterText.toString(); } } } if (mCheckStates != null) { ss.checkState = mCheckStates.clone(); } if (mCheckedIdStates != null) { final LongSparseArray<Integer> idState = new LongSparseArray<Integer>(); final int count = mCheckedIdStates.size(); for (int i = 0; i < count; i++) { idState.put(mCheckedIdStates.keyAt(i), mCheckedIdStates.valueAt(i)); } ss.checkIdState = idState; } ss.checkedItemCount = mCheckedItemCount; return ss; }