List of usage examples for java.lang CharSequence length
int length();
From source file:org.csp.everyaware.offline.Map.java
private void insertAnnDialog(final ExtendedLatLng annLatLng) { final Dialog insertDialog = new Dialog(Map.this); insertDialog.setContentView(R.layout.insert_dialog); insertDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); insertDialog.setTitle(R.string.annotation_insertion); insertDialog.setCancelable(false);//w w w .ja v a 2 s .c om //get reference to send button final Button sendButton = (Button) insertDialog.findViewById(R.id.send_button); sendButton.setEnabled(false); //active only if there's text //get reference to cancel/close window button final Button cancelButton = (Button) insertDialog.findViewById(R.id.cancel_button); cancelButton.setEnabled(true); //active all time cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { insertDialog.dismiss(); } }); //get reference to edittext in which user writes annotation final EditText editText = (EditText) insertDialog.findViewById(R.id.annotation_editText); editText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { //if modified text length is more than 0, activate send button if (s.length() > 0) sendButton.setEnabled(true); else sendButton.setEnabled(false); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); //get checkbox references CheckBox facebookChBox = (CheckBox) insertDialog.findViewById(R.id.facebook_checkBox); CheckBox twitterChBox = (CheckBox) insertDialog.findViewById(R.id.twitter_checkBox); //activate check boxes depends from log in facebook/twitter boolean[] logs = new boolean[2]; logs[0] = Utils.getValidFbSession(getApplicationContext()); logs[1] = Utils.getValidTwSession(getApplicationContext()); facebookChBox.setEnabled(logs[0]); twitterChBox.setEnabled(logs[1]); //checked on check boxes final boolean[] checkeds = Utils.getShareCheckedOn(getApplicationContext()); if (checkeds[0] == true) facebookChBox.setChecked(true); else facebookChBox.setChecked(false); if (checkeds[1] == true) twitterChBox.setChecked(true); else twitterChBox.setChecked(false); facebookChBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean checked) { Utils.setShareCheckedOn(checked, checkeds[1], getApplicationContext()); checkeds[0] = checked; } }); twitterChBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean checked) { Utils.setShareCheckedOn(checkeds[0], checked, getApplicationContext()); checkeds[1] = checked; } }); //send annotation to server and on facebook/twitter if user is logged on sendButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { //1 - read inserted annotation String annotation = editText.getText().toString(); //2 - update record on db with annotation and save recordId double recordId = annLatLng.mRecordId; int result = mDbManager.updateRecordAnnotation(recordId, annotation); if (result == 1) Toast.makeText(getApplicationContext(), "Updated record", Toast.LENGTH_LONG).show(); else Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_LONG).show(); boolean[] checks = Utils.getShareCheckedOn(getApplicationContext()); //3 - share on facebook is user wants and internet is active now if (checks[0] == true) { Record annotatedRecord = mDbManager.loadRecordById(recordId); try { FacebookManager fb = FacebookManager.getInstance(null, null); if (fb != null) fb.postMessageOnWall(annotatedRecord); } catch (Exception e) { e.printStackTrace(); } } //4 - share on twitter is user wants and internet is active now if (checks[1] == true) { Record annotatedRecord = mDbManager.loadRecordById(recordId); try { TwitterManager twManager = TwitterManager.getInstance(null); twManager.postMessage(annotatedRecord); } catch (Exception e) { e.printStackTrace(); } } //5 - show marker for annotated record Record annotatedRecord = mDbManager.loadRecordById(recordId); String userAnn = annotatedRecord.mUserData1; if (!userAnn.equals("") && (annotatedRecord.mValues[0] != 0)) { BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.annotation_marker); Marker marker = mGoogleMap.addMarker(new MarkerOptions() .position(new LatLng(annotatedRecord.mValues[0], annotatedRecord.mValues[1])) .title("BC: " + String.valueOf(annotatedRecord.mBcMobile) + " " + getResources().getString(R.string.micrograms)) .snippet("Annotation: " + userAnn).icon(icon).anchor(0f, 1f)); } insertDialog.dismiss(); } }); insertDialog.show(); }
From source file:com.tsp.clipsy.audio.RingdroidEditActivity.java
private String makeRingtoneFilename(CharSequence title, String extension) { String parentdir = "/sdcard/media/audio/clipsy"; // Create the parent directory File parentDirFile = new File(parentdir); parentDirFile.mkdirs();/*w ww .j av a 2 s . c om*/ // If we can't write to that special path, try just writing // directly to the sdcard if (!parentDirFile.isDirectory()) { parentdir = "/sdcard"; } // Turn the title into a filename String filename = ""; for (int i = 0; i < title.length(); i++) { if (Character.isLetterOrDigit(title.charAt(i))) { filename += title.charAt(i); } } // Try to make the filename unique String path = null; for (int i = 0; i < 100; i++) { String testPath; if (i > 0) testPath = parentdir + "/" + filename + i + extension; else testPath = parentdir + "/" + filename + extension; try { RandomAccessFile f = new RandomAccessFile(new File(testPath), "r"); } catch (Exception e) { // Good, the file didn't exist path = testPath; break; } } return path; }
From source file:com.example.carsharing.ShortWayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { photouri = Uri//from w w w. j a va2 s . co m .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2)); super.onCreate(savedInstanceState); setContentView(R.layout.activity_short_way); activity_drawer = new Drawer(this, R.id.short_way_layout); mDrawerToggle = activity_drawer.newdrawer(); mDrawerLayout = activity_drawer.setDrawerLayout(); bdriver = true; // SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0"); // standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE); primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE); standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE); primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE); queue = Volley.newRequestQueue(this); exchange = (ImageView) findViewById(R.id.shortway_exchange); exchange.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String temp = startplace.getText().toString(); if (!temp.equals("") && !endplace.getText().toString().equals("")) { startplace.setText(endplace.getText().toString()); endplace.setText(temp); float a, b; a = startplace_longitude; b = startplace_latitude; startplace_longitude = destination_longitude; startplace_latitude = destination_latitude; destination_longitude = a; destination_latitude = b; } } }); datebutton = (Button) findViewById(R.id.shortway_dates); earlystarttime = (Button) findViewById(R.id.shortway_earliest_start_time); latestarttime = (Button) findViewById(R.id.shortway_latest_start_time); increase = (Button) findViewById(R.id.shortway_increase); decrease = (Button) findViewById(R.id.shortway_decrease); s2 = (TextView) findViewById(R.id.shortway_count); startplace = (Button) findViewById(R.id.shortway_startplace); endplace = (Button) findViewById(R.id.shortway_endplace); sure = (Button) findViewById(R.id.shortway_sure); commute = findViewById(R.id.drawer_commute); shortway = findViewById(R.id.drawer_shortway); longway = findViewById(R.id.drawer_longway); setting = findViewById(R.id.drawer_setting); personalcenter = findViewById(R.id.drawer_personalcenter); about = findViewById(R.id.drawer_respond); taxi = findViewById(R.id.drawer_taxi); drawericon = (ImageView) findViewById(R.id.drawer_icon); drawername = (TextView) findViewById(R.id.drawer_name); drawernum = (TextView) findViewById(R.id.drawer_phone); carbrand = (EditText) findViewById(R.id.shortway_CarBrand); model = (EditText) findViewById(R.id.shortway_CarModel); color = (EditText) findViewById(R.id.shortway_color); licensenum = (EditText) findViewById(R.id.shortway_Num); licensenum.addTextChangedListener(numTextWatcher); carbrand.addTextChangedListener(detTextWatcher); color.addTextChangedListener(coTextWatcher); model.addTextChangedListener(moTextWatcher); next = (Button) findViewById(R.id.shortway_sure); next.setEnabled(false); db = new DatabaseHelper(ShortWayActivity.this, "test", null, 1); db1 = db.getWritableDatabase(); final TextView content = (TextView) findViewById(R.id.shortway_content); mRadio1 = (RadioButton) findViewById(R.id.shortway_radioButton1); mRadio2 = (RadioButton) findViewById(R.id.shortway_radioButton2); shortway_group = (RadioGroup) findViewById(R.id.shortway_radiobutton01); star1 = (ImageView) findViewById(R.id.shortway_star); star2 = (ImageView) findViewById(R.id.shortway_star01); // judge the value of "pre_page" Bundle bundle = this.getIntent().getExtras(); String PRE_PAGE = bundle.getString("pre_page"); if (PRE_PAGE.compareTo("ReOrder") == 0) { // startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname")); bstart = true; endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname")); bend = true; startplace_longitude = bundle.getFloat("stpx"); Log.e("startplace_longitude", String.valueOf(startplace_longitude)); startplace_latitude = bundle.getFloat("stpy"); Log.e("startplace_latitude", String.valueOf(startplace_latitude)); destination_longitude = bundle.getFloat("epx"); Log.e("destination_longitude", String.valueOf(destination_longitude)); destination_latitude = bundle.getFloat("epy"); Log.e("destination_latitude", String.valueOf(destination_latitude)); datebutton.setText(bundle.getString("re_short_startdate")); bdate = true; earlystarttime.setText(bundle.getString("re_short_starttime")); best = true; latestarttime.setText(bundle.getString("re_short_endtime")); blst = true; } // judge the value of "pre_page" about.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent about = new Intent(ShortWayActivity.this, AboutActivity.class); startActivity(about); } }); setting.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent setting = new Intent(ShortWayActivity.this, SettingActivity.class); startActivity(setting); } }); // database db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1); db1 = db.getWritableDatabase(); // database end star1.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (bstart) { if (Pointisliked(StartPointMapName)) { // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { StartPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs); star1.setImageResource(R.drawable.ic_action_not_important); } else { ContentValues content = new ContentValues(); content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName); content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName); content.put(getString(R.string.dbstring_longitude), startplace_longitude); content.put(getString(R.string.dbstring_latitude), startplace_latitude); db1.insert(getString(R.string.dbtable_placeliked), null, content); // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { StartPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs); star1.setImageResource(R.drawable.ic_action_important); } } } }); star2.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if (bend) { if (Pointisliked(EndPointMapName)) { // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { EndPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs); star2.setImageResource(R.drawable.ic_action_not_important); } else { ContentValues content = new ContentValues(); content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName); content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName); content.put(getString(R.string.dbstring_longitude), destination_longitude); content.put(getString(R.string.dbstring_latitude), destination_latitude); db1.insert(getString(R.string.dbtable_placeliked), null, content); // Define 'where' part of query. String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?"; // Specify arguments in placeholder order. String[] selelectionArgs = { EndPointMapName }; // Issue SQL statement. db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs); star2.setImageResource(R.drawable.ic_action_important); } } } }); taxi.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); personalcenter.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent personalcenter = new Intent(ShortWayActivity.this, PersonalCenterActivity.class); startActivity(personalcenter); } }); shortway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); longway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent longway = new Intent(ShortWayActivity.this, MainActivity.class); startActivity(longway); } }); commute.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent commute = new Intent(ShortWayActivity.this, CommuteActivity.class); commute.putExtra("pre_page", "Drawer"); startActivity(commute); } }); // RadioGroup shortway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int checkedId) { // TODO Auto-generated method stub18 // ID // """"textView if (checkedId == mRadio2.getId()) { bpassenager = true; bdriver = false; licensenum.setEnabled(false); carbrand.setEnabled(false); color.setEnabled(false); model.setEnabled(false); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); content.setText(getString(R.string.warningInfo_seatNeed)); licensenum.setHintTextColor(Color.parseColor("#cccccc")); carbrand.setHintTextColor(Color.parseColor("#cccccc")); color.setHintTextColor(Color.parseColor("#cccccc")); model.setHintTextColor(Color.parseColor("#cccccc")); licensenum.setInputType(InputType.TYPE_NULL); carbrand.setInputType(InputType.TYPE_NULL); color.setInputType(InputType.TYPE_NULL); model.setInputType(InputType.TYPE_NULL); } else { bpassenager = false; bdriver = true; licensenum.setEnabled(true); carbrand.setEnabled(true); color.setEnabled(true); model.setEnabled(true); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); content.setText(getString(R.string.warningInfo_seatOffer)); licensenum.setHintTextColor(Color.parseColor("#9F35FF")); carbrand.setHintTextColor(Color.parseColor("#9F35FF")); color.setHintTextColor(Color.parseColor("#9F35FF")); model.setHintTextColor(Color.parseColor("#9F35FF")); // licensenum.setText(""); // carbrand.setText(""); // color.setText(""); // model.setText(""); licensenum.setInputType(InputType.TYPE_CLASS_TEXT); carbrand.setInputType(InputType.TYPE_CLASS_TEXT); color.setInputType(InputType.TYPE_CLASS_TEXT); model.setInputType(InputType.TYPE_CLASS_TEXT); // start! selectcarinfo(UserPhoneNumber); // end! } confirm(); } }); sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if (shortway_group.getCheckedRadioButtonId() == mRadio1.getId()) userrole = "d"; else userrole = "p"; // start! shortway_request(UserPhoneNumber, datebutton.getText().toString(), earlystarttime.getText().toString(), latestarttime.getText().toString()); // end! } private void shortway_request(final String shortway_phonenum, final String shortway_date, final String shortway_starttime, final String shortway_endtime) { // TODO Auto-generated method stub // start try { test_date = primary_date.parse(shortway_date); standard_shortway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_starttime); standard_shortway_starttime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_endtime); standard_shortway_endtime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! String shortway_baseurl = getString(R.string.uri_base) + getString(R.string.uri_ShortwayRequest) + getString(R.string.uri_addrequest_action); // "http://192.168.1.111:8080/CarsharingServer/ShortwayRequest!addrequest.action?"; Log.w("URL", shortway_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, shortway_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d("shortway_result", response); JSONObject json1 = null; try { json1 = new JSONObject(response); requestok = json1.getBoolean("result"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (requestok == true) { if (carinfochoosing_type == 1) { // add // start! carinfo(shortway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 1); // end! } else { // update // start! carinfo(shortway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 2); // end! } Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "true"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } else { // Toast errorinfo = // Toast.makeText(getApplicationContext(), // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("shortway_result", error.getMessage(), error); // Toast errorinfo = Toast.makeText(null, // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } }) { protected Map<String, String> getParams() { // POSTgetParams // start try { test_date = primary_date.parse(shortway_date); standard_shortway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_starttime); standard_shortway_starttime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { test_date = primary_time.parse(shortway_endtime); standard_shortway_endtime = standard_time.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! Map<String, String> params = new HashMap<String, String>(); params.put("phonenum", shortway_phonenum); params.put("userrole", userrole); params.put("startplacex", String.valueOf(startplace_longitude)); params.put("startplacey", String.valueOf(startplace_latitude)); params.put(getString(R.string.uri_startplace), startplace.getText().toString()); params.put("destinationx", String.valueOf(destination_longitude)); params.put("destinationy", String.valueOf(destination_latitude)); params.put(getString(R.string.uri_destination), endplace.getText().toString()); params.put("startdate", standard_shortway_startdate); params.put("starttime", standard_shortway_starttime); params.put("endtime", standard_shortway_endtime); return params; } }; queue.add(stringRequest); } }); startplace.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivityForResult(new Intent(ShortWayActivity.this, ChooseAddressActivity.class), 1); } }); endplace.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub startActivityForResult(new Intent(ShortWayActivity.this, ChooseArrivalActivity.class), 2); } }); increase.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum++; s2.setText("" + sum); confirm(); } }); decrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum--; if (sum < 0) { sum = 0; } s2.setText("" + sum); confirm(); } }); datebutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(DATE_DIALOG); } }); earlystarttime.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(TIME_DIALOG); } }); latestarttime.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(TIME_DIALOG1); } }); }
From source file:com.huofu.RestaurantOS.ui.splash.activate.java
/** * ?//from w ww . java 2 s . c om */ public void widgetConfigure() { buttonActivate.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub if (authDialog == null) { authDialog = new Dialog(activate.this, R.style.PauseDialog); } if (ttv.getParent() != null) { ttv = new TitanicTextView(ctxt); } String key = etActivteCode.getText().toString(); if (key.length() >= 16) { CommonUtils.LogWuwei(tag, "key is " + key); CommonUtils.sendMsg("?", activate.SHOW_LOADING_TEXT, mUiHandler); activate(ctxt, key); } else { CommonUtils.sendMsg("????", activate.SHOW_ERROR_MESSAGE, mUiHandler); } } }); InputFilter filter = new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { // TODO Auto-generated method stub for (int i = start; i < end; i++) { //???'-' if (!Character.isLetter(source.charAt(i)) && source.charAt(i) != '-') { return ""; } } return null; } }; InputFilter filterLength = new InputFilter.LengthFilter(19); etActivteCode.setCursorVisible(false); etActivteCode.setFilters(new InputFilter[] { filter, filterLength }); etActivteCode.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub } @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 etActivteCode.setCursorVisible(true); etActivteCode.removeTextChangedListener(this);// ? etActivteCode.setText(s.toString().toUpperCase());// ? etActivteCode.setSelection(s.toString().length());// ?? etActivteCode.addTextChangedListener(this);// ? String licensePlateNumber = etActivteCode.getText().toString().trim(); if (s.length() == 19) { InputMethodUtils.HideKeyboard(etActivteCode); } } }); etActivteCode.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub if (keyCode == KeyEvent.KEYCODE_DEL) { CommonUtils.LogWuwei(tag, "delete"); etActivteCode.setCursorVisible(false); } return false; } }); rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); OnClickListener oclGetQrCode = new OnClickListener() { @Override public void onClick(View v) { flagInQrcodeDialog = true; CommonUtils.sendMsg("??", SHOW_LOADING_TEXT, mUiHandler); if (LocalDataDeal.readFromLocalPublicKey(ctxt) == null || LocalDataDeal.readFromLocalPublicKey(ctxt).equals("")) { ApisManager.GetPublicKey(new ApiCallback() { @Override public void success(Object object) { sendUIMessage(HIDE_LOADING, ""); try { org.json.JSONObject obj = new org.json.JSONObject((String) object); String public_key = obj.getString("public_key"); LocalDataDeal.writeToLocalPublicKey(public_key, ctxt);//key?base64? } catch (Exception e) { } CommonUtils.sendMsg("", GET_QRCODE, mUiHandler); } @Override public void error(BaseApi.ApiResponse response) { sendUIMessage(HIDE_LOADING, ""); sendUIMessage(SHOW_ERROR_MESSAGE, response.error_message); } }); } else { CommonUtils.sendMsg("", GET_QRCODE, mUiHandler); } rl_activate_input.setVisibility(View.INVISIBLE); rl_activate_qrscan_ready.setVisibility(View.VISIBLE); imageViewQrcode.setVisibility(View.INVISIBLE); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); textviewScanStauts.setTextColor(Color.parseColor("#898989")); textviewScanStauts.setText(R.string.activateByQrCodeTips); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_in)); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_out)); } }; buttonSwitchQrScan.setOnClickListener(oclGetQrCode); findViewById(R.id.rl_switch_activate_qrcode_way).setOnClickListener(oclGetQrCode); buttonSwitchInputCode.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); stopQrScanTimer(); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_right_in)); rl_activate_qrscan_ready .startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.slide_left_out)); } }); findViewById(R.id.rl_switch_activate_keyboard_way).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub flagInQrcodeDialog = false; flagWaitingCmd = false; rl_activate_qrscan_ready.setVisibility(View.INVISIBLE); rl_activate_input.setVisibility(View.VISIBLE); rl_activate_input.startAnimation(new AnimationUtils().loadAnimation(ctxt, R.anim.small_2_big)); stopQrScanTimer(); } }); PackageManager manager; PackageInfo info = null; manager = this.getPackageManager(); String versionName = null; try { info = manager.getPackageInfo(this.getPackageName(), 0); versionName = info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } ((TextView) findViewById(R.id.tv_app_version)) .setText(getResources().getString(R.string.app_name) + " V" + versionName); LocalDataDeal.writeToLocalVersion(versionName, ctxt); LocalDataDeal.writeToLocalVersionCode(info.versionCode, ctxt); ftpServiceStart(); }
From source file:org.apache.noggit.JSONParser.java
public void writeString(CharSequence str) { JSONUtil.writeString(str, 0, str.length(), out); }
From source file:org.apache.noggit.JSONParser.java
public final Appendable append(CharSequence csq) throws IOException { return append(csq, 0, csq.length()); }
From source file:com.mobicage.rogerthat.registration.RegistrationActivity2.java
@Override protected void onServiceBound() { T.UI();//from w w w.j av a 2s . c om if (mNotYetProcessedIntent != null) { processIntent(mNotYetProcessedIntent); mNotYetProcessedIntent = null; } setContentView(R.layout.registration2); //Apply Fonts TextUtils.overrideFonts(this, findViewById(android.R.id.content)); final Typeface faTypeFace = Typeface.createFromAsset(getAssets(), "FontAwesome.ttf"); final int[] visibleLogos; final int[] goneLogos; if (AppConstants.FULL_WIDTH_HEADERS) { visibleLogos = FULL_WIDTH_ROGERTHAT_LOGOS; goneLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS; View viewFlipper = findViewById(R.id.registration_viewFlipper); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) viewFlipper.getLayoutParams(); params.setMargins(0, 0, 0, 0); } else { visibleLogos = NORMAL_WIDTH_ROGERTHAT_LOGOS; goneLogos = FULL_WIDTH_ROGERTHAT_LOGOS; } for (int id : visibleLogos) findViewById(id).setVisibility(View.VISIBLE); for (int id : goneLogos) findViewById(id).setVisibility(View.GONE); handleScreenOrientation(getResources().getConfiguration().orientation); ScrollView rc = (ScrollView) findViewById(R.id.registration_container); Resources resources = getResources(); if (CloudConstants.isRogerthatApp()) { rc.setBackgroundColor(resources.getColor(R.color.mc_page_dark)); } else { rc.setBackgroundColor(resources.getColor(R.color.mc_homescreen_background)); } TextView rogerthatWelcomeTextView = (TextView) findViewById(R.id.rogerthat_welcome); TextView tosTextView = (TextView) findViewById(R.id.registration_tos); Typeface FONT_THIN_ITALIC = Typeface.createFromAsset(getAssets(), "fonts/lato_light_italic.ttf"); tosTextView.setTypeface(FONT_THIN_ITALIC); tosTextView.setTextColor(ContextCompat.getColor(RegistrationActivity2.this, R.color.mc_words_color)); Button agreeBtn = (Button) findViewById(R.id.registration_agree_tos); TextView tvRegistration = (TextView) findViewById(R.id.registration); tvRegistration.setText(getString(R.string.registration_city_app_sign_up, getString(R.string.app_name))); mEnterEmailAutoCompleteTextView = (AutoCompleteTextView) findViewById(R.id.registration_enter_email); if (CloudConstants.isEnterpriseApp()) { rogerthatWelcomeTextView .setText(getString(R.string.rogerthat_welcome_enterprise, getString(R.string.app_name))); tosTextView.setVisibility(View.GONE); agreeBtn.setText(R.string.start_registration); mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint_enterprise); } else { rogerthatWelcomeTextView .setText(getString(R.string.registration_welcome_text, getString(R.string.app_name))); tosTextView.setText(Html.fromHtml( "<a href=\"" + CloudConstants.TERMS_OF_SERVICE_URL + "\">" + tosTextView.getText() + "</a>")); tosTextView.setMovementMethod(LinkMovementMethod.getInstance()); agreeBtn.setText(R.string.registration_btn_agree_tos); mEnterEmailAutoCompleteTextView.setHint(R.string.registration_enter_email_hint); } agreeBtn.getBackground().setColorFilter(Message.GREEN_BUTTON_COLOR, PorterDuff.Mode.MULTIPLY); agreeBtn.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_AGREED_TOS); mWiz.proceedToNextPage(); } }); initLocationUsageStep(faTypeFace); View.OnClickListener emailLoginListener = new View.OnClickListener() { @Override public void onClick(View v) { sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_EMAIL_LOGIN); mWiz.proceedToNextPage(); } }; findViewById(R.id.login_via_email).setOnClickListener(emailLoginListener); Button facebookButton = (Button) findViewById(R.id.login_via_fb); View.OnClickListener facebookLoginListener = new View.OnClickListener() { @Override public void onClick(View v) { // Check network connectivity if (!mService.getNetworkConnectivityManager().isConnected()) { UIUtils.showNoNetworkDialog(RegistrationActivity2.this); return; } sendRegistrationStep(RegistrationWizard2.REGISTRATION_STEP_FACEBOOK_LOGIN); FacebookUtils.ensureOpenSession(RegistrationActivity2.this, AppConstants.PROFILE_SHOW_GENDER_AND_BIRTHDATE ? Arrays.asList("email", "user_friends", "user_birthday") : Arrays.asList("email", "user_friends"), PermissionType.READ, new Session.StatusCallback() { @Override public void call(Session session, SessionState state, Exception exception) { if (session != Session.getActiveSession()) { session.removeCallback(this); return; } if (exception != null) { session.removeCallback(this); if (!(exception instanceof FacebookOperationCanceledException)) { L.bug("Facebook SDK error during registration", exception); AlertDialog.Builder builder = new AlertDialog.Builder( RegistrationActivity2.this); builder.setMessage(R.string.error_please_try_again); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } else if (session.isOpened()) { session.removeCallback(this); if (session.getPermissions().contains("email")) { registerWithAccessToken(session.getAccessToken()); } else { AlertDialog.Builder builder = new AlertDialog.Builder( RegistrationActivity2.this); builder.setMessage(R.string.facebook_registration_email_missing); builder.setPositiveButton(R.string.rogerthat, null); AlertDialog dialog = builder.create(); dialog.show(); } } } }, false); } ; }; facebookButton.setOnClickListener(facebookLoginListener); final Button getAccountsButton = (Button) findViewById(R.id.get_accounts); if (configureEmailAutoComplete()) { // GET_ACCOUNTS permission is granted getAccountsButton.setVisibility(View.GONE); } else { getAccountsButton.setTypeface(faTypeFace); getAccountsButton.setOnClickListener(new SafeViewOnClickListener() { @Override public void safeOnClick(View v) { ActivityCompat.requestPermissions(RegistrationActivity2.this, new String[] { Manifest.permission.GET_ACCOUNTS }, PERMISSION_REQUEST_GET_ACCOUNTS); } }); } mEnterPinEditText = (EditText) findViewById(R.id.registration_enter_pin); mEnterPinEditText.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) { if (s.length() == PIN_LENGTH) onPinEntered(); } }); Button requestNewPinButton = (Button) findViewById(R.id.registration_request_new_pin); requestNewPinButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mWiz.setEmail(null); hideNotification(); mWiz.reInit(); mWiz.goBackToPrevious(); mEnterEmailAutoCompleteTextView.setText(""); } }); mWiz = RegistrationWizard2.getWizard(mService); mWiz.setFlipper((ViewFlipper) findViewById(R.id.registration_viewFlipper)); setFinishHandler(); addAgreeTOSHandler(); addIBeaconUsageHandler(); addChooseLoginMethodHandler(); addEnterPinHandler(); mWiz.run(); mWiz.setDeviceId(Installation.id(this)); handleEnterEmail(); if (mWiz.getBeaconRegions() != null && mBeaconManager == null) { bindBeaconManager(); } if (CloudConstants.USE_GCM_KICK_CHANNEL && GoogleServicesUtils.checkPlayServices(this, true)) { GoogleServicesUtils.registerGCMRegistrationId(mService, new GCMRegistrationIdFoundCallback() { @Override public void idFound(String registrationId) { mGCMRegistrationId = registrationId; } }); } }
From source file:android.hqs.view.pager.indicator.TitlePageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) { return;//from w w w .j a v a 2 s. co m } final int count = mViewPager.getAdapter().getCount(); if (count == 0) { return; } // mCurrentPage is -1 on first start and after orientation changed. If so, retrieve the correct index from viewpager. if (mCurrentPage == -1 && mViewPager != null) { mCurrentPage = mViewPager.getCurrentItem(); } //Calculate views bounds ArrayList<Rect> bounds = calculateAllBounds(mPaintText); final int boundsSize = bounds.size(); //Make sure we're on a page that still exists if (mCurrentPage >= boundsSize) { setCurrentItem(boundsSize - 1); return; } final int countMinusOne = count - 1; final float halfWidth = getWidth() / 2f; final int left = getLeft(); final float leftClip = left + mClipPadding; final int width = getWidth(); int height = getHeight(); final int right = left + width; final float rightClip = right - mClipPadding; int page = mCurrentPage; float offsetPercent; if (mPageOffset <= 0.5) { offsetPercent = mPageOffset; } else { page += 1; offsetPercent = 1 - mPageOffset; } final boolean currentSelected = (offsetPercent <= SELECTION_FADE_PERCENTAGE); final boolean currentBold = (offsetPercent <= BOLD_FADE_PERCENTAGE); final float selectedPercent = (SELECTION_FADE_PERCENTAGE - offsetPercent) / SELECTION_FADE_PERCENTAGE; //Verify if the current view must be clipped to the screen Rect curPageBound = bounds.get(mCurrentPage); float curPageWidth = curPageBound.right - curPageBound.left; if (curPageBound.left < leftClip) { //Try to clip to the screen (left side) clipViewOnTheLeft(curPageBound, curPageWidth, left); } if (curPageBound.right > rightClip) { //Try to clip to the screen (right side) clipViewOnTheRight(curPageBound, curPageWidth, right); } //Left views starting from the current position if (mCurrentPage > 0) { for (int i = mCurrentPage - 1; i >= 0; i--) { Rect bound = bounds.get(i); //Is left side is outside the screen if (bound.left < leftClip) { int w = bound.right - bound.left; //Try to clip to the screen (left side) clipViewOnTheLeft(bound, w, left); //Except if there's an intersection with the right view Rect rightBound = bounds.get(i + 1); //Intersection if (bound.right + mTitlePadding > rightBound.left) { bound.left = (int) (rightBound.left - w - mTitlePadding); bound.right = bound.left + w; } } } } //Right views starting from the current position if (mCurrentPage < countMinusOne) { for (int i = mCurrentPage + 1; i < count; i++) { Rect bound = bounds.get(i); //If right side is outside the screen if (bound.right > rightClip) { int w = bound.right - bound.left; //Try to clip to the screen (right side) clipViewOnTheRight(bound, w, right); //Except if there's an intersection with the left view Rect leftBound = bounds.get(i - 1); //Intersection if (bound.left - mTitlePadding < leftBound.right) { bound.left = (int) (leftBound.right + mTitlePadding); bound.right = bound.left + w; } } } } //Now draw views int colorTextAlpha = mColorText >>> 24; for (int i = 0; i < count; i++) { //Get the title Rect bound = bounds.get(i); //Only if one side is visible if ((bound.left > left && bound.left < right) || (bound.right > left && bound.right < right)) { final boolean currentPage = (i == page); final CharSequence pageTitle = getTitle(i); //Only set bold if we are within bounds mPaintText.setFakeBoldText(currentPage && currentBold && mBoldText); //Draw text as unselected mPaintText.setColor(mColorText); if (currentPage && currentSelected) { //Fade out/in unselected text as the selected text fades in/out mPaintText.setAlpha(colorTextAlpha - (int) (colorTextAlpha * selectedPercent)); } //Except if there's an intersection with the right view if (i < boundsSize - 1) { Rect rightBound = bounds.get(i + 1); //Intersection if (bound.right + mTitlePadding > rightBound.left) { int w = bound.right - bound.left; bound.left = (int) (rightBound.left - w - mTitlePadding); bound.right = bound.left + w; } } canvas.drawText(pageTitle, 0, pageTitle.length(), bound.left, bound.bottom + mTopPadding, mPaintText); //If we are within the selected bounds draw the selected text if (currentPage && currentSelected) { mPaintText.setColor(mColorSelected); mPaintText.setAlpha((int) ((mColorSelected >>> 24) * selectedPercent)); canvas.drawText(pageTitle, 0, pageTitle.length(), bound.left, bound.bottom + mTopPadding, mPaintText); } } } //If we want the line on the top change height to zero and invert the line height to trick the drawing code float footerLineHeight = mFooterLineHeight; float footerIndicatorLineHeight = mFooterIndicatorHeight; if (mLinePosition == LinePosition.Top) { height = 0; footerLineHeight = -footerLineHeight; footerIndicatorLineHeight = -footerIndicatorLineHeight; } //Draw the footer line mPath.reset(); mPath.moveTo(0, height - footerLineHeight / 2f); mPath.lineTo(width, height - footerLineHeight / 2f); mPath.close(); canvas.drawPath(mPath, mPaintFooterLine); float heightMinusLine = height - footerLineHeight; switch (mFooterIndicatorStyle) { case Triangle: mPath.reset(); mPath.moveTo(halfWidth, heightMinusLine - footerIndicatorLineHeight); mPath.lineTo(halfWidth + footerIndicatorLineHeight, heightMinusLine); mPath.lineTo(halfWidth - footerIndicatorLineHeight, heightMinusLine); mPath.close(); canvas.drawPath(mPath, mPaintFooterIndicator); break; case Underline: if (!currentSelected || page >= boundsSize) { break; } Rect underlineBounds = bounds.get(page); final float rightPlusPadding = underlineBounds.right + mFooterIndicatorUnderlinePadding; final float leftMinusPadding = underlineBounds.left - mFooterIndicatorUnderlinePadding; final float heightMinusLineMinusIndicator = heightMinusLine - footerIndicatorLineHeight; mPath.reset(); mPath.moveTo(leftMinusPadding, heightMinusLine); mPath.lineTo(rightPlusPadding, heightMinusLine); mPath.lineTo(rightPlusPadding, heightMinusLineMinusIndicator); mPath.lineTo(leftMinusPadding, heightMinusLineMinusIndicator); mPath.close(); mPaintFooterIndicator.setAlpha((int) (0xFF * selectedPercent)); canvas.drawPath(mPath, mPaintFooterIndicator); mPaintFooterIndicator.setAlpha(0xFF); break; default: break; } }
From source file:com.benefit.buy.library.http.query.AbstractAQuery.java
/** * Set the text of a TextView. Hide the view (gone) if text is empty. * @param text the text//from ww w . j av a 2 s.co m * @param goneIfEmpty hide if text is null or length is 0 * @return self */ public T text(CharSequence text, boolean goneIfEmpty) { if (goneIfEmpty && ((text == null) || (text.length() == 0))) { return gone(); } else { return text(text); } }
From source file:com.healthmarketscience.jackcess.Column.java
/** * Encodes a text value, possibly compressing. *//*w w w.j a va2s. c o m*/ private ByteBuffer encodeTextValue(Object obj, int minChars, int maxChars, boolean forceUncompressed) throws IOException { CharSequence text = toCharSequence(obj); if ((text.length() > maxChars) || (text.length() < minChars)) { throw new IOException("Text is wrong length for " + getType() + " column, max " + maxChars + ", min " + minChars + ", got " + text.length()); } // may only compress if column type allows it if (!forceUncompressed && isCompressedUnicode()) { // for now, only do very simple compression (only compress text which is // all ascii text) if (isAsciiCompressible(text)) { byte[] encodedChars = new byte[TEXT_COMPRESSION_HEADER.length + text.length()]; encodedChars[0] = TEXT_COMPRESSION_HEADER[0]; encodedChars[1] = TEXT_COMPRESSION_HEADER[1]; for (int i = 0; i < text.length(); ++i) { encodedChars[i + TEXT_COMPRESSION_HEADER.length] = (byte) text.charAt(i); } return ByteBuffer.wrap(encodedChars); } } return encodeUncompressedText(text, getCharset()); }