Example usage for android.text TextWatcher TextWatcher

List of usage examples for android.text TextWatcher TextWatcher

Introduction

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

Prototype

TextWatcher

Source Link

Usage

From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java

private void setOnclick() {
    mRecordImage.setOnClickListener(new OnClickListener() {
        @Override/*from   w  w  w.j a  v a  2  s.c  o m*/
        public void onClick(View v) {
            try {
                JSONObject ret = new JSONObject();
                ret.put("eventType", "record");
                mUZContext.success(ret, false);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    });

    deleteTextImg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            mEditText.setText("");
            if (config.showRecordBtn) {
                mRecordImage.setVisibility(View.VISIBLE);
            } else {
                mRecordImage.setVisibility(View.GONE);
            }
        }
    });

    mListView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long longid) {
            if (position == list.size() - 1) {
                hide();
                id = 0;
                list.clear();
                list.add(relativeLayoutClean);
                adapter.notifyDataSetChanged();
                editor.clear();
                editor.commit();
            } else {
                int tv_listId = UZResourcesIDFinder.getResIdID("tv_listview");
                TextView tv = (TextView) view.findViewById(tv_listId);
                String searchText = tv.getText().toString();
                try {
                    JSONObject ret = new JSONObject();
                    ret.put("eventType", "history");
                    ret.put("text", searchText);
                    mUZContext.success(ret, false);
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                SearchBarActivity.this.finish();
            }
        }
    });

    mEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (!TextUtils.isEmpty(arg0)) {
                mRecordImage.setVisibility(View.GONE);
                deleteTextImg.setVisibility(View.VISIBLE);
            } else {
                deleteTextImg.setVisibility(View.GONE);
                if (config.showRecordBtn) {
                    mRecordImage.setVisibility(View.VISIBLE);
                }
            }
        }

        @Override
        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        @Override
        public void afterTextChanged(Editable arg0) {

        }
    });

    mEditText.setOnEditorActionListener(new OnEditorActionListener() {

        @SuppressWarnings("unchecked")
        @Override
        public boolean onEditorAction(TextView arg0, int actionId, KeyEvent event) {

            if (actionId == EditorInfo.IME_ACTION_SEARCH) {
                id++;
                String text = mEditText.getText().toString();
                if (!TextUtils.isEmpty(text)) {

                    if (recordCount <= 0) {

                        try {
                            JSONObject ret = new JSONObject();
                            ret.put("eventType", "search");
                            ret.put("text", text);
                            mUZContext.success(ret, false);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                        SearchBarActivity.this.finish();
                        clearText();

                        return false;
                    }

                    int index = id % recordCount;
                    if (id > recordCount) {

                        editor.remove(1 + "");
                        editor.commit();
                        Map<String, String> map = (Map<String, String>) mPref.getAll();
                        if (map != null) {
                            if (map.size() != 0) {
                                for (int i = 1; i <= (map.size() + 1); i++) {
                                    for (Entry<String, String> iterable_element : map.entrySet()) {
                                        String key = iterable_element.getKey();
                                        if ((i + "").equals(key)) {
                                            editor.putString((i - 1) + "", iterable_element.getValue());
                                            editor.commit();
                                        }
                                    }
                                }
                            }
                        }
                        editor.putString(recordCount + "", text);
                        editor.commit();
                    } else {
                        editor.putString((index == 0 ? recordCount : index) + "", text);
                        editor.commit();
                    }

                    try {
                        JSONObject ret = new JSONObject();
                        ret.put("eventType", "search");
                        ret.put("text", text);
                        mUZContext.success(ret, false);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    SearchBarActivity.this.finish();
                    clearText();
                }

            }
            return false;
        }
    });

    mTextView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            SearchBarActivity.this.finish();
            clearText();

        }
    });
}

From source file:com.cssn.samplesdk.MainActivity.java

