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.tum.frm2.nicos_android.gui.MainActivity.java

private void onStepButtonClicked(Button btn) {
    // The EditText which needs to be parsed for the correct step.
    EditText editTextToBeParsed = null;/*from  w  w w . ja v  a2  s.  co  m*/
    // Whether to multiply by -1 (for right or left steps)
    short factor = 0;

    if (btn == _coarseStepLeftButton) {
        editTextToBeParsed = _coarseStepEditText;
        factor = -1;
    }

    else if (btn == _fineStepLeftButton) {
        editTextToBeParsed = _fineStepEditText;
        factor = -1;
    }

    else if (btn == _coarseStepRightButton) {
        editTextToBeParsed = _coarseStepEditText;
        factor = 1;
    }

    else if (btn == _fineStepRightButton) {
        editTextToBeParsed = _fineStepEditText;
        factor = 1;
    }

    Double step = null;
    try {
        if (editTextToBeParsed != null) {
            Editable doubleString = editTextToBeParsed.getText();
            if (doubleString != null) {
                step = Double.parseDouble(doubleString.toString());
            }
        }
    } catch (Exception e) {
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(getApplicationContext(), "Invalid step.", Toast.LENGTH_SHORT).show();
            }
        });
        return;
    }

    if (step != null && _currentDevice.getValue() != null) {
        Double current;
        try {
            current = (double) _currentDevice.getValue();
        } catch (ClassCastException e) {
            try {
                current = Double.parseDouble(_currentDevice.getValue().toString());
            } catch (NumberFormatException e1) {
                return;
            }
        }
        double newVal = current + step * factor;
        exec_command("move(" + _currentDevice.getName() + ", " + String.valueOf(newVal) + ")");
    }
}

From source file:org.wso2.emm.agent.AuthenticationActivity.java

/**
 * Initialize the Android IDP SDK by passing credentials,client ID and
 * client secret.//from  ww  w .j  a v a2s .  com
 *
 * @param clientKey    client id value to access APIs..
 * @param clientSecret client secret value to access APIs.
 */
private void initializeIDPLib(String clientKey, String clientSecret) {
    String serverIP = Constants.DEFAULT_HOST;
    String prefIP = Preference.getString(AuthenticationActivity.this, Constants.PreferenceFlag.IP);
    if (prefIP != null) {
        serverIP = prefIP;
    }
    if (serverIP != null && !serverIP.isEmpty()) {
        ServerConfig utils = new ServerConfig();
        utils.setServerIP(serverIP);
        String serverURL = utils.getServerURL(context) + Constants.OAUTH_ENDPOINT;
        Editable tenantDomain = etDomain.getText();

        if (tenantDomain != null && !tenantDomain.toString().trim().isEmpty()) {
            username = etUsername.getText().toString().trim()
                    + context.getResources().getString(R.string.intent_extra_at)
                    + tenantDomain.toString().trim();

        } else {
            username = etUsername.getText().toString().trim();
        }

        Preference.putString(context, Constants.CLIENT_ID, clientKey);
        Preference.putString(context, Constants.CLIENT_SECRET, clientSecret);

        CredentialInfo info = new CredentialInfo();
        info.setClientID(clientKey);
        info.setClientSecret(clientSecret);
        info.setUsername(username);
        info.setPassword(passwordVal);
        info.setTokenEndPoint(serverURL);
        if (tenantDomain != null && !tenantDomain.toString().trim().isEmpty()) {
            info.setTenantDomain(tenantDomain.toString().trim());
        }

        IdentityProxy.getInstance().init(info, AuthenticationActivity.this, this.getApplicationContext());
    }
}

From source file:org.thoughtcrime.securesms.GroupCreateActivity.java

