Example usage for android.text Editable toString

List of usage examples for android.text Editable toString

Introduction

In this page you can find the example usage for android.text Editable toString.

Prototype

public String toString();

Source Link

Document

Returns a string containing the characters in this sequence in the same order as this sequence.

Usage

From source file:de.baumann.browser.popups.Popup_readLater.java

private void setReadLaterList() {

    //display data
    final int layoutstyle = R.layout.list_item;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "readLater_title", "readLater_content", "readLater_creation" };
    final Cursor row = db.fetchAllData(this);
    adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0);

    //display data by filter
    final String note_search = sharedPref.getString("filter_readLaterBY", "readLater_title");
    sharedPref.edit().putString("filter_readLaterBY", "readLater_title").apply();
    editText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }//from w  w  w . ja  v a2  s.c  o  m

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

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s.toString());
        }
    });
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return db.fetchDataByFilter(constraint.toString(), note_search);
        }
    });

    listView.setAdapter(adapter);
    //onClick function
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {

            Cursor row = (Cursor) listView.getItemAtPosition(position);
            final String readLater_content = row.getString(row.getColumnIndexOrThrow("readLater_content"));
            sharedPref.edit().putString("openURL", readLater_content).apply();
            finish();
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            Cursor row2 = (Cursor) listView.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String readLater_title = row2.getString(row2.getColumnIndexOrThrow("readLater_title"));
            final String readLater_content = row2.getString(row2.getColumnIndexOrThrow("readLater_content"));
            final String readLater_icon = row2.getString(row2.getColumnIndexOrThrow("readLater_icon"));
            final String readLater_attachment = row2
                    .getString(row2.getColumnIndexOrThrow("readLater_attachment"));
            final String readLater_creation = row2.getString(row2.getColumnIndexOrThrow("readLater_creation"));

            final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save),
                    getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) };
            new AlertDialog.Builder(Popup_readLater.this)
                    .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            if (options[item].equals(getString(R.string.bookmark_edit_title))) {
                                sharedPref.edit().putString("edit_id", _id).apply();
                                sharedPref.edit().putString("edit_content", readLater_content).apply();
                                sharedPref.edit().putString("edit_icon", readLater_icon).apply();
                                sharedPref.edit().putString("edit_attachment", readLater_attachment).apply();
                                sharedPref.edit().putString("edit_creation", readLater_creation).apply();
                                editText.setVisibility(View.VISIBLE);
                                helper_editText.showKeyboard(Popup_readLater.this, editText, 2, readLater_title,
                                        getString(R.string.bookmark_edit_title));
                            }

                            if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) {
                                Snackbar snackbar = Snackbar
                                        .make(listView, R.string.bookmark_remove_confirmation,
                                                Snackbar.LENGTH_LONG)
                                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                db.delete(Integer.parseInt(_id));
                                                setReadLaterList();
                                            }
                                        });
                                snackbar.show();
                            }

                            if (options[item].equals(getString(R.string.menu_share))) {
                                final CharSequence[] options = { getString(R.string.menu_share_link),
                                        getString(R.string.menu_share_link_copy) };
                                new AlertDialog.Builder(Popup_readLater.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_share_link))) {
                                                    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                                    sharingIntent.setType("text/plain");
                                                    sharingIntent.putExtra(Intent.EXTRA_SUBJECT,
                                                            readLater_title);
                                                    sharingIntent.putExtra(Intent.EXTRA_TEXT,
                                                            readLater_content);
                                                    startActivity(Intent.createChooser(sharingIntent,
                                                            (getString(R.string.app_share_link))));
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_share_link_copy))) {
                                                    ClipboardManager clipboard = (ClipboardManager) Popup_readLater.this
                                                            .getSystemService(Context.CLIPBOARD_SERVICE);
                                                    clipboard.setPrimaryClip(
                                                            ClipData.newPlainText("text", readLater_content));
                                                    Snackbar.make(listView, R.string.context_linkCopy_toast,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }
                            if (options[item].equals(getString(R.string.menu_save))) {
                                final CharSequence[] options = { getString(R.string.menu_save_bookmark),
                                        getString(R.string.menu_save_pass),
                                        getString(R.string.menu_createShortcut) };
                                new AlertDialog.Builder(Popup_readLater.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_save_pass))) {
                                                    helper_editText.editText_savePass(Popup_readLater.this,
                                                            listView, readLater_title, readLater_content);
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_save_bookmark))) {
                                                    DbAdapter_Bookmarks db = new DbAdapter_Bookmarks(
                                                            Popup_readLater.this);
                                                    db.open();

                                                    if (db.isExist(readLater_content)) {
                                                        Snackbar.make(listView,
                                                                getString(R.string.toast_newTitle),
                                                                Snackbar.LENGTH_LONG).show();
                                                    } else {
                                                        db.insert(readLater_title, readLater_content, "", "",
                                                                helper_main.createDate());
                                                        Snackbar.make(listView, R.string.bookmark_added,
                                                                Snackbar.LENGTH_LONG).show();
                                                    }
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_createShortcut))) {
                                                    Intent i = new Intent();
                                                    i.setAction(Intent.ACTION_VIEW);
                                                    i.setClassName(Popup_readLater.this,
                                                            "de.baumann.browser.Browser_left");
                                                    i.setData(Uri.parse(readLater_content));

                                                    Intent shortcut = new Intent();
                                                    shortcut.putExtra("android.intent.extra.shortcut.INTENT",
                                                            i);
                                                    shortcut.putExtra("android.intent.extra.shortcut.NAME",
                                                            "THE NAME OF SHORTCUT TO BE SHOWN");
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                                                            readLater_content);
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                                                            Intent.ShortcutIconResource.fromContext(
                                                                    Popup_readLater.this
                                                                            .getApplicationContext(),
                                                                    R.mipmap.ic_launcher));
                                                    shortcut.setAction(
                                                            "com.android.launcher.action.INSTALL_SHORTCUT");
                                                    Popup_readLater.this.sendBroadcast(shortcut);
                                                    Snackbar.make(listView,
                                                            R.string.menu_createShortcut_success,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }

                        }
                    }).show();
            return true;
        }
    });

    listView.post(new Runnable() {
        public void run() {
            listView.setSelection(listView.getCount() - 1);
        }
    });
}