/**
 *
 *//*from   w  w w . j  av a  2s . c om*/
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    if (Util.LOG_ENABLED) {
        Utils.appendLog(TAG, "protected void onCreate(Bundle savedInstanceState)");
    }

    // load the model
    if (savedInstanceState == null) {
        if (Util.LOG_ENABLED) {
            Utils.appendLog(TAG, "if (savedInstanceState == null)");
        }
        mainActivityModel = new MainActivityModel();
    } else {
        if (Util.LOG_ENABLED) {
            Utils.appendLog(TAG, "if (savedInstanceState != null)");
        }
        mainActivityModel = DataContext.getInstance().getMainActivityModel();
        // if coming from background and kill the app, restart the model
        if (mainActivityModel == null) {
            mainActivityModel = new MainActivityModel();
        }
    }
    DataContext.getInstance().setContext(getApplicationContext());

    String licenseKey = DataContext.getInstance().getLicenseKey();

    // load the controller instance
    acuantAndroidMobileSdkControllerInstance = AcuantAndroidMobileSDKController.getInstance(this, licenseKey);
    if (!Util.isTablet(this)) {
        acuantAndroidMobileSdkControllerInstance
                .setPdf417BarcodeImageDrawable(getResources().getDrawable(R.drawable.barcode));
    }

    acuantAndroidMobileSdkControllerInstance.setWebServiceListener(this);
    acuantAndroidMobileSdkControllerInstance.setCloudUrl("cssnwebservices.com");
    acuantAndroidMobileSdkControllerInstance.setWatermarkText("Powered By Acuant", 0, 0, 30, 0);
    DisplayMetrics metrics = this.getResources().getDisplayMetrics();

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int height = displaymetrics.heightPixels;
    int width = displaymetrics.widthPixels;
    int minLength = (int) (Math.min(width, height) * 0.9);
    int maxLength = (int) (minLength * 1.5);
    int left = minLength / 2 - 50;
    int top = maxLength / 2 - 100;
    Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    Typeface currentTypeFace = textPaint.getTypeface();
    Typeface bold = Typeface.create(currentTypeFace, Typeface.BOLD);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(50);
    textPaint.setTextAlign(Paint.Align.LEFT);
    textPaint.setTypeface(bold);
    Paint.FontMetrics metric = textPaint.getFontMetrics();
    acuantAndroidMobileSdkControllerInstance.setInstructionText("Blink Slowly", left, top, textPaint);
    //acuantAndroidMobileSdkControllerInstance.setShowActionBar(false);
    //acuantAndroidMobileSdkControllerInstance.setShowStatusBar(false);
    acuantAndroidMobileSdkControllerInstance.setFlashlight(false);
    //acuantAndroidMobileSdkControllerInstance.setFlashlight(0,0,50,0);
    //acuantAndroidMobileSdkControllerInstance.setFlashlightImageDrawable(getResources().getDrawable(R.drawable.lighton), getResources().getDrawable(R.drawable.lightoff));
    //acuantAndroidMobileSdkControllerInstance.setShowInitialMessage(true);
    //acuantAndroidMobileSdkControllerInstance.setCropBarcode(true);
    //acuantAndroidMobileSdkControllerInstance.setPdf417BarcodeDialogWaitingBarcode("AcuantAndroidMobileSampleSDK","ALIGN AND TAP", 10, "Try Again", "Yes");
    acuantAndroidMobileSdkControllerInstance.setCanShowBracketsOnTablet(true);
    // load several member variables
    setContentView(R.layout.activity_main);

    layoutCards = (LinearLayout) findViewById(R.id.cardImagesLayout);
    layoutBackImage = (RelativeLayout) findViewById(R.id.relativeLayoutBackImage);
    layoutFrontImage = (RelativeLayout) findViewById(R.id.relativeLayoutFrontImage);

    frontImageView = (ImageView) findViewById(R.id.frontImageView);
    backImageView = (ImageView) findViewById(R.id.backImageView);

    editTextLicense = (EditText) findViewById(R.id.editTextLicenceKey);
    editTextLicense.setText(DataContext.getInstance().getLicenseKey());

    txtTapToCaptureFront = (TextView) findViewById(R.id.txtTapToCaptureFront);
    txtTapToCaptureBack = (TextView) findViewById(R.id.txtTapToCaptureBack);

    activateLicenseButton = (Button) findViewById(R.id.activateLicenseButton);

    processCardButton = (Button) findViewById(R.id.processCardButton);
    processCardButton.setVisibility(View.INVISIBLE);

    editTextLicense.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            validateLicenseKey(editTextLicense.getText().toString());
            DataContext.getInstance().setLicenseKey(editTextLicense.getText().toString());
            return true;
        }
    });

    // it is necessary to use a post UI call, because of the previous set text on 'editTextLicense'
    new Handler().post(new Runnable() {
        @Override
        public void run() {
            editTextLicense.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    mainActivityModel.setState(State.NO_VALIDATED);
                    updateActivateLicenseButtonFromModel();
                }

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

                }

                public void onTextChanged(CharSequence s, int start, int before, int count) {

                }
            });
        }
    });

    editTextLicense.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
                hideVirtualKeyboard();
            }
        }
    });

    // update the UI from the model
    updateUI();
    acuantAndroidMobileSdkControllerInstance.setCardCroppingListener(this);
    acuantAndroidMobileSdkControllerInstance.setAcuantErrorListener(this);
    if (Utils.LOG_ENABLED) {
        Utils.appendLog(TAG, "getScreenOrientation()=" + Util.getScreenOrientation(this));
    }
}

From source file:com.sxt.superqq.activity.LoginActivity.java

/**
 * ???//w w  w  .  j ava2s. c om
 */
private void setUsernameTextChangedListener() {
    // ????
    usernameEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            passwordEditText.setText(null);
        }

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

        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
}

From source file:edu.cens.loci.ui.widget.GenericEditorView.java

/**
 * Prepare this editor using the given {@link DataKind} for defining
 * structure and {@link ValuesDelta} describing the content to edit.
 *//*  ww  w .j a  v  a 2  s . c  o m*/