private void initializeResources() {
    groupRecipient = RecipientFactory.getRecipientForId(this,
            getIntent().getLongExtra(GROUP_RECIPIENT_EXTRA, -1), true);
    groupThread = getIntent().getLongExtra(GROUP_THREAD_EXTRA, -1);
    if (groupRecipient != null) {
        final String encodedGroupId = groupRecipient.getNumber();
        if (encodedGroupId != null) {
            try {
                groupId = GroupUtil.getDecodedId(encodedGroupId);
            } catch (IOException ioe) {
                Log.w(TAG, "Couldn't decode the encoded groupId passed in via intent", ioe);
                groupId = null;/*from w w w. j  a  va  2 s .  c o m*/
            }
            if (groupId != null) {
                new FillExistingGroupInfoAsyncTask().execute();
            }
        }
    }

    lv = (ListView) findViewById(R.id.selected_contacts_list);
    avatar = (ImageView) findViewById(R.id.avatar);
    groupName = (EditText) findViewById(R.id.group_name);
    creatingText = (TextView) findViewById(R.id.creating_group_text);
    recipientsPanel = (PushRecipientsPanel) findViewById(R.id.recipients);

    groupName.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

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

        @Override
        public void afterTextChanged(Editable editable) {
            final int prefixResId = (groupId != null) ? R.string.GroupCreateActivity_actionbar_update_title
                    : R.string.GroupCreateActivity_actionbar_title;
            if (editable.length() > 0) {
                getSupportActionBar().setTitle(getString(prefixResId) + ": " + editable.toString());
            } else {
                getSupportActionBar().setTitle(prefixResId);
            }
        }
    });

    SelectedRecipientsAdapter adapter = new SelectedRecipientsAdapter(this, android.R.id.text1,
            new ArrayList<SelectedRecipientsAdapter.RecipientWrapper>());
    adapter.setOnRecipientDeletedListener(new SelectedRecipientsAdapter.OnRecipientDeletedListener() {
        @Override
        public void onRecipientDeleted(Recipient recipient) {
            removeSelectedContact(recipient);
        }
    });
    lv.setAdapter(adapter);

    recipientsPanel.setPanelChangeListener(new PushRecipientsPanel.RecipientsPanelChangedListener() {
        @Override
        public void onRecipientsPanelUpdate(Recipients recipients) {
            Log.i(TAG, "onRecipientsPanelUpdate received.");
            if (recipients != null) {
                addAllSelectedContacts(recipients.getRecipientsList());
                syncAdapterWithSelectedContacts();
            }
        }
    });
    (findViewById(R.id.contacts_button)).setOnClickListener(new AddRecipientButtonListener());

    avatar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Crop.pickImage(GroupCreateActivity.this);
        }
    });

    ((RecipientsEditor) findViewById(R.id.recipients_text)).setHint(R.string.recipients_panel__add_member);
}

From source file:com.myapps.upesse.upes_spefest.ui.activity.CommentsFragment.java

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

    final DatabaseReference commentsRef = FirebaseUtil.getCommentsRef().child(mPostRef);
    mAdapter = new FirebaseRecyclerAdapter<Comment, CommentViewHolder>(Comment.class, R.layout.item_comment,
            CommentViewHolder.class, commentsRef) {
        @Override/*w w  w.ja va  2  s  . co  m*/
        protected void populateViewHolder(final CommentViewHolder viewHolder, Comment comment, int position) {
            Author author = comment.getAuthor();
            viewHolder.commentAuthor.setText(author.getFull_name());
            if (author.getProfile_picture() == null) {
                viewHolder.commentPhoto.setImageResource(R.drawable.ic_person_outline_black);
            } else {
                try {
                    GlideUtil.loadProfileIcon(author.getProfile_picture(), viewHolder.commentPhoto);
                } catch (Exception e) {
                }
            }
            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.getPhotoUrl() != null ? user.getPhotoUrl().toString() : null, 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:edu.pitt.gis.uniapp.UniApp.java

/**
 * Create Custom title bar//from w  ww .ja va2s . com
 * @return
 */
protected void createCustomTitleBar() {
    final UniApp me = this;

    if (this.customTitleSupported) {
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title_bar);

        // Go to home
        final ImageButton homeBtn = (ImageButton) findViewById(R.id.appHomeBtn);
        homeBtn.setOnClickListener(new ImageButton.OnClickListener() {
            public void onClick(View v) {
                me.loadUrl(HOME_URL);
            }
        });

        // Input address
        final ImageButton urlBtn = (ImageButton) findViewById(R.id.appUrlBtn);
        urlBtn.setOnClickListener(new ImageButton.OnClickListener() {
            public void onClick(View v) {
                // Open input address dialog
                // Set an EditText view to get user input 
                final EditText input = new EditText(me);

                new AlertDialog.Builder(me).setTitle("Input URL").setMessage("Input URL to Load").setView(input)
                        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                Editable value = input.getText();
                                me.loadUrl(value.toString());
                            }
                        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // Do nothing.
                            }
                        }).show();
            }
        });

        final ImageButton aboutBtn = (ImageButton) findViewById(R.id.aboutBtn);
        aboutBtn.setOnClickListener(new ImageButton.OnClickListener() {
            public void onClick(View v) {
                about.setTitle("About this app");
                about.show();
            }
        });
    }
}