From source file:com.janardhan.blood2life.CommentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_comments, container, false);
    Log.d("mPostRef", mPostRef);
    db = new SQLiteHandler(getActivity());
    user_ = db.getUserDetails();//from w w  w . j a  v a 2  s  .  c om
    RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list);
    mEditText = (EditText) rootView.findViewById(R.id.editText);
    final Button sendButton = (Button) rootView.findViewById(R.id.send_comment);

    final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef);
    mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item,
            CommentViewHolder.class, commentsRef) {
        @Override
        protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) {
            String aurth = comment.getAuthor();

            viewHolder.commentAuthor.setText(comment.getAuthor());
            GlideUtil.loadProfileIcon(comment.getUser_propic(), viewHolder.commentPhoto);

            viewHolder.authorRef = comment.getUser_id();
            viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp()));
            viewHolder.commentText.setText(comment.getText());
        }
    };
    sendButton.setEnabled(false);
    mEditText.setHint(R.string.new_comment_hint);
    mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) });
    mEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0) {
                sendButton.setEnabled(true);
            } else {
                sendButton.setEnabled(false);
            }
        }
    });
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Clear input box and hide keyboard.
            final Editable commentText = mEditText.getText();
            mEditText.setText("");
            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
            if (user == null) {
                Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show();
            }

            Comment comment = new Comment(user.getDisplayName(), commentText.toString(), ServerValue.TIMESTAMP,
                    user_.get("uid"), user_.get("profile_pic_url"));
            commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() {
                @Override
                public void onComplete(DatabaseError error, DatabaseReference firebase) {
                    if (error != null) {
                        Log.w(TAG, getString(R.string.error_posting) + error.getMessage());
                        Toast.makeText(getActivity(), R.string.error_posting, Toast.LENGTH_SHORT).show();
                        mEditText.setText(commentText);
                    }
                }
            });
        }
    });
    mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mCommentsView.setAdapter(mAdapter);
    return rootView;
}

From source file:de.baumann.browser.popups.Popup_history.java