public void setValues(DataKind kind, ValuesDelta entry, EntityDelta state, boolean readOnly,
        ViewIdGenerator vig) {
    mKind = kind;
    mEntry = entry;
    mState = state;
    mReadOnly = readOnly;
    mViewIdGenerator = vig;

    setId(vig.getId(state, kind, entry, ViewIdGenerator.NO_VIEW_INDEX));

    final boolean enabled = !readOnly;

    //Log.d(TAG, "setValues: kind=" + mKind.mimeType);

    if (!entry.isVisible()) {
        // Hide ourselves entirely if deleted
        setVisibility(View.GONE);
        return;
    } else {
        setVisibility(View.VISIBLE);
    }

    // Display label selector if multiple types available
    final boolean hasTypes = EntityModifier.hasEditTypes(kind);
    mLabel.setVisibility(hasTypes ? View.VISIBLE : View.GONE);
    mLabel.setEnabled(enabled);
    if (hasTypes) {
        mType = EntityModifier.getCurrentType(entry, kind);
        rebuildLabel();
    }

    // Build out set of fields
    mFields.removeAllViews();
    boolean hidePossible = false;
    int n = 0;

    if (mKind.mimeType.equals(WifiFingerprint.CONTENT_ITEM_TYPE)) {

        //Log.d(TAG, "setValues: Wifi");

        for (EditField field : kind.fieldList) {
            Button fieldView = (Button) mInflater.inflate(RES_WIFI_FIELD, mFields, false);

            mWifiFieldButtonId = vig.getId(state, kind, entry, n++);

            fieldView.setId(mWifiFieldButtonId);

            final String column = field.column;
            final String value = entry.getAsString(column);
            fieldView.setText("Fingerprint on " + MyDateUtils.getAbrv_MMM_d_h_m(new Long(value)));

            final String extra1column = field.extra1;
            final String extra1value = entry.getAsString(extra1column);
            try {
                mWifiFingerprint = new LociWifiFingerprint(extra1value);
                mWifiFingerprintTimeStamp = MyDateUtils.getDateFormatLong(new Long(value));
            } catch (JSONException e) {
                MyLog.e(LociConfig.D.JSON, TAG, "LociWifiFingerprint parsing failed");
                e.printStackTrace();
            }

            // Hide field when empty and optional value
            final boolean couldHide = (field.optional);
            final boolean willHide = (mHideOptional && couldHide);
            fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
            fieldView.setEnabled(enabled);
            hidePossible = hidePossible || couldHide;

            fieldView.setOnClickListener(this);

            mFields.addView(fieldView);
        }
    } else if (mKind.mimeType.equals(Keyword.CONTENT_ITEM_TYPE)) {

        //Log.d(TAG, "setValues: Keywords");

        for (EditField field : kind.fieldList) {

            AutoCompleteTextView fieldView = (AutoCompleteTextView) mInflater.inflate(RES_AUTOCOMPLETE_FIELD,
                    mFields, false);
            fieldView.setId(vig.getId(state, kind, entry, n++));
            if (field.titleRes > 0) {
                fieldView.setHint(field.titleRes);
            }
            int inputType = field.inputType;
            fieldView.setInputType(inputType);
            fieldView.setMinLines(field.minLines);

            // Read current value from state
            final String column = field.column;
            final String value = entry.getAsString(column);
            fieldView.setText(value);

            // Prepare listener for writing changes
            fieldView.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    // Trigger event for newly changed value
                    onFieldChanged(column, s.toString());
                }

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

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });

            // Hide field when empty and optional value
            final boolean couldHide = (field.optional);
            final boolean willHide = (mHideOptional && couldHide);
            fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
            fieldView.setEnabled(enabled);
            hidePossible = hidePossible || couldHide;

            String[] usedKeywords = getResources().getStringArray(R.array.keyword_default);

            LociDbUtils myDb = new LociDbUtils(getContext());
            ArrayList<String> suggestedKeywords = myDb.getSavedKeywords();
            HashSet<String> suggestedKeywordsSet = new HashSet<String>();

            for (String keyword : suggestedKeywords) {
                suggestedKeywordsSet.add(keyword);
            }

            //Log.d(TAG, "size of usedKeywords : " + usedKeywords.length);
            //Log.d(TAG, "size of suggestedKeywords : " + suggestedKeywords.size());

            for (String usedKeyword : usedKeywords) {
                if (!suggestedKeywordsSet.contains(usedKeyword))
                    suggestedKeywords.add(usedKeyword);
            }

            //Log.d(TAG, "size of suggestedKeywords : " + suggestedKeywords.size());

            Collections.sort(suggestedKeywords);

            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(),
                    R.layout.item_suggestion_list, suggestedKeywords);
            fieldView.setAdapter(adapter);
            fieldView.setThreshold(0);

            mFields.addView(fieldView);
        }

    } else {

        //Log.d(TAG, "General Types...");

        for (EditField field : kind.fieldList) {
            // Inflate field from definition
            EditText fieldView = (EditText) mInflater.inflate(RES_FIELD, mFields, false);
            fieldView.setId(vig.getId(state, kind, entry, n++));
            if (field.titleRes > 0) {
                fieldView.setHint(field.titleRes);
            }
            int inputType = field.inputType;
            fieldView.setInputType(inputType);
            if (inputType == InputType.TYPE_CLASS_PHONE) {
                fieldView.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
            }
            fieldView.setMinLines(field.minLines);

            // Read current value from state
            final String column = field.column;
            final String value = entry.getAsString(column);
            fieldView.setText(value);

            //Log.d(TAG, "setValues: column=" + column);
            //Log.d(TAG, "setValues: value=" + value);

            // Prepare listener for writing changes
            fieldView.addTextChangedListener(new TextWatcher() {
                public void afterTextChanged(Editable s) {
                    // Trigger event for newly changed value
                    onFieldChanged(column, s.toString());
                }

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

                public void onTextChanged(CharSequence s, int start, int before, int count) {
                }
            });

            // Hide field when empty and optional value
            final boolean couldHide = (field.optional);
            final boolean willHide = (mHideOptional && couldHide);
            fieldView.setVisibility(willHide ? View.GONE : View.VISIBLE);
            fieldView.setEnabled(enabled);
            hidePossible = hidePossible || couldHide;

            mFields.addView(fieldView);
        }
    }

    // When hiding fields, place expandable
    if (hidePossible) {
        mMore.setVisibility(mHideOptional ? View.VISIBLE : View.GONE);
        mLess.setVisibility(mHideOptional ? View.GONE : View.VISIBLE);
    } else {
        mMore.setVisibility(View.GONE);
        mLess.setVisibility(View.GONE);
    }
    mMore.setEnabled(enabled);
    mLess.setEnabled(enabled);
}

