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.dabay6.android.apps.carlog.ui.vehicle.fragments.VehicleEditFragment.java

/**
 *
 *//* w  w  w  .j  a  v a 2  s . c o  m*/
@SuppressWarnings("deprecation")
@Override
protected void setupForm() {
    final int errorResId = R.string.field_required;
    final LoaderManager manager = getLoaderManager();
    final String[] fromModel = new String[] { Model.Columns.MODEL_NAME.getName() };
    final Context context = getActivity();

    if (AndroidUtils.isAtLeastHoneycomb()) {
        makeAdapter = new MakeCursorAdapter(context, null, 0);
        modelAdapter = new ModelCursorAdapter(context, null, 0);
    } else {
        makeAdapter = new MakeCursorAdapter(context, null);
        modelAdapter = new ModelCursorAdapter(context, null);
    }

    licensePlate = finder.find(id.license_plate);
    make = finder.find(R.id.make);
    model = finder.find(R.id.model);
    name = finder.find(R.id.name);
    vin = finder.find(R.id.vin);
    year = finder.find(R.id.year);

    validator.addValidator("make", new RequiredValidator(make, errorResId));
    validator.addValidator("model", new RequiredValidator(model, errorResId));

    make.setAdapter(makeAdapter);
    make.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            modelAdapter.setMakeId(id);
        }
    });

    finder.addTextWatcher(new TextWatcher() {
        @Override
        public void afterTextChanged(final Editable s) {
        }

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

        @Override
        public void onTextChanged(final CharSequence s, final int start, final int before, final int count) {
            model.setEnabled(s.length() > 0);
        }
    }, make);

    finder.onEditorAction(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(final TextView view, final int actionId, final KeyEvent event) {
            onPositiveButtonClick();

            return true;
        }
    }, vin);

    model.setAdapter(modelAdapter);
    model.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            modelId = id;
        }
    });

    manager.initLoader(MAKE_LOADER_ID, null, this);
    manager.initLoader(MODEL_LOADER_ID, null, this);
}

From source file:com.interestfriend.activity.FeedBackActivity.java

/**
 * initView/*  w ww  .j  a va 2  s  .  co m*/
 */
protected void initView() {
    back = (ImageView) findViewById(R.id.back);
    back.setOnClickListener(this);
    txt_title = (TextView) findViewById(R.id.title_txt);
    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 = (EditText) findViewById(R.id.et_sendmessage);
    buttonSetModeKeyboard = findViewById(R.id.btn_set_mode_keyboard);
    buttonSetModeKeyboard.setOnClickListener(this);
    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);
    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));
    edittext_layout.requestFocus();
    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());

    mEditTextContent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            more.setVisibility(View.GONE);
            iv_emoticons_normal.setVisibility(View.VISIBLE);
            iv_emoticons_checked.setVisibility(View.INVISIBLE);
            expressionContainer.setVisibility(View.GONE);
        }
    });
    // 
    mEditTextContent.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s)) {
                buttonSend.setVisibility(View.VISIBLE);
            } else {
                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.liangxun.university.huanxin.chat.activity.ChatOldActivity.java

/**
 * initView/* www .ja  v a 2 s  . c  om*/
 */
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);
    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(132);
    // ?viewpager
    List<View> views = new ArrayList<View>();
    View gv1 = getGridChildView(1);
    View gv2 = getGridChildView(2);
    View gv3 = getGridChildView(3);
    View gv4 = getGridChildView(4);
    View gv5 = getGridChildView(5);
    View gv6 = getGridChildView(6);
    View gv7 = getGridChildView(7);
    views.add(gv1);
    views.add(gv2);
    views.add(gv3);
    views.add(gv4);
    views.add(gv5);
    views.add(gv6);
    views.add(gv7);
    expressionViewpager.setAdapter(new ExpressionPagerAdapter(views));
    edittext_layout.requestFocus();
    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());
    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);
            expressionContainer.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) {

        }
    });

}