private void setHistoryList() {

    //display data
    final int layoutstyle = R.layout.list_item;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "history_title", "history_content", "history_creation" };
    final Cursor row = db.fetchAllData(this);
    adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0);

    //display data by filter
    final String note_search = sharedPref.getString("filter_historyBY", "history_title");
    sharedPref.edit().putString("filter_historyBY", "history_title").apply();
    editText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }/*from   ww  w  .j  a v  a2  s .  c o  m*/

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

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s.toString());
        }
    });
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return db.fetchDataByFilter(constraint.toString(), note_search);
        }
    });

    listView.setAdapter(adapter);
    //onClick function
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {

            Cursor row = (Cursor) listView.getItemAtPosition(position);
            final String history_content = row.getString(row.getColumnIndexOrThrow("history_content"));
            sharedPref.edit().putString("openURL", history_content).apply();
            finish();
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            Cursor row2 = (Cursor) listView.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String history_title = row2.getString(row2.getColumnIndexOrThrow("history_title"));
            final String history_content = row2.getString(row2.getColumnIndexOrThrow("history_content"));
            final String history_icon = row2.getString(row2.getColumnIndexOrThrow("history_icon"));
            final String history_attachment = row2.getString(row2.getColumnIndexOrThrow("history_attachment"));
            final String history_creation = row2.getString(row2.getColumnIndexOrThrow("history_creation"));

            final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save),
                    getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) };
            new AlertDialog.Builder(Popup_history.this)
                    .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            if (options[item].equals(getString(R.string.bookmark_edit_title))) {
                                sharedPref.edit().putString("edit_id", _id).apply();
                                sharedPref.edit().putString("edit_content", history_content).apply();
                                sharedPref.edit().putString("edit_icon", history_icon).apply();
                                sharedPref.edit().putString("edit_attachment", history_attachment).apply();
                                sharedPref.edit().putString("edit_creation", history_creation).apply();
                                editText.setVisibility(View.VISIBLE);
                                helper_editText.showKeyboard(Popup_history.this, editText, 2, history_title,
                                        getString(R.string.bookmark_edit_title));
                            }

                            if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) {
                                Snackbar snackbar = Snackbar
                                        .make(listView, R.string.bookmark_remove_confirmation,
                                                Snackbar.LENGTH_LONG)
                                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                db.delete(Integer.parseInt(_id));
                                                setHistoryList();
                                            }
                                        });
                                snackbar.show();
                            }

                            if (options[item].equals(getString(R.string.menu_share))) {
                                final CharSequence[] options = { getString(R.string.menu_share_link),
                                        getString(R.string.menu_share_link_copy) };
                                new AlertDialog.Builder(Popup_history.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_share_link))) {
                                                    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                                    sharingIntent.setType("text/plain");
                                                    sharingIntent.putExtra(Intent.EXTRA_SUBJECT, history_title);
                                                    sharingIntent.putExtra(Intent.EXTRA_TEXT, history_content);
                                                    startActivity(Intent.createChooser(sharingIntent,
                                                            (getString(R.string.app_share_link))));
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_share_link_copy))) {
                                                    ClipboardManager clipboard = (ClipboardManager) Popup_history.this
                                                            .getSystemService(Context.CLIPBOARD_SERVICE);
                                                    clipboard.setPrimaryClip(
                                                            ClipData.newPlainText("text", history_content));
                                                    Snackbar.make(listView, R.string.context_linkCopy_toast,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }
                            if (options[item].equals(getString(R.string.menu_save))) {
                                final CharSequence[] options = { getString(R.string.menu_save_bookmark),
                                        getString(R.string.menu_save_readLater),
                                        getString(R.string.menu_save_pass),
                                        getString(R.string.menu_createShortcut) };
                                new AlertDialog.Builder(Popup_history.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_save_pass))) {
                                                    helper_editText.editText_savePass(Popup_history.this,
                                                            listView, history_title, history_content);
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_save_bookmark))) {

                                                    DbAdapter_Bookmarks db = new DbAdapter_Bookmarks(
                                                            Popup_history.this);
                                                    db.open();

                                                    if (db.isExist(history_content)) {
                                                        Snackbar.make(listView,
                                                                getString(R.string.toast_newTitle),
                                                                Snackbar.LENGTH_LONG).show();
                                                    } else {
                                                        db.insert(history_title, history_content, "", "",
                                                                helper_main.createDate());
                                                        Snackbar.make(listView, R.string.bookmark_added,
                                                                Snackbar.LENGTH_LONG).show();
                                                    }
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_save_readLater))) {
                                                    DbAdapter_ReadLater db = new DbAdapter_ReadLater(
                                                            Popup_history.this);
                                                    db.open();
                                                    if (db.isExist(history_content)) {
                                                        Snackbar.make(listView,
                                                                getString(R.string.toast_newTitle),
                                                                Snackbar.LENGTH_LONG).show();
                                                    } else {
                                                        db.insert(history_title, history_content, "", "",
                                                                helper_main.createDate());
                                                        Snackbar.make(listView, R.string.bookmark_added,
                                                                Snackbar.LENGTH_LONG).show();
                                                    }
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_createShortcut))) {
                                                    Intent i = new Intent();
                                                    i.setAction(Intent.ACTION_VIEW);
                                                    i.setClassName(Popup_history.this,
                                                            "de.baumann.browser.Browser_left");
                                                    i.setData(Uri.parse(history_content));

                                                    Intent shortcut = new Intent();
                                                    shortcut.putExtra("android.intent.extra.shortcut.INTENT",
                                                            i);
                                                    shortcut.putExtra("android.intent.extra.shortcut.NAME",
                                                            "THE NAME OF SHORTCUT TO BE SHOWN");
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                                                            history_title);
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                                                            Intent.ShortcutIconResource.fromContext(
                                                                    Popup_history.this.getApplicationContext(),
                                                                    R.mipmap.ic_launcher));
                                                    shortcut.setAction(
                                                            "com.android.launcher.action.INSTALL_SHORTCUT");
                                                    Popup_history.this.sendBroadcast(shortcut);
                                                    Snackbar.make(listView,
                                                            R.string.menu_createShortcut_success,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }

                        }
                    }).show();
            return true;
        }
    });

    listView.post(new Runnable() {
        public void run() {
            listView.setSelection(listView.getCount() - 1);
        }
    });
}