From source file:org.anhonesteffort.flock.SubscriptionStripeFragment.java

private void initCardExpirationHelper() {
    final EditText cardExpirationView = (EditText) subscriptionActivity.findViewById(R.id.card_expiration);
    final EditText cardCvcView = (EditText) subscriptionActivity.findViewById(R.id.card_cvc);

    if (cardExpirationTextWatcher != null)
        cardExpirationView.removeTextChangedListener(cardExpirationTextWatcher);

    cardExpirationTextWatcher = new TextWatcher() {

        @Override//  w w w.j ava2  s . co  m
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            String formattedCardExpiration = s.toString();

            if (lastCardExpirationLength <= formattedCardExpiration.length()
                    && formattedCardExpiration.length() == 2) {
                formattedCardExpiration = formattedCardExpiration + "/";
            }

            lastCardExpirationLength = formattedCardExpiration.length();

            cardExpirationView.removeTextChangedListener(this);
            cardExpirationView.setText(formattedCardExpiration);
            cardExpirationView.setSelection(formattedCardExpiration.length());
            cardExpirationView.addTextChangedListener(this);

            if (formattedCardExpiration.length() == 5)
                cardCvcView.requestFocus();
        }
    };

    cardExpirationView.addTextChangedListener(cardExpirationTextWatcher);
}

From source file:com.kevin.cattalk.ui.SettingsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;/*  w  w w.  ja  va  2s. c  om*/
    rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);
    rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave);
    rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_delete_msg_when_exit_group);
    rl_switch_auto_accept_group_invitation = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_auto_accept_group_invitation);
    rl_switch_adaptive_video_encode = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_adaptive_video_encode);
    rl_custom_appkey = (RelativeLayout) getView().findViewById(R.id.rl_custom_appkey);
    rl_custom_server = (RelativeLayout) getView().findViewById(R.id.rl_custom_server);
    rl_push_settings = (RelativeLayout) getView().findViewById(R.id.rl_push_settings);

    ll_call_option = (LinearLayout) getView().findViewById(R.id.ll_call_option);

    rl_mail_log = (RelativeLayout) getView().findViewById(R.id.rl_mail_log);

    notifySwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification);
    soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound);
    vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate);
    speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker);
    ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave);
    switch_delete_msg_when_exit_group = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_delete_msg_when_exit_group);
    switch_auto_accept_group_invitation = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_auto_accept_group_invitation);
    switch_adaptive_video_encode = (EaseSwitchButton) getView().findViewById(R.id.switch_adaptive_video_encode);
    LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change);
    logoutBtn = (Button) getView().findViewById(R.id.btn_logout);
    if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) {
        logoutBtn.setText(
                getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")");
    }
    customServerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_custom_server);
    customAppkeySwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_custom_appkey);

    textview1 = (TextView) getView().findViewById(R.id.textview1);
    textview2 = (TextView) getView().findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list);
    userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile);
    llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose);
    pushNick = (LinearLayout) getView().findViewById(R.id.ll_set_push_nick);
    edit_custom_appkey = (EditText) getView().findViewById(R.id.edit_custom_appkey);

    settingsModel = DemoHelper.getInstance().getModel();
    chatOptions = EMClient.getInstance().getOptions();

    blacklistContainer.setOnClickListener(this);
    userProfileContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    customAppkeySwitch.setOnClickListener(this);
    customServerSwitch.setOnClickListener(this);
    rl_custom_server.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);
    llDiagnose.setOnClickListener(this);
    pushNick.setOnClickListener(this);
    rl_switch_chatroom_leave.setOnClickListener(this);
    rl_switch_delete_msg_when_exit_group.setOnClickListener(this);
    rl_switch_auto_accept_group_invitation.setOnClickListener(this);
    rl_switch_adaptive_video_encode.setOnClickListener(this);
    rl_push_settings.setOnClickListener(this);
    ll_call_option.setOnClickListener(this);
    llChange.setOnClickListener(this);
    rl_mail_log.setOnClickListener(this);

    // the vibrate and sound notification are allowed or not?
    if (settingsModel.getSettingMsgNotification()) {
        notifySwitch.openSwitch();
    } else {
        notifySwitch.closeSwitch();
    }

    // sound notification is switched on or not?
    if (settingsModel.getSettingMsgSound()) {
        soundSwitch.openSwitch();
    } else {
        soundSwitch.closeSwitch();
    }

    // vibrate notification is switched on or not?
    if (settingsModel.getSettingMsgVibrate()) {
        vibrateSwitch.openSwitch();
    } else {
        vibrateSwitch.closeSwitch();
    }

    // the speaker is switched on or not?
    if (settingsModel.getSettingMsgSpeaker()) {
        speakerSwitch.openSwitch();
    } else {
        speakerSwitch.closeSwitch();
    }

    // if allow owner leave
    if (settingsModel.isChatroomOwnerLeaveAllowed()) {
        ownerLeaveSwitch.openSwitch();
    } else {
        ownerLeaveSwitch.closeSwitch();
    }

    // delete messages when exit group?
    if (settingsModel.isDeleteMessagesAsExitGroup()) {
        switch_delete_msg_when_exit_group.openSwitch();
    } else {
        switch_delete_msg_when_exit_group.closeSwitch();
    }

    if (settingsModel.isAutoAcceptGroupInvitation()) {
        switch_auto_accept_group_invitation.openSwitch();
    } else {
        switch_auto_accept_group_invitation.closeSwitch();
    }

    if (settingsModel.isAdaptiveVideoEncode()) {
        switch_adaptive_video_encode.openSwitch();
        EMClient.getInstance().callManager().getCallOptions().enableFixedVideoResolution(false);
    } else {
        switch_adaptive_video_encode.closeSwitch();
        EMClient.getInstance().callManager().getCallOptions().enableFixedVideoResolution(true);
    }

    if (settingsModel.isCustomServerEnable()) {
        customServerSwitch.openSwitch();
    } else {
        customServerSwitch.closeSwitch();
    }

    if (settingsModel.isCustomAppkeyEnabled()) {
        customAppkeySwitch.openSwitch();
    } else {
        customAppkeySwitch.closeSwitch();
    }
    edit_custom_appkey.setEnabled(settingsModel.isCustomAppkeyEnabled());

    edit_custom_appkey.setText(settingsModel.getCutomAppkey());
    edit_custom_appkey.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            PreferenceManager.getInstance().setCustomAppkey(s.toString());
        }
    });
}

