List of usage examples for android.text TextWatcher TextWatcher
TextWatcher
From source file:it.feio.android.omninotes.SettingsFragment.java
private void export(View v) { final List<String> backups = Arrays.asList(StorageHelper.getExternalStoragePublicDir().list()); // Sets default export file name SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_FORMAT_EXPORT); String fileName = sdf.format(Calendar.getInstance().getTime()); final EditText fileNameEditText = (EditText) v.findViewById(R.id.export_file_name); final TextView backupExistingTextView = (TextView) v.findViewById(R.id.backup_existing); fileNameEditText.setHint(fileName);//from w ww . j a va 2 s.c o m fileNameEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { if (backups.contains(arg0.toString())) { backupExistingTextView.setText(R.string.backup_existing); } else { backupExistingTextView.setText(""); } } }); new MaterialDialog.Builder(getActivity()).title(R.string.data_export_message).customView(v, false) .positiveText(R.string.confirm).callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog materialDialog) { AnalyticsHelper.trackEvent(AnalyticsHelper.CATEGORIES.SETTING, "settings_export_data"); // An IntentService will be launched to accomplish the export task Intent service = new Intent(getActivity(), DataBackupIntentService.class); service.setAction(DataBackupIntentService.ACTION_DATA_EXPORT); String backupName = StringUtils.isEmpty(fileNameEditText.getText().toString()) ? fileNameEditText.getHint().toString() : fileNameEditText.getText().toString(); service.putExtra(DataBackupIntentService.INTENT_BACKUP_NAME, backupName); getActivity().startService(service); } }).build().show(); }
From source file:com.dycody.android.idealnote.SettingsFragment.java
private void export(View v) { final List<String> backups = Arrays.asList(StorageHelper.getExternalStoragePublicDir().list()); // Sets default export file name SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATE_FORMAT_EXPORT); String fileName = sdf.format(Calendar.getInstance().getTime()); final EditText fileNameEditText = (EditText) v.findViewById(R.id.export_file_name); final TextView backupExistingTextView = (TextView) v.findViewById(R.id.backup_existing); fileNameEditText.setHint(fileName);//from w w w. jav a 2 s. c o m fileNameEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void afterTextChanged(Editable arg0) { if (backups.contains(arg0.toString())) { backupExistingTextView.setText(R.string.backup_existing); } else { backupExistingTextView.setText(""); } } }); new MaterialDialog.Builder(getActivity()).title(R.string.data_export_message).customView(v, false) .positiveText(R.string.confirm).callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog materialDialog) { ((IdealNote) getActivity().getApplication()).getAnalyticsHelper() .trackEvent(AnalyticsHelper.CATEGORIES.SETTING, "settings_export_data"); // An IntentService will be launched to accomplish the export task Intent service = new Intent(getActivity(), DataBackupIntentService.class); service.setAction(DataBackupIntentService.ACTION_DATA_EXPORT); String backupName = StringUtils.isEmpty(fileNameEditText.getText().toString()) ? fileNameEditText.getHint().toString() : fileNameEditText.getText().toString(); service.putExtra(DataBackupIntentService.INTENT_BACKUP_NAME, backupName); getActivity().startService(service); } }).build().show(); }
From source file:com.entradahealth.entrada.android.app.personal.activities.job_list.JobListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; application = (EntradaApplication) EntradaApplication.getAppContext(); sp = getSharedPreferences("Entrada", Context.MODE_WORLD_READABLE); if (sp.getBoolean("SECURE_MSG", true)) getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE); else/* w w w . j a v a 2 s .com*/ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE); final JobListActivity thisActivity = this; //Custom view as action bar LayoutInflater mInflater = LayoutInflater.from(this); View mCustomView = mInflater.inflate(R.layout.acbar_job_list, null); tvAcTitle = (TextView) mCustomView.findViewById(R.id.tvAcTitle); ivInbox = (ImageView) mCustomView.findViewById(R.id.ivInbox); ivAddJob = (ImageView) mCustomView.findViewById(R.id.ivAddJob); ivSync = (ImageView) mCustomView.findViewById(R.id.ivSync); ivSchedule = (ImageView) mCustomView.findViewById(R.id.ivSchedule); tvAcTitle.setText(BundleKeys.title); //Sample icon badger on Action bar item badge = new BadgeView(this, ivInbox); if (BundleKeys.fromSecureMessaging || !application.isJobListEnabled()) { startActivity(new Intent(JobListActivity.this, SecureMessaging.class)); finish(); } ivInbox.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub startActivity(new Intent(JobListActivity.this, SecureMessaging.class)); finish(); } }); ivAddJob.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent addJobIntent = new Intent(JobListActivity.this, AddJobActivity.class); addJobIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(addJobIntent); finish(); } }); ivSync.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub ns = new NetworkState(getApplicationContext()); isConnected = ns.isConnectingToInternet(); if (isConnected) { running = false; ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.entradahealth.entrada.android.app.personal.sync.SyncService" .equals(service.service.getClassName()) || "com.entradahealth.entrada.android.app.personal.sync.DictationUploadService" .equals(service.service.getClassName())) { running = true; } } if (!running) { etSearch.setText(null); if (!isFinishing()) { //retryUploads(); boolean canSync = true; try { List<Job> jobs = AndroidState.getInstance().getUserState() .getProvider(currentAccount).getJobs(); for (Job j : jobs) { if (j.isPending()) { canSync = false; UserState state = AndroidState.getInstance().getUserState(); Log.e("", "onOptionsItemSelected-syncMenuItem--" + j.id); DictationUploadService.startUpload(JobListActivity.this, state, currentAccount, j); } } } catch (Exception ex) { ACRA.getErrorReporter().handleSilentException(ex); canSync = false; } if (!canSync) { Toast.makeText(JobListActivity.this, "Please wait for all uploads to complete before syncing.", Toast.LENGTH_SHORT).show(); } else { rlSyncError.setVisibility(View.GONE); rlUpdated.setVisibility(View.INVISIBLE); tvUpdating.setVisibility(View.VISIBLE); Intent i = new Intent(JobListActivity.this, SyncService.class); startService(i); } isSyncing = true; BundleKeys.SYNC_FOR_ACC = currentAccount.getDisplayName(); //BundleKeys.SYNC_FOR_CLINIC = currentAccount.getClinicCode(); /*task1 = buildMinderTask(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { task1.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } else { task1.execute(); }*/ } } else { if (!isResumed) Toast.makeText(JobListActivity.this, "Please wait for all uploads to complete before syncing.", Toast.LENGTH_SHORT) .show(); } isResumed = false; } else { rlSyncError.setVisibility(View.VISIBLE); rlUpdated.setVisibility(View.GONE); tvUpdating.setVisibility(View.GONE); } } }); ivSchedule.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(JobListActivity.this, ScheduleActivity.class)); finish(); } }); getActionBar().setCustomView(mCustomView); getActionBar().setDisplayShowCustomEnabled(true); //ActionBar ab = getActionBar(); //ab.setTitle(BundleKeys.title); this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); registerReceiver(broadcastReceiver, new IntentFilter("CONNECTIVITY_CHANGED")); jobIds = new ArrayList<Long>(); BundleKeys.fromImageDisplay = false; BundleKeys.fromCaputreImages = false; BundleKeys.fromSecureMessaging = false; /*Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread paramThread, Throwable paramThrowable) { Log.e("Job-List-Activity","Uncaught-Exception"); System.exit(2); } });*/ setBehindContentView(R.layout.job_list_sliding_menu); tvListTitle = (TextView) findViewById(R.id.tvListTitle); tvListTitle.setText("Jobs"); lvSliding = (ListView) findViewById(R.id.lvSlidingMenu); lvSliding.setBackgroundColor(Color.parseColor("#262b38")); // Get screen width and set sliding width to 3/4 Display display = getWindowManager().getDefaultDisplay(); int width = display.getWidth(); int req_width = width * 3 / 4; slidingMenu = getSlidingMenu(); slidingMenu.setFadeEnabled(true); slidingMenu.setFadeDegree(0.35f); slidingMenu.setBehindWidth(req_width); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_MARGIN); setContentView(R.layout.job_list); ivDrawer = (ImageView) findViewById(R.id.ivDrawer); ivDrawer.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub slidingMenu.toggle(); // JobCountTask(); } }); rlUpdated = (RelativeLayout) findViewById(R.id.rlDateTime); rlSyncError = (RelativeLayout) findViewById(R.id.rlSyncError); rlSyncError.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.title_sync_error); builder.setMessage(R.string.msg_sync_error); builder.setPositiveButton("OK", null); dgSyncError = builder.create(); dgSyncError.show(); } }); tvDate = (TextView) findViewById(R.id.tvDate); tvTime = (TextView) findViewById(R.id.tvTime); tvUpdating = (TextView) findViewById(R.id.lblUpdating); tvSyncFailed = (TextView) findViewById(R.id.lblSyncError); handler = new Handler(); handler.postDelayed(runnable, BundleKeys.mins_to_sync * 60 * 1000); handler.postDelayed(runnable_logs, 5 * 60 * 1000); jobListView = (ListView) findViewById(R.id.jobListView); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); jobListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { // TODO: evaluate whether to save search text in // UserState to repopulate on back press. itemClicked = true; if (searchTask != null) { searchTask.cancel(true); } Log.d("", "-- Job ItemClick --"); List<Long> jobList = thisActivity.getJobIdList(); Preconditions.checkNotNull(jobList, "null List<Job> when adapter view clicked."); Job job = AndroidState.getInstance().getUserState().getProvider(currentAccount) .getJob(jobList.get(position)); if (job != null) { Preconditions.checkNotNull(job, "null item in List<Job> when adapter view clicked."); if (job.isFlagSet(Job.Flags.UPLOAD_COMPLETED) || job.isFlagSet(Job.Flags.UPLOAD_IN_PROGRESS) || (job.isFlagSet(Job.Flags.UPLOAD_PENDING) && BundleKeys.which == 6)) { Toast.makeText(thisActivity, "Cannot open a completed dictation.", Toast.LENGTH_SHORT) .show(); return; } else if (job.isFlagSet(Job.Flags.LOCALLY_DELETED)) { return; } Intent intent = new Intent(thisActivity, JobDisplayActivity.class); Bundle b = new Bundle(); if (!job.isFlagSet(Flags.HOLD)) job = job.setFlag(Flags.IS_FIRST); else job = job.clearFlag(Flags.IS_FIRST); try { AndroidState.getInstance().getUserState().getProvider(currentAccount).updateJob(job); } catch (DomainObjectWriteException e) { // TODO Auto-generated catch block e.printStackTrace(); } b.putBoolean("isFirst", true); b.putBoolean("isFromList", true); b.putBoolean("isNew", false); b.putLong(BundleKeys.SELECTED_JOB, job.id); b.putString(BundleKeys.SELECTED_JOB_ACCOUNT, currentAccount.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtras(b); thisActivity.startActivity(intent); thisActivity.finish(); } } }); jobListView.setMultiChoiceModeListener(new JobListMultiChoiceModeListener(this)); slidingMenu.setOnOpenListener(new OnOpenListener() { @Override public void onOpen() { // TODO Auto-generated method stub openSlide(); } }); lvSliding.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { // TODO Auto-generated method stub switch (pos) { case 1: //getActionBar().setTitle("Today's Jobs"); tvAcTitle.setText("Today's Jobs"); BundleKeys.title = "Today's Jobs"; BundleKeys.which = 1; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 2: //getActionBar().setTitle("Tomorrow's Jobs"); tvAcTitle.setText("Tomorrow's Jobs"); BundleKeys.which = 2; BundleKeys.title = "Tomorrow's Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 3: //getActionBar().setTitle("Stat Jobs"); tvAcTitle.setText("Stat Jobs"); BundleKeys.which = 3; BundleKeys.title = "Stat Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 4: //getActionBar().setTitle("All Jobs"); tvAcTitle.setText("All Jobs"); BundleKeys.which = 4; BundleKeys.title = "All Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 6: //getActionBar().setTitle("Hold Jobs"); tvAcTitle.setText("Hold Jobs"); BundleKeys.which = 5; BundleKeys.title = "Hold Jobs"; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); etSearch.setText(""); break; case 7: //getActionBar().setTitle("Deleted Jobs"); tvAcTitle.setText("Deleted Jobs"); BundleKeys.which = 7; BundleKeys.title = "Deleted Jobs"; // Hide "Add Job" menu item //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(false); ivAddJob.setVisibility(View.GONE); jobListView.setChoiceMode(ListView.CHOICE_MODE_NONE); etSearch.setText(""); break; case 8: //getActionBar().setTitle("Completed Jobs"); tvAcTitle.setText("Completed Jobs"); BundleKeys.which = 6; BundleKeys.title = "Completed Jobs"; // Hide "Add Job" menu item //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(false); ivAddJob.setVisibility(View.GONE); jobListView.setChoiceMode(ListView.CHOICE_MODE_NONE); etSearch.setText(""); break; case 10: isSetting = true; //getActionBar().setTitle("Settings"); tvAcTitle.setText("Settings Jobs"); startActivity(new Intent(JobListActivity.this, EntradaSettings.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); finish(); break; case 11: // Check if there are any held jobs or any uploads in // progress boolean isHeld = true, isPending = true; try { List<Job> jobs = AndroidState.getInstance().getUserState().getProvider(currentAccount) .getJobs(); for (Job j : jobs) { if (j.isPending()) isPending = false; if (j.isFlagSet(Job.Flags.HOLD)) isHeld = false; } } catch (Exception ex) { ACRA.getErrorReporter().handleSilentException(ex); isPending = false; isHeld = false; } if (SyncService.isRunning()) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_upload_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } else if (isPending && isHeld) { Intent qIntent = new Intent(JobListActivity.this, ManageQueuesActivity.class); qIntent.putExtra("from_settings", false); qIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(qIntent); finish(); } else if (!isHeld) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_hold_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } else if (!isPending) { AlertDialog.Builder builder = new AlertDialog.Builder(JobListActivity.this); builder.setTitle(R.string.del_acc_err_title); builder.setMessage(R.string.manage_q_upload_error); builder.setPositiveButton("OK", null); builder.setCancelable(true); dgManageQ = builder.create(); dgManageQ.show(); } break; default: //getActionBar().setTitle("Today's Jobs"); tvAcTitle.setText("Today's Jobs"); BundleKeys.title = "Today's Jobs"; BundleKeys.which = 1; //menuItem = j_Menu.findItem(R.id.addJobMenuItem); //menuItem.setVisible(true); ivAddJob.setVisibility(View.VISIBLE); jobListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); } Log.e(LOG_NAME, Integer.toString(BundleKeys.which) + " - " + BundleKeys.title); isSync = false; slidingMenu.toggle(true); /* * Log.e("isSetting", Boolean.toString(isSetting)); * if(BundleKeys.which != 8 && BundleKeys.which != 9 && * !isSetting) etSearch.setText(""); */ } }); rlSearch = (RelativeLayout) findViewById(R.id.rlSearch); etSearch = (EditText) findViewById(R.id.etSearch); etSearch.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //launchSearchTask(); } @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 try { Thread.sleep(200); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } launchSearchTask(); } }); GetResourcesTask task = new GetResourcesTask(); task.execute(); }
From source file:com.github.akinaru.hcidebugger.activity.HciDebuggerActivity.java
/** * setup a filter//from ww w. j a va 2 s . com */ private void filter() { Log.v(TAG, "setting filter"); final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(HciDebuggerActivity.this); LayoutInflater inflater = getLayoutInflater(); final View dialogView = inflater.inflate(R.layout.filter_dialog, null); dialogBuilder.setView(dialogView); //packet type setupSpinnerAdapter(R.array.packet_type_array, dialogView, R.id.packet_type_filter, filters.getPacketTypeFilter()); //event type setupSpinnerAdapter(R.array.event_type_array, dialogView, R.id.event_type_filter, filters.getEventTypeFilter()); //ogf setupSpinnerAdapter(R.array.ogf_array, dialogView, R.id.cmd_ogf_filter, filters.getOgfFilter()); //subevent_type_filter setupSpinnerAdapter(R.array.subevent_array, dialogView, R.id.subevent_type_filter, filters.getSubeventFilter()); EditText addressText = (EditText) dialogView.findViewById(R.id.device_address_edit); addressText.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) { filters.setAddress(s.toString()); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.PREFERENCES_ADVERTISING_ADDR, s.toString()); editor.commit(); } @Override public void afterTextChanged(Editable s) { } }); addressText.setText(filters.getAdvertizingAddr()); final AlertDialog alertDialog = dialogBuilder.create(); final Button button_withdraw_filter = (Button) dialogView.findViewById(R.id.button_withdraw_filter); if (isFiltered) button_withdraw_filter.setVisibility(View.VISIBLE); else button_withdraw_filter.setVisibility(View.GONE); button_withdraw_filter.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { isFiltered = false; packetAdapter.setPacketList(packetList); notifyAdapter(); alertDialog.cancel(); alertDialog.dismiss(); packetFilteredList.clear(); } }); Button button_apply = (Button) dialogView.findViewById(R.id.button_apply_filter); button_apply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Spinner packet_type_filter = (Spinner) dialogView.findViewById(R.id.packet_type_filter); Spinner ogf_filter = (Spinner) dialogView.findViewById(R.id.cmd_ogf_filter); Spinner event_type_filter = (Spinner) dialogView.findViewById(R.id.event_type_filter); Spinner subevent_type_filter = (Spinner) dialogView.findViewById(R.id.subevent_type_filter); EditText device_address_edit = (EditText) dialogView.findViewById(R.id.device_address_edit); filters = new Filters(HciDebuggerActivity.this, packet_type_filter.getSelectedItem().toString(), event_type_filter.getSelectedItem().toString(), ogf_filter.getSelectedItem().toString(), subevent_type_filter.getSelectedItem().toString(), device_address_edit.getText().toString()); packetFilteredList = new ArrayList<Packet>(); for (int i = 0; i < packetList.size(); i++) { if (matchFilter(packetList.get(i))) { packetFilteredList.add(packetList.get(i)); } } isFiltered = true; packetAdapter.setPacketList(packetFilteredList); notifyAdapter(); alertDialog.cancel(); alertDialog.dismiss(); } }); Button button_cancel = (Button) dialogView.findViewById(R.id.button_cancel_filter); button_cancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { alertDialog.cancel(); alertDialog.dismiss(); } }); alertDialog.show(); }
From source file:com.inter.trade.ui.fragment.smsreceivepayment.SmsReceivePaymentMainFragment.java
/** * //from w w w. j a v a 2 s .co m */ private void setFeeOnMoneyEdit(EditText et_money) { if (et_money == null) { return; } et_money.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub String money = s.toString(); if (TextUtils.isEmpty(money)) { mFee = ""; tv_fee.setText(mFee); return; } money = money.trim(); /** * ????"." */ int d = money.indexOf("."); /** * ?? */ if (d != 0) { mMoney = money; cleanText();//? mfeeData.putValue("money", money); getCost(); } /** * */ // if(d!=0 && checkMoney(money)){ // double dmoney = mDoubleMoney*mFeeRate; // String fee = String.format("%.2f", dmoney); // if(!TextUtils.isEmpty(fee) && checkFee(fee)){ // tv_fee.setText(mFee); // } // }else{ // mFee = ""; // tv_fee.setText(mFee); // } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } /** * ???2? */ @Override public void afterTextChanged(Editable s) { // TODO Auto-generated method stub String temp = s.toString(); int d = temp.indexOf("."); if (d < 0) return; if (temp.length() - d - 1 > 2) { s.delete(d + 3, d + 4); } else if (d == 0) { s.delete(d, d + 1); } } }); }
From source file:com.kmshack.BusanBus.activity.SearchMainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_common); setTitle(""); mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setDrawerListener(new DrawerListener() { public void onDrawerOpened(View drawerView) { mDrawerToggle.onDrawerOpened(drawerView); getActionBarHelper().onDrawerOpened(); }/*from w ww .j a v a2 s. c om*/ public void onDrawerClosed(View drawerView) { mDrawerToggle.onDrawerClosed(drawerView); getActionBarHelper().onDrawerClosed(); } public void onDrawerSlide(View drawerView, float slideOffset) { mDrawerToggle.onDrawerSlide(drawerView, slideOffset); } public void onDrawerStateChanged(int newState) { mDrawerToggle.onDrawerStateChanged(newState); } }); mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); mDrawerToggle = new SherlockActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_dark, R.string.drawer_open, R.string.drawer_close); mDrawerToggle.syncState(); mBusDb = BusDb.getInstance(getApplicationContext()); mUserDb = UserDb.getInstance(getApplicationContext()); mBusanBusPrefrence = BusanBusPrefrence.getInstance(getApplicationContext()); mInputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); mHandler = new Handler() { @Override public void handleMessage(Message msg) { switch (msg.what) { case TAB_NOSUN: searchNosun((String) msg.obj); break; case TAB_BUSSTOP: searchBusStop((String) msg.obj); break; } } }; mImageFavorite = (ImageView) findViewById(R.id.main_tap_favorite_image); mImageNosun = (ImageView) findViewById(R.id.main_tap_nosun_image); mImageBusstop = (ImageView) findViewById(R.id.main_tap_busstop_image); mImageLocation = (ImageView) findViewById(R.id.main_tap_setting_image); mFavoriteImageNosun = (TextView) findViewById(R.id.favorite_tab_nosun); mFavoriteImageBusstop = (TextView) findViewById(R.id.favorite_tab_busstop); mTextFavorite = (TextView) findViewById(R.id.main_tap_favorite_text); mTextNosun = (TextView) findViewById(R.id.main_tap_nosun_text); mTextBusstop = (TextView) findViewById(R.id.main_tap_busstop_text); mTextSetting = (TextView) findViewById(R.id.main_tap_setting_text); mNosunListView = (ListView) findViewById(R.id.lv_nosun); mBusStopListView = (ListView) findViewById(R.id.lv_busstop); mFavoriteListView = (DragSortListView) findViewById(R.id.lv_favorite); mNosunListView.setEmptyView((TextView) findViewById(R.id.nosun_empty)); mBusStopListView.setEmptyView((TextView) findViewById(R.id.busstop_empty)); mFavoriteListView.setEmptyView((TextView) findViewById(R.id.favorite_empty)); mFavoriteListView.setDropListener(mOnDrop); mFavoriteListView.setRemoveListener(mOnRemove); mTextSettingNotice = (TextView) findViewById(R.id.setting_notice); mTextSettingUpdate = (TextView) findViewById(R.id.setting_update); mLayoutSettingTextSize = (LinearLayout) findViewById(R.id.setting_textsize_sun); mLayoutSettingArrive = (LinearLayout) findViewById(R.id.setting_arrive_sun); mLayoutSettingFavorite = (LinearLayout) findViewById(R.id.setting_favorite_start); mLayoutSettingFavoriteLocation = (LinearLayout) findViewById(R.id.setting_favorite_location); mTextViewSettingTextSize = (TextView) findViewById(R.id.setting_textsize_value); mCheckSettingArrive = (ImageView) findViewById(R.id.setting_check_arrive_sun); mCheckSettingFavorite = (ImageView) findViewById(R.id.setting_check_favorite_start); mCheckSettingFavoriteLocation = (ImageView) findViewById(R.id.setting_check_favorite_location); mTextSettingNotice.setOnClickListener(mSettingClick); mTextSettingUpdate.setOnClickListener(mSettingClick); mLayoutSettingTextSize.setOnClickListener(mSettingClick); mLayoutSettingArrive.setOnClickListener(mSettingClick); mLayoutSettingFavorite.setOnClickListener(mSettingClick); mLayoutSettingFavoriteLocation.setOnClickListener(mSettingClick); findViewById(R.id.setting_opensource).setOnClickListener(mSettingClick); findViewById(R.id.setting_bin).setOnClickListener(mSettingClick); if (mBusanBusPrefrence.getIsArriveSort()) mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_check); else mCheckSettingArrive.setImageResource(R.drawable.btn_setting_checkbox_uncheck); if (mBusanBusPrefrence.getIsFavoriteStart()) mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_check); else mCheckSettingFavorite.setImageResource(R.drawable.btn_setting_checkbox_uncheck); if (mBusanBusPrefrence.getIsFavoriteLocation()) mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_check); else mCheckSettingFavoriteLocation.setImageResource(R.drawable.btn_setting_checkbox_uncheck); mNosunSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext()) .inflate(R.layout.search_bar_nosun, null); mNosunSearchView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); mNosunEditText = (EditText) mNosunSearchView.findViewById(R.id.et_search_nosun); mNosunEditText.setHint(" "); mNosunEditText.setInputType(InputType.TYPE_CLASS_NUMBER); mNosunEditText.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { mHandler.removeMessages(TAB_NOSUN); Message msg = Message.obtain(mHandler, TAB_NOSUN, s.toString()); mHandler.sendMessageDelayed(msg, 200); } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); ((LinearLayout) findViewById(R.id.search_nosun)).addView(mNosunSearchView); mNosunListView.setOnScrollListener(new OnScrollListener() { public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) { } public void onScrollStateChanged(AbsListView arg0, int arg1) { mInputMethodManager.hideSoftInputFromWindow(mNosunEditText.getWindowToken(), 0); } }); mNosunListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Cursor cursor = mMainNosunSearchAdapter.getCursor(); cursor.moveToPosition(position); String nosun = cursor.getString(1); String realtime = cursor.getString(cursor.getColumnIndexOrThrow("WEBREALTIME")); String up = cursor.getString(2); String down = cursor.getString(3); Intent intent = new Intent(getApplicationContext(), NosunDetailActivity.class); intent.putExtra("NoSun", nosun); intent.putExtra("RealTimeNoSun", realtime); intent.putExtra("Up", up); intent.putExtra("Down", down); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); mBusstopSearchView = (LinearLayout) LayoutInflater.from(getApplicationContext()) .inflate(R.layout.search_bar_busstop, null); mBusStopEditText = (EditText) mBusstopSearchView.findViewById(R.id.et_search_busstop); mBusStopEditText.setHint("/ "); mBusStopEditText.setInputType(InputType.TYPE_CLASS_TEXT); mBusStopEditText.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { mHandler.removeMessages(TAB_BUSSTOP); Message msg = Message.obtain(mHandler, TAB_BUSSTOP, s.toString()); mHandler.sendMessageDelayed(msg, 200); } public void afterTextChanged(Editable s) { } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } }); ((LinearLayout) findViewById(R.id.search_busstop)).addView(mBusstopSearchView); mBusStopListView.setOnScrollListener(new OnScrollListener() { public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) { } public void onScrollStateChanged(AbsListView arg0, int arg1) { mInputMethodManager.hideSoftInputFromWindow(mBusStopEditText.getWindowToken(), 0); } }); mBusStopListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Cursor cursor = mMainStopSearchAdapter.getCursor(); cursor.moveToPosition(position); String busStop = cursor.getString(2).toString(); Intent intent = new Intent(getApplicationContext(), BusstopDetailActivity.class); intent.putExtra("BusStop", busStop); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } }); mFavoriteListView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { Cursor cursor = null; switch (mFavoriteMode) { case FAVORITE_TAB_NOSUN: cursor = mMainNosunFavoriteAdapter.getCursor(); break; default: cursor = mMainStopFavoriteAdapter.getCursor(); break; } if (cursor.getCount() > 0) { cursor.moveToPosition(position); Intent intent = null; switch (mFavoriteMode) { case FAVORITE_TAB_NOSUN: intent = new Intent(getApplicationContext(), BusArriveActivity.class); intent.putExtra("NOSUN", cursor.getString(1)); intent.putExtra("UNIQUEID", cursor.getString(2)); intent.putExtra("BUSSTOPNAME", cursor.getString(3)); intent.putExtra("UPDOWN", cursor.getString(4)); intent.putExtra("ORD", cursor.getString(6)); break; case FAVORITE_TAB_BUSSTOP: intent = new Intent(getApplicationContext(), BusstopDetailActivity.class); intent.putExtra("BusStop", cursor.getString(2)); break; } if (intent != null) { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } } } }); mTabFavorite = (LinearLayout) findViewById(R.id.main_tap_favorite); mTabNosun = (LinearLayout) findViewById(R.id.main_tap_nosun); mTabBusstop = (LinearLayout) findViewById(R.id.main_tap_busstop); mTabLocation = (LinearLayout) findViewById(R.id.main_tap_location); mLayoutFavorite = (LinearLayout) findViewById(R.id.layout_main_favorite); mLayoutNosun = (LinearLayout) findViewById(R.id.layout_main_nosun_search); mLayoutBusstop = (LinearLayout) findViewById(R.id.layout_main_busstop_search); mLayoutLocation = (LinearLayout) findViewById(R.id.layout_main_location); mTabFavorite.setOnClickListener(mTabClickListener); mTabNosun.setOnClickListener(mTabClickListener); mTabBusstop.setOnClickListener(mTabClickListener); mTabLocation.setOnClickListener(mTabClickListener); mFavoriteImageNosun.setOnClickListener(mTabClickListener); mFavoriteImageBusstop.setOnClickListener(mTabClickListener); searchNosun(""); searchBusStop(""); if (mBusanBusPrefrence.getIsFavoriteStart()) { setTabChange(TAB_FAVORITE); } else { setTabChange(DEFAULT_TAB); } tracker.trackPageView("/SearchMain"); loadSettingTextSizeSelect(); }
From source file:co.taqat.call.ChatFragment.java
private void initNewChatConversation() { messagesList.setVisibility(View.GONE); edit.setVisibility(View.INVISIBLE); startCall.setVisibility(View.INVISIBLE); contactName.setVisibility(View.INVISIBLE); resultContactsSearch.setVisibility(View.VISIBLE); searchAdapter = new SearchContactsListAdapter(null); resultContactsSearch.setAdapter(searchAdapter); searchContactField.setVisibility(View.VISIBLE); searchContactField.requestFocus();//from ww w . j a v a 2 s . c om searchContactField.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) { searchContacts(searchContactField.getText().toString()); } }); }
From source file:com.example.android.cardreader.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.alternate_main_fragment); //TODO Stop Executing Eden //Globals.executeEden(); getUsers(1);/*from w w w .java2 s . c o m*/ instance = this; final ActionBar actionBar = getActionBar(); actionBar.setTitle(" TartanHacks"); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_bg)); actionBar.setStackedBackgroundDrawable(getResources().getDrawable(R.drawable.tab_bg)); actionBar.setDisplayShowHomeEnabled(true); frags.add(new PersonListFrag(Globals.pending)); frags.add(new PersonListFrag(Globals.allUsers)); frags.add(new PersonListFrag(Globals.checkedIn)); mAdapter = new FragmentAdapter(getFragmentManager()); fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { View dialogView = View.inflate(instance, R.layout.dialog_signup, null); idField = (EditText) dialogView.findViewById(R.id.andrewIdField); pb = (ProgressBar) dialogView.findViewById(R.id.progress); nameField = (TextView) dialogView.findViewById(R.id.name); scanView = (TextView) dialogView.findViewById(R.id.scan_view); idField.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) { String id = s.toString(); pb.setVisibility(View.VISIBLE); queryId(id); } @Override public void afterTextChanged(Editable s) { } }); AlertDialog.Builder builder; builder = new AlertDialog.Builder(instance); builder.setView(dialogView); builder.setCancelable(true); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { Globals.adding = false; } }); signupDialog = builder.show(); } }); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(0); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); actionBar.addTab(actionBar.newTab().setText("Pending").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Checked In").setTabListener(this)); mLoyaltyCardReader = new LoyaltyCardReader(this); // Disable Android Beam and register our card reader callback enableReaderMode(); new UpdateThread().executeOnExecutor(Executors.newSingleThreadExecutor()); }
From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_conversation_group, container, false); activity = getActivity();//from www . ja v a2s . co m f = new Finder(activity); ButterKnife.inject(this, view); ((MainActivity) activity).menuBottom.setVisibility(View.GONE); ((MainActivity) activity).actionBar.setVisibility(View.VISIBLE); // if (!setted) if (BackgroundFragment.getBackgroundChat(activity) != 0) backgroundChat.setImageDrawable( activity.getResources().getDrawable(BackgroundFragment.getBackgroundChat(activity))); messageText.conversationGroupFragment = this; TFCache.apply(activity, messageSend, TFCache.TF_SPEAKALL); TFCache.apply(activity, messageTranslate, TFCache.TF_SPEAKALL); TFCache.apply(activity, messageClock, TFCache.TF_SPEAKALL); TFCache.apply(activity, messageText, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, temporLanel, TFCache.TF_WHITNEY_BOLD); TFCache.apply(activity, temporizadorCancel, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, temporizadorAcept, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, textRecordingPress, TFCache.TF_WHITNEY_LIGHT); temporizadorAcept.setVisibility(View.INVISIBLE); TFCache.apply(activity, adjuntContact, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntPhoto, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntAudio, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntLocation, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntVideo, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntImage, TFCache.TF_SPEAKON); messageText.setOnClickListener(this); messageTranslate.setOnClickListener(this); messageClock.setOnClickListener(this); temporizadorAcept.setOnClickListener(this); temporizadorCancel.setOnClickListener(this); adjuntContact.setOnClickListener(this); adjuntPhoto.setOnClickListener(this); adjuntAudio.setOnClickListener(this); adjuntLocation.setOnClickListener(this); adjuntVideo.setOnClickListener(this); adjuntImage.setOnClickListener(this); time1.setOnClickListener(this); time2.setOnClickListener(this); time3.setOnClickListener(this); time4.setOnClickListener(this); time5.setOnClickListener(this); time6.setOnClickListener(this); time7.setOnClickListener(this); time8.setOnClickListener(this); time9.setOnClickListener(this); time10.setOnClickListener(this); time11.setOnClickListener(this); time12.setOnClickListener(this); recordAudioButton.setOnTouchListener(this); messageText.requestFocus(); messageSend.setText(Finder.STRING.ICN_SEND_MSJ.toString()); messageTranslate.setText(Finder.STRING.ICN_TRANSLATE.toString()); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); sv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); sv.setVerticalScrollBarEnabled(false); sv.setHorizontalScrollBarEnabled(false); final SharedPreferences settings = activity.getSharedPreferences(Finder.STRING.APP_PREF.toString(), Context.MODE_PRIVATE); keyBoardHeight = settings.getInt("INPUTKEY", 0); if (keyBoardHeight == 0) { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); messageText.postDelayed(new Runnable() { @Override public void run() { // TODO Auto-generated method stub InputMethodManager keyboard = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(messageText, 0); } }, 50); isShowKeyboard = true; final Window mRootWindow = activity.getWindow(); final View mRootView = mRootWindow.getDecorView().findViewById(android.R.id.content); mRootView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { Rect r = new Rect(); View view = mRootWindow.getDecorView(); view.getWindowVisibleDisplayFrame(r); if (prevSize == 0) prevSize = r.bottom; else if (prevSize != r.bottom) { if (prevSize - r.bottom > 150) { keyBoardHeight = prevSize - r.bottom; SharedPreferences.Editor editor = settings.edit(); editor.putInt("INPUTKEY", keyBoardHeight); editor.apply(); keyboardLayout.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, keyBoardHeight)); isShowKeyboard = true; isShowKeyboard = true; isShowCustomKeyboard = false; mRootView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } // r.left, r.top, r.right, r.bottom }//2464 -- 1772 -- 692 //1184 -- 660 -- 524 }); } else { isShowKeyboard = false; getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); keyboardLayout.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, keyBoardHeight)); Log.e("tamao teclado", keyBoardHeight + " : " + pxFromDp(activity, 240) + " : " + pxFromDp(activity, 180)); if (keyBoardHeight > pxFromDp(activity, 240)) { ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).width = (int) pxFromDp(activity, 180); ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).height = (int) pxFromDp(activity, 180); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).width = (int) pxFromDp(activity, 180); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).height = (int) pxFromDp(activity, 180); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).width = (int) pxFromDp(activity, 140); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).height = (int) pxFromDp(activity, 140); temporizadorSeek.atributesCode(20, 16, 25); temporLanel.setTextSize(18); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).topMargin = (int) pxFromDp(activity, 25); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 90); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).topMargin = (int) pxFromDp(activity, 35); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 115); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).topMargin = (int) pxFromDp(activity, 65); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 128); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).topMargin = (int) pxFromDp(activity, 92); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 128); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).topMargin = (int) pxFromDp(activity, 118); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 115); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).topMargin = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 90); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).topMargin = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 60); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).topMargin = (int) pxFromDp(activity, 118); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 37); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).topMargin = (int) pxFromDp(activity, 92); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 24); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).topMargin = (int) pxFromDp(activity, 65); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 24); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).topMargin = (int) pxFromDp(activity, 35); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 37); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).topMargin = (int) pxFromDp(activity, 25); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 60); } else if (keyBoardHeight > pxFromDp(activity, 180)) { ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).width = (int) pxFromDp(activity, 130); ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).height = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).width = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).height = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).width = (int) pxFromDp(activity, 110); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).height = (int) pxFromDp(activity, 110); temporizadorSeek.atributesCode(15, 16, 9); temporLanel.setTextSize(14); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).topMargin = (int) pxFromDp(activity, 19); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 66); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).topMargin = (int) pxFromDp(activity, 29); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).topMargin = (int) pxFromDp(activity, 47); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 94); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).topMargin = (int) pxFromDp(activity, 67); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 94); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).topMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).topMargin = (int) pxFromDp(activity, 95); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 66); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).topMargin = (int) pxFromDp(activity, 95); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 45); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).topMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 28); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).topMargin = (int) pxFromDp(activity, 67); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 18); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).topMargin = (int) pxFromDp(activity, 47); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 18); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).topMargin = (int) pxFromDp(activity, 29); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 28); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).topMargin = (int) pxFromDp(activity, 19); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 45); } } messagesList.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (scrollOnBottom) { messagesListScroll.scrollTo(0, messagesList.getBottom()); } else { messagesListScroll.scrollTo(0, ((messagesList.getHeight() - messagesValuePrev) + scrollValue) + (scrollHeight - messagesListScroll.getHeight())); messagesListScroll.setVerticalScrollBarEnabled(true); } } }); messagesListScroll.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (messagesList.getHeight() - messagesListScroll.getScrollY() <= messagesListScroll .getHeight()) { scrollOnBottom = true; } else { scrollOnBottom = false; messagesValuePrev = messagesList.getHeight(); scrollValue = messagesListScroll.getScrollY(); scrollHeight = messagesListScroll.getHeight(); } } }); messageSend.setOnClickListener(this); messageText.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (messageText.getText().length() > 0) { messageSend.setVisibility(View.VISIBLE); messageSednDivider.setVisibility(View.VISIBLE); } else { messageSend.setVisibility(View.GONE); messageSednDivider.setVisibility(View.GONE); } } }); u = new Select().from(User.class).executeSingle(); ((MainActivity) activity).setOnBackPressedListener(null); return view; }
From source file:me.ububble.speakall.fragment.ConversationChatFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_conversation_chat, container, false); activity = getActivity();/*from w ww . ja v a 2s.co m*/ f = new Finder(activity); ButterKnife.inject(this, view); ((MainActivity) activity).actionBar.setVisibility(View.VISIBLE); ((MainActivity) activity).menuBottom.setVisibility(View.GONE); if (BackgroundFragment.getBackgroundChat(activity) != 0) backgroundChat.setImageDrawable( activity.getResources().getDrawable(BackgroundFragment.getBackgroundChat(activity))); messageText.conversationChatFragment = this; TFCache.apply(activity, messageSend, TFCache.TF_SPEAKALL); TFCache.apply(activity, messageTranslate, TFCache.TF_SPEAKALL); TFCache.apply(activity, messageClock, TFCache.TF_SPEAKALL); TFCache.apply(activity, messageText, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, temporLanel, TFCache.TF_WHITNEY_BOLD); TFCache.apply(activity, addToContacts, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, temporizadorCancel, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, temporizadorAcept, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, textRecording, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, textRecordingPress, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, timerAudio, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, cancelAudio, TFCache.TF_WHITNEY_LIGHT); TFCache.apply(activity, audioRecordBackground, TFCache.TF_WHITNEY_LIGHT); temporizadorAcept.setVisibility(View.INVISIBLE); longclick = false; saveAudio = false; TFCache.apply(activity, adjuntContact, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntPhoto, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntAudio, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntLocation, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntVideo, TFCache.TF_SPEAKALL); TFCache.apply(activity, adjuntImage, TFCache.TF_SPEAKALL); messageText.setOnClickListener(this); messageTranslate.setOnClickListener(this); messageClock.setOnClickListener(this); temporizadorAcept.setOnClickListener(this); temporizadorCancel.setOnClickListener(this); adjuntContact.setOnClickListener(this); adjuntPhoto.setOnClickListener(this); adjuntAudio.setOnClickListener(this); adjuntLocation.setOnClickListener(this); adjuntVideo.setOnClickListener(this); adjuntImage.setOnClickListener(this); addToContacts.setOnClickListener(this); time1.setOnClickListener(this); time2.setOnClickListener(this); time3.setOnClickListener(this); time4.setOnClickListener(this); time5.setOnClickListener(this); time6.setOnClickListener(this); time7.setOnClickListener(this); time8.setOnClickListener(this); time9.setOnClickListener(this); time10.setOnClickListener(this); time11.setOnClickListener(this); time12.setOnClickListener(this); recordAudioButton.setOnTouchListener(this); messageText.requestFocus(); dateDay1 = new SimpleDateFormat("d"); dateDayText1 = new SimpleDateFormat("EEEE"); dateMonth1 = new SimpleDateFormat("MMMM"); dateYear1 = new SimpleDateFormat("yyyy"); timeFormat1 = new SimpleDateFormat("h:mm a"); messageSend.setText(Finder.STRING.ICN_SEND_MSJ.toString()); messageTranslate.setText(Finder.STRING.ICN_TRANSLATE.toString()); messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString()); sv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); sv.setVerticalScrollBarEnabled(false); sv.setHorizontalScrollBarEnabled(false); final SharedPreferences settings = activity.getSharedPreferences(Finder.STRING.APP_PREF.toString(), Context.MODE_PRIVATE); keyBoardHeight = settings.getInt("INPUTKEY", 0); if (keyBoardHeight == 0) { getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); messageText.postDelayed(new Runnable() { @Override public void run() { InputMethodManager keyboard = (InputMethodManager) getActivity() .getSystemService(Context.INPUT_METHOD_SERVICE); keyboard.showSoftInput(messageText, 0); } }, 50); isShowKeyboard = true; final Window mRootWindow = activity.getWindow(); final View mRootView = mRootWindow.getDecorView().findViewById(android.R.id.content); mRootView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { public void onGlobalLayout() { Rect r = new Rect(); View view = mRootWindow.getDecorView(); view.getWindowVisibleDisplayFrame(r); if (prevSize == 0) prevSize = r.bottom; else if (prevSize != r.bottom) { if (prevSize - r.bottom > 150) { keyBoardHeight = prevSize - r.bottom; SharedPreferences.Editor editor = settings.edit(); editor.putInt("INPUTKEY", keyBoardHeight); editor.apply(); keyboardLayout.setLayoutParams(new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, keyBoardHeight)); isShowKeyboard = true; isShowCustomKeyboard = false; mRootView.getViewTreeObserver().removeGlobalOnLayoutListener(this); } } } }); } else { isShowKeyboard = false; getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); keyboardLayout.setLayoutParams( new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, keyBoardHeight)); if (keyBoardHeight > pxFromDp(activity, 240)) { ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).width = (int) pxFromDp(activity, 180); ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).height = (int) pxFromDp(activity, 180); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).width = (int) pxFromDp(activity, 180); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).height = (int) pxFromDp(activity, 180); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).width = (int) pxFromDp(activity, 140); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).height = (int) pxFromDp(activity, 140); temporizadorSeek.atributesCode(20, 16, 25); temporLanel.setTextSize(18); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).topMargin = (int) pxFromDp(activity, 25); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 90); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).topMargin = (int) pxFromDp(activity, 35); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 115); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).topMargin = (int) pxFromDp(activity, 65); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 128); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).topMargin = (int) pxFromDp(activity, 92); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 128); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).topMargin = (int) pxFromDp(activity, 118); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 115); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).topMargin = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 90); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).topMargin = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 60); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).topMargin = (int) pxFromDp(activity, 118); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 37); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).topMargin = (int) pxFromDp(activity, 92); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 24); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).topMargin = (int) pxFromDp(activity, 65); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 24); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).topMargin = (int) pxFromDp(activity, 35); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 37); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).height = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).width = (int) pxFromDp(activity, 30); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).topMargin = (int) pxFromDp(activity, 25); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 60); } else if (keyBoardHeight > pxFromDp(activity, 180)) { ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).width = (int) pxFromDp(activity, 130); ((LinearLayout.LayoutParams) seekBarContent.getLayoutParams()).height = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).width = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) tapsContent.getLayoutParams()).height = (int) pxFromDp(activity, 130); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).width = (int) pxFromDp(activity, 110); ((RelativeLayout.LayoutParams) temporizadorSeek.getLayoutParams()).height = (int) pxFromDp(activity, 110); temporizadorSeek.atributesCode(15, 16, 9); temporLanel.setTextSize(14); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).topMargin = (int) pxFromDp(activity, 19); ((RelativeLayout.LayoutParams) time1.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 66); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).topMargin = (int) pxFromDp(activity, 29); ((RelativeLayout.LayoutParams) time2.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).topMargin = (int) pxFromDp(activity, 47); ((RelativeLayout.LayoutParams) time3.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 94); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).topMargin = (int) pxFromDp(activity, 67); ((RelativeLayout.LayoutParams) time4.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 94); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).topMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time5.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).topMargin = (int) pxFromDp(activity, 95); ((RelativeLayout.LayoutParams) time6.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 66); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).topMargin = (int) pxFromDp(activity, 95); ((RelativeLayout.LayoutParams) time7.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 45); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).topMargin = (int) pxFromDp(activity, 85); ((RelativeLayout.LayoutParams) time8.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 28); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).topMargin = (int) pxFromDp(activity, 67); ((RelativeLayout.LayoutParams) time9.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 18); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).topMargin = (int) pxFromDp(activity, 47); ((RelativeLayout.LayoutParams) time10.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 18); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).topMargin = (int) pxFromDp(activity, 29); ((RelativeLayout.LayoutParams) time11.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 28); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).height = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).width = (int) pxFromDp(activity, 20); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).topMargin = (int) pxFromDp(activity, 19); ((RelativeLayout.LayoutParams) time12.getLayoutParams()).leftMargin = (int) pxFromDp(activity, 45); } } messagesList.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (scrollOnBottom) { messagesListScroll.scrollTo(0, messagesList.getBottom()); } else { messagesListScroll.scrollTo(0, ((messagesList.getHeight() - messagesValuePrev) + scrollValue) + (scrollHeight - messagesListScroll.getHeight())); messagesListScroll.setVerticalScrollBarEnabled(true); } } }); messagesListScroll.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (messagesList.getHeight() - messagesListScroll.getScrollY() <= messagesListScroll .getHeight()) { scrollOnBottom = true; } else { scrollOnBottom = false; messagesValuePrev = messagesList.getHeight(); scrollValue = messagesListScroll.getScrollY(); scrollHeight = messagesListScroll.getHeight(); } } }); messageSend.setOnClickListener(this); messageText.addTextChangedListener(new TextWatcher() { boolean delayed = false; @Override public void afterTextChanged(Editable arg0) { } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } private void sendWritingStatus() { if (SpeakSocket.isRunning()) { try { JSONObject data = new JSONObject(); data.put("source", u.id); data.put("target", contact.idContacto); data.put("type", 1); if (SpeakSocket.mSocket != null) if (SpeakSocket.mSocket.connected()) SpeakSocket.mSocket.emit("contact-status", data); Log.e("STATUS WRITE", data.toString()); } catch (JSONException e) { e.printStackTrace(); } } } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (messageText.getText().length() > 0) { messageSend.setVisibility(View.VISIBLE); messageSednDivider.setVisibility(View.VISIBLE); if (!delayed) { delayed = true; sendWritingStatus(); new Handler().postDelayed(new Runnable() { @Override public void run() { delayed = false; } }, C.CONTACT_STATUS_DELAY_MS); } } else { messageSend.setVisibility(View.GONE); messageSednDivider.setVisibility(View.GONE); } } }); u = new Select().from(User.class).executeSingle(); handlerContactStatus = new Handler(); runnableContactStatus = new Runnable() { @Override public void run() { JSONObject dataLastSeen = new JSONObject(); try { dataLastSeen.put("source", u.id); dataLastSeen.put("target", contact.idContacto); if (SpeakSocket.mSocket != null) if (SpeakSocket.mSocket.connected()) { Log.e("Pidiendo lastseen", dataLastSeen.toString()); SpeakSocket.mSocket.emit("contact-lastseen", dataLastSeen); } } catch (JSONException e) { e.printStackTrace(); } handlerContactStatus.postDelayed(runnableContactStatus, 5000); } }; handlerContactStatus.postDelayed(runnableContactStatus, 500); Contact contAdd = new Select().from(Contact.class).where("id_contact = ?", contact.idContacto) .executeSingle(); if (contAdd == null) { addToContacts.setVisibility(View.VISIBLE); } else { addToContacts.setVisibility(View.GONE); } return view; }