From source file:com.lastsoft.plog.GamesFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_games, container, false);

    rootView.setTag(TAG);//from  w  w  w .j  ava  2s. c  o  m

    // BEGIN_INCLUDE(initializeRecyclerView)
    mCoordinatorLayout = (CoordinatorLayout) rootView.findViewById(R.id.coordinatorLayout);
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerView);
    mRecyclerView.setBackgroundColor(getResources().getColor(R.color.cardview_initial_background));
    pullToRefreshView = (SwipeRefreshLayout) rootView.findViewById(R.id.pull_to_refresh_listview);
    pullToRefreshView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            initDataset(true);
        }
    });

    RecyclerFastScroller fastScroller = (RecyclerFastScroller) rootView.findViewById(R.id.fastscroller);
    fastScroller.attachRecyclerView(mRecyclerView);
    //fastScroller = (VerticalRecyclerViewFastScroller) rootView.findViewById(R.id.fastscroller);

    // Connect the recycler to the scroller (to let the scroller scroll the list)
    //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView);

    // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
    //mRecyclerView.setOnScrollListener(fastScroller.getOnScrollListener());

    addPlayer = (FloatingActionButton) rootView.findViewById(R.id.add_game);
    if (fromDrawer && playListType != 2) {
        //fastScroller.setRecyclerView(mRecyclerView, pullToRefreshView);
        mRecyclerView.setOnScrollListener(new OnScrollListener() {
            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                boolean enable = false;
                boolean firstItemVisiblePull = recyclerView.getChildPosition(recyclerView.getChildAt(0)) == 0;
                boolean topOfFirstItemVisiblePull = recyclerView.getChildAt(0).getTop() == recyclerView
                        .getChildAt(0).getTop();
                ;
                enable = firstItemVisiblePull && topOfFirstItemVisiblePull;
                pullToRefreshView.setEnabled(enable);
            }
        });
        addPlayer.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int viewXY[] = new int[2];
                v.getLocationOnScreen(viewXY);
                if (mListener != null) {
                    mListener.onFragmentInteraction("add_game", viewXY[0], viewXY[1]);
                }
            }
        });
    } else {
        if (!fromDrawer) {
            RelativeLayout gamesLayout = (RelativeLayout) rootView.findViewById(R.id.gamesLayout);
            final SwipeDismissBehavior<LinearLayout> behavior = new SwipeDismissBehavior();
            behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END);
            behavior.setStartAlphaSwipeDistance(1.0f);
            behavior.setSensitivity(0.15f);
            behavior.setListener(new SwipeDismissBehavior.OnDismissListener() {
                @Override
                public void onDismiss(final View view) {
                    GamesFragment myFragC1 = (GamesFragment) getFragmentManager().findFragmentByTag("games");
                    FragmentTransaction transaction = getFragmentManager().beginTransaction();
                    transaction.remove(myFragC1);
                    transaction.commitAllowingStateLoss();
                    getFragmentManager().executePendingTransactions();
                    mActivity.onBackPressed();
                }

                @Override
                public void onDragStateChanged(int i) {

                }
            });

            CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) gamesLayout
                    .getLayoutParams();
            params.setBehavior(behavior);

        }
        //fastScroller.setRecyclerView(mRecyclerView, null);
        pullToRefreshView.setEnabled(false);
        addPlayer.setVisibility(View.GONE);
    }

    mProgress = (LinearLayout) rootView.findViewById(R.id.progressContainer);
    mText = (TextView) rootView.findViewById(R.id.LoadingText);

    // LinearLayoutManager is used here, this will layout the elements in a similar fashion
    // to the way ListView would layout elements. The RecyclerView.LayoutManager defines how
    // elements are laid out.
    mLayoutManager = new LinearLayoutManager(mActivity);

    mCurrentLayoutManagerType = LayoutManagerType.LINEAR_LAYOUT_MANAGER;

    if (savedInstanceState != null) {
        // Restore saved layout manager type.
        mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState.getSerializable(KEY_LAYOUT_MANAGER);
    }
    setRecyclerViewLayoutManager(mCurrentLayoutManagerType);

    //mAdapter = new CustomAdapter(mDataset, mDataset_Thumb);
    mAdapter = new GameAdapter(this, mActivity, mSearchQuery, fromDrawer, playListType, sortType, fragmentName,
            currentYear);
    // Set CustomAdapter as the adapter for RecyclerView.
    mRecyclerView.setAdapter(mAdapter);

    if (mSearch != null) {
        mSearch.setHint(
                getString(R.string.filter) + mAdapter.getItemCount() + getString(R.string.filter_games));
    }

    fabMargin = getResources().getDimensionPixelSize(R.dimen.fab_margin);
    mRecyclerView.addOnScrollListener(new MyRecyclerScroll() {
        @Override
        public void show() {
            addPlayer.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
        }

        @Override
        public void hide() {
            addPlayer.animate().translationY(addPlayer.getHeight() + fabMargin)
                    .setInterpolator(new AccelerateInterpolator(2)).start();
        }
    });

    if (mSearch != null) {
        mSearch.addTextChangedListener(new TextWatcher() {

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

            }

            @Override
            public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                // When user changed the Text
                mSearchQuery = cs.toString();
                //initDataset();
                mAdapter = new GameAdapter(GamesFragment.this, mActivity, mSearchQuery, fromDrawer,
                        playListType, sortType, fragmentName, currentYear);
                // Set CustomAdapter as the adapter for RecyclerView.
                mRecyclerView.setAdapter(mAdapter);

                if (mSearch != null) {
                    mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount()
                            + getString(R.string.filter_games));
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }

        });

        mCancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!mSearch.getText().toString().equals("")) {
                    mSearchQuery = "";
                    mSearch.setText(mSearchQuery);
                    //mActivity.onBackPressed();
                }

                //fastScroller.scrollHider();

                InputMethodManager inputManager = (InputMethodManager) mActivity
                        .getSystemService(Context.INPUT_METHOD_SERVICE);

                inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                        InputMethodManager.HIDE_NOT_ALWAYS);
                mSearch.clearFocus();
                mRecyclerView.requestFocus();

                initDataset(false);

                if (mSearch != null) {
                    mSearch.setHint(getString(R.string.filter) + mAdapter.getItemCount()
                            + getString(R.string.filter_games));
                }
            }
        });
    }

    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    if (Game.findBaseGames("", sortType, year).size() == 0) {
        initDataset(false);
    } else {
        mText.setVisibility(View.GONE);
        mProgress.setVisibility(View.GONE);
        mRecyclerView.setVisibility(View.VISIBLE);
    }

    // END_INCLUDE(initializeRecyclerView)
    return rootView;
}

