Search in sources :

Example 11 with KeyboardHelper

use of im.actor.sdk.util.KeyboardHelper in project actor-platform by actorapp.

the class EditAboutFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    type = getArguments().getInt("EXTRA_TYPE");
    id = getArguments().getInt("EXTRA_ID");
    helper = new KeyboardHelper(getActivity());
    View res = inflater.inflate(R.layout.fragment_edit_about, container, false);
    res.setBackgroundColor(ActorSDK.sharedActor().style.getMainBackgroundColor());
    aboutEdit = (EditText) res.findViewById(R.id.nameEdit);
    aboutEdit.setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    hintTv = (TextView) res.findViewById(R.id.hint);
    hintTv.setTextColor(ActorSDK.sharedActor().style.getTextHintColor());
    if (type == EditAboutActivity.TYPE_ME) {
        UserVM userModel = users().get(myUid());
        aboutEdit.setText(userModel.getAbout().get());
        aboutEdit.setHint(getString(R.string.edit_about_edittext_hint));
    } else if (type == EditAboutActivity.TYPE_GROUP) {
        GroupVM group = groups().get(id);
        aboutEdit.setText(group.getAbout().get());
    }
    res.findViewById(R.id.dividerTop).setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    res.findViewById(R.id.dividerBot).setBackgroundColor(ActorSDK.sharedActor().style.getDividerColor());
    res.findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }
    });
    ((TextView) res.findViewById(R.id.cancel)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    res.findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String about = aboutEdit.getText().toString().trim();
            if (about.length() == 0) {
                about = null;
            }
            if (type == EditAboutActivity.TYPE_ME) {
                execute(messenger().editMyAbout(about), R.string.progress_common, new CommandCallback<Boolean>() {

                    @Override
                    public void onResult(Boolean res) {
                        getActivity().finish();
                    }

                    @Override
                    public void onError(Exception e) {
                        Toast.makeText(getActivity(), R.string.toast_unable_change, Toast.LENGTH_SHORT).show();
                    }
                });
            //TODO: set group about
            }
        }
    });
    ((TextView) res.findViewById(R.id.ok)).setTextColor(ActorSDK.sharedActor().style.getTextPrimaryColor());
    return res;
}
Also used : UserVM(im.actor.core.viewmodel.UserVM) GroupVM(im.actor.core.viewmodel.GroupVM) TextView(android.widget.TextView) KeyboardHelper(im.actor.sdk.util.KeyboardHelper) CommandCallback(im.actor.core.viewmodel.CommandCallback) TextView(android.widget.TextView) View(android.view.View)

Aggregations

KeyboardHelper (im.actor.sdk.util.KeyboardHelper)11 View (android.view.View)10 TextView (android.widget.TextView)9 StateListDrawable (android.graphics.drawable.StateListDrawable)5 Editable (android.text.Editable)3 TextWatcher (android.text.TextWatcher)3 CommandCallback (im.actor.core.viewmodel.CommandCallback)3 UserVM (im.actor.core.viewmodel.UserVM)3 DialogInterface (android.content.DialogInterface)2 GroupVM (im.actor.core.viewmodel.GroupVM)2 AlertDialog (android.app.AlertDialog)1 Intent (android.content.Intent)1 SpannableString (android.text.SpannableString)1 KeyEvent (android.view.KeyEvent)1 Button (android.widget.Button)1 NumberParseException (com.google.i18n.phonenumbers.NumberParseException)1 Phonenumber (com.google.i18n.phonenumbers.Phonenumber)1 Void (im.actor.runtime.actors.messages.Void)1 Country (im.actor.sdk.util.country.Country)1 AvatarView (im.actor.sdk.view.avatar.AvatarView)1