List of usage examples for android.widget TextView getText
@ViewDebug.CapturedViewProperty
public CharSequence getText()
From source file:com.android.calendar.EventInfoFragment.java
private void addFieldToAccessibilityEvent(List<CharSequence> text, TextView tv, ExpandableTextView etv) { CharSequence cs;/*from w w w.java 2 s.c om*/ if (tv != null) { cs = tv.getText(); } else if (etv != null) { cs = etv.getText(); } else { return; } if (!TextUtils.isEmpty(cs)) { cs = cs.toString().trim(); if (cs.length() > 0) { text.add(cs); text.add(PERIOD_SPACE); } } }
From source file:com.justone.android.main.MainActivity.java
@Override protected void onStart() { super.onStart(); if (this.justOne.getCurrentTabIndex() != 0) { tabs.setCurrentTab(this.justOne.getCurrentTabIndex()); }//from w w w .java 2 s . com mStatusTracker.setStatus(mActivityName, getString(R.string.on_start)); Utils.printStatus(mStatusView, mStatusAllView); /** * Activity * timeViewHandler Handler * MSG_UPDATE int */ new Thread(new Runnable() { @Override public void run() { isUpdate = true; int currentTab = 0; String id = ""; TextView idView; View targetView = null; boolean isNew = false; String currentUrl = ""; do { try { Thread.sleep(100); } catch (InterruptedException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (currentTab != tabs.getCurrentTab()) isUpdate = true; if (isUpdate && main_item != null) { currentTab = tabs.getCurrentTab(); switch (currentTab) { //home case 0: if (main_item == null) break; targetView = main_item.findViewById(R.id.homeTab); if (targetView == null) break; if (targetView.findViewById(R.id.home_id) != null) { targetView = main_item.findViewById(R.id.homeTab); idView = (TextView) targetView.findViewById(R.id.home_id); id = (String) idView.getText(); if (id == "") id = "0"; if (currentId != 0) { if (leftOrRight == 1) { currentId = currentId - 1; leftOrRight = 0; if (currentId <= 0) break; } else if (leftOrRight == 2) { currentId = currentId + 1; leftOrRight = 0; if (currentId > maxId) break; } } if (currentId > -1 && currentId <= maxId) { isUpdate = false; } if (currentId == 0) { currentUrl = url + "home"; isNew = true; } else currentUrl = url + "home&id=" + currentId; /*synchronized (this){ Thread.yield();} System.out.println("wait.................");*/ } break; // case 1: if (main_item == null) break; if (main_item.findViewById(R.id.tab2) == null) break; if (main_item.findViewById(R.id.tab2).findViewById(R.id.list_id) != null) { targetView = main_item.findViewById(R.id.tab2); idView = (TextView) targetView.findViewById(R.id.list_id); id = (String) idView.getText(); if (id == "") id = "0"; if (currentId != 0) { if (leftOrRight == 1) { currentId = currentId - 1; leftOrRight = 0; if (currentId <= 0) break; } else if (leftOrRight == 2) { currentId = currentId + 1; leftOrRight = 0; if (currentId > maxId) break; } } if (currentId > -1 && currentId <= maxId) { isUpdate = false; } if (currentId == 0) { currentUrl = url + "list"; isNew = true; } else currentUrl = url + "list&id=" + currentId; } break; // case 2: if (main_item == null) break; if (main_item.findViewById(R.id.QAtab) == null) break; if (main_item.findViewById(R.id.QAtab).findViewById(R.id.QA_id) != null) { targetView = main_item.findViewById(R.id.QAtab); idView = (TextView) targetView.findViewById(R.id.QA_id); id = (String) idView.getText(); if (id == "") id = "0"; if (currentId != 0) { if (leftOrRight == 1) { currentId = currentId - 1; leftOrRight = 0; if (currentId <= 0) { break; } } else if (leftOrRight == 2) { currentId = currentId + 1; leftOrRight = 0; if (currentId > maxId) { break; } } } if (currentId > -1 && currentId <= maxId) { isUpdate = false; } if (currentId == 0) { currentUrl = url + "QA"; isNew = true; } else currentUrl = url + "QA&id=" + currentId; } break; } if (isUpdate == false) { try { viewHandler.sendMessage(Message.obtain(viewHandler, 0, currentId, 1, targetView)); data = dataOp.getDataAsyn(currentUrl); if (isNew) { //maxId= getDataId(data); maxId = JustOne.getMaxId(); isNew = false; } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } viewHandler.sendMessage(Message.obtain(viewHandler, 1, currentId, 1, targetView)); } } } while (true); } }).start(); //viewMap.put("list", this.listAdapter); try { checkVersion(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:com.aslanoba.hwc.SettingsActivity.java
/** * Click handler for the list items. Will create the appropriate edit * box for the clicked setting.//w w w. j ava 2s . c o m */ @Override public void onListItemClick(ListView oParent, View v, int iPos, long id) { final ListView oParentListView = oParent; final SettingsListItem oItem = m_filteredSettings.get(iPos); if (oItem instanceof ChoiceSettingsListItem) { final ChoiceSettingsListItem oChoiceItem = (ChoiceSettingsListItem) oItem; // Show dialog new AlertDialog.Builder(SettingsActivity.this) .setTitle(getString(R.string.Label_Edit) + " " + oItem.m_sLabel) .setSingleChoiceItems(oChoiceItem.m_asText, oChoiceItem.m_iSelectedItem, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { oChoiceItem.select(whichButton); if (oItem.m_iPropId == PropertyID.CONNECTION_AUTO_REGISTRATION_HINT) { m_iRegistrationMethod = (Integer) oChoiceItem.m_oValue; if (m_iRegistrationMethod == Settings.REGISTRATION_METHOD.CERTIFICATE) { handleLocalCertificateSelection(); } } // refresh in ui refreshList(); oParentListView.invalidate(); // Close dialog dialog.dismiss(); } }) .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Close dialog dialog.dismiss(); } }).show(); } else { // inflate the xml layout final View oView = m_oInflater.inflate(R.layout.settings_edit, null); TextView tv = (TextView) oView.findViewById(R.id.TextViewEditSettings); if (tv != null) tv.setText(getItemLabel(oItem)); // set value tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); if (tv != null) tv.setText(oItem.m_oValue.toString()); // special input validator for integers if (oItem.m_oValue instanceof Integer) tv.setInputType(InputType.TYPE_CLASS_NUMBER); if (oItem.m_bPassword) tv.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); // show dialog, valid value when user clicks ok button new AlertDialog.Builder(this).setTitle(getString(R.string.Label_Edit) + " " + getItemLabel(oItem)) .setView(oView).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { TextView tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); String sText = tv.getText().toString(); if (oItem.m_oValue instanceof Integer) oItem.m_oValue = Integer.parseInt(sText); else if (oItem.m_oValue instanceof Boolean) oItem.m_oValue = Boolean.parseBoolean(sText); else oItem.m_oValue = sText; InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); //validate the input value if (!validateField(oItem)) { // validation failed, reset to original value oItem.m_oValue = oItem.m_oOrigValue; showValidationErrorDialog(oItem.m_sLabel); } else { // refresh in ui refreshList(); oParentListView.invalidate(); } } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { TextView tv = (TextView) oView.findViewById(R.id.EditTextEditSettings); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); dialog.dismiss(); } }).show(); } }
From source file:com.zen.androidhtmleditor.AHEActivity.java
public void deleteFile(View v) { View rl = v;//from www .j a va 2 s .c o m TextView typeId = (TextView) rl.findViewById(R.id.typeId); TextView fileFolderName = (TextView) rl.findViewById(R.id.fileFolderName); String name = fileFolderName.getText().toString(); String type = typeId.getText().toString(); int i = 0; int pos = 0; String file = ""; for (String[] s : alrts) { if (s[0].equals(name) && s[1].equals(type)) { Log.i("List", "Removing " + s[0] + "=" + name + "," + s[1] + "=" + type); file = s[0]; pos = i; break; //alrts.remove(i); } i++; } //Log.i("remove file",folderPath+file); SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); int connectedTo = settings.getInt("connectedTo", -1); if (connectedTo != -1) { if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result s = results.get(connectedTo); if (s.serverName != "" && s.userName != "" && s.port.trim() != "") { new DeleteFileFolderTask(s.serverName, s.userName, s.passWord, type, file, s.sftp, s.port, pos) .execute(); } } } //arrayAdapter.notifyDataSetChanged(); }
From source file:ca.ualberta.cs.drivr.RequestsListAdapter.java
/** * Called when the view holder is wants to bind the request at a certain position in the list. * @param viewHolder/*from w w w .j av a 2 s. c o m*/ * @param position */ @Override public void onBindViewHolder(final RequestsListAdapter.ViewHolder viewHolder, final int position) { final Request request = requestsToDisplay.get(position); // Get the views to update final TextView otherUserNameTextView = viewHolder.otherUserNameTextView; final TextView descriptionTextView = viewHolder.descriptionTextView; final TextView fareTextView = viewHolder.fareTextView; final TextView routeTextView = viewHolder.routeTextView; final TextView statusTextView = viewHolder.statusTextView; final ImageView callImageView = viewHolder.callImageView; final ImageView emailImageView = viewHolder.emailImageView; final ImageView checkImageView = viewHolder.checkMarkImageView; final ImageView deleteImageView = viewHolder.xMarkImageView; // Todo Hide Image Views until correct Request State if (request.getRequestState() != RequestState.CONFIRMED) { checkImageView.setVisibility(View.INVISIBLE); } if (request.getRequestState() != RequestState.PENDING) { deleteImageView.setVisibility(View.INVISIBLE); } // Show the other person's name final DriversList drivers = request.getDrivers(); // Get the username of the other user if (userManager.getUserMode() == UserMode.RIDER) { final String multipleDrivers = "Multiple Drivers Accepted"; final String driverUsername = drivers.size() == 1 ? drivers.get(0).getUsername() : "No Driver Yet"; otherUserNameTextView.setText(drivers.size() > 1 ? multipleDrivers : driverUsername); } else { otherUserNameTextView.setText(request.getRider().getUsername()); } // If the request has a description, show it. Otherwise, hide te description if (Strings.isNullOrEmpty(request.getDescription())) descriptionTextView.setVisibility(View.GONE); else descriptionTextView.setText(request.getDescription()); // Show the fare fareTextView.setText("$" + request.getFareString()); // Show the route routeTextView.setText(request.getRoute()); // Driver User otherUserNameTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String otherUsername = otherUserNameTextView.getText().toString(); // there exists drivers if (otherUsername != "No Driver Yet") { if (otherUsername != "Multiple Drivers Accepted") { Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create(); ElasticSearch elasticSearch = new ElasticSearch( UserManager.getInstance().getConnectivityManager()); User user = elasticSearch.loadUser(otherUsername); String driverString = gson.toJson(user, User.class); Intent intent = new Intent(context, DriverProfileActivity.class); intent.putExtra(DriverProfileActivity.DRIVER, driverString); context.startActivity(intent); } else { startMultipleDriverIntent(request); } } } }); routeTextView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Gson gson = new GsonBuilder().registerTypeAdapter(Uri.class, new UriSerializer()).create(); String requestString = gson.toJson(request, Request.class); Intent intent = new Intent(context, RequestActivity.class); intent.putExtra("UniqueID", "From_RequestListActivity"); intent.putExtra(RequestActivity.EXTRA_REQUEST, requestString); context.startActivity(intent); } }); // Show the status text statusTextView.setText(request.getRequestState().toString()); // Add a listener to the call image callImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (drivers.size() == 0) { Toast.makeText(context, "No driver number available at this time", Toast.LENGTH_SHORT).show(); } // Start Dialer else if (drivers.size() == 1) { Intent intent = new Intent(Intent.ACTION_CALL); String number; if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) { number = drivers.get(0).getPhoneNumber(); } else { number = request.getRider().getPhoneNumber(); } number = "tel:" + number; intent.setData(Uri.parse(number)); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } context.startActivity(intent); } else { startMultipleDriverIntent(request); } } }); // Add a listener to the email image emailImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (drivers.size() == 0) { Toast.makeText(context, "No driver email available at this time", Toast.LENGTH_SHORT).show(); } //http://stackoverflow.com/questions/8701634/send-email-intent else if (drivers.size() == 1) { Intent intent = new Intent(); ComponentName emailApp = intent.resolveActivity(context.getPackageManager()); ComponentName unsupportedAction = ComponentName .unflattenFromString("com.android.fallback/.Fallback"); boolean hasEmailApp = emailApp != null && !emailApp.equals(unsupportedAction); String email; if (UserManager.getInstance().getUserMode().equals(UserMode.RIDER)) { email = drivers.get(0).getEmail(); } else { email = request.getRider().getEmail(); } String subject = "Drivr Request: " + request.getId(); String body = "Drivr user " + drivers.get(0).getUsername(); if (hasEmailApp) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body); context.startActivity(Intent.createChooser(emailIntent, "Chooser Title")); } else { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", email, null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, ""); emailIntent.putExtra(Intent.EXTRA_TEXT, ""); context.startActivity(Intent.createChooser(emailIntent, "Send email...")); } } else { startMultipleDriverIntent(request); } } }); // Complete The Request checkImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(context, RequestCompletedActivity.class); intent.putExtra(RequestCompletedActivity.REQUEST_ID_EXTRA, request.getId()); context.startActivity(intent); } }); deleteImageView.setOnClickListener(new View.OnClickListener() { // Todo Delete the Request @Override public void onClick(View v) { v.getContext(); ElasticSearch elasticSearch = new ElasticSearch( (ConnectivityManager) v.getContext().getSystemService(Context.CONNECTIVITY_SERVICE)); elasticSearch.deleteRequest(request.getId()); UserManager userManager = UserManager.getInstance(); userManager.getRequestsList().removeById(request); userManager.notifyObservers(); requestsToDisplay.remove(request); notifyItemRemoved(viewHolder.getAdapterPosition()); } }); }
From source file:com.zen.androidhtmleditor.AHEActivity.java
public void uploadFile() { ndialog = new Dialog(AHEActivity.this); ndialog.requestWindowFeature(Window.FEATURE_NO_TITLE); ndialog.setContentView(R.layout.uploadfilediag); ndialog.setCancelable(true);/*from w ww . j av a 2s.c o m*/ Button lb = (Button) ndialog.findViewById(R.id.localBackButton); lstLocal = (ListView) ndialog.findViewById(R.id.list); // lstTest.setDividerHeight(10); lstLocal.setPadding(0, 5, 0, 5); File sdCardRoot = Environment.getExternalStorageDirectory(); File yourDir = new File(sdCardRoot, localPath); localalrts = new ArrayList<String[]>(); for (File f : yourDir.listFiles()) { if (f.isDirectory()) { String values[] = { f.getName(), "folder" }; localalrts.add(values); //Log.i("localDirectory",f.getName()); } } for (File f : yourDir.listFiles()) { if (f.isFile()) { //Log.i("localFile",f.getName()); String values[] = { f.getName(), "file" }; localalrts.add(values); } } //localPath = localPath+"/"+fn+"/"; lb.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String[] localPathBits = localPath.split("/"); localPath = ""; for (int i = 0; i < localPathBits.length - 1; i++) { localPath += localPathBits[i] + "/"; } TextView lp = (TextView) ndialog.findViewById(R.id.localPath); lp.setText(localPath); uploadFileList(); } }); arrayLocalAdapter = new FetchAdapter(AHEActivity.this, R.layout.listitems, localalrts); lstLocal.setAdapter(arrayLocalAdapter); lstLocal.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> av, View v, int pos, long id) { TextView type = (TextView) v.findViewById(R.id.typeId); String t = type.getText().toString(); TextView fileFolder = (TextView) v.findViewById(R.id.fileFolderName); String fn = fileFolder.getText().toString(); if (t.equals("folder")) { localPath = localPath + fn + "/"; TextView lp = (TextView) ndialog.findViewById(R.id.localPath); lp.setText(localPath); Button lb = (Button) ndialog.findViewById(R.id.localBackButton); if (localPath.equals("/")) { lb.setVisibility(View.GONE); } else { lb.setVisibility(View.VISIBLE); } uploadFileList(); } if (t.equals("file")) { SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); int connectedTo = settings.getInt("connectedTo", -1); if (connectedTo != -1) { if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result s = results.get(connectedTo); if (s.serverName != "" && s.userName != "") { String local = localPath + fn; String remote = folderPath + fn; new LocalUploadTask(s.serverName, s.userName, s.passWord, local, remote, s.sftp, s.port, 0).execute(); ndialog.dismiss(); } } } } //loadFileFolder(v); } }); ndialog.show(); }
From source file:com.zen.androidhtmleditor.AHEActivity.java
public void loadFileFolder(View v) { //RelativeLayout rl = (RelativeLayout)v.getParent(); //RelativeLayout rl = (RelativeLayout)v; View rl = v;/*from w w w . j ava 2s. c o m*/ TextView typeId = (TextView) rl.findViewById(R.id.typeId); TextView fileFolderName = (TextView) rl.findViewById(R.id.fileFolderName); if (typeId.getText().toString().equals("folder")) { arrayAdapter.clear(); folderPath = folderPath + fileFolderName.getText().toString() + "/"; SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); String currentServers = settings.getString("Accounts", ""); if (currentServers.equals("")) { } else { Gson gson = new Gson(); SearchResponse response = gson.fromJson(currentServers, SearchResponse.class); List<Result> results = response.data; Result l = results.get(connectedTo); if (l.serverName != "" && l.userName != "" && l.port.trim() != "") { if (l.sftp.equals("0") || l.sftp.equals("1") || l.sftp.equals("2")) { new MyFetchTask(l.serverName, l.userName, l.passWord, "folder", folderPath, l.sftp, l.port) .execute(); } else if (l.sftp.equals("3")) { new FetchSSLTask(l.serverName, l.userName, l.passWord, "folder", folderPath, l.sftp, l.port) .execute(); } } } //new MyFetchTask("zenstudio.com.au", "zenstudi", ".-x$%Wmd5b#C","folder",folderPath).execute(); } else { //tabCount++; int tabNum = tabHost.getTabWidget().getChildCount(); for (int i = 0; i < tabNum; i++) { Button b = (Button) tabHost.getTabWidget().getChildAt(i); //b.setBackgroundResource(R.drawable.tab_buttons_off); } SharedPreferences settings = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); SharedPreferences.Editor editor = settings.edit(); //editor.putString("fileName", folderPath+fileFolderName.getText().toString()); editor.putInt("connectedTo", connectedTo); editor.commit(); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); Button tview = new Button(this); tview.setLayoutParams(lp); tview.setText(fileFolderName.getText().toString()); tview.setTextColor(Color.WHITE); //tview.setBackgroundResource(R.drawable.tab_buttons_on); Intent editFileIntent = new Intent(AHEActivity.this, EditFile.class); editFileIntent.putExtra("fileName", folderPath + fileFolderName.getText().toString()); TabHost.TabSpec spec = tabHost.newTabSpec(folderPath + fileFolderName.getText().toString()) .setIndicator(tview).setContent(editFileIntent); tabHost.addTab(spec); tabHost.setCurrentTab(tabNum); tabHost.refreshDrawableState(); //Log.i("TabCount",String.valueOf(tabCount)); //Intent editFileIntent = new Intent(AHEActivity.this,EditFile.class); //startActivity(editFileIntent); //Intent editFileIntent = new Intent(AHEActivity.this,TabLoader.class); //startActivity(editFileIntent); } Log.i("clicked", typeId.toString()); }
From source file:com.android.calendar.EventInfoFragment.java
private void updateEvent(View view) { if (mEventCursor == null || view == null) { return;//from w ww.j av a 2 s.co m } Context context = view.getContext(); if (context == null) { return; } String eventName = mEventCursor.getString(EVENT_INDEX_TITLE); if (eventName == null || eventName.length() == 0) { eventName = getActivity().getString(R.string.no_title_label); } // 3rd parties might not have specified the start/end time when firing the // Events.CONTENT_URI intent. Update these with values read from the db. if (mStartMillis == 0 && mEndMillis == 0) { mStartMillis = mEventCursor.getLong(EVENT_INDEX_DTSTART); mEndMillis = mEventCursor.getLong(EVENT_INDEX_DTEND); if (mEndMillis == 0) { String duration = mEventCursor.getString(EVENT_INDEX_DURATION); if (!TextUtils.isEmpty(duration)) { try { Duration d = new Duration(); d.parse(duration); long endMillis = mStartMillis + d.getMillis(); if (endMillis >= mStartMillis) { mEndMillis = endMillis; } else { Log.d(TAG, "Invalid duration string: " + duration); } } catch (DateException e) { Log.d(TAG, "Error parsing duration string " + duration, e); } } if (mEndMillis == 0) { mEndMillis = mStartMillis; } } } mAllDay = mEventCursor.getInt(EVENT_INDEX_ALL_DAY) != 0; String location = mEventCursor.getString(EVENT_INDEX_EVENT_LOCATION); String description = mEventCursor.getString(EVENT_INDEX_DESCRIPTION); String rRule = mEventCursor.getString(EVENT_INDEX_RRULE); String eventTimezone = mEventCursor.getString(EVENT_INDEX_EVENT_TIMEZONE); mHeadlines.setBackgroundColor(mCurrentColor); // What if (eventName != null) { setTextCommon(view, R.id.title, eventName); } // When // Set the date and repeats (if any) String localTimezone = Utils.getTimeZone(mActivity, mTZUpdater); Resources resources = context.getResources(); String displayedDatetime = Utils.getDisplayedDatetime(mStartMillis, mEndMillis, System.currentTimeMillis(), localTimezone, mAllDay, context); String displayedTimezone = null; if (!mAllDay) { displayedTimezone = Utils.getDisplayedTimezone(mStartMillis, localTimezone, eventTimezone); } // Display the datetime. Make the timezone (if any) transparent. if (displayedTimezone == null) { setTextCommon(view, R.id.when_datetime, displayedDatetime); } else { int timezoneIndex = displayedDatetime.length(); displayedDatetime += " " + displayedTimezone; SpannableStringBuilder sb = new SpannableStringBuilder(displayedDatetime); ForegroundColorSpan transparentColorSpan = new ForegroundColorSpan( resources.getColor(R.color.event_info_headline_transparent_color)); sb.setSpan(transparentColorSpan, timezoneIndex, displayedDatetime.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); setTextCommon(view, R.id.when_datetime, sb); } // Display the repeat string (if any) String repeatString = null; if (!TextUtils.isEmpty(rRule)) { EventRecurrence eventRecurrence = new EventRecurrence(); eventRecurrence.parse(rRule); Time date = new Time(localTimezone); date.set(mStartMillis); if (mAllDay) { date.timezone = Time.TIMEZONE_UTC; } eventRecurrence.setStartDate(date); repeatString = EventRecurrenceFormatter.getRepeatString(mContext, resources, eventRecurrence, true); } if (repeatString == null) { view.findViewById(R.id.when_repeat).setVisibility(View.GONE); } else { setTextCommon(view, R.id.when_repeat, repeatString); } // Organizer view is setup in the updateCalendar method // Where if (location == null || location.trim().length() == 0) { setVisibilityCommon(view, R.id.where, View.GONE); } else { final TextView textView = mWhere; if (textView != null) { textView.setAutoLinkMask(0); textView.setText(location.trim()); try { textView.setText(Utils.extendedLinkify(textView.getText().toString(), true)); // Linkify.addLinks() sets the TextView movement method if it finds any links. // We must do the same here, in case linkify by itself did not find any. // (This is cloned from Linkify.addLinkMovementMethod().) MovementMethod mm = textView.getMovementMethod(); if ((mm == null) || !(mm instanceof LinkMovementMethod)) { if (textView.getLinksClickable()) { textView.setMovementMethod(LinkMovementMethod.getInstance()); } } } catch (Exception ex) { // unexpected Log.e(TAG, "Linkification failed", ex); } textView.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { try { return v.onTouchEvent(event); } catch (ActivityNotFoundException e) { // ignore return true; } } }); } } // Description if (description != null && description.length() != 0) { mDesc.setText(description); } // Launch Custom App if (Utils.isJellybeanOrLater()) { updateCustomAppButton(); } }
From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*//w w w . j a v a 2 s . c o m * device = (DeviceDescription) getIntent().getSerializableExtra( * Constants.INTENT_EXTRA_DEVICE); isCurrentDevice = * getIntent().getBooleanExtra( * Constants.INTENT_EXTRA_IS_CURRENT_DEVICE, false); * * List<DeviceDescription> devices = AppSettings.getInstance() * .getDevices(); String imei = * PhoneIdentityDataCollector.getImei(this); currentDevice = new * CurrentDeviceDescription(imei); OtherUtils.removeDeviceForImei(imei, * devices); */ this.setTitle(getString(R.string.average_results_title)); setContentView(R.layout.page_views); dbHelper = new DBHelper(SamKnowsAggregateStatViewerActivity.this); dbHelperAsync = new DBHelper(SamKnowsAggregateStatViewerActivity.this); adapter = new MyPagerAdapter(this); viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(adapter); // viewPager.setOffscreenPageLimit(3); final TextView tvHeader = (TextView) findViewById(R.id.textViewHeader); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int page) { tvHeader.setText(getString(R.string.page) + " " + (page + 1)); if (page == 0) { on_aggregate_page = true; boolean db_refresh = false; SamKnowsAggregateStatViewerActivity.this.setTitle(getString(R.string.average_results)); TextView timestamp; View v; v = viewPager.findViewWithTag(page); timestamp = (TextView) v.findViewById(R.id.average_results_title); timestamp.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); if (setTotalArchiveRecords()) { adapter = new MyPagerAdapter(SamKnowsAggregateStatViewerActivity.this); viewPager = (ViewPager) findViewById(R.id.viewPager); viewPager.setAdapter(adapter); } } else { TextView timestamp; View v; v = viewPager.findViewWithTag(page); timestamp = (TextView) v.findViewById(R.id.timestamp); timestamp.setContentDescription(getString(R.string.archive_result) + " " + timestamp.getText()); timestamp.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); on_aggregate_page = false; SamKnowsAggregateStatViewerActivity.this.setTitle(getString(R.string.archive_result)); } } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageScrollStateChanged(int state) { if (state == ViewPager.SCROLL_STATE_SETTLING) { } } }); Util.initializeFonts(this); Util.overrideFonts(this, findViewById(android.R.id.content)); }
From source file:com.filemanager.free.activities.MainActivity.java
private void searchView() { //search/*www .ja v a2 s . c o m*/ mHistoryDatabase = new SearchHistoryTable(this); mSuggestionsList = new ArrayList<>(); // SearchView basic attributes ------------------------------------------------------------ mSearchView = (SearchView) findViewById(R.id.searchView); if (mSearchView != null) { mSearchView.setVersion(SearchCodes.VERSION_MENU_ITEM); } mSearchView.setStyle(SearchCodes.STYLE_MENU_ITEM_CLASSIC); int mTheme = SearchCodes.THEME_LIGHT; mSearchView.setTheme(mTheme); // ----------------------------------------------------------------------------------------- mSearchView.setDivider(false); mSearchView.setHint("Search"); mSearchView.setHint(R.string.search); mSearchView.setHintSize(getResources().getDimension(R.dimen.search_text_medium)); mSearchView.setVoice(true); mSearchView.setVoiceText("Voice"); mSearchView.setAnimationDuration(300); mSearchView.setShadowColor(ContextCompat.getColor(this, R.color.search_shadow_layout)); mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { mSearchView.hide(false); mHistoryDatabase.addItem(new SearchItem(query)); mainActivityHelper.search(query); return false; } @Override public boolean onQueryTextChange(String newText) { return false; } }); mSearchView.setOnSearchViewListener(new SearchView.SearchViewListener() { @Override public void onSearchViewShown() { floatingActionButton.hideMenuButton(true); } @Override public void onSearchViewClosed() { floatingActionButton.showMenuButton(true); } }); List<SearchItem> mResultsList = new ArrayList<>(); SearchAdapter mSearchAdapter = new SearchAdapter(this, mResultsList, mSuggestionsList, mTheme); mSearchAdapter.setOnItemClickListener(new SearchAdapter.OnItemClickListener() { @Override public void onItemClick(View view, int position) { mSearchView.hide(false); TextView textView = (TextView) view.findViewById(R.id.textView_item_text); CharSequence text = textView.getText(); mHistoryDatabase.addItem(new SearchItem(text)); mainActivityHelper.search(text.toString()); } }); mSearchView.setAdapter(mSearchAdapter); }