From source file:com.easemob.ui.ChatActivity.java

/**
 * initView//from  w  w  w.  j a  v a 2 s.  c  o m
 */
protected void initView() {
    recordingContainer = findViewById(R.id.recording_container);
    micImage = (ImageView) findViewById(R.id.mic_image);
    recordingHint = (TextView) findViewById(R.id.recording_hint);
    listView = (ListView) findViewById(R.id.list);
    mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
    buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
    buttonSend = findViewById(R.id.btn_send);
    buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
    expressionViewpager = (ViewPager) findViewById(R.id.vPager);
    expressionContainer = (LinearLayout) findViewById(R.id.ll_face_container);
    btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container);
    locationImgview = (ImageView) findViewById(R.id.btn_location);
    iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal);
    iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked);
    loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more);
    iv_emoticons_normal.setVisibility(View.VISIBLE);
    iv_emoticons_checked.setVisibility(View.INVISIBLE);
    more = findViewById(R.id.more);

    // ?,
    micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01),
            getResources().getDrawable(R.drawable.record_animate_02),
            getResources().getDrawable(R.drawable.record_animate_03),
            getResources().getDrawable(R.drawable.record_animate_04),
            getResources().getDrawable(R.drawable.record_animate_05),
            getResources().getDrawable(R.drawable.record_animate_06),
            getResources().getDrawable(R.drawable.record_animate_07),
            getResources().getDrawable(R.drawable.record_animate_08),
            getResources().getDrawable(R.drawable.record_animate_09),
            getResources().getDrawable(R.drawable.record_animate_10),
            getResources().getDrawable(R.drawable.record_animate_11),
            getResources().getDrawable(R.drawable.record_animate_12),
            getResources().getDrawable(R.drawable.record_animate_13),
            getResources().getDrawable(R.drawable.record_animate_14), };
    // list
    reslist = getExpressionRes(35);
    // ?viewpager
    List<View> views = new ArrayList<View>();
    View gv1 = getGridChildView(1);
    View gv2 = getGridChildView(2);
    views.add(gv1);
    views.add(gv2);
    expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));

    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());

    // ?
    mEditTextContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                buttonSetModeVoice.setVisibility(View.GONE);
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) {
                    buttonSetModeVoice.setVisibility(View.VISIBLE);
                    buttonSend.setVisibility(View.GONE);
                }

            }
        }

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

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

}