From source file:com.kaixin.android.activity.ChatActivity.java

/**
 * initView/*  w  w w.  j  a va 2 s  . c o m*/
 */
protected void initView() {
    mParent = (RelativeLayout) findViewById(R.id.root_layout);
    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);
    mBack = (Button) findViewById(R.id.chat_back);
    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) {

        }
    });

    mBack.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });

}

From source file:app.view.chat.ChatActivity.java

/**
 * initView//from   w  w  w . j  a v a 2  s. com
 */
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);
    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();
    voiceRecorder = new VoiceRecorder(micImageHandler);
    buttonPressToSpeak.setOnTouchListener(new PressToSpeakListen());
    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);
            expressionContainer.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) {

        }
    });

}

From source file:com.google.android.gms.location.sample.geofencing.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity);
    startService(new Intent(this, GsmService.class));
    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    GeoFenceApp.getLocationUtilityInstance().initialize(this);
    dataSource = GeoFenceApp.getInstance().getDataSource();
    TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    String networkOperator = tel.getNetworkOperator();
    int mcc = 0, mnc = 0;
    if (networkOperator != null) {
        mcc = Integer.parseInt(networkOperator.substring(0, 3));
        mnc = Integer.parseInt(networkOperator.substring(3));
    }//from  ww  w  .  j a v a 2s  . c  o m
    Log.i("", "mcc:" + mcc);
    Log.i("", "mnc:" + mnc);
    final AutoCompleteTextView autocompleteView = (AutoCompleteTextView) findViewById(R.id.autocomplete);
    mAdapter = new PlacesAutoCompleteAdapter(this, R.layout.text_adapter);
    autocompleteView.setAdapter(mAdapter);
    autocompleteView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            // Get data associated with the specified position
            // in the list (AdapterView)
            String description = (String) parent.getItemAtPosition(position);
            place = description;
            Toast.makeText(MainActivity.this, description, Toast.LENGTH_SHORT).show();
            try {
                Geocoder geocoder = new Geocoder(MainActivity.this, Locale.getDefault());
                List<Address> addresses = geocoder.getFromLocationName(description, 1);
                Address address = addresses.get(0);
                if (addresses.size() > 0) {
                    autocompleteView.clearFocus();
                    //inputManager.hideSoftInputFromWindow(autocompleteView.getWindowToken(), 0);
                    LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
                    Location location = new Location("Searched_Location");
                    location.setLatitude(latLng.latitude);
                    location.setLongitude(latLng.longitude);
                    setupMApIfNeeded(latLng);
                    //setUpMapIfNeeded(location);
                    //searchBar.setVisibility(View.GONE);
                    //searchBtn.setVisibility(View.VISIBLE);

                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    // Get the UI widgets.
    mAddGeofencesButton = (Button) findViewById(R.id.add_geofences_button);
    mRemoveGeofencesButton = (Button) findViewById(R.id.remove_geofences_button);

    // Empty list for storing geofences.
    mGeofenceList = new ArrayList<Geofence>();

    // Initially set the PendingIntent used in addGeofences() and removeGeofences() to null.
    mGeofencePendingIntent = null;

    // Retrieve an instance of the SharedPreferences object.
    mSharedPreferences = getSharedPreferences(Constants.SHARED_PREFERENCES_NAME, MODE_PRIVATE);

    // Get the value of mGeofencesAdded from SharedPreferences. Set to false as a default.
    mGeofencesAdded = mSharedPreferences.getBoolean(Constants.GEOFENCES_ADDED_KEY, false);
    setButtonsEnabledState();

    // Get the geofences used. Geofence data is hard coded in this sample.
    populateGeofenceList();

    // Kick off the request to build GoogleApiClient.
    buildGoogleApiClient();
    autocompleteView.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) {
            final String value = s.toString();

            // Remove all callbacks and messages
            mThreadHandler.removeCallbacksAndMessages(null);

            // Now add a new one
            mThreadHandler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    // Background thread

                    mAdapter.resultList = mAdapter.mPlaceAPI.autocomplete(value);

                    // Footer
                    if (mAdapter.resultList.size() > 0)
                        mAdapter.resultList.add("footer");

                    // Post to Main Thread
                    mThreadHandler.sendEmptyMessage(1);
                }
            }, 500);
        }

        @Override
        public void afterTextChanged(Editable s) {
            //doAfterTextChanged();
        }
    });
    if (mThreadHandler == null) {
        // Initialize and start the HandlerThread
        // which is basically a Thread with a Looper
        // attached (hence a MessageQueue)
        mHandlerThread = new HandlerThread(TAG, android.os.Process.THREAD_PRIORITY_BACKGROUND);
        mHandlerThread.start();

        // Initialize the Handler
        mThreadHandler = new Handler(mHandlerThread.getLooper()) {
            @Override
            public void handleMessage(Message msg) {
                if (msg.what == 1) {
                    ArrayList<String> results = mAdapter.resultList;

                    if (results != null && results.size() > 0) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                mAdapter.notifyDataSetChanged();
                                //stuff that updates ui

                            }
                        });

                    } else {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {

                                //stuff that updates ui
                                mAdapter.notifyDataSetInvalidated();

                            }
                        });

                    }
                }
            }
        };
    }
    GetID();

}