From source file:org.telegram.ui.GroupCreateActivity.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentView == null) {
        fragmentView = inflater.inflate(R.layout.group_create_layout, container, false);

        epmtyTextView = (TextView) fragmentView.findViewById(R.id.searchEmptyView);
        userSelectEditText = (EditText) fragmentView.findViewById(R.id.bubble_input_text);
        countTextView = (TextView) fragmentView.findViewById(R.id.bubble_counter_text);
        if (Build.VERSION.SDK_INT >= 11) {
            userSelectEditText.setTextIsSelectable(false);
        }/*from w  ww . jav a  2 s . co m*/
        userSelectEditText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int start, int count, int after) {
                if (!ignoreChange) {
                    beforeChangeIndex = userSelectEditText.getSelectionStart();
                    changeString = new SpannableString(charSequence);
                }
            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                if (!ignoreChange) {
                    boolean search = false;
                    int afterChangeIndex = userSelectEditText.getSelectionEnd();
                    if (editable.toString().length() < changeString.toString().length()) {
                        String deletedString = "";
                        try {
                            deletedString = changeString.toString().substring(afterChangeIndex,
                                    beforeChangeIndex);
                        } catch (Exception e) {
                            FileLog.e("tmessages", e);
                        }
                        if (deletedString.length() > 0) {
                            if (searching && searchWas) {
                                search = true;
                            }
                            Spannable span = userSelectEditText.getText();
                            for (int a = 0; a < allSpans.size(); a++) {
                                Emoji.XImageSpan sp = allSpans.get(a);
                                if (span.getSpanStart(sp) == -1) {
                                    allSpans.remove(sp);
                                    selectedContacts.remove(sp.uid);
                                }
                            }
                            if (selectedContacts.isEmpty()) {
                                doneTextView.setText(getStringEntry(R.string.Done));
                            } else {
                                doneTextView.setText(
                                        getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")");
                            }
                            countTextView.setText(selectedContacts.size() + "/200");
                            listView.invalidateViews();
                        } else {
                            search = true;
                        }
                    } else {
                        search = true;
                    }
                    if (search) {
                        String text = userSelectEditText.getText().toString().replace("<", "");
                        if (text.length() != 0) {
                            searchDialogs(text);
                            searching = true;
                            searchWas = true;
                            epmtyTextView.setText(getStringEntry(R.string.NoResult));
                            listViewAdapter.notifyDataSetChanged();
                        } else {
                            searchResult = null;
                            searchResultNames = null;
                            searching = false;
                            searchWas = false;
                            epmtyTextView.setText(getStringEntry(R.string.NoContacts));
                            listViewAdapter.notifyDataSetChanged();
                        }
                    }
                }
            }
        });

        listView = (PinnedHeaderListView) fragmentView.findViewById(R.id.listView);
        listView.setEmptyView(epmtyTextView);
        listView.setVerticalScrollBarEnabled(false);

        listView.setAdapter(listViewAdapter = new ListAdapter(parentActivity));
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                TLRPC.User user;
                int section = listViewAdapter.getSectionForPosition(i);
                int row = listViewAdapter.getPositionInSectionForPosition(i);
                if (searching && searchWas) {
                    user = searchResult.get(row);
                } else {
                    ArrayList<TLRPC.TL_contact> arr = ContactsController.Instance.usersSectionsDict
                            .get(ContactsController.Instance.sortedUsersSectionsArray.get(section));
                    user = MessagesController.Instance.users.get(arr.get(row).user_id);
                    listView.invalidateViews();
                }
                if (selectedContacts.containsKey(user.id)) {
                    Emoji.XImageSpan span = selectedContacts.get(user.id);
                    selectedContacts.remove(user.id);
                    SpannableStringBuilder text = new SpannableStringBuilder(userSelectEditText.getText());
                    text.delete(text.getSpanStart(span), text.getSpanEnd(span));
                    allSpans.remove(span);
                    ignoreChange = true;
                    userSelectEditText.setText(text);
                    userSelectEditText.setSelection(text.length());
                    ignoreChange = false;
                } else {
                    if (selectedContacts.size() == 200) {
                        return;
                    }
                    ignoreChange = true;
                    Emoji.XImageSpan span = createAndPutChipForUser(user);
                    span.uid = user.id;
                    ignoreChange = false;
                }
                if (selectedContacts.isEmpty()) {
                    doneTextView.setText(getStringEntry(R.string.Done));
                } else {
                    doneTextView.setText(getStringEntry(R.string.Done) + " (" + selectedContacts.size() + ")");
                }
                countTextView.setText(selectedContacts.size() + "/200");
                if (searching || searchWas) {
                    searching = false;
                    searchWas = false;
                    epmtyTextView.setText(getStringEntry(R.string.NoContacts));

                    ignoreChange = true;
                    SpannableStringBuilder ssb = new SpannableStringBuilder("");
                    for (ImageSpan sp : allSpans) {
                        ssb.append("<<");
                        ssb.setSpan(sp, ssb.length() - 2, ssb.length(),
                                SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
                    }
                    userSelectEditText.setText(ssb);
                    userSelectEditText.setSelection(ssb.length());
                    ignoreChange = false;

                    listViewAdapter.notifyDataSetChanged();
                } else {
                    listView.invalidateViews();
                }
            }
        });
    } else {
        ViewGroup parent = (ViewGroup) fragmentView.getParent();
        if (parent != null) {
            parent.removeView(fragmentView);
        }
    }
    return fragmentView;
}