From source file:com.hyphenate.chatuidemo.ui.SettingsFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false))
        return;//from  w  ww  . ja va  2 s .com
    rl_switch_notification = (RelativeLayout) getView().findViewById(R.id.rl_switch_notification);
    rl_switch_sound = (RelativeLayout) getView().findViewById(R.id.rl_switch_sound);
    rl_switch_vibrate = (RelativeLayout) getView().findViewById(R.id.rl_switch_vibrate);
    rl_switch_speaker = (RelativeLayout) getView().findViewById(R.id.rl_switch_speaker);
    rl_switch_chatroom_leave = (RelativeLayout) getView().findViewById(R.id.rl_switch_chatroom_owner_leave);
    rl_switch_delete_msg_when_exit_group = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_delete_msg_when_exit_group);
    rl_switch_auto_accept_group_invitation = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_auto_accept_group_invitation);
    rl_switch_adaptive_video_encode = (RelativeLayout) getView()
            .findViewById(R.id.rl_switch_adaptive_video_encode);
    rl_custom_appkey = (RelativeLayout) getView().findViewById(R.id.rl_custom_appkey);
    rl_custom_server = (RelativeLayout) getView().findViewById(R.id.rl_custom_server);
    rl_switch_offline_call_push = (RelativeLayout) getView().findViewById(R.id.rl_switch_offline_call_push);

    notifySwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_notification);
    soundSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_sound);
    vibrateSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_vibrate);
    speakerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_speaker);
    ownerLeaveSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_owner_leave);
    switch_delete_msg_when_exit_group = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_delete_msg_when_exit_group);
    switch_auto_accept_group_invitation = (EaseSwitchButton) getView()
            .findViewById(R.id.switch_auto_accept_group_invitation);
    switch_adaptive_video_encode = (EaseSwitchButton) getView().findViewById(R.id.switch_adaptive_video_encode);
    switch_offline_call_push = (EaseSwitchButton) getView().findViewById(R.id.switch_offline_call_push);
    LinearLayout llChange = (LinearLayout) getView().findViewById(R.id.ll_change);
    logoutBtn = (Button) getView().findViewById(R.id.btn_logout);
    if (!TextUtils.isEmpty(EMClient.getInstance().getCurrentUser())) {
        logoutBtn.setText(
                getString(R.string.button_logout) + "(" + EMClient.getInstance().getCurrentUser() + ")");
    }
    customServerSwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_custom_server);
    customAppkeySwitch = (EaseSwitchButton) getView().findViewById(R.id.switch_custom_appkey);

    textview1 = (TextView) getView().findViewById(R.id.textview1);
    textview2 = (TextView) getView().findViewById(R.id.textview2);

    blacklistContainer = (LinearLayout) getView().findViewById(R.id.ll_black_list);
    userProfileContainer = (LinearLayout) getView().findViewById(R.id.ll_user_profile);
    llDiagnose = (LinearLayout) getView().findViewById(R.id.ll_diagnose);
    pushNick = (LinearLayout) getView().findViewById(R.id.ll_set_push_nick);
    edit_custom_appkey = (EditText) getView().findViewById(R.id.edit_custom_appkey);

    settingsModel = DemoHelper.getInstance().getModel();
    chatOptions = EMClient.getInstance().getOptions();

    blacklistContainer.setOnClickListener(this);
    userProfileContainer.setOnClickListener(this);
    rl_switch_notification.setOnClickListener(this);
    rl_switch_sound.setOnClickListener(this);
    rl_switch_vibrate.setOnClickListener(this);
    rl_switch_speaker.setOnClickListener(this);
    customAppkeySwitch.setOnClickListener(this);
    customServerSwitch.setOnClickListener(this);
    rl_custom_server.setOnClickListener(this);
    logoutBtn.setOnClickListener(this);
    llDiagnose.setOnClickListener(this);
    pushNick.setOnClickListener(this);
    rl_switch_chatroom_leave.setOnClickListener(this);
    rl_switch_delete_msg_when_exit_group.setOnClickListener(this);
    rl_switch_auto_accept_group_invitation.setOnClickListener(this);
    rl_switch_adaptive_video_encode.setOnClickListener(this);
    rl_switch_offline_call_push.setOnClickListener(this);
    llChange.setOnClickListener(this);

    // the vibrate and sound notification are allowed or not?
    if (settingsModel.getSettingMsgNotification()) {
        notifySwitch.openSwitch();
    } else {
        notifySwitch.closeSwitch();
    }

    // sound notification is switched on or not?
    if (settingsModel.getSettingMsgSound()) {
        soundSwitch.openSwitch();
    } else {
        soundSwitch.closeSwitch();
    }

    // vibrate notification is switched on or not?
    if (settingsModel.getSettingMsgVibrate()) {
        vibrateSwitch.openSwitch();
    } else {
        vibrateSwitch.closeSwitch();
    }

    // the speaker is switched on or not?
    if (settingsModel.getSettingMsgSpeaker()) {
        speakerSwitch.openSwitch();
    } else {
        speakerSwitch.closeSwitch();
    }

    // if allow owner leave
    if (settingsModel.isChatroomOwnerLeaveAllowed()) {
        ownerLeaveSwitch.openSwitch();
    } else {
        ownerLeaveSwitch.closeSwitch();
    }

    // delete messages when exit group?
    if (settingsModel.isDeleteMessagesAsExitGroup()) {
        switch_delete_msg_when_exit_group.openSwitch();
    } else {
        switch_delete_msg_when_exit_group.closeSwitch();
    }

    if (settingsModel.isAutoAcceptGroupInvitation()) {
        switch_auto_accept_group_invitation.openSwitch();
    } else {
        switch_auto_accept_group_invitation.closeSwitch();
    }

    if (settingsModel.isAdaptiveVideoEncode()) {
        switch_adaptive_video_encode.openSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(true);
    } else {
        switch_adaptive_video_encode.closeSwitch();
        EMClient.getInstance().callManager().getVideoCallHelper().setAdaptiveVideoFlag(false);
    }

    if (settingsModel.isCustomServerEnable()) {
        customServerSwitch.openSwitch();
    } else {
        customServerSwitch.closeSwitch();
    }
    if (settingsModel.isPushCall()) {
        switch_offline_call_push.openSwitch();
        EMClient.getInstance().callManager().getCallOptions().setIsSendPushIfOffline(true);
    } else {
        switch_offline_call_push.closeSwitch();
        EMClient.getInstance().callManager().getCallOptions().setIsSendPushIfOffline(false);
    }

    if (settingsModel.isCustomAppkeyEnabled()) {
        customAppkeySwitch.openSwitch();
    } else {
        customAppkeySwitch.closeSwitch();
    }
    edit_custom_appkey.setEnabled(settingsModel.isCustomAppkeyEnabled());

    edit_custom_appkey.setText(settingsModel.getCutomAppkey());
    edit_custom_appkey.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            PreferenceManager.getInstance().setCustomAppkey(s.toString());
        }
    });
}