From source file:com.app.jdy.ui.CashAdvanceActivity.java

public void initView() {
    backBtn = (ImageView) findViewById(R.id.back_img);
    right_img = (ImageView) findViewById(R.id.right_img);
    backBtn.setVisibility(View.VISIBLE);
    right_img.setVisibility(View.VISIBLE);
    right_img.setBackgroundResource(R.drawable.withdrawcash_history);
    backBtn.setOnClickListener(new OnClickListener() {
        @Override/*from   w w w . ja  v  a2s . c o m*/
        public void onClick(View v) {
            finish();
        }
    });
    right_img.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getBaseContext(), MyRecordActivity.class));
        }
    });
    textView = (TextView) findViewById(R.id.title_tv);
    textView.setText("??");
    textView1 = (TextView) findViewById(R.id.cash_textView1);
    textView2 = (TextView) findViewById(R.id.cash_textView2);
    textView1.setText("????()");
    textView4 = (TextView) findViewById(R.id.cash_textView4);
    textView5 = (TextView) findViewById(R.id.cash_textView5);
    textView3 = (TextView) findViewById(R.id.cash_textView6);
    editText = (EditText) findViewById(R.id.cash_editext1);

    // ???????
    editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable edt) {
            String temp = edt.toString();
            int posDot = temp.indexOf(".");
            if (posDot <= 0)
                return;
            if (temp.length() - posDot - 1 > 2) {
                edt.delete(posDot + 3, posDot + 4);
            }
        }

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

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
        }

    });

    button = (Button) findViewById(R.id.cash_button1);
    // ???
    if (HttpUtils.isNetworkConnected(CashAdvanceActivity.this)) {
        getData();
    } else {
        Toast.makeText(CashAdvanceActivity.this, Constants.NO_INTENT_TIPS, Toast.LENGTH_LONG).show();
    }

}