From source file:org.eyeseetea.malariacare.LoginActivity.java

protected void onLoginButtonClicked(Editable server, Editable username, Editable password) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    if (!sharedPreferences.getBoolean(getString(R.string.eula_accepted), false)) {
        askEula(R.string.app_EULA, R.raw.eula, LoginActivity.this);
    } else {/*from   ww  w  .j av a 2s .  c o m*/
        login(server.toString(), username.toString(), password.toString());
    }
}

From source file:org.mozilla.gecko.AwesomeBar.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Log.d(LOGTAG, "creating awesomebar");

    mResolver = Tabs.getInstance().getContentResolver();

    setContentView(R.layout.awesomebar);

    if (Build.VERSION.SDK_INT >= 11) {
        RelativeLayout actionBarLayout = (RelativeLayout) GeckoActionBar.getCustomView(this);
        mGoButton = (ImageButton) actionBarLayout.findViewById(R.id.awesomebar_button);
        mText = (AwesomeBarEditText) actionBarLayout.findViewById(R.id.awesomebar_text);
    } else {/*from  w  w  w. j a v a2  s  . c  o m*/
        mGoButton = (ImageButton) findViewById(R.id.awesomebar_button);
        mText = (AwesomeBarEditText) findViewById(R.id.awesomebar_text);
    }

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    tabWidget.setDividerDrawable(null);

    mAwesomeTabs = (AwesomeBarTabs) findViewById(R.id.awesomebar_tabs);
    mAwesomeTabs.setOnUrlOpenListener(new AwesomeBarTabs.OnUrlOpenListener() {
        public void onUrlOpen(String url) {
            openUrlAndFinish(url);
        }

        public void onSearch(String engine) {
            openSearchAndFinish(mText.getText().toString(), engine);
        }
    });

    mGoButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View v) {
            openUserEnteredAndFinish(mText.getText().toString());
        }
    });

    Resources resources = getResources();

    int padding[] = { mText.getPaddingLeft(), mText.getPaddingTop(), mText.getPaddingRight(),
            mText.getPaddingBottom() };

    GeckoStateListDrawable states = new GeckoStateListDrawable();
    states.initializeFilter(GeckoApp.mBrowserToolbar.getHighlightColor());
    states.addState(new int[] { android.R.attr.state_focused },
            resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] { android.R.attr.state_pressed },
            resources.getDrawable(R.drawable.address_bar_url_pressed));
    states.addState(new int[] {}, resources.getDrawable(R.drawable.address_bar_url_default));
    mText.setBackgroundDrawable(states);

    mText.setPadding(padding[0], padding[1], padding[2], padding[3]);

    Intent intent = getIntent();
    String currentUrl = intent.getStringExtra(CURRENT_URL_KEY);
    mType = intent.getStringExtra(TYPE_KEY);
    if (currentUrl != null) {
        mText.setText(currentUrl);
        mText.selectAll();
    }

    mText.setOnKeyPreImeListener(new AwesomeBarEditText.OnKeyPreImeListener() {
        public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
            // We only want to process one event per tap
            if (event.getAction() != KeyEvent.ACTION_DOWN)
                return false;

            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                openUserEnteredAndFinish(mText.getText().toString());
                return true;
            }

            // If input method is in fullscreen mode, we want to dismiss
            // it instead of closing awesomebar straight away.
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (keyCode == KeyEvent.KEYCODE_BACK && !imm.isFullscreenMode()) {
                // Let mAwesomeTabs try to handle the back press, since we may be in a
                // bookmarks sub-folder.
                if (mAwesomeTabs.onBackPressed())
                    return true;

                // If mAwesomeTabs.onBackPressed() returned false, we didn't move up
                // a folder level, so just exit the activity.
                cancelAndFinish();
                return true;
            }

            return false;
        }
    });

    mText.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
            // do nothing
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // do nothing
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            String text = s.toString();

            mAwesomeTabs.filter(text);
            updateGoButton(text);
        }
    });

    mText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() != KeyEvent.ACTION_DOWN)
                    return true;

                openUserEnteredAndFinish(mText.getText().toString());
                return true;
            } else {
                return false;
            }
        }
    });

    mText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            }
        }
    });

    registerForContextMenu(mAwesomeTabs.findViewById(R.id.all_pages_list));
    registerForContextMenu(mAwesomeTabs.findViewById(R.id.bookmarks_list));
    registerForContextMenu(mAwesomeTabs.findViewById(R.id.history_list));

    GeckoAppShell.registerGeckoEventListener("SearchEngines:Data", this);
    GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("SearchEngines:Get", null));
}