From source file:com.fanxin.app.fx.ChatActivity.java

/**
 * initView/* w ww . j a  va2s  .c  o m*/
 */
protected void initView() {
    recordingContainer = findViewById(R.id.recording_container);
    micImage = (ImageView) findViewById(R.id.mic_image);
    recordingHint = (TextView) findViewById(R.id.recording_hint);
    listView = (ListView) findViewById(R.id.list);
    mEditTextContent = (PasteEditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    edittext_layout = (RelativeLayout) findViewById(R.id.edittext_layout);
    buttonSetModeVoice = findViewById(R.id.btn_set_mode_voice);
    buttonSend = findViewById(R.id.btn_send);
    buttonPressToSpeak = findViewById(R.id.btn_press_to_speak);
    expressionViewpager = (ViewPager) findViewById(R.id.vPager);
    emojiIconContainer = (LinearLayout) findViewById(R.id.ll_face_container);
    btnContainer = (LinearLayout) findViewById(R.id.ll_btn_container);
    iv_emoticons_normal = (ImageView) findViewById(R.id.iv_emoticons_normal);
    iv_emoticons_checked = (ImageView) findViewById(R.id.iv_emoticons_checked);
    loadmorePB = (ProgressBar) findViewById(R.id.pb_load_more);
    btnMore = (Button) findViewById(R.id.btn_more);
    iv_emoticons_normal.setVisibility(View.VISIBLE);
    iv_emoticons_checked.setVisibility(View.INVISIBLE);
    more = findViewById(R.id.more);
    edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);

    // ?,
    micImages = new Drawable[] { getResources().getDrawable(R.drawable.record_animate_01),
            getResources().getDrawable(R.drawable.record_animate_02),
            getResources().getDrawable(R.drawable.record_animate_03),
            getResources().getDrawable(R.drawable.record_animate_04),
            getResources().getDrawable(R.drawable.record_animate_05),
            getResources().getDrawable(R.drawable.record_animate_06),
            getResources().getDrawable(R.drawable.record_animate_07),
            getResources().getDrawable(R.drawable.record_animate_08),
            getResources().getDrawable(R.drawable.record_animate_09),
            getResources().getDrawable(R.drawable.record_animate_10),
            getResources().getDrawable(R.drawable.record_animate_11),
            getResources().getDrawable(R.drawable.record_animate_12),
            getResources().getDrawable(R.drawable.record_animate_13),
            getResources().getDrawable(R.drawable.record_animate_14), };

    // list
    reslist = getExpressionRes(35);
    // ?viewpager
    List<View> views = new ArrayList<View>();
    View gv1 = getGridChildView(1);
    View gv2 = getGridChildView(2);
    views.add(gv1);
    views.add(gv2);
    expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));
    edittext_layout.requestFocus();
    mEditTextContent.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            } else {
                edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_normal);
            }

        }
    });
    mEditTextContent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            edittext_layout.setBackgroundResource(R.drawable.input_bar_bg_active);
            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            emojiIconContainer.setVisibility(View.GONE);
            btnContainer.setVisibility(View.GONE);
        }
    });
    // ?
    mEditTextContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                btnMore.setVisibility(View.GONE);
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                btnMore.setVisibility(View.VISIBLE);
                buttonSend.setVisibility(View.GONE);
            }
        }

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

        @Override
        public void afterTextChanged(Editable s) {

        }
    });

    adapter = new MessageAdapter(this);
    // ?
    listView.setAdapter(adapter);

}