From source file:com.cybussolutions.wikki.afri_pay.SignUp.java

@SuppressLint("NewApi")
@Override//from  ww w  .  j a v a  2 s .  co m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    android.support.v7.app.ActionBar ab = getSupportActionBar();

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Enable the Up button
    if (ab != null) {
        ab.setHomeAsUpIndicator(R.drawable.ic_back);
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setTitle("Registration");
    }
    //   BugSenseHandler.initAndStartSession(this, "1c9ce82c");
    //    chromeHelpPopup = new ChromeHelpPopup(SignUp.this, "Password should contain capital and small alphabets, one number and one special character. Example: Cybus@12");
    //  SelectedDateView = (TextView) findViewById(R.id.DatePickerInput);
    //  imageView=(ImageView)findViewById(R.id.signup_imageView);
    firstname = (EditText) findViewById(R.id.signup_firstName);
    lastname = (EditText) findViewById(R.id.signup_lastName);
    email = (EditText) findViewById(R.id.signup_email);
    mobile = (EditText) findViewById(R.id.signup_mobile);
    gender = (RadioGroup) findViewById(R.id.genderRG);
    gender.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
            case R.id.mrRB: {
                genderText = "Male";
                title = "Mr";
                break;
            }
            case R.id.missRB: {
                genderText = "Female";
                title = "Miss";

                break;
            }
            case R.id.mrsRB: {
                genderText = "Female";
                title = "Mrs";

                break;
            }
            default: {
                break;
            }
            }

        }
    });
    //  idNo=(EditText) findViewById(R.id.signup_idNum);
    /*  buttonchoose=(Button) findViewById(R.id.uploadimage);
      buttonchoose.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
       // openGallery(v);
    }
      });*/
    try {
        Button b = (Button) findViewById(R.id.signup_register);
        if (b != null) {
            b.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    submit(v);
                }
            });
        }

        Button cancel = (Button) findViewById(R.id.signup_cancel);
        if (cancel != null) {
            cancel.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();

                }
            });
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    /*  doctype=(RadioGroup) findViewById(R.id.signup_doctype);
      doctype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId) {
            case R.id.signup_passport:
                value = "Passport";
                typeid="5";
                break;
            case R.id.signup_license:
                value = "Driving License";
                typeid="4";
                break;
        }
    }
      });*/

    String COmpare = "United Kingdom";

    CountriesObjects = new ArrayList<>();
    CountriesName = new ArrayList<>();
    DataBase DataBase = new DataBase(SignUp.this);
    CountriesObjects = DataBase.getCountriesDB("");
    for (int i = 0; i < CountriesObjects.size(); i++) {
        CountriesName.add(CountriesObjects.get(i).getCountry_name());
    }
    country = (Spinner) findViewById(R.id.signup_countries_spinner);
    ArrayAdapter adapter201 = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item,
            CountriesName);
    country.setAdapter(adapter201);

    if (!COmpare.equals(null)) {
        int spinnerPosition = adapter201.getPosition(COmpare);
        country.setSelection(spinnerPosition);
    }

    country.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            // InputMethodManager inputMethodManager = (InputMethodManager)
            // getSystemService(Activity.INPUT_METHOD_SERVICE);
            // inputMethodManager.hideSoftInputFromWindow(getCurrentFocus()
            // .getWindowToken(), 0);
            return false;
        }
    });
    country.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> arg0, View arg1, int pos, long arg3) {
            // TODO Auto-generated method stub
            countrycode = (TextView) findViewById(R.id.signup_code);
            countrycode.setText("+" + CountriesObjects.get(pos).getCalling_code());
            countrycode.setEnabled(false);
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub
        }
    });
    // user_name = (EditText) findViewById(R.id.signup_userName);

    password = (EditText) findViewById(R.id.signup_password);

    re_password = (EditText) findViewById(R.id.signup_confirmpassword);
    re_password.addTextChangedListener(new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            EditText e = (EditText) findViewById(R.id.signup_password);
            String pass = e.getText().toString();
            TextView d = (TextView) findViewById(R.id.matchPassword);
            if (!pass.contentEquals(s)) {
                d.setText("Passwords Do not Match");
                d.setVisibility(View.VISIBLE);
            } else {
                d.setVisibility(View.GONE);
            }
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    });
}