From source file:de.baumann.hhsmoodle.data_count.Count_Fragment.java

public void setCountList() {

    if (isFABOpen) {
        closeFABMenu();//from  w  w w  .j a va 2  s.com
    }

    //display data
    final int layoutstyle = R.layout.list_item_notes;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "count_title", "count_content", "count_creation" };
    final Cursor row = db.fetchAllData(getActivity());
    adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String count_title = row2.getString(row2.getColumnIndexOrThrow("count_title"));
            final String count_content = row2.getString(row2.getColumnIndexOrThrow("count_content"));
            final String count_icon = row2.getString(row2.getColumnIndexOrThrow("count_icon"));
            final String count_attachment = row2.getString(row2.getColumnIndexOrThrow("count_attachment"));
            final String count_creation = row2.getString(row2.getColumnIndexOrThrow("count_creation"));

            View v = super.getView(position, convertView, parent);
            final TextView tv = (TextView) v.findViewById(R.id.text);

            if (count_attachment.isEmpty()) {

                tv.setText(count_content);

                new Handler().postDelayed(new Runnable() {
                    public void run() {
                        int n = tv.getLineCount();

                        StringBuilder sb = new StringBuilder(n);
                        for (int i = 0; i < n; ++i) {
                            sb.append("0" + '\n');
                        }
                        String result = sb.toString();

                        db.update(Integer.parseInt(_id), count_title, count_content, count_icon, result,
                                count_creation);
                        setCountList();
                    }
                }, 500);
            }

            ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes);
            helper_main.switchIcon(getActivity(), count_icon, "count_icon", iv_icon);

            iv_icon.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    final helper_main.Item[] items = {
                            new helper_main.Item(getString(R.string.note_priority_0), R.drawable.circle_green),
                            new helper_main.Item(getString(R.string.note_priority_1), R.drawable.circle_yellow),
                            new helper_main.Item(getString(R.string.note_priority_2), R.drawable.circle_red), };

                    ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(),
                            android.R.layout.select_dialog_item, android.R.id.text1, items) {
                        @NonNull
                        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                            //Use super class to create the View
                            View v = super.getView(position, convertView, parent);
                            TextView tv = (TextView) v.findViewById(android.R.id.text1);
                            tv.setTextSize(18);
                            tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
                            //Add margin between image and text (support various screen densities)
                            int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f);
                            tv.setCompoundDrawablePadding(dp5);

                            return v;
                        }
                    };

                    new AlertDialog.Builder(getActivity())
                            .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    dialog.cancel();
                                }
                            }).setAdapter(adapter, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int item) {
                                    if (item == 0) {
                                        db.update(Integer.parseInt(_id), count_title, count_content, "3",
                                                count_attachment, count_creation);
                                        setCountList();
                                    } else if (item == 1) {
                                        db.update(Integer.parseInt(_id), count_title, count_content, "2",
                                                count_attachment, count_creation);
                                        setCountList();
                                    } else if (item == 2) {
                                        db.update(Integer.parseInt(_id), count_title, count_content, "1",
                                                count_attachment, count_creation);
                                        setCountList();
                                    }
                                }
                            }).show();
                }
            });
            return v;
        }
    };

    //display data by filter
    final String note_search = sharedPref.getString("filter_countBY", "note_title");
    sharedPref.edit().putString("filter_countBY", "note_title").apply();
    filter.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);
        }
    });

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

            if (isFABOpen) {
                closeFABMenu();
            }

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String count_title = row2.getString(row2.getColumnIndexOrThrow("count_title"));
            final String count_content = row2.getString(row2.getColumnIndexOrThrow("count_content"));
            final String count_icon = row2.getString(row2.getColumnIndexOrThrow("count_icon"));
            final String count_attachment = row2.getString(row2.getColumnIndexOrThrow("count_attachment"));
            final String count_creation = row2.getString(row2.getColumnIndexOrThrow("count_creation"));

            sharedPref.edit().putString("count_title", count_title).apply();
            sharedPref.edit().putString("count_content", count_content).apply();
            sharedPref.edit().putString("count_seqno", _id).apply();
            sharedPref.edit().putString("count_icon", count_icon).apply();
            sharedPref.edit().putString("count_create", count_creation).apply();
            sharedPref.edit().putString("count_attachment", count_attachment).apply();

            helper_main.switchToActivity(getActivity(), Activity_count.class, false);
        }
    });

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

            if (isFABOpen) {
                closeFABMenu();
            }

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String count_title = row2.getString(row2.getColumnIndexOrThrow("count_title"));
            final String count_content = row2.getString(row2.getColumnIndexOrThrow("count_content"));
            final String count_icon = row2.getString(row2.getColumnIndexOrThrow("count_icon"));
            final String count_attachment = row2.getString(row2.getColumnIndexOrThrow("count_attachment"));
            final String count_creation = row2.getString(row2.getColumnIndexOrThrow("count_creation"));

            final CharSequence[] options = { getString(R.string.number_edit_entry),
                    getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_share),
                    getString(R.string.bookmark_createNote), getString(R.string.bookmark_createEvent) };
            new AlertDialog.Builder(getActivity())
                    .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.number_edit_entry))) {

                                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                                View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null);

                                final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title);
                                edit_title.setHint(R.string.bookmark_edit_title);
                                edit_title.setText(count_title);

                                builder.setView(dialogView);
                                builder.setTitle(R.string.bookmark_edit_title);
                                builder.setPositiveButton(R.string.toast_yes,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {

                                                String inputTag = edit_title.getText().toString().trim();
                                                db.update(Integer.parseInt(_id), inputTag, count_content,
                                                        count_icon, count_attachment, count_creation);
                                                setCountList();
                                                Snackbar.make(lv, R.string.bookmark_added,
                                                        Snackbar.LENGTH_SHORT).show();
                                            }
                                        });
                                builder.setNegativeButton(R.string.toast_cancel,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                dialog.cancel();
                                            }
                                        });

                                final AlertDialog dialog2 = builder.create();
                                // Display the custom alert dialog on interface
                                dialog2.show();
                                helper_main.showKeyboard(getActivity(), edit_title);
                            }

                            if (options[item].equals(getString(R.string.todo_share))) {
                                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                sharingIntent.setType("text/plain");
                                sharingIntent.putExtra(Intent.EXTRA_SUBJECT, count_title);
                                sharingIntent.putExtra(Intent.EXTRA_TEXT, count_content);
                                startActivity(Intent.createChooser(sharingIntent,
                                        (getString(R.string.note_share_2))));
                            }

                            if (options[item].equals(getString(R.string.bookmark_createEvent))) {
                                helper_main.createCalendarEvent(getActivity(), count_title, count_content);
                            }

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

                            if (options[item].equals(getString(R.string.bookmark_createNote))) {
                                Notes_helper.newNote(getActivity(), count_title, count_content, "", "", "", "");
                            }

                        }
                    }).show();

            return true;
        }
    });
}