From source file:com.github.michalbednarski.intentslab.editor.IntentGeneralFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.intent_editor_general, container, false);

    // Prepare form
    mActionText = (AutoCompleteTextView) v.findViewById(R.id.action);
    mActionsSpinner = (Spinner) v.findViewById(R.id.action_spinner);
    mDataText = (AutoCompleteTextView) v.findViewById(R.id.data);
    mDataTextWrapper = v.findViewById(R.id.data_wrapper);
    mDataTextHeader = v.findViewById(R.id.data_header);
    mDataTypeHeader = v.findViewById(R.id.data_type_header);
    mDataTypeText = (TextView) v.findViewById(R.id.data_type);
    mDataTypeSpinner = (Spinner) v.findViewById(R.id.data_type_spinner);
    mDataTypeSpinnerWrapper = v.findViewById(R.id.data_type_spinner_wrapper);
    mDataTypeSlash = v.findViewById(R.id.data_type_slash);
    mDataSubtypeText = (TextView) v.findViewById(R.id.data_type_after_slash);
    mComponentText = (TextView) v.findViewById(R.id.component);

    mComponentTypeSpinner = (Spinner) v.findViewById(R.id.componenttype);
    mComponentTypeSpinner.setAdapter(new ArrayAdapter<String>(getActivity(),
            android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.componenttypes)));

    mMethodSpinner = (Spinner) v.findViewById(R.id.method);

    mCategoriesContainer = (ViewGroup) v.findViewById(R.id.categories);
    mAddCategoryButton = (Button) v.findViewById(R.id.category_add);
    mCategoriesHeader = v.findViewById(R.id.categories_header);
    mResponseCodeTextView = (TextView) v.findViewById(R.id.response_code);
    mPackageNameText = (AutoCompleteTextView) v.findViewById(R.id.package_name);

    mResultCodeWrapper = v.findViewById(R.id.result_intent_wrapper);
    mComponentTypeAndMethodSpinners = v.findViewById(R.id.component_and_method_spinners);
    mComponentHeader = v.findViewById(R.id.component_header);
    mComponentFieldWithButtons = v.findViewById(R.id.component_field_with_buttons);
    mPackageNameHeader = v.findViewById(R.id.package_name_header);
    mIntentTrackerSummary = (TextView) v.findViewById(R.id.intent_tracker_summary);
    mIntentTrackerSummary.setMovementMethod(LinkMovementMethod.getInstance());

    // Apparently using android:scrollHorizontally="true" does not work.
    // http://stackoverflow.com/questions/9011944/android-ice-cream-sandwich-edittext-disabling-spell-check-and-word-wrap
    mComponentText.setHorizontallyScrolling(true);

    // Bind button actions (android:onClick="" applies to hosting activity)
    mAddCategoryButton.setOnClickListener(new OnClickListener() {
        @Override/*w w w  . java2s  . c o m*/
        public void onClick(View v) {
            addCategoryTextField("");
        }
    });
    v.findViewById(R.id.component_pick).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pickComponent();
        }
    });
    v.findViewById(R.id.component_pick).setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            findComponent();
            return true;
        }
    });
    v.findViewById(R.id.component_clear).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mComponentText.setText("");
        }
    });
    v.findViewById(R.id.data_query_button).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            getIntentEditor().updateIntent();
            startActivity(
                    new Intent(getActivity(), AdvancedQueryActivity.class).setData(mEditedIntent.getData()));
        }
    });
    v.findViewById(R.id.data_query_button)
            .setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
                @Override
                public void onCreateContextMenu(ContextMenu menu, View v,
                        ContextMenu.ContextMenuInfo menuInfo) {
                    getIntentEditor().updateIntent();
                    final Uri uri = mEditedIntent.getData();
                    if (uri != null) {
                        final String scheme = uri.getScheme();
                        final String authority = uri.getAuthority();
                        if ("content".equals(scheme) && authority != null) {
                            menu.add("Wrap").setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                                @Override
                                public boolean onMenuItemClick(MenuItem item) {
                                    mDataText.setText("content://" + ((mEditedIntent.getFlags()
                                            & (Intent.FLAG_GRANT_READ_URI_PERMISSION
                                                    | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0
                                                            ? ProxyProviderForGrantUriPermission.AUTHORITY
                                                            : ProxyProvider.AUTHORITY)
                                            + "/" + authority + uri.getPath());
                                    return true;
                                }
                            });
                        }
                    }
                }
            });

    // Set up autocomplete
    mUriAutocompleteAdapter = new UriAutocompleteAdapter(getActivity());
    mDataText.setAdapter(mUriAutocompleteAdapter);
    mPackageNameText.setAdapter(new PackageNameAutocompleteAdapter(getActivity()));

    // Get edited intent for form filling
    mEditedIntent = getEditedIntent();

    // Component field, affects options menu
    if (mEditedIntent.getComponent() != null) {
        mComponentText.setText(mEditedIntent.getComponent().flattenToShortString());
    }
    mComponentText.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            updateIntentComponent();
        }

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

        @Override
        public void afterTextChanged(Editable s) {
        }
    });

    // Fill the form
    setupActionSpinnerOrField();
    updateNonActionIntentFilter(true);
    mDataText.setText(mEditedIntent.getDataString());
    mPackageNameText.setText(mEditedIntent.getPackage());

    showOrHideFieldsForResultIntent();
    showOrHideAdvancedFields();
    if (getComponentType() == IntentEditorConstants.RESULT) {
        mResponseCodeTextView.setText(String.valueOf(getIntentEditor().getMethodId()));
        mResponseCodeTextView.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                try {
                    getIntentEditor().setMethodId(Integer.parseInt(s.toString()));
                    mResponseCodeTextView.setError(null);
                } catch (NumberFormatException e) {
                    mResponseCodeTextView.setError(getIntentEditor().getText(R.string.value_parse_error));
                }
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });
    } else {
        initComponentAndMethodSpinners();
    }

    setupActionAutocomplete();

    // Prepare intent tracker
    {
        IntentTracker tracker = getIntentEditor().getIntentTracker();
        if (tracker != null) {
            tracker.setUpdateListener(this, true);
        } else {
            onNoTracker();
        }
    }

    return v;
}