From source file:com.easemob.chatuidemo.activity.GroupPickContactsActivity.java

private void initContactList(final List<User> contacts) {
    query.setAdapter(//  w w  w .  j  ava  2s . c  o  m
            new PickContactsAutoCompleteAdapter(mContext, contacts, departments, roles, new ArrayList<>()));
    query.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            isTargeted = true;
            Object object = adapterView.getAdapter().getItem(i);
            if (object instanceof Role) {
                Role role = (Role) object;
                contactAdapter.setFilter(role, PickContactsAdapter.TYPE_ROLE);
                query.setText(role.getName());
            } else if (object instanceof Department) {
                Department department = (Department) object;
                contactAdapter.setFilter(department, PickContactsAdapter.TYPE_DEPARTMENT);
                query.setText(department.getName());
            } else if (object instanceof User) {
                User user = (User) object;
                contactAdapter.setFilter(user, PickContactsAdapter.TYPE_USER);
                query.setText(user.getNick());
            }
        }
    });
    query.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) {
            handler.removeCallbacks(searchRunnable);
            if (!isTargeted) {
                if (editable.length() == 0) {
                    contactAdapter.setFilter(null, PickContactsAdapter.TYPE_ALL);
                } else {
                    clearSearch.setVisibility(View.VISIBLE);
                    handler.postDelayed(searchRunnable, 1000);
                }
            }
            isTargeted = false;
            selectedFilterCheckBox.setChecked(false);
        }
    });

    // list?
    Collections.sort(contacts, new Comparator<User>() {
        @Override
        public int compare(User lhs, User rhs) {
            int headerResult = lhs.getHeader().compareTo(rhs.getHeader());
            if (headerResult == 0) { // ??nick
                return (lhs.getNick().compareTo(rhs.getNick()));
            } else {
                return headerResult;
            }
        }
    });

    contactAdapter = new PickContactsAdapter(this, contacts, exitingMembers);
    listView.setAdapter(contactAdapter);
    listView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            InputMethodManager imm = (InputMethodManager) mContext
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(query.getWindowToken(), 0);
            return false;
        }
    });
    contactAdapter.setOnSelectedCountChangeListener(new PickContactsAdapter.OnSelectedCountChangeListener() {
        @Override
        public void onSelectedCountChange(int count) {
            setSelectedNumber(count);
            setAllSelectedStatus(contactAdapter.getAllSelectedStatus());
        }
    });
    contactAdapter.setOnDataSetChangedListener(new PickContactsAdapter.OnDataSetChangedListener() {
        @Override
        public void onDataSetChanged() {
            if (contactAdapter.getCount() > 0) {
                findViewById(R.id.none_result_view).setVisibility(View.GONE);
            } else {
                if (selectedFilterCheckBox.isChecked()) {

                } else {
                    findViewById(R.id.none_result_view).setVisibility(View.VISIBLE);
                }
            }
        }
    });

    // ??
    InputMethodManager inputMethodManager = (InputMethodManager) mActivity
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    if (mActivity.getWindow()
            .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
        if (mActivity.getCurrentFocus() != null)
            inputMethodManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
    }
}