List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.hdu.tx.aschool.ui.fragment.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*w w w . j ava 2 s . c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageView) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? // startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? startActivity(new Intent(getActivity(), RobotsActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:cn.ucai.superwechart.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*from w w w . j a va 2s .c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? startActivity(new Intent(getActivity(), RobotsActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:cn.ucai.fulicenter.fragment.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;/*w w w . jav a2 s . c o m*/ inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<EMUser>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, mContactList); listView.setAdapter(adapter); setListener(); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } registerContactListChangedReceiver(); }
From source file:cn.hbm.superwechat.activity.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mContext = getActivity();/* w w w . ja va2s . c o m*/ updateContactListener();//? //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return; inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(R.id.list); sidebar = (Sidebar) getView().findViewById(R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); contactList = new ArrayList<User>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(R.id.query); query.setHint(R.string.search); clearSearch = (ImageButton) getView().findViewById(R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), R.layout.row_contact, contactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getUsername(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? User user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? startActivity(new Intent(getActivity(), RobotsActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getUsername())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } }
From source file:com.neighbor.ex.tong.ui.activity.MainActivity2Activity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity2); mPlanetTitles = getResources().getStringArray(R.array.menu_array); drawerView = findViewById(R.id.drawer); mTitle = mDrawerTitle = getTitle();/*from www . jav a 2s .c om*/ titleTextView = (TextView) findViewById(R.id.textViewTile); prefs = PreferenceManager.getDefaultSharedPreferences(this); mUserName = (TextView) findViewById(R.id.textViewUserName); mUserNickName = (TextView) findViewById(R.id.textViewNickName); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerBtn = (Button) findViewById(R.id.left); findViewById(R.id.menu0).setOnClickListener(onClickListener); findViewById(R.id.menu1).setOnClickListener(onClickListener); findViewById(R.id.menu2).setOnClickListener(onClickListener); findViewById(R.id.menu3).setOnClickListener(onClickListener); findViewById(R.id.menu4).setOnClickListener(onClickListener); autoCompleteAdapter = new AutoCompleteDbAdapter(MainActivity2Activity.this, null, false); inputCarNo = (AutoCompleteTextView) findViewById(R.id.title); inputCarNo.setAdapter(autoCompleteAdapter); inputCarNo.setThreshold(4); inputCarNo.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { Cursor cursor = (Cursor) adapterView.getItemAtPosition(i); String number = cursor.getString(cursor.getColumnIndexOrThrow("PLATE_NUMBER")); Intent intent = new Intent(MainActivity2Activity.this, SendMsgActivity.class); intent.putExtra("destNo", number); inputCarNo.setText(""); startActivity(intent); } }); inputCarNo.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void afterTextChanged(Editable editable) { if (inputCarNo.getText().toString().trim().length() == 4) { String tem = inputCarNo.getText().toString().substring(inputCarNo.getText().length() - 2, inputCarNo.getText().length()); String condition = "PLATE_NUMBER LIKE '%" + tem + "'"; Cursor query = getContentResolver().query(DataProvider.PLATE_URI, null, condition, null, null); if (query.getCount() == 0 && !isPause) { Toast.makeText(MainActivity2Activity.this, "? .", Toast.LENGTH_SHORT).show(); } } } }); inputCarNo.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { switch (actionId) { case EditorInfo.IME_ACTION_SEARCH: Intent intent = new Intent(MainActivity2Activity.this, CarSearchActivity.class); intent.putExtra("inputCarNo", inputCarNo.getText().toString()); hideKeyboard(); isPause = true; startActivity(intent); break; default: return false; } return false; } }); RequestAllCarNo carNumbers = new RequestAllCarNo(); carNumbers.Action(MainActivity2Activity.this); ImageButton carNo = (ImageButton) findViewById(R.id.search_carNo); carNo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // cameraIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1); // startActivityForResult(cameraIntent, PICK_CAMERA_REQUEST); // inputCarNo.setText(""); Intent cameraIntent = new Intent(MainActivity2Activity.this, OilCamera.class); startActivityForResult(cameraIntent, PICK_CAMERA_REQUEST); } }); ImageButton voiceRec = (ImageButton) findViewById(R.id.search_voice); voiceRec.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { promptSpeechInput(); } }); if (checkPlayServices()) { // Log.d("hts", "checkPlayServices "); _gcm = GoogleCloudMessaging.getInstance(this); // Log.d("hts", "_gcm : " + _gcm); if (TextUtils.isEmpty(_regId)) { registerInBackground(); } } mDrawerBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mDrawerLayout.isDrawerOpen(drawerView)) { mDrawerLayout.closeDrawer(drawerView); hideKeyboard(); } else { hideKeyboard(); mUserName.setText(prefs.getString(CONST.ACCOUNT_LICENSE, "")); mUserNickName.setText(prefs.getString(CONST.ACCOUNT_NAME, "")); mDrawerLayout.openDrawer(drawerView); } } }); if (false == checkGPS()) chkGpsService(); Bundle bundle = getIntent().getExtras(); if (!SharedPreferenceManager.getValue(this, SharedPreferenceManager.positionAgree) .equalsIgnoreCase("true")) { showDialogAree(); } if (null != bundle) { String pushNoit = bundle.getString(Common.PUSH_NOIT, Common.PUSH_NOIT); if (pushNoit != null && !pushNoit.isEmpty()) { selectItem(3); setTitle(getResources().getStringArray(R.array.menu_array)[3]); } } else { selectItem(0); setTitle(getResources().getStringArray(R.array.menu_array)[0]); } }
From source file:com.macleod2486.fragment.Map.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.map, container, false); //Gets the building lists into an arraylist buildingList.clear();//from w ww . j a v a 2 s . c o m buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.intramuralfields))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages))); buildingList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls))); Collections.sort(buildingList, String.CASE_INSENSITIVE_ORDER); completeList.clear(); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.fraternity))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.sorority))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.maincampus))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.pickleresearchcampus))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.parkinggarages))); completeList.addAll(Arrays.asList(getResources().getStringArray(R.array.residencehalls))); Collections.sort(completeList, String.CASE_INSENSITIVE_ORDER); //Only puts the building name for the autocomplete text for (int index = 0; index < buildingList.size(); index++) { buildingList.set(index, buildingList.get(index).substring(0, buildingList.get(index).indexOf(','))); } search = (AutoCompleteTextView) view.findViewById(R.id.mapSearch); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, buildingList); search.setThreshold(1); search.setAdapter(adapter); search.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { final Double lat; final Double lon; final String selection = (String) parent.getItemAtPosition(position); latitude = completeList.get(buildingList.indexOf(selection)); latitude = latitude.substring(latitude.indexOf(",") + 1, latitude.lastIndexOf(",")); longitude = completeList.get(buildingList.indexOf(selection)); longitude = longitude.substring(longitude.lastIndexOf(",") + 1); lat = Double.parseDouble(latitude); lon = Double.parseDouble(longitude); navigate = 0; final MarkerOptions markerOpt = new MarkerOptions(); markerOpt.position(new LatLng(lat, lon)).title(selection); markerOpt.snippet("Touch marker twice to navigate"); UT.clear(); UT.addMarker(markerOpt); UT.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lon), 17)); UT.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { Log.i("Map", "Marker clicked"); navigate++; //If the marker is clicked twice it launches navigation if (navigate == 2) { navigate = 0; String url = "http://maps.google.com/maps?f=d&daddr=" + latitude + "," + longitude + "&dirflg=d"; Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(url)); intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"); startActivity(intent); } return false; } }); imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(search.getWindowToken(), 0); } }); search.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { if (arg0.toString().isEmpty()) { clear.setVisibility(View.INVISIBLE); } } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { Log.i("Map", "Text changed"); clear.setVisibility(View.VISIBLE); } }); clear = (ImageButton) view.findViewById(R.id.clearButton); clear.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { search.setText(""); clear.setVisibility(View.INVISIBLE); } }); //Sets up the map setUpUT(); return view; }
From source file:com.dgsd.android.ShiftTracker.Fragment.EditShiftFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_edit_shift, container, false); mName = (StatefulAutoCompleteTextView) v.findViewById(R.id.name); mNotes = (StatefulEditText) v.findViewById(R.id.notes); mPayRate = (StatefulEditText) v.findViewById(R.id.pay_rate); mUnpaidBreak = (StatefulEditText) v.findViewById(R.id.unpaid_break); mStartDate = (TextView) v.findViewById(R.id.start_date); mEndDate = (TextView) v.findViewById(R.id.end_date); mStartTime = (TextView) v.findViewById(R.id.start_time); mEndTime = (TextView) v.findViewById(R.id.end_time); mSaveAsTemplate = (CheckBox) v.findViewById(R.id.is_template); mReminders = v.findViewById(R.id.reminders); ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getActivity(), R.layout.reminders_spinner_item, mRemindersLabels); adapter.setDropDownViewResource(R.layout.reminders_spinner_dropdown_item); setAdapter(mReminders, adapter);//from w w w . j a va2 s . com if (StApp.isFreeApp(getActivity())) { mReminders.setEnabled(false); mReminders.setClickable(false); ViewGroup parent = ((ViewGroup) mReminders.getParent()); parent.setClickable(true); parent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mLinkToPaidAppFragment != null && mLinkToPaidAppFragment.isResumed()) return; //Already showing mLinkToPaidAppFragment = LinkToPaidAppFragment .newInstance(getString(R.string.reminders_unavailable_message)); mLinkToPaidAppFragment.show(getSherlockActivity().getSupportFragmentManager(), null); } }); } mStartDate.setOnClickListener(this); mEndDate.setOnClickListener(this); mStartTime.setOnClickListener(this); mEndTime.setOnClickListener(this); mNameAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_1, null, new String[] { DbField.NAME.name }, new int[] { android.R.id.text1 }, 0); mNameAdapter.setStringConversionColumn(0);//Index of 'Name' column mName.setAdapter(mNameAdapter); mName.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) { mName.setError(null); mLastNameFilter = mName.getText() == null ? null : mName.getText().toString(); getLoaderManager().restartLoader(LOADER_ID_NAMES, null, EditShiftFragment.this); } }); mUnpaidBreak.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) { mUnpaidBreak.setError(null); } }); return v; }
From source file:net.kourlas.voipms_sms.activities.ConversationActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.conversation); database = Database.getInstance(getApplicationContext()); preferences = Preferences.getInstance(getApplicationContext()); contact = getIntent().getStringExtra(getString(R.string.conversation_extra_contact)); // Remove the leading one from a North American phone number (e.g. +1 (123) 555-4567) if ((contact.length() == 11) && (contact.charAt(0) == '1')) { contact = contact.substring(1);//from w w w . j a v a 2 s . co m } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); ViewCompat.setElevation(toolbar, getResources().getDimension(R.dimen.toolbar_elevation)); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { String contactName = Utils.getContactName(this, contact); if (contactName != null) { actionBar.setTitle(contactName); } else { actionBar.setTitle(Utils.getFormattedPhoneNumber(contact)); } actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } layoutManager = new LinearLayoutManager(this); layoutManager.setOrientation(LinearLayoutManager.VERTICAL); layoutManager.setStackFromEnd(true); adapter = new ConversationRecyclerViewAdapter(this, layoutManager, contact); recyclerView = (RecyclerView) findViewById(R.id.list); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(layoutManager); recyclerView.setAdapter(adapter); actionMode = null; actionModeEnabled = false; final EditText messageText = (EditText) findViewById(R.id.message_edit_text); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { messageText.setOutlineProvider(new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 15); } }); messageText.setClipToOutline(true); } messageText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Do nothing. } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Do nothing. } @Override public void afterTextChanged(Editable s) { ViewSwitcher viewSwitcher = (ViewSwitcher) findViewById(R.id.view_switcher); if (s.toString().equals("") && viewSwitcher.getDisplayedChild() == 1) { viewSwitcher.setDisplayedChild(0); } else if (viewSwitcher.getDisplayedChild() == 0) { viewSwitcher.setDisplayedChild(1); } } }); messageText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { adapter.refresh(); } } }); String intentMessageText = getIntent().getStringExtra(getString(R.string.conversation_extra_message_text)); if (intentMessageText != null) { messageText.setText(intentMessageText); } boolean intentFocus = getIntent().getBooleanExtra(getString(R.string.conversation_extra_focus), false); if (intentFocus) { messageText.requestFocus(); } RelativeLayout messageSection = (RelativeLayout) findViewById(R.id.message_section); ViewCompat.setElevation(messageSection, 8); QuickContactBadge photo = (QuickContactBadge) findViewById(R.id.photo); Utils.applyCircularMask(photo); photo.assignContactFromPhone(preferences.getDid(), true); String photoUri = Utils.getContactPhotoUri(getApplicationContext(), preferences.getDid()); if (photoUri != null) { photo.setImageURI(Uri.parse(photoUri)); } else { photo.setImageToDefault(); } final ImageButton sendButton = (ImageButton) findViewById(R.id.send_button); Utils.applyCircularMask(sendButton); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { preSendMessage(); } }); }
From source file:com.example.emachine.FXcalcActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fxcalc); // String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; // SharedPreferences sp = PreferenceManager // .getDefaultSharedPreferences(this); // sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true) // .commit(); // ((MyApplication) getApplication()).component().inject(this); TextView todayView = (TextView) findViewById(R.id.date); long millis = getIntent().getLongExtra(KEY_MILLIS, -1); // DateTime dateTime = (millis > 0) ? new DateTime(millis) : clock.getNow(); // todayView.setText(DateUtils.format(dateTime)); btn_calc = (Button) findViewById(R.id.btn_calc); mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = getTitle();//from ww w . java 2 s. com // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); // mNavigationDrawerFragment.setMenuVisibility(false); download(); pb_us = (AnimatedProgressBar) findViewById(R.id.pb_us); pb_england = (AnimatedProgressBar) findViewById(R.id.pb_england); pb_euro = (AnimatedProgressBar) findViewById(R.id.pb_euro); pb_brazil = (AnimatedProgressBar) findViewById(R.id.pb_brazil); pb_japan = (AnimatedProgressBar) findViewById(R.id.pb_japan); et_us = (EditText) findViewById(R.id.et_us); tv_england = (TextView) findViewById(R.id.tv_england); tv_euro = (TextView) findViewById(R.id.tv_euro); tv_brazil = (TextView) findViewById(R.id.tv_brazil); tv_japan = (TextView) findViewById(R.id.tv_japan); appIcon = (View) findViewById(R.id.appIcon); cv_england = (View) findViewById(R.id.cv_england); cv_euro = (View) findViewById(R.id.cv_euro); cv_brazil = (View) findViewById(R.id.cv_brazil); cv_japan = (View) findViewById(R.id.cv_japan); observeGraph(); et_us.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (s.length() > 0) clearScreen(); } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); appIcon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideKeyboard(); ArrayList<String> dialogItemList = new ArrayList<String>(); dialogItemList.add("BAD QA"); dialogItemList.add("Curious, how about a field of fields?"); // showDialog("Field of Dreams, the grass is greener?", dialogItemList, dialogItemList.size()); textDialog("Decisions, Decisions", "No logical way out now, so be curious"); } }); cv_england.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alert(getString(R.string.str_england_rate) + englandRate); } }); cv_euro.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alert(getString(R.string.str_euro_rate) + euroRate); } }); cv_brazil.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alert(getString(R.string.str_brazil_rate) + brazilRate); } }); cv_japan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alert(getString(R.string.str_japan_rate) + japanRate); } }); }
From source file:cn.ucai.superwechat.fragment.ContactlistFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); //T??home???appcrash if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) return;//from ww w . j a va2 s . com inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); listView = (ListView) getView().findViewById(cn.ucai.superwechat.R.id.list); sidebar = (Sidebar) getView().findViewById(cn.ucai.superwechat.R.id.sidebar); sidebar.setListView(listView); //??? blackList = EMContactManager.getInstance().getBlackListUsernames(); mContactList = new ArrayList<Contact>(); // ?contactlist getContactList(); //? query = (EditText) getView().findViewById(cn.ucai.superwechat.R.id.query); query.setHint(cn.ucai.superwechat.R.string.search); clearSearch = (ImageButton) getView().findViewById(cn.ucai.superwechat.R.id.search_clear); query.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { adapter.getFilter().filter(s); if (s.length() > 0) { clearSearch.setVisibility(View.VISIBLE); } else { clearSearch.setVisibility(View.INVISIBLE); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void afterTextChanged(Editable s) { } }); clearSearch.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { query.getText().clear(); hideSoftKeyboard(); } }); // adapter adapter = new ContactAdapter(getActivity(), cn.ucai.superwechat.R.layout.row_contact, mContactList); listView.setAdapter(adapter); listView.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String username = adapter.getItem(position).getMContactCname(); if (Constant.NEW_FRIENDS_USERNAME.equals(username)) { // ? EMUser user = ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getContactList() .get(Constant.NEW_FRIENDS_USERNAME); user.setUnreadMsgCount(0); startActivity(new Intent(getActivity(), NewFriendsMsgActivity.class)); } else if (Constant.GROUP_USERNAME.equals(username)) { // ?? startActivity(new Intent(getActivity(), GroupsActivity.class)); } else if (Constant.CHAT_ROOM.equals(username)) { //?? // startActivity(new Intent(getActivity(), PublicChatRoomsActivity.class)); } else if (Constant.CHAT_ROBOT.equals(username)) { //Robot? // startActivity(new Intent(getActivity(), RobotsActivity.class)); } else { // demo?? startActivity(new Intent(getActivity(), ChatActivity.class).putExtra("userId", adapter.getItem(position).getMContactCname())); } } }); listView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // ?? if (getActivity().getWindow() .getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) { if (getActivity().getCurrentFocus() != null) inputMethodManager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS); } return false; } }); ImageView addContactView = (ImageView) getView().findViewById(cn.ucai.superwechat.R.id.iv_new_contact); // ? addContactView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(getActivity(), AddContactActivity.class)); } }); registerForContextMenu(listView); progressBar = (View) getView().findViewById(cn.ucai.superwechat.R.id.progress_bar); contactSyncListener = new HXContactSyncListener(); HXSDKHelper.getInstance().addSyncContactListener(contactSyncListener); blackListSyncListener = new HXBlackListSyncListener(); HXSDKHelper.getInstance().addSyncBlackListListener(blackListSyncListener); contactInfoSyncListener = new HXContactInfoSyncListener(); ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager() .addSyncContactInfoListener(contactInfoSyncListener); if (!HXSDKHelper.getInstance().isContactsSyncedWithServer()) { progressBar.setVisibility(View.VISIBLE); } else { progressBar.setVisibility(View.GONE); } registerContactListChangedReceiver(); }