From source file:com.skyousuke.ivtool.windows.MainWindow.java

@SuppressLint("InflateParams")
public MainWindow(final Context context, WindowManager windowManager, Handler handler) {
    this.context = context;
    this.windowManager = windowManager;
    this.handler = handler;
    inputData.setListener(this);

    layout = (CustomRelativeLayout) LayoutInflater.from(context).inflate(R.layout.tool_window, null);
    pokemonView = (AutoCompleteTextView) layout.findViewById(R.id.pokemon);
    dustView = (AutoCompleteTextView) layout.findViewById(R.id.dust);
    cpView = (AutoCompleteTextView) layout.findViewById(R.id.cp);
    hpView = (AutoCompleteTextView) layout.findViewById(R.id.hp);
    maxIVTextView = (TextView) layout.findViewById(R.id.max_iv);
    minIVTextView = (TextView) layout.findViewById(R.id.min_iv);
    final CheckBox powerUpCheck = (CheckBox) layout.findViewById(R.id.check_powered);
    TextView textCheck = (TextView) layout.findViewById(R.id.powered);
    message = (TextView) layout.findViewById(R.id.message);
    pokemonValidation = (ImageView) layout.findViewById(R.id.image_validation_pokemon);
    dustValidation = (ImageView) layout.findViewById(R.id.image_validation_dust);
    cpValidation = (ImageView) layout.findViewById(R.id.image_validation_cp);
    hpValidation = (ImageView) layout.findViewById(R.id.image_validation_hp);
    powerUpValidation = (ImageView) layout.findViewById(R.id.image_validation_power_up);
    seeResultButton = (Button) layout.findViewById(R.id.button_tool);
    appraisalButton = (Button) layout.findViewById(R.id.button_appraisal);

    appraisalLayout = (LinearLayout) layout.findViewById(R.id.appraisal);
    teamSelectLayout = (LinearLayout) layout.findViewById(R.id.team_select);
    teamSpinner = (Spinner) teamSelectLayout.findViewById(R.id.spinner_team);
    rangePhraseSpinner = (Spinner) layout.findViewById(R.id.spinner_iv_phrase);
    statPhraseSpinner = (Spinner) layout.findViewById(R.id.spinner_stats_phrase);
    appraisalWrong = (TextView) layout.findViewById(R.id.appraisal_wrong);

    layoutParams.gravity = Gravity.TOP | Gravity.CENTER;

    enableBackKey(true);/*w  ww .  j  av  a  2  s  .  com*/
    setTouchListener();

    pokemonView.setAdapter(new ArrayAdapter<>(context, R.layout.simple_dropdown, Pokemon.values));
    pokemonView.addTextChangedListener(new DefaultTextChangedListener() {
        @Override
        public void afterTextChanged(Editable editable) {
            inputData.setPokemon(editable.toString());
            updateValidation();
        }
    });
    pokemonView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> p, View v, int pos, long id) {
            if (inputData.isDustUnset())
                focusDustView();
        }
    });
    pokemonView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if (hasFocus) {
                pokemonView.setText("");
            }
        }
    });
    pokemonView.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                focusDustView();
                return true;
            }
            return false;
        }
    });
    dustView.setAdapter(new ArrayAdapter<>(context, R.layout.simple_dropdown, IVCalculator.dustList));
    dustView.addTextChangedListener(new DefaultTextChangedListener() {
        @Override
        public void afterTextChanged(Editable editable) {
            inputData.setDust(editable.toString());
            updateValidation();
        }
    });
    dustView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> p, View v, int pos, long id) {
            if (inputData.isCpUnset())
                focusCpView();
        }
    });
    dustView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if (hasFocus) {
                dustView.setText("");
            }
        }
    });
    dustView.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                focusCpView();
                return true;
            }
            return false;
        }
    });

    cpView.addTextChangedListener(new DefaultTextChangedListener() {
        @Override
        public void afterTextChanged(Editable editable) {
            inputData.setCp(editable.toString());
            updateValidation();
        }
    });
    cpView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> p, View v, int pos, long id) {
            if (inputData.isHpUnset())
                focusHpView();
        }
    });
    cpView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if (hasFocus) {
                cpView.setText("");
            }
        }
    });
    cpView.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                focusHpView();
                return true;
            }
            return false;
        }
    });
    hpView.addTextChangedListener(new DefaultTextChangedListener() {
        @Override
        public void afterTextChanged(Editable editable) {
            inputData.setHp(editable.toString());
            updateValidation();
        }
    });
    hpView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View view, boolean hasFocus) {
            if (hasFocus) {
                hpView.setText("");
            }
        }
    });
    powerUpCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            inputData.setPoweredUp(isChecked);
            updateValidation();
        }
    });
    textCheck.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            powerUpCheck.toggle();
        }
    });
    seeResultButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (resultWindow != null) {
                resultWindow.show();
                enableBackKey(false);
            }
        }
    });

    hideAppraisal();
}

