List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java
private EditText createEditText(String hint, int inputType, int imeOption, boolean shouldMoveToNext, final String key) { EditText ret = new EditText(mContext); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);// w ww.j a v a 2s . c o m ret.setLayoutParams(params); ret.setHint(hint); ret.setInputType(inputType); ret.setImeOptions(imeOption); if (shouldMoveToNext) { ret.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (mDelegate != null) { if (EditorInfo.IME_ACTION_NEXT == actionId) { mDelegate.scroll(CreateAccountDelegate.FORWARD); } else { processForm(); } return true; } else { return false; } } }); } ret.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { mFormData.put(key, s.toString()); } }); return ret; }
From source file:com.aliyun.homeshell.Folder.java
@Override protected void onFinishInflate() { super.onFinishInflate(); setContent((CellLayout) findViewById(R.id.folder_content)); mContent.setGridSize(0, 0);//w ww.ja v a2s . co m mContent.getShortcutsAndWidgets().setMotionEventSplittingEnabled(false); mContent.setInvertIfRtl(true); mContentList.add(mContent); mFolderName = (FolderEditText) findViewById(R.id.folder_name); mFolderName.setFolder(this); mFolderName.setOnFocusChangeListener(this); /*YUNOS BEGIN*/ //##date:2014/9/25 ##author:yangshan.ys BugId:5255762 mContentAdapter = new FolderContentAdapter(); mFolderViewPager = (FolderSelectPager) findViewById(R.id.folder_view_pager); mFolderViewPager.setOffscreenPageLimit(40); mFolderViewPager.setAdapter(mContentAdapter); mFolderViewPager.setOnPageChangeListener(pageChangeListener); mFolderViewPager.setOnClickListener(this); mPageIndicator = (PageIndicatorView) findViewById(R.id.folder_page_indicator); mPageIndicator.setNeedLine(false); /*YUNOS END*/ // We find out how tall the text view wants to be (it is set to wrap_content), so that // we can allocate the appropriate amount of space for it. int measureSpec = MeasureSpec.UNSPECIFIED; mFolderName.measure(measureSpec, measureSpec); /*YUNOS BEGIN*/ //##module(component name) //##date:2014/06/06 ##author:jun.dongj@alibaba-inc.com##BugID:124683 //folder name show wrong, when the system font is super big mFolderNameHeight = mFolderName.getMeasuredHeight(); /*YUNOS END*/ mFolderNameContentGap = getResources().getDimensionPixelSize(R.dimen.folder_name_content_gap); // We disable action mode for now since it messes up the view on phones mFolderName.setOnEditorActionListener(this); mFolderName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { mFolderName.requestLayout(); } }); mFolderName.setSelectAllOnFocus(true); mFolderName.setInputType(mFolderName.getInputType() | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_FLAG_CAP_WORDS); showFolderNameOutline(false); updateFolderLayout(mIconManager.supprtCardIcon()); mLastOrientation = getResources().getConfiguration().orientation; }
From source file:com.amazonaws.youruserpools.MainActivity.java
private void initApp() { inUsername = (EditText) findViewById(R.id.editTextUserId); inUsername.addTextChangedListener(new TextWatcher() { @Override//www. j a v a 2 s . c o m public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (s.length() == 0) { TextView label = (TextView) findViewById(R.id.textViewUserIdLabel); label.setText(R.string.Username); inUsername.setBackground(getDrawable(R.drawable.text_border_selector)); } } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { TextView label = (TextView) findViewById(R.id.textViewUserIdMessage); label.setText(""); } @Override public void afterTextChanged(Editable s) { if (s.length() == 0) { TextView label = (TextView) findViewById(R.id.textViewUserIdLabel); label.setText(""); } } }); inPassword = (EditText) findViewById(R.id.editTextUserPassword); inPassword.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { if (s.length() == 0) { TextView label = (TextView) findViewById(R.id.textViewUserPasswordLabel); label.setText(R.string.Password); inPassword.setBackground(getDrawable(R.drawable.text_border_selector)); } } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { TextView label = (TextView) findViewById(R.id.textViewUserPasswordMessage); label.setText(""); } @Override public void afterTextChanged(Editable s) { if (s.length() == 0) { TextView label = (TextView) findViewById(R.id.textViewUserPasswordLabel); label.setText(""); } } }); }
From source file:com.dcy.psychology.ChatActivity.java
/** * initView/*from ww w .ja v a 2s. 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); // ?????iewpager 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); 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) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:com.ccxt.whl.activity.ChatActivity.java
/** * initView/*from ww w . j ava 2s .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); 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) { } }); AseoZdpAseo.initType(this, AseoZdpAseo.SCREEN_TYPE); mEditTextContent.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) { // TODO Auto-generated method stub if (arg1 == EditorInfo.IME_ACTION_UNSPECIFIED) { //String s = mEditTextContent.getText().toString(); //sendText(s); //mEditTextContent.setText(""); //Toast.makeText(ChatActivity.this, "", Toast.LENGTH_SHORT).show(); } return false; } }); }
From source file:com.interestfriend.activity.ChatActivity.java
/** * initView/*from w ww . j ava 2 s .c o m*/ */ protected void initView() { mGridView = (GridView) findViewById(R.id.m_gridview); mGridView.setAdapter(new ChatGridViewAdapter(this, 0)); mGridView.setOnItemClickListener(this); 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 = (RelativeLayout) 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); initDots(); // , 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(160); new Thread() { public void run() { // viewpager for (int i = 1; i < 9; i++) { views.add(getGridChildView(i)); } mEmjoiHandler.sendEmptyMessage(0); } }.start(); 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); 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) { } }); expressionViewpager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int index) { for (View view : dots) { view.setBackgroundResource(R.drawable.viewpager_normal_circle); } dots.get(index).setBackgroundResource(R.drawable.viewpager_select_circle); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); }
From source file:com.BeatYourRecord.SubmitActivity.java
@Override public void onCreate(Bundle savedInstanceState) { boolean haveConnectedWifi = false; boolean haveConnectedMobile = false; ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] netInfo = cm.getAllNetworkInfo(); for (NetworkInfo ni : netInfo) { if (ni.getTypeName().equalsIgnoreCase("WIFI")) if (ni.isConnected()) haveConnectedWifi = true; if (ni.getTypeName().equalsIgnoreCase("MOBILE")) if (ni.isConnected()) haveConnectedMobile = true; }//from ww w.j a va2s.c om if (haveConnectedWifi == false) { showDialog(11); } super.onCreate(savedInstanceState); // SharedPreferences pref = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref.edit(); //auth = pref.getString("BYR_session", null); /*SharedPreferences pref6 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor7 = pref6.edit(); //this.setContentView(R.layout.submit); String logoutme = pref6.getString("log", null); //log.v("log",logoutme); */ SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor1 = pref1.edit(); tourid = pref1.getString("id", null); logout = pref1.getString("log", null); filepath = pref1.getString("filepath", null); //log.v("id",tourid); //log.v("log",logout); Log.v("reached here first", "reached here first"); File f = new File("/data/data/com.BeatYourRecord/shared_prefs/Tester15.xml"); if (f.exists() && logout.equals("yes") == false) { //log.v("yyy","yyy"); SharedPreferences pref = SubmitActivity.this.getSharedPreferences("Tester15", 0); // 0 - for private mode Editor editor = pref.edit(); this.setContentView(R.layout.submit); auth = pref.getString("BYR_session", null); } else { //log.v("yyy","yyy1"); this.setContentView(R.layout.submit1); showDialog(10); } // String checksession = pref.getString("BYR_session", null); // //log.v("checksession", checksession); ////log.v("Authhere",auth); this.authorizer = new ClientLoginAuthorizer.ClientLoginAuthorizerFactory().getAuthorizer(this, ClientLoginAuthorizer.YOUTUBE_AUTH_TOKEN_TYPE); dbHelper = new DbHelper(this); dbHelper = dbHelper.open(); Intent intent = this.getIntent(); this.videoUri = intent.getData(); SharedPreferences pref1223 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor1223 = pref1223.edit(); filepath = pref1223.getString("filepath", null); // this.videoUri = // Uri path = Uri.parse(filepath); //File f1 = new File(filepath); //Uri imageUri = Uri.fromFile(f1); //this.videoUri = imageUri; //this.videoUri = path; Log.v("Reached here second", "Reached here secord"); //this.videoUri= Uri.fromFile(new File("/sdcard/Movies/com.BeatYourRecord/BYR_tournName_dateTim_20130724181901222.mp4")); //log.v("haha","haha"); MediaScannerConnectionClient mediaScannerClient = new MediaScannerConnectionClient() { private MediaScannerConnection msc = null; { msc = new MediaScannerConnection(getApplicationContext(), this); msc.connect(); } public void onMediaScannerConnected() { msc.scanFile(filepath, null); } public void onScanCompleted(String path, Uri uri) { //This is where you get your content uri Log.d("test3", uri.toString()); needed = uri; // videoUri=needed; msc.disconnect(); } }; String videoPath = ""; try { videoPath = getFilePathFromUri(this.videoUri); filepath1 = videoPath; Log.v("videoPath", videoPath); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } File videoFile = new File(videoPath); this.ytdDomain = intent.getExtras().getString(DbHelper.YTD_DOMAIN); this.assignmentId = intent.getExtras().getString(DbHelper.ASSIGNMENT_ID); this.domainHeader = (TextView) this.findViewById(R.id.domainHeader); domainHeader.setText(SettingActivity.getYtdDomains(this).get(this.ytdDomain)); this.preferences = this.getSharedPreferences(MainActivity.SHARED_PREF_NAME, Activity.MODE_PRIVATE); this.youTubeName = preferences.getString(DbHelper.YT_ACCOUNT, null); final Button submitButton = (Button) findViewById(R.id.submitButton); submitButton.setEnabled(false); submitButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { showDialog(DIALOG_LEGAL); } }); addusertotournament(); Button cancelButton = (Button) findViewById(R.id.cancelButton); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref1.edit(); //editor.putString("filepath", permfilepath); //editor.commit(); Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class); // intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com"); //intent.setData(Uri.fromFile(file)); startActivity(intent); finish(); // setResult(RESULT_CANCELED); //finish(); } }); Button forgotButton = (Button) findViewById(R.id.forgotButton); forgotButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //SharedPreferences pref1 = SubmitActivity.this.getSharedPreferences("TourPref", 0); // 0 - for private mode //Editor editor = pref1.edit(); //editor.putString("filepath", permfilepath); //editor.commit(); SharedPreferences pref155 = getApplicationContext().getSharedPreferences("TourPref", 0); // 0 - for private mode Editor editor155 = pref155.edit(); editor155.putString("filepath", filepath1); editor155.commit(); Log.v("fielpathss", filepath1); Intent intent = new Intent(SubmitActivity.this, DetailsActivity.class); // intent.putExtra(DbHelper.YTD_DOMAIN, "TODO-appname.appspot.com"); //intent.setData(Uri.fromFile(file)); startActivity(intent); // finish(); // setResult(RESULT_CANCELED); //finish(); } }); EditText titleEdit = (EditText) findViewById(R.id.submitTitle); titleEdit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); EditText descriptionEdit = (EditText) findViewById(R.id.submitDescription); descriptionEdit.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { enableSubmitIfReady(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } }); Cursor cursor = this.managedQuery(this.videoUri, null, null, null, null); if (cursor.getCount() == 0) { Log.d(LOG_TAG, "not a valid video uri"); Toast.makeText(SubmitActivity.this, "not a valid video uri", Toast.LENGTH_LONG).show(); } else { getVideoLocation(); if (cursor.moveToFirst()) { long id = cursor.getLong(cursor.getColumnIndex(Video.VideoColumns._ID)); this.dateTaken = new Date(cursor.getLong(cursor.getColumnIndex(Video.VideoColumns.DATE_TAKEN))); Log.v("here", "here12"); SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, MMM d, yyyy hh:mm aaa"); Configuration userConfig = new Configuration(); Settings.System.getConfiguration(getContentResolver(), userConfig); /* Calendar cal = Calendar.getInstance(userConfig.locale); TimeZone tz = cal.getTimeZone();*/ Log.v("here", "here13"); // dateFormat.setTimeZone(tz); TextView dateTakenView = (TextView) findViewById(R.id.dateCaptured); dateTakenView.setText("Date captured: " + dateFormat.format(dateTaken)); ImageView thumbnail = (ImageView) findViewById(R.id.thumbnail); ContentResolver crThumb = getContentResolver(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = 1; Bitmap curThumb = MediaStore.Video.Thumbnails.getThumbnail(crThumb, id, MediaStore.Video.Thumbnails.MICRO_KIND, options); thumbnail.setImageBitmap(curThumb); } } }
From source file:com.app.jiaxiaotong.activity.ChatActivity.java
/** * initView//from w w w. j ava 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); emojiIconContainer = (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); voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call); videoCallBtn = (ImageView) findViewById(R.id.btn_video_call); // ?, micImages = new Drawable[] { getResources().getDrawable(R.mipmap.record_animate_01), getResources().getDrawable(R.mipmap.record_animate_02), getResources().getDrawable(R.mipmap.record_animate_03), getResources().getDrawable(R.mipmap.record_animate_04), getResources().getDrawable(R.mipmap.record_animate_05), getResources().getDrawable(R.mipmap.record_animate_06), getResources().getDrawable(R.mipmap.record_animate_07), getResources().getDrawable(R.mipmap.record_animate_08), getResources().getDrawable(R.mipmap.record_animate_09), getResources().getDrawable(R.mipmap.record_animate_10), getResources().getDrawable(R.mipmap.record_animate_11), getResources().getDrawable(R.mipmap.record_animate_12), getResources().getDrawable(R.mipmap.record_animate_13), getResources().getDrawable(R.mipmap.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); 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) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:com.easemob.chatuidemo.activity.ChatActivity.java
/** * initView//w w w . j a v a 2s . 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); // 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); // voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call); // videoCallBtn = (ImageView) findViewById(R.id.btn_video_call); // ?, 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); 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) { } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }
From source file:com.grass.caishi.cc.activity.ChatActivity.java
/** * initView/*from 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); 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); voiceCallBtn = (ImageView) findViewById(R.id.btn_voice_call); videoCallBtn = (ImageView) findViewById(R.id.btn_video_call); // ?, 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(143); // ?viewpager List<View> views = getGridChildView(); 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) { } }); mEditTextContent.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView arg0, int arg1, KeyEvent arg2) { // TODO Auto-generated method stub if (arg1 == EditorInfo.IME_ACTION_UNSPECIFIED) { // String s = mEditTextContent.getText().toString(); // sendText(s); // mEditTextContent.setText(""); // Toast.makeText(ChatActivity.this, "", // Toast.LENGTH_SHORT).show(); } return false; } }); swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.chat_swipe_layout); // swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefreshLayout.setOnRefreshListener(new OnRefreshListener() { @Override public void onRefresh() { new Handler().postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() == 0 && !isloading && haveMoreData) { List<EMMessage> messages; try { if (chatType == CHATTYPE_SINGLE) { messages = conversation.loadMoreMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } else { messages = conversation.loadMoreGroupMsgFromDB(adapter.getItem(0).getMsgId(), pagesize); } } catch (Exception e1) { swipeRefreshLayout.setRefreshing(false); return; } if (messages.size() > 0) { adapter.notifyDataSetChanged(); // adapter.refreshSeekTo(messages.size() - 1); if (messages.size() != pagesize) { haveMoreData = false; } } else { haveMoreData = false; } isloading = false; } else { // Toast.makeText(ChatActivity.this, getResources().getString(R.string.no_more_messages), Toast.LENGTH_SHORT).show(); } swipeRefreshLayout.setRefreshing(false); } }, 1000); } }); }