From source file:org.cocos2dx.lib.TextInputWraper.java

@Override
public void afterTextChanged(Editable s) {
    if (isFullScreenEdit()) {
        return;//www . j a  v a  2 s  .  c om
    }

    LogD("afterTextChanged: " + s);
    int nModified = s.length() - mText.length();
    if (nModified > 0) {
        final String insertText = s.subSequence(mText.length(), s.length()).toString();
        mMainView.insertText(insertText);
        LogD("insertText(" + insertText + ")");
    } else {
        for (; nModified < 0; ++nModified) {
            mMainView.deleteBackward();
            LogD("deleteBackward");
        }
    }
    mText = s.toString();
}

From source file:tv.acfun.a63.CommentsActivity.java

String getComment() {
    Editable text = SpannableStringBuilder.valueOf(mCommentText.getText());
    Quote quote = TextViewUtils.getLast(text, Quote.class);
    int start = text.getSpanStart(quote);
    int end = text.getSpanEnd(quote);
    if (start < 0)
        return text.toString();
    else if (start == 0) {
        return text.subSequence(end, text.length()).toString();
    } else/*w  w w.j  a v a  2s .co  m*/
        return text.subSequence(0, start).toString() + text.subSequence(end, text.length()).toString();
}

From source file:com.barak.pix.CommentsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_comments, container, false);
    RecyclerView mCommentsView = (RecyclerView) rootView.findViewById(R.id.comment_list);
    mEditText = (EditText) rootView.findViewById(R.id.editText);
    final Button sendButton = (Button) rootView.findViewById(R.id.send_comment);

    final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef);
    mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.comment_item,
            CommentViewHolder.class, commentsRef) {
        @Override/*from  ww w.j a v a 2s.co  m*/
        protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) {
            Author author = comment.getAuthor();
            viewHolder.commentAuthor.setText(author.getFull_name());
            GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto);

            viewHolder.authorRef = author.getUid();
            viewHolder.commentTime.setText(DateUtils.getRelativeTimeSpanString((long) comment.getTimestamp()));
            viewHolder.commentText.setText(comment.getText());
        }
    };
    sendButton.setEnabled(false);
    mEditText.setHint(R.string.new_comment_hint);
    mEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) });
    mEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            if (editable.length() > 0) {
                sendButton.setEnabled(true);
            } else {
                sendButton.setEnabled(false);
            }
        }
    });
    sendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Clear input box and hide keyboard.
            final Editable commentText = mEditText.getText();
            mEditText.setText("");
            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.hideSoftInputFromWindow(mEditText.getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);

            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
            if (user == null) {
                Toast.makeText(getActivity(), R.string.user_logged_out_error, Toast.LENGTH_SHORT).show();
            }

            Author author = new Author(user.getDisplayName(), "", user.getUid());

            Comment comment = new Comment(author, commentText.toString(), ServerValue.TIMESTAMP);
            commentsRef.push().setValue(comment, new DatabaseReference.CompletionListener() {
                @Override
                public void onComplete(DatabaseError error, DatabaseReference firebase) {
                    if (error != null) {
                        Log.w(TAG, "Error posting comment: " + error.getMessage());
                        Toast.makeText(getActivity(), "Error posting comment.", Toast.LENGTH_SHORT).show();
                        mEditText.setText(commentText);
                    }
                }
            });
        }
    });
    mCommentsView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mCommentsView.setAdapter(mAdapter);
    return rootView;
}