From source file:com.polito.dion.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);
    mETAddType = (EditText) rootView.findViewById(R.id.etAddType);
    mETAddCost = (EditText) rootView.findViewById(R.id.etAddCost);

    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/* www.  j  a va2  s.  c o  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());
            viewHolder.commentAddType.setText(comment.getAddType());
            viewHolder.commentAddCost.setText(comment.getAddCost());

        }
    };
    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();
            final Editable commentAddType = mETAddType.getText();
            final Editable commentAddCost = mETAddCost.getText();
            mEditText.setText("");
            mETAddType.setText("");
            mETAddCost.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.getPhotoUrl().toString(), user.getUid());

            Comment comment = new Comment(author, commentAddCost.toString(), commentAddType.toString(),
                    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:com.gimranov.zandy.app.ItemActivity.java

protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_NEW:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getResources().getString(R.string.item_type))
                // XXX i18n
                .setItems(Item.ITEM_TYPES_EN, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int pos) {
                        Item item = new Item(getBaseContext(), Item.ITEM_TYPES[pos]);
                        item.dirty = APIRequest.API_DIRTY;
                        item.save(db);//  ww w  . j av a 2  s.  co  m
                        if (collectionKey != null) {
                            ItemCollection coll = ItemCollection.load(collectionKey, db);
                            if (coll != null) {
                                coll.loadChildren(db);
                                coll.add(item);
                                coll.saveChildren(db);
                            }
                        }
                        Log.d(TAG, "Loading item data with key: " + item.getKey());
                        // We create and issue a specified intent with the necessary data
                        Intent i = new Intent(getBaseContext(), ItemDataActivity.class);
                        i.putExtra("com.gimranov.zandy.app.itemKey", item.getKey());
                        startActivity(i);
                    }
                });
        AlertDialog dialog = builder.create();
        return dialog;
    case DIALOG_SORT:

        // We generate the sort name list for our current locale
        String[] sorts = new String[SORT_NAMES.length];
        for (int j = 0; j < SORT_NAMES.length; j++) {
            sorts[j] = getResources().getString(SORT_NAMES[j]);
        }

        AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
        builder2.setTitle(getResources().getString(R.string.set_sort_order)).setItems(sorts,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int pos) {
                        Cursor cursor;
                        setSortBy(SORTS[pos]);
                        ItemCollection collection;
                        if (collectionKey != null
                                && (collection = ItemCollection.load(collectionKey, db)) != null) {
                            cursor = getCursor(collection);
                        } else {
                            if (query != null) {
                                cursor = getCursor(query);
                            } else {
                                cursor = getCursor();
                            }
                        }
                        ItemAdapter adapter = (ItemAdapter) getListAdapter();
                        adapter.changeCursor(cursor);
                        Log.d(TAG, "Re-sorting by: " + SORTS[pos]);

                        Persistence.write(SORT_CHOICE, SORTS[pos]);
                    }
                });
        AlertDialog dialog2 = builder2.create();
        return dialog2;
    case DIALOG_PROGRESS:
        mProgressDialog = new ProgressDialog(this);
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setMessage(getResources().getString(R.string.identifier_looking_up));
        return mProgressDialog;
    case DIALOG_IDENTIFIER:
        final EditText input = new EditText(this);
        input.setHint(getResources().getString(R.string.identifier_hint));

        final ItemActivity current = this;

        dialog = new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.identifier_message))
                .setView(input).setPositiveButton(getResources().getString(R.string.menu_search),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                Editable value = input.getText();
                                // run search
                                Bundle c = new Bundle();
                                c.putString("mode", "isbn");
                                c.putString("identifier", value.toString());
                                removeDialog(DIALOG_PROGRESS);
                                ItemActivity.this.b = c;
                                showDialog(DIALOG_PROGRESS);
                            }
                        })
                .setNeutralButton(getResources().getString(R.string.scan),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // If we're about to download from Google play, cancel that dialog
                                // and prompt from Amazon if we're on an Amazon device
                                IntentIntegrator integrator = new IntentIntegrator(current);
                                @Nullable
                                AlertDialog producedDialog = integrator.initiateScan();
                                if (producedDialog != null && "amazon".equals(BuildConfig.FLAVOR)) {
                                    producedDialog.dismiss();
                                    AmazonZxingGlue.showDownloadDialog(current);
                                }
                            }
                        })
                .setNegativeButton(getResources().getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                // do nothing
                            }
                        })
                .create();
        return dialog;
    default:
        return null;
    }
}

From source file:de.baumann.hhsmoodle.data_todo.Todo_Fragment.java

public void setTodoList() {

    if (isFABOpen) {
        closeFABMenu();// w ww  . ja  v  a 2  s  .  c o m
    }

    NotificationManager nMgr = (NotificationManager) getActivity()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    nMgr.cancelAll();

    //display data
    final int layoutstyle = R.layout.list_item_notes;
    int[] xml_id = new int[] { R.id.textView_title_notes, R.id.textView_des_notes, R.id.textView_create_notes };
    String[] column = new String[] { "todo_title", "todo_content", "todo_creation" };
    final Cursor row = db.fetchAllData(getActivity());
    adapter = new SimpleCursorAdapter(getActivity(), layoutstyle, row, column, xml_id, 0) {
        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            View v = super.getView(position, convertView, parent);
            ImageView iv_icon = (ImageView) v.findViewById(R.id.icon_notes);
            ImageView iv_attachment = (ImageView) v.findViewById(R.id.att_notes);
            helper_main.switchIcon(getActivity(), todo_icon, "todo_icon", iv_icon);

            switch (todo_attachment) {
            case "true":
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle);
                break;
            default:
                iv_attachment.setVisibility(View.VISIBLE);
                iv_attachment.setImageResource(R.drawable.alert_circle_red);

                int n = Integer.valueOf(_id);

                android.content.Intent iMain = new android.content.Intent();
                iMain.setAction("shortcutToDo");
                iMain.setClassName(getActivity(), "de.baumann.hhsmoodle.activities.Activity_splash");
                PendingIntent piMain = PendingIntent.getActivity(getActivity(), n, iMain, 0);

                NotificationCompat.Builder builderSummary = new NotificationCompat.Builder(getActivity())
                        .setSmallIcon(R.drawable.school)
                        .setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary))
                        .setGroup("HHS_Moodle").setGroupSummary(true).setContentIntent(piMain);

                Notification notification = new NotificationCompat.Builder(getActivity())
                        .setColor(ContextCompat.getColor(getActivity(), R.color.colorPrimary))
                        .setSmallIcon(R.drawable.school).setContentTitle(todo_title)
                        .setContentText(todo_content).setContentIntent(piMain).setAutoCancel(true)
                        .setGroup("HHS_Moodle")
                        .setStyle(new NotificationCompat.BigTextStyle().bigText(todo_content))
                        .setPriority(Notification.PRIORITY_DEFAULT).setVibrate(new long[0]).build();

                NotificationManager notificationManager = (NotificationManager) getActivity()
                        .getSystemService(NOTIFICATION_SERVICE);
                notificationManager.notify(n, notification);
                notificationManager.notify(0, builderSummary.build());
                break;
            }

            iv_icon.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    final helper_main.Item[] items = {
                            new helper_main.Item(getString(R.string.note_priority_0), R.drawable.circle_green),
                            new helper_main.Item(getString(R.string.note_priority_1), R.drawable.circle_yellow),
                            new helper_main.Item(getString(R.string.note_priority_2), R.drawable.circle_red), };

                    ListAdapter adapter = new ArrayAdapter<helper_main.Item>(getActivity(),
                            android.R.layout.select_dialog_item, android.R.id.text1, items) {
                        @NonNull
                        public View getView(int position, View convertView, @NonNull ViewGroup parent) {
                            //Use super class to create the View
                            View v = super.getView(position, convertView, parent);
                            TextView tv = (TextView) v.findViewById(android.R.id.text1);
                            tv.setTextSize(18);
                            tv.setCompoundDrawablesWithIntrinsicBounds(items[position].icon, 0, 0, 0);
                            //Add margin between image and text (support various screen densities)
                            int dp5 = (int) (24 * getResources().getDisplayMetrics().density + 0.5f);
                            tv.setCompoundDrawablePadding(dp5);

                            return v;
                        }
                    };

                    new AlertDialog.Builder(getActivity())
                            .setPositiveButton(R.string.toast_cancel, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int whichButton) {
                                    dialog.cancel();
                                }
                            }).setAdapter(adapter, new DialogInterface.OnClickListener() {

                                public void onClick(DialogInterface dialog, int item) {
                                    if (item == 0) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "3",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    } else if (item == 1) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "2",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    } else if (item == 2) {
                                        db.update(Integer.parseInt(_id), todo_title, todo_content, "1",
                                                todo_attachment, todo_creation);
                                        setTodoList();
                                    }
                                }
                            }).show();
                }
            });
            iv_attachment.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {
                    switch (todo_attachment) {
                    case "true":
                        db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "",
                                todo_creation);
                        setTodoList();
                        break;
                    default:
                        db.update(Integer.parseInt(_id), todo_title, todo_content, todo_icon, "true",
                                todo_creation);
                        setTodoList();
                        break;
                    }
                }
            });
            return v;
        }
    };

    //display data by filter
    final String note_search = sharedPref.getString("filter_todoBY", "note_title");
    sharedPref.edit().putString("filter_todoBY", "note_title").apply();
    filter.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);
        }
    });

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

            if (isFABOpen) {
                closeFABMenu();
            }

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            sharedPref.edit().putString("toDo_title", todo_title).apply();
            sharedPref.edit().putString("toDo_text", todo_content).apply();
            sharedPref.edit().putString("toDo_seqno", _id).apply();
            sharedPref.edit().putString("toDo_icon", todo_icon).apply();
            sharedPref.edit().putString("toDo_create", todo_creation).apply();
            sharedPref.edit().putString("toDo_attachment", todo_attachment).apply();

            helper_main.switchToActivity(getActivity(), Activity_todo.class, false);
        }
    });

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

            if (isFABOpen) {
                closeFABMenu();
            }

            Cursor row2 = (Cursor) lv.getItemAtPosition(position);
            final String _id = row2.getString(row2.getColumnIndexOrThrow("_id"));
            final String todo_title = row2.getString(row2.getColumnIndexOrThrow("todo_title"));
            final String todo_content = row2.getString(row2.getColumnIndexOrThrow("todo_content"));
            final String todo_icon = row2.getString(row2.getColumnIndexOrThrow("todo_icon"));
            final String todo_attachment = row2.getString(row2.getColumnIndexOrThrow("todo_attachment"));
            final String todo_creation = row2.getString(row2.getColumnIndexOrThrow("todo_creation"));

            final CharSequence[] options = { getString(R.string.number_edit_entry),
                    getString(R.string.bookmark_remove_bookmark), getString(R.string.todo_share),
                    getString(R.string.bookmark_createNote), getString(R.string.count_create),
                    getString(R.string.bookmark_createEvent) };
            new AlertDialog.Builder(getActivity())
                    .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.number_edit_entry))) {

                                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                                View dialogView = View.inflate(getActivity(), R.layout.dialog_edit_title, null);

                                final EditText edit_title = (EditText) dialogView.findViewById(R.id.pass_title);
                                edit_title.setHint(R.string.bookmark_edit_title);
                                edit_title.setText(todo_title);

                                builder.setView(dialogView);
                                builder.setTitle(R.string.bookmark_edit_title);
                                builder.setPositiveButton(R.string.toast_yes,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {

                                                String inputTag = edit_title.getText().toString().trim();
                                                db.update(Integer.parseInt(_id), inputTag, todo_content,
                                                        todo_icon, todo_attachment, todo_creation);
                                                setTodoList();
                                                Snackbar.make(lv, R.string.bookmark_added,
                                                        Snackbar.LENGTH_SHORT).show();
                                            }
                                        });
                                builder.setNegativeButton(R.string.toast_cancel,
                                        new DialogInterface.OnClickListener() {

                                            public void onClick(DialogInterface dialog, int whichButton) {
                                                dialog.cancel();
                                            }
                                        });

                                final AlertDialog dialog2 = builder.create();
                                // Display the custom alert dialog on interface
                                dialog2.show();
                                helper_main.showKeyboard(getActivity(), edit_title);
                            }

                            if (options[item].equals(getString(R.string.todo_share))) {
                                Intent sharingIntent = new Intent(Intent.ACTION_SEND);
                                sharingIntent.setType("text/plain");
                                sharingIntent.putExtra(Intent.EXTRA_SUBJECT, todo_title);
                                sharingIntent.putExtra(Intent.EXTRA_TEXT, todo_content);
                                startActivity(Intent.createChooser(sharingIntent,
                                        (getString(R.string.note_share_2))));
                            }

                            if (options[item].equals(getString(R.string.bookmark_createEvent))) {
                                helper_main.createCalendarEvent(getActivity(), todo_title, todo_content);
                            }

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

                            if (options[item].equals(getString(R.string.bookmark_createNote))) {
                                Notes_helper.newNote(getActivity(), todo_title, todo_content, "", "", "", "");
                            }

                            if (options[item].equals(getString(R.string.count_create))) {
                                Count_helper.newCount(getActivity(), todo_title, todo_content,
                                        getActivity().getString(R.string.note_content), false);
                            }

                        }
                    }).show();

            return true;
        }
    });
}