From source file:de.baumann.browser.popups.Popup_bookmarks.java

private void setBookmarksList() {

    //display data
    final int layoutstyle = R.layout.list_item;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "bookmarks_title", "bookmarks_content", "bookmarks_creation" };
    final Cursor row = db.fetchAllData(this);
    adapter = new SimpleCursorAdapter(this, layoutstyle, row, column, xml_id, 0) {
        @Override/* w w  w  . j av a 2s .  c om*/
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) listView.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title"));
            final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content"));
            final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon"));
            final String bookmarks_attachment = row2
                    .getString(row2.getColumnIndexOrThrow("bookmarks_attachment"));
            final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation"));

            View v = super.getView(position, convertView, parent);
            final ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);

            switch (bookmarks_attachment) {
            case "":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.star_outline);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.star_grey);
                break;
            }

            iv_attachment.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    if (bookmarks_attachment.equals("")) {

                        if (db.isExistFav("true")) {
                            Snackbar.make(listView, R.string.bookmark_setFav_not, Snackbar.LENGTH_LONG).show();
                        } else {
                            iv_attachment.setImageResource(R.drawable.star_grey);
                            db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon,
                                    "true", bookmarks_creation);
                            setBookmarksList();
                            sharedPref.edit().putString("startURL", bookmarks_content).apply();
                            Snackbar.make(listView, R.string.bookmark_setFav, Snackbar.LENGTH_LONG).show();
                        }
                    } else {
                        iv_attachment.setImageResource(R.drawable.star_outline);
                        db.update(Integer.parseInt(_id), bookmarks_title, bookmarks_content, bookmarks_icon, "",
                                bookmarks_creation);
                        setBookmarksList();
                    }
                }
            });
            return v;
        }
    };

    //display data by filter
    final String note_search = sharedPref.getString("filter_bookmarksBY", "bookmarks_title");
    sharedPref.edit().putString("filter_bookmarksBY", "bookmarks_title").apply();
    editText.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) {
            adapter.getFilter().filter(s.toString());
        }
    });
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return db.fetchDataByFilter(constraint.toString(), note_search);
        }
    });

    listView.setAdapter(adapter);
    //onClick function
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {

            Cursor row = (Cursor) listView.getItemAtPosition(position);
            final String bookmarks_content = row.getString(row.getColumnIndexOrThrow("bookmarks_content"));

            sharedPref.edit().putString("openURL", bookmarks_content).apply();
            finish();
        }
    });

    listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

            Cursor row2 = (Cursor) listView.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String bookmarks_title = row2.getString(row2.getColumnIndexOrThrow("bookmarks_title"));
            final String bookmarks_content = row2.getString(row2.getColumnIndexOrThrow("bookmarks_content"));
            final String bookmarks_icon = row2.getString(row2.getColumnIndexOrThrow("bookmarks_icon"));
            final String bookmarks_attachment = row2
                    .getString(row2.getColumnIndexOrThrow("bookmarks_attachment"));
            final String bookmarks_creation = row2.getString(row2.getColumnIndexOrThrow("bookmarks_creation"));

            final CharSequence[] options = { getString(R.string.menu_share), getString(R.string.menu_save),
                    getString(R.string.bookmark_edit_title), getString(R.string.bookmark_remove_bookmark) };
            new AlertDialog.Builder(Popup_bookmarks.this)
                    .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int whichButton) {
                            dialog.cancel();
                        }
                    }).setItems(options, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int item) {
                            if (options[item].equals(getString(R.string.bookmark_edit_title))) {
                                sharedPref.edit().putString("edit_id", _id).apply();
                                sharedPref.edit().putString("edit_content", bookmarks_content).apply();
                                sharedPref.edit().putString("edit_icon", bookmarks_icon).apply();
                                sharedPref.edit().putString("edit_attachment", bookmarks_attachment).apply();
                                sharedPref.edit().putString("edit_creation", bookmarks_creation).apply();
                                editText.setVisibility(View.VISIBLE);
                                helper_editText.showKeyboard(Popup_bookmarks.this, editText, 2, bookmarks_title,
                                        getString(R.string.bookmark_edit_title));
                            }

                            if (options[item].equals(getString(R.string.bookmark_remove_bookmark))) {
                                Snackbar snackbar = Snackbar
                                        .make(listView, R.string.bookmark_remove_confirmation,
                                                Snackbar.LENGTH_LONG)
                                        .setAction(R.string.toast_yes, new View.OnClickListener() {
                                            @Override
                                            public void onClick(View view) {
                                                db.delete(Integer.parseInt(_id));
                                                setBookmarksList();
                                            }
                                        });
                                snackbar.show();
                            }
                            if (options[item].equals(getString(R.string.menu_share))) {
                                final CharSequence[] options = { getString(R.string.menu_share_link),
                                        getString(R.string.menu_share_link_copy) };
                                new AlertDialog.Builder(Popup_bookmarks.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_share_link))) {
                                                    Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                                    sharingIntent.setType("text/plain");
                                                    sharingIntent.putExtra(Intent.EXTRA_SUBJECT,
                                                            bookmarks_title);
                                                    sharingIntent.putExtra(Intent.EXTRA_TEXT,
                                                            bookmarks_content);
                                                    startActivity(Intent.createChooser(sharingIntent,
                                                            (getString(R.string.app_share_link))));
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_share_link_copy))) {
                                                    ClipboardManager clipboard = (ClipboardManager) Popup_bookmarks.this
                                                            .getSystemService(Context.CLIPBOARD_SERVICE);
                                                    clipboard.setPrimaryClip(
                                                            ClipData.newPlainText("text", bookmarks_content));
                                                    Snackbar.make(listView, R.string.context_linkCopy_toast,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }
                            if (options[item].equals(getString(R.string.menu_save))) {
                                final CharSequence[] options = { getString(R.string.menu_save_readLater),
                                        getString(R.string.menu_save_pass),
                                        getString(R.string.menu_createShortcut) };
                                new AlertDialog.Builder(Popup_bookmarks.this)
                                        .setPositiveButton(R.string.toast_cancel,
                                                new DialogInterface.OnClickListener() {

                                                    public void onClick(DialogInterface dialog,
                                                            int whichButton) {
                                                        dialog.cancel();
                                                    }
                                                })
                                        .setItems(options, new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int item) {
                                                if (options[item].equals(getString(R.string.menu_save_pass))) {
                                                    helper_editText.editText_savePass(Popup_bookmarks.this,
                                                            listView, bookmarks_title, bookmarks_content);
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_save_readLater))) {
                                                    DbAdapter_ReadLater db = new DbAdapter_ReadLater(
                                                            Popup_bookmarks.this);
                                                    db.open();
                                                    if (db.isExist(bookmarks_content)) {
                                                        Snackbar.make(editText,
                                                                getString(R.string.toast_newTitle),
                                                                Snackbar.LENGTH_LONG).show();
                                                    } else {
                                                        db.insert(bookmarks_title, bookmarks_content, "", "",
                                                                helper_main.createDate());
                                                        Snackbar.make(listView, R.string.bookmark_added,
                                                                Snackbar.LENGTH_LONG).show();
                                                    }
                                                }
                                                if (options[item]
                                                        .equals(getString(R.string.menu_createShortcut))) {
                                                    Intent i = new Intent();
                                                    i.setAction(Intent.ACTION_VIEW);
                                                    i.setClassName(Popup_bookmarks.this,
                                                            "de.baumann.browser.Browser_left");
                                                    i.setData(Uri.parse(bookmarks_content));

                                                    Intent shortcut = new Intent();
                                                    shortcut.putExtra("android.intent.extra.shortcut.INTENT",
                                                            i);
                                                    shortcut.putExtra("android.intent.extra.shortcut.NAME",
                                                            "THE NAME OF SHORTCUT TO BE SHOWN");
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_NAME,
                                                            bookmarks_title);
                                                    shortcut.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
                                                            Intent.ShortcutIconResource.fromContext(
                                                                    Popup_bookmarks.this
                                                                            .getApplicationContext(),
                                                                    R.mipmap.ic_launcher));
                                                    shortcut.setAction(
                                                            "com.android.launcher.action.INSTALL_SHORTCUT");
                                                    Popup_bookmarks.this.sendBroadcast(shortcut);
                                                    Snackbar.make(listView,
                                                            R.string.menu_createShortcut_success,
                                                            Snackbar.LENGTH_SHORT).show();
                                                }
                                            }
                                        }).show();
                            }

                        }
                    }).show();
            return true;
        }
    });
}