List of usage examples for android.widget TextView setTypeface
public void setTypeface(@Nullable Typeface tf)
From source file:com.androidquery.AQuery.java
/** * Set the text typeface of a TextView./* ww w . j a v a2 s . c om*/ * * @param typeface typeface * @return self */ public AQuery typeface(Typeface tf) { if (view instanceof TextView) { TextView tv = (TextView) view; tv.setTypeface(tf); } return self(); }
From source file:com.derrick.movies.MovieDetailsActivity.java
private void setTrailers(Videos videos) { videosList = videos.getResults();/* ww w . j av a2 s .c o m*/ int size = videosList.size(); if (size == 1) { txt_title_trailer.setText("Trailer"); } for (int i = 0; i < size; i++) { Result result = videosList.get(i); String url = IMAGE_YOUTUBE + result.getKey() + YOUTUBE_QUALITY; ImageView imageView; ImageView imageView_play; TextView txt_name; ViewGroup.LayoutParams lp = new RelativeLayout.LayoutParams(70, 70); ViewGroup.LayoutParams lp2 = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); RelativeLayout relativeLayout = new RelativeLayout(this); relativeLayout.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); if (size == 1) { imageView = new ImageView(getApplicationContext()); imageView.setLayoutParams(new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } else { imageView = new ImageView(getApplicationContext()); imageView .setLayoutParams(new RelativeLayout.LayoutParams(500, ViewGroup.LayoutParams.MATCH_PARENT)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); } imageView_play = new ImageView(getApplicationContext()); imageView_play.setLayoutParams(lp); RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView_play .getLayoutParams(); layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); imageView_play.setLayoutParams(layoutParams); imageView_play.setScaleType(ImageView.ScaleType.CENTER_CROP); Drawable drawable = getResources() .getDrawable(getResources().getIdentifier("play", "drawable", getPackageName())); imageView_play.setImageDrawable(drawable); txt_name = new TextView(getApplicationContext()); txt_name.setLayoutParams(lp2); RelativeLayout.LayoutParams layoutParams2 = (RelativeLayout.LayoutParams) txt_name.getLayoutParams(); layoutParams2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE); layoutParams2.setMargins(8, 8, 8, 16); txt_name.setLayoutParams(layoutParams2); txt_name.setTypeface(robotoCondensed); txt_name.setText(result.getName()); txt_name.setTextColor(getResources().getColor(R.color.colorWhite)); Glide.with(getBaseContext()).load(url).diskCacheStrategy(DiskCacheStrategy.ALL) .listener(new RequestListener<String, GlideDrawable>() { @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } @Override public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { return false; } }).into(imageView); // trailerSlider.addView(imageView_play); relativeLayout.addView(imageView); relativeLayout.addView(imageView_play); relativeLayout.addView(txt_name); trailerSlider.addView(relativeLayout); } }
From source file:knayi.delevadriver.JobDetailActivity.java
@Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); final long timestamp = System.currentTimeMillis(); final String token = sPref.getString(Config.TOKEN, null); switch (v.getId()) { case R.id.job_reject: if (job_reject.getText().toString().equals("Reject")) { MaterialDialog dialog = new MaterialDialog.Builder(this).titleColor(R.color.white) .customView(R.layout.reject_layout, true).positiveText("REJECT") .positiveColor(R.color.white).positiveColorRes(R.color.white).negativeText("CANCEL") .negativeColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); if (!et_message.getText().toString().equals("")) { AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, et_message.getText().toString(), "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Job is successfully rejected", Toast.LENGTH_SHORT) .show(); dialog.dismiss(); //remove job id that is saved to use in locatin update sPref.edit().putString(Config.TOKEN_JOBID, null).commit(); sPref.edit().putString(Config.TOKEN_DELAY, null).commit(); //check report service is alive //if alive stop service if (sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)) { Intent intentservice = new Intent(JobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT) .show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err") .getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); } else { Toast.makeText(JobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); }// w ww . j ava2s . c o m progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ).build(); dialog.show(); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); et_message.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); } /*else{ final Dialog msgDialog = new Dialog(JobDetailActivity.this); msgDialog.setTitle("Why do u reject?"); msgDialog.setCancelable(true); msgDialog.setContentView(R.layout.custom_dialog_reason); final EditText message = (EditText) msgDialog.findViewById(R.id.messagebox); Button submit = (Button) msgDialog.findViewById(R.id.submitbutton); msgDialog.show(); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(message.getText().toString().equals("") && message.getText().toString().equals(null)){ Toast.makeText(getApplicationContext(), "Please input message to submit", Toast.LENGTH_SHORT).show(); }else{ msgDialog.dismiss(); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(token == null){ new SweetAlertDialog(JobDetailActivity.this, SweetAlertDialog.WARNING_TYPE) .setTitleText("") .setContentText("Please Login again!") .show(); finish(); startActivity(new Intent(JobDetailActivity.this, LoginActivity.class)); } else{ AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, location, String.valueOf(timestamp), message.getText().toString(), new Callback<String>() { @Override public void success(String s, Response response) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); startActivity(new Intent(JobDetailActivity.this, TabMainActivity.class)); finish(); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); Toast.makeText(getApplicationContext(), "Something Went Wrong!", Toast.LENGTH_SHORT).show(); } }); } } } }); }*/ break; case R.id.job_bid: progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (token == null) { MaterialDialog dialog = new MaterialDialog.Builder(this) .customView(R.layout.custom_message_dialog, false).positiveText("OK") .positiveColor(R.color.white).positiveColorRes(R.color.white) .backgroundColorRes(R.color.primary).typeface("ciclefina.ttf", "ciclegordita.ttf").build(); dialog.show(); TextView txt_title = (TextView) dialog.findViewById(R.id.dialog_title); TextView txt_message = (TextView) dialog.findViewById(R.id.dialog_message); txt_title.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); txt_message.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); txt_title.setText("Please Login again!"); txt_message.setText("Server doesn't know this account!"); Intent intent = new Intent(JobDetailActivity.this, LoginActivity.class); startActivity(intent); finish(); } if (job_bid.getText().toString().equals("Bid")) { final long ts1 = System.currentTimeMillis(); Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } acceptJob(token, String.valueOf(ts1), ""); /*MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Estimate time of arrival to pick up point") .customView(R.layout.estimatetime_layout, true) .positiveText("BID") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .cancelable(false) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); if(!et_estimatetime.getText().toString().equals("")) { acceptJob(token, String.valueOf(ts1), et_estimatetime.getText().toString()); }else{ Toast.makeText(JobDetailActivity.this, "Please Input Fields!", Toast.LENGTH_SHORT).show(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); final EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); et_estimatetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar mcurrentTime = Calendar.getInstance(); int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY); int minute = mcurrentTime.get(Calendar.MINUTE); TimePickerDialog mTimePicker; mTimePicker = new TimePickerDialog(JobDetailActivity.this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { et_estimatetime.setText( selectedHour + ":" + selectedMinute); } }, hour, minute, true);//Yes 24 hour time mTimePicker.setTitle("Select Time"); mTimePicker.show(); } });*/ } else if (job_bid.getText().toString().equals("Agree")) { AvaliableJobsAPI.getInstance().getService().agreeJob(jobitem.get_id(), token, "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Success", Toast.LENGTH_SHORT).show(); getDataFromServer(job_id); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } } }); } else if (job_bid.getText().toString().equals("Finished")) { MaterialDialog dialog = new MaterialDialog.Builder(this).titleColor(R.color.white) .customView(R.layout.custom_request_message_dialog, true).positiveText("SEND") .positiveColor(R.color.white).positiveColorRes(R.color.white).negativeText("CANCEL") .negativeColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText request_secret_code = (EditText) dialog .findViewById(R.id.request_secret_code); /*EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg);*/ if (request_secret_code != null) { if (request_secret_code.getText().toString() != null && request_secret_code.getText().toString() != "") { Location mLastLocation = LocationServices.FusedLocationApi .getLastLocation(mGoogleApiClient); Long tsLong = System.currentTimeMillis(); String ts = tsLong.toString(); String location = "96,16"; if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } final long timestamp = System.currentTimeMillis(); JSONObject obj = new JSONObject(); try { obj.put("location", location); obj.put("timestamp", String.valueOf(timestamp)); obj.put("secret_code", request_secret_code.getText().toString()); obj.put("message", "");//request_msg.getText().toString()); } catch (JSONException e) { e.printStackTrace(); } String json = obj.toString(); try { TypedInput in = new TypedByteArray("application/json", json.getBytes("UTF-8")); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); AvaliableJobsAPI.getInstance().getService().jobDone(jobitem.get_id(), token, in, new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Message is sent successfully", Toast.LENGTH_SHORT).show(); sPref.edit().putString(Config.TOKEN_DELAY, null) .commit(); if (sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)) { Intent intentservice = new Intent( JobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); bitLayout.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { //Toast.makeText(JobDetailActivity.this, "Failed, Please Try Again!", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err") .getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } }); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ).build(); dialog.show(); EditText request_secret_code = (EditText) dialog.findViewById(R.id.request_secret_code); /*EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg);*/ request_secret_code.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); /*request_msg.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL));*/ } break; case R.id.job_report: isFirstDialog = true; totalprice = Double.parseDouble(jobitem.get_price()); final MaterialDialog dialog = new MaterialDialog.Builder(this).customView(R.layout.report_layout, true) .positiveText("REPORT").positiveColor(R.color.white).positiveColorRes(R.color.white) .negativeText("CANCEL").negativeColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf").callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); //CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); //Refrage if (!et_message.getText().toString().equals("") && et_message.getText().toString() != null) { if (cb_weight.isChecked() || cb_express.isChecked() || cb_refrig.isChecked()) { String message = "";//et_message.getText().toString(); if (cb_express.isChecked()) { message += "true,"; } else { message += "false,"; } if (cb_refrig.isChecked()) { message += "true,"; } else { message += "false,"; } if (cb_weight.isChecked()) { message += weightlist.get(sp_weight.getSelectedItemPosition()) + ","; } else { message += ","; } AvaliableJobsAPI.getInstance().getService().reportJob(jobitem.get_id(), token, message, "0", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(JobDetailActivity.this, "Your report has successfully sent", Toast.LENGTH_SHORT) .show(); dialog.dismiss(); } @Override public void failure(RetrofitError error) { //Toast.makeText(JobDetailActivity.this, "Report is Failed", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(JobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT) .show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err") .getString("message"); Toast.makeText(JobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); } else { Toast.makeText(JobDetailActivity.this, "Please select report reason", Toast.LENGTH_SHORT).show(); } } else { Toast.makeText(JobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ).build(); dialog.show(); final CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); //final CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); et_message.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); cb_weight.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); cb_express.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); cb_refrig.setTypeface(MyTypeFace.get(JobDetailActivity.this, MyTypeFace.NORMAL)); if (jobitem.getIsExpress().equals("true")) { cb_express.setChecked(true); } if (jobitem.getIsRefrigerated().equals("true")) { cb_refrig.setChecked(true); } //final TextView tv_price = (TextView) dialog.findViewById(R.id.report_price_tag); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); sp_weight.setEnabled(false); //sp_type.setEnabled(false); //tv_price.setText("price " + jobitem.get_price()); sp_weight.setAdapter(new ArrayAdapter<String>(JobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, weightshowlist)); //sp_type.setAdapter(new ArrayAdapter<String>(JobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, new String[]{"Other", "Express", "Refrigerated"})); sp_weight.setSelection(weightpos); //sp_type.setSelection(typepos); sp_weight.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (!isFirstDialog) { totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } else { isFirstDialog = false; } /*if(cb_type.isChecked()){ totalprice += typepricelist.get(position); }*/ // tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); /*sp_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { totalprice = Double.parseDouble(jobitem.get_price()); if (!isFirstDialog) { totalprice += typepricelist.get(position); } else { isFirstDialog = false; } if (cb_weight.isChecked()) { totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } });*/ cb_weight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { sp_weight.setEnabled(true); totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } else { sp_weight.setEnabled(false); totalprice -= weightPricelist.get(sp_weight.getSelectedItemPosition()); } //tv_price.setText("price " + String.valueOf(totalprice)); } }); /*cb_type.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ sp_type.setEnabled(true); totalprice += typepricelist.get(sp_type.getSelectedItemPosition()); }else{ sp_type.setEnabled(false); totalprice -= typepricelist.get(sp_type.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } });*/ break; default: Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); break; } }
From source file:com.androidquery.AbstractAQuery.java
/** * Set the text typeface of a TextView./*from w w w. ja va2s.c o m*/ * * @param typeface typeface * @return self */ public T typeface(Typeface tf) { if (view instanceof TextView) { TextView tv = (TextView) view; tv.setTypeface(tf); } return self(); }
From source file:knayi.delevadriver.AvaliableJobDetailActivity.java
@Override public void onClick(View v) { Calendar calendar = Calendar.getInstance(); final long timestamp = System.currentTimeMillis(); final String token = sPref.getString(Config.TOKEN, null); switch (v.getId()) { /*case R.id.job_reject: //from w ww .j a v a2s .c om if(job_reject.getText().toString().equals("Reject")){ MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Rejecting") .titleColor(R.color.white) .customView(R.layout.reject_layout, true) .positiveText("REJECT") .positiveColor(R.color.white) .positiveColorRes(R.color.white) .negativeText("CANCEL") .negativeColorRes(R.color.white) .backgroundColorRes(R.color.primary) .typeface("ciclefina", "ciclegordita") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); if(!et_message.getText().toString().equals("")){ AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, et_message.getText().toString(), "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Job is successfully rejected", Toast.LENGTH_SHORT).show(); dialog.dismiss(); //remove job id that is saved to use in locatin update sPref.edit().putString(Config.TOKEN_JOBID, null).commit(); sPref.edit().putString(Config.TOKEN_DELAY, null).commit(); //check report service is alive //if alive stop service if(sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)){ Intent intentservice = new Intent(AvaliableJobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } Intent intent = new Intent(AvaliableJobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); }else{ Toast.makeText(AvaliableJobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); EditText et_message = (EditText) dialog.findViewById(R.id.reject_message); et_message.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); } *//*else{ final Dialog msgDialog = new Dialog(AvaliableJobDetailActivity.this); msgDialog.setTitle("Why do u reject?"); msgDialog.setCancelable(true); msgDialog.setContentView(R.layout.custom_dialog_reason); final EditText message = (EditText) msgDialog.findViewById(R.id.messagebox); Button submit = (Button) msgDialog.findViewById(R.id.submitbutton); msgDialog.show(); submit.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(message.getText().toString().equals("") && message.getText().toString().equals(null)){ Toast.makeText(getApplicationContext(), "Please input message to submit", Toast.LENGTH_SHORT).show(); }else{ msgDialog.dismiss(); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if(token == null){ new SweetAlertDialog(AvaliableJobDetailActivity.this, SweetAlertDialog.WARNING_TYPE) .setTitleText("") .setContentText("Please Login again!") .show(); finish(); startActivity(new Intent(AvaliableJobDetailActivity.this, LoginActivity.class)); } else{ AvaliableJobsAPI.getInstance().getService().rejectJob(jobitem.get_id(), token, location, String.valueOf(timestamp), message.getText().toString(), new Callback<String>() { @Override public void success(String s, Response response) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); startActivity(new Intent(AvaliableJobDetailActivity.this, TabMainActivity.class)); finish(); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); Toast.makeText(getApplicationContext(), "Something Went Wrong!", Toast.LENGTH_SHORT).show(); } }); } } } }); }*//* break;*/ case R.id.job_bid: progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (token == null) { MaterialDialog dialog = new MaterialDialog.Builder(this).positiveText("OK") .customView(R.layout.custom_message_dialog, false).positiveColor(R.color.white) .positiveColorRes(R.color.white).backgroundColorRes(R.color.primary) .typeface("ciclefina.ttf", "ciclegordita.ttf").build(); dialog.show(); TextView txt_title = (TextView) dialog.findViewById(R.id.dialog_title); TextView txt_message = (TextView) dialog.findViewById(R.id.dialog_message); txt_title.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); txt_message.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); txt_title.setText("Please Login again!"); txt_message.setText("Server doesn't know this account!"); Intent intent = new Intent(AvaliableJobDetailActivity.this, LoginActivity.class); startActivity(intent); finish(); } if (job_bid.getText().toString().equals("Bid")) { final long ts1 = System.currentTimeMillis(); Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } acceptJob(token, String.valueOf(ts1), ""); /*MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Estimate time of arrival to pick up point") .customView(R.layout.estimatetime_layout, true) .positiveText("BID") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .cancelable(false) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); if(!et_estimatetime.getText().toString().equals("")) { acceptJob(token, String.valueOf(ts1), et_estimatetime.getText().toString()); }else{ Toast.makeText(AvaliableJobDetailActivity.this, "Please Input Fields!", Toast.LENGTH_SHORT).show(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); final EditText et_estimatetime = (EditText) dialog.findViewById(R.id.estimatetime_et); et_estimatetime.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Calendar mcurrentTime = Calendar.getInstance(); int hour = mcurrentTime.get(Calendar.HOUR_OF_DAY); int minute = mcurrentTime.get(Calendar.MINUTE); TimePickerDialog mTimePicker; mTimePicker = new TimePickerDialog(AvaliableJobDetailActivity.this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { et_estimatetime.setText( selectedHour + ":" + selectedMinute); } }, hour, minute, true);//Yes 24 hour time mTimePicker.setTitle("Select Time"); mTimePicker.show(); } });*/ } else if (job_bid.getText().toString().equals("Agree")) { AvaliableJobsAPI.getInstance().getService().agreeJob(jobitem.get_id(), token, "true", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Success", Toast.LENGTH_SHORT) .show(); getDataFromServer(job_id); } @Override public void failure(RetrofitError error) { if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT) .show(); } catch (JSONException e) { e.printStackTrace(); } } } }); } /*else if(job_bid.getText().toString().equals("Finished")){ MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Secret Code") .customView(R.layout.custom_request_message_dialog, true) .positiveText("SEND") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .typeface("ciclefina", "ciclegordita") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); EditText request_secret_code = (EditText) dialog.findViewById(R.id.request_secret_code); EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg); if (request_secret_code != null) { if (request_secret_code.getText().toString() != null && request_secret_code.getText().toString() != "") { Location mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); Long tsLong = System.currentTimeMillis(); String ts = tsLong.toString(); String location = "96,16"; if (mLastLocation != null) { location = mLastLocation.getLongitude() + "," + mLastLocation.getLatitude(); } final long timestamp = System.currentTimeMillis(); JSONObject obj = new JSONObject(); try { obj.put("location", location); obj.put("timestamp", String.valueOf(timestamp)); obj.put("secret_code", request_secret_code.getText().toString()); obj.put("message", request_msg.getText().toString()); } catch (JSONException e) { e.printStackTrace(); } String json = obj.toString(); try { TypedInput in = new TypedByteArray("application/json", json.getBytes("UTF-8")); progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); AvaliableJobsAPI.getInstance().getService().jobDone(jobitem.get_id(), token, in, new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Message is sent successfully", Toast.LENGTH_SHORT).show(); sPref.edit().putString(Config.TOKEN_DELAY, null).commit(); if(sPref.getBoolean(Config.TOKEN_SERVICE_ALIVE, false)){ Intent intentservice = new Intent(AvaliableJobDetailActivity.this, BackgroundLocationService.class); stopService(intentservice); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); bitLayout.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { //Toast.makeText(AvaliableJobDetailActivity.this, "Failed, Please Try Again!", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } }); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); EditText request_secret_code = (EditText) dialog.findViewById(R.id.request_secret_code); EditText request_msg = (EditText) dialog.findViewById(R.id.request_msg); request_secret_code.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); request_msg.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); } break;*/ /*case R.id.job_report: isFirstDialog = true; totalprice = Double.parseDouble(jobitem.get_price()); final MaterialDialog dialog = new MaterialDialog.Builder(this) .title("Reporting") .customView(R.layout.report_layout, true) .positiveText("REPORT") .positiveColor(R.color.primary) .positiveColorRes(R.color.primary) .negativeText("CANCEL") .negativeColorRes(R.color.primary) .typeface("ciclefina", "ciclegordita") .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(final MaterialDialog dialog) { super.onPositive(dialog); CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); //CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); //Refrage if(!et_message.getText().toString().equals("") && et_message.getText().toString() != null) { if (cb_weight.isChecked() || cb_express.isChecked() || cb_refrig.isChecked()) { String message = "";//et_message.getText().toString(); if(cb_express.isChecked()){ message += "true,"; }else{ message += "false,"; } if(cb_refrig.isChecked()){ message += "true,"; }else{ message += "false,"; } if (cb_weight.isChecked()) { message += weightlist.get(sp_weight.getSelectedItemPosition()) + ","; }else{ message += ","; } AvaliableJobsAPI.getInstance().getService().reportJob(jobitem.get_id(), token, message, "0", new Callback<String>() { @Override public void success(String s, Response response) { Toast.makeText(AvaliableJobDetailActivity.this, "Your report has successfully sent", Toast.LENGTH_SHORT).show(); dialog.dismiss(); } @Override public void failure(RetrofitError error) { //Toast.makeText(AvaliableJobDetailActivity.this, "Report is Failed", Toast.LENGTH_SHORT).show(); if (error.getBody() == null) { Toast.makeText(AvaliableJobDetailActivity.this, "Cannot connect to server!", Toast.LENGTH_SHORT).show(); } else { String errmsg = error.getBody().toString(); String errcode = ""; try { JSONObject errobj = new JSONObject(errmsg); errcode = errobj.getJSONObject("err").getString("message"); Toast.makeText(AvaliableJobDetailActivity.this, errcode, Toast.LENGTH_SHORT).show(); } catch (JSONException e) { e.printStackTrace(); } } dialog.dismiss(); } }); } else { Toast.makeText(AvaliableJobDetailActivity.this, "Please select report reason", Toast.LENGTH_SHORT).show(); } }else{ Toast.makeText(AvaliableJobDetailActivity.this, "Please enter your message", Toast.LENGTH_SHORT).show(); } progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } @Override public void onNegative(MaterialDialog dialog) { super.onNegative(dialog); dialog.dismiss(); progress.setVisibility(View.INVISIBLE); progress_background.setVisibility(View.INVISIBLE); } } ) .build(); dialog.show(); */ /* TextView tv_pricecategory = (TextView) dialog.findViewById(R.id.to_pricecategory); tv_pricecategory.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(new Intent(dialog.getContext(), PriceCategoryActivity.class)); } });*//* final CheckBox cb_weight = (CheckBox) dialog.findViewById(R.id.report_cb_overweight); //final CheckBox cb_type = (CheckBox) dialog.findViewById(R.id.report_cb_type); CheckBox cb_express = (CheckBox) dialog.findViewById(R.id.report_cb_express); CheckBox cb_refrig = (CheckBox) dialog.findViewById(R.id.report_cb_refrigerated); EditText et_message = (EditText) dialog.findViewById(R.id.report_et_message); cb_weight.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); cb_express.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); cb_refrig.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); et_message.setTypeface(MyTypeFace.get(AvaliableJobDetailActivity.this, MyTypeFace.NORMAL)); if(typepos == 1){ cb_express.setChecked(true); } if(typepos == 2){ cb_refrig.setChecked(true); } //final TextView tv_price = (TextView) dialog.findViewById(R.id.report_price_tag); final Spinner sp_weight = (Spinner) dialog.findViewById(R.id.report_spinner_overweight); //final Spinner sp_type = (Spinner) dialog.findViewById(R.id.report_spinner_type); sp_weight.setEnabled(false); //sp_type.setEnabled(false); //tv_price.setText("price " + jobitem.get_price()); sp_weight.setAdapter(new ArrayAdapter<String>(AvaliableJobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, weightshowlist)); //sp_type.setAdapter(new ArrayAdapter<String>(AvaliableJobDetailActivity.this, android.R.layout.simple_spinner_dropdown_item, new String[]{"Other", "Express", "Refrigerated"})); sp_weight.setSelection(weightpos); //sp_type.setSelection(typepos); sp_weight.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { if (!isFirstDialog){ totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); }else{ isFirstDialog = false; } *//*if(cb_type.isChecked()){ totalprice += typepricelist.get(position); }*//* // tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); *//*sp_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { totalprice = Double.parseDouble(jobitem.get_price()); if (!isFirstDialog) { totalprice += typepricelist.get(position); } else { isFirstDialog = false; } if (cb_weight.isChecked()) { totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } @Override public void onNothingSelected(AdapterView<?> parent) { } });*//* cb_weight.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ sp_weight.setEnabled(true); totalprice += weightPricelist.get(sp_weight.getSelectedItemPosition()); }else{ sp_weight.setEnabled(false); totalprice -= weightPricelist.get(sp_weight.getSelectedItemPosition()); } //tv_price.setText("price " + String.valueOf(totalprice)); } }); *//*cb_type.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(isChecked){ sp_type.setEnabled(true); totalprice += typepricelist.get(sp_type.getSelectedItemPosition()); }else{ sp_type.setEnabled(false); totalprice -= typepricelist.get(sp_type.getSelectedItemPosition()); } tv_price.setText("price " + String.valueOf(totalprice)); } });*//* break;*/ default: Intent intent = new Intent(AvaliableJobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); break; } }
From source file:com.farmerbb.notepad.fragment.NoteViewFragment.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*ww w . ja v a 2s . com*/ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Get filename of saved note filename = getArguments().getString("filename"); // Change window title String title; try { title = listener.loadNoteTitle(filename); } catch (IOException e) { title = getResources().getString(R.string.view_note); } getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Bitmap bitmap = ((BitmapDrawable) ContextCompat.getDrawable(getActivity(), R.drawable.ic_recents_logo)) .getBitmap(); ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, bitmap, ContextCompat.getColor(getActivity(), R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view TextView noteContents = getActivity().findViewById(R.id.textView); markdownView = getActivity().findViewById(R.id.markdownView); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = getActivity().findViewById(R.id.scrollView); String theme = pref.getString("theme", "light-sans"); int textSize = -1; int textColor = -1; String fontFamily = null; if (theme.contains("light")) { if (noteContents != null) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (markdownView != null) { markdownView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); textColor = ContextCompat.getColor(getActivity(), R.color.text_color_primary); } scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (theme.contains("dark")) { if (noteContents != null) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark)); noteContents .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (markdownView != null) { markdownView .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); textColor = ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark); } scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (theme.contains("sans")) { if (noteContents != null) noteContents.setTypeface(Typeface.SANS_SERIF); if (markdownView != null) fontFamily = "sans-serif"; } if (theme.contains("serif")) { if (noteContents != null) noteContents.setTypeface(Typeface.SERIF); if (markdownView != null) fontFamily = "serif"; } if (theme.contains("monospace")) { if (noteContents != null) noteContents.setTypeface(Typeface.MONOSPACE); if (markdownView != null) fontFamily = "monospace"; } switch (pref.getString("font_size", "normal")) { case "smallest": textSize = 12; break; case "small": textSize = 14; break; case "normal": textSize = 16; break; case "large": textSize = 18; break; case "largest": textSize = 20; break; } if (noteContents != null) noteContents.setTextSize(textSize); String css = ""; if (markdownView != null) { String topBottom = " " + Float.toString(getResources().getDimension(R.dimen.padding_top_bottom) / getResources().getDisplayMetrics().density) + "px"; String leftRight = " " + Float.toString(getResources().getDimension(R.dimen.padding_left_right) / getResources().getDisplayMetrics().density) + "px"; String fontSize = " " + Integer.toString(textSize) + "px"; String fontColor = " #" + StringUtils.remove(Integer.toHexString(textColor), "ff"); String linkColor = " #" + StringUtils.remove( Integer.toHexString(new TextView(getActivity()).getLinkTextColors().getDefaultColor()), "ff"); css = "body { " + "margin:" + topBottom + topBottom + leftRight + leftRight + "; " + "font-family:" + fontFamily + "; " + "font-size:" + fontSize + "; " + "color:" + fontColor + "; " + "}" + "a { " + "color:" + linkColor + "; " + "}"; markdownView.getSettings().setJavaScriptEnabled(false); markdownView.getSettings().setLoadsImagesAutomatically(false); markdownView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) try { startActivity(intent); } catch (ActivityNotFoundException | FileUriExposedException e) { /* Gracefully fail */ } else try { startActivity(intent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } return true; } }); } // Load note contents try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } // Set TextView contents if (noteContents != null) noteContents.setText(contentsOnLoad); if (markdownView != null) markdownView.loadMarkdown(contentsOnLoad, "data:text/css;base64," + Base64.encodeToString(css.getBytes(), Base64.DEFAULT)); // Show a toast message if this is the user's first time viewing a note final SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); firstLoad = sharedPref.getInt("first-load", 0); if (firstLoad == 0) { // Show dialog with info DialogFragment firstLoad = new FirstViewDialogFragment(); firstLoad.show(getFragmentManager(), "firstloadfragment"); // Set first-load preference to 1; we don't need to show the dialog anymore SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("first-load", 1); editor.apply(); } // Detect single and double-taps using GestureDetector final GestureDetector detector = new GestureDetector(getActivity(), new GestureDetector.OnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public boolean onDown(MotionEvent e) { return false; } }); detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true)) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("show_double_tap_message", false); editor.apply(); } Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true) && showMessage) { showToastLong(R.string.double_tap); showMessage = false; } return false; } }); if (noteContents != null) noteContents.setOnTouchListener((v, event) -> { detector.onTouchEvent(event); return false; }); if (markdownView != null) markdownView.setOnTouchListener((v, event) -> { detector.onTouchEvent(event); return false; }); }
From source file:com.anjalimacwan.fragment.NoteViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from w ww . jav a 2 s .c o m*/ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Set values setRetainInstance(true); setHasOptionsMenu(true); // Get filename of saved note filename = getArguments().getString("filename"); // Change window title String title; try { title = listener.loadNoteTitle(filename); } catch (IOException e) { title = getResources().getString(R.string.view_note); } getActivity().setTitle(title); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription(title, null, ContextCompat.getColor(getActivity(), R.color.primary)); getActivity().setTaskDescription(taskDescription); } // Show the Up button in the action bar. ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Animate elevation change if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-large") && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { LinearLayout noteViewEdit = (LinearLayout) getActivity().findViewById(R.id.noteViewEdit); LinearLayout noteList = (LinearLayout) getActivity().findViewById(R.id.noteList); noteList.animate().z(0f); if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) noteViewEdit.animate() .z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation_land)); else noteViewEdit.animate().z(getResources().getDimensionPixelSize(R.dimen.note_view_edit_elevation)); } // Set up content view TextView noteContents = (TextView) getActivity().findViewById(R.id.textView); markdownView = (MarkdownView) getActivity().findViewById(R.id.markdownView); // Apply theme SharedPreferences pref = getActivity().getSharedPreferences(getActivity().getPackageName() + "_preferences", Context.MODE_PRIVATE); ScrollView scrollView = (ScrollView) getActivity().findViewById(R.id.scrollView); String theme = pref.getString("theme", "light-sans"); int textSize = -1; int textColor = -1; String fontFamily = null; if (theme.contains("light")) { if (noteContents != null) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary)); noteContents.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (markdownView != null) { markdownView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); textColor = ContextCompat.getColor(getActivity(), R.color.text_color_primary); } scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background)); } if (theme.contains("dark")) { if (noteContents != null) { noteContents.setTextColor(ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark)); noteContents .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (markdownView != null) { markdownView .setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); textColor = ContextCompat.getColor(getActivity(), R.color.text_color_primary_dark); } scrollView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.window_background_dark)); } if (theme.contains("sans")) { if (noteContents != null) noteContents.setTypeface(Typeface.SANS_SERIF); if (markdownView != null) fontFamily = "sans-serif"; } if (theme.contains("serif")) { if (noteContents != null) noteContents.setTypeface(Typeface.SERIF); if (markdownView != null) fontFamily = "serif"; } if (theme.contains("monospace")) { if (noteContents != null) noteContents.setTypeface(Typeface.MONOSPACE); if (markdownView != null) fontFamily = "monospace"; } switch (pref.getString("font_size", "normal")) { case "smallest": textSize = 12; break; case "small": textSize = 14; break; case "normal": textSize = 16; break; case "large": textSize = 18; break; case "largest": textSize = 20; break; } if (noteContents != null) noteContents.setTextSize(textSize); if (markdownView != null) { String topBottom = " " + Float.toString(getResources().getDimension(R.dimen.padding_top_bottom) / getResources().getDisplayMetrics().density) + "px"; String leftRight = " " + Float.toString(getResources().getDimension(R.dimen.padding_left_right) / getResources().getDisplayMetrics().density) + "px"; String fontSize = " " + Integer.toString(textSize) + "px"; String fontColor = " #" + StringUtils.remove(Integer.toHexString(textColor), "ff"); final String css = "body { " + "margin:" + topBottom + topBottom + leftRight + leftRight + "; " + "font-family:" + fontFamily + "; " + "font-size:" + fontSize + "; " + "color:" + fontColor + "; " + "}"; final String js = "var styleNode = document.createElement('style');\n" + "styleNode.type = \"text/css\";\n" + "var styleText = document.createTextNode('" + css + "');\n" + "styleNode.appendChild(styleText);\n" + "document.getElementsByTagName('head')[0].appendChild(styleNode);\n"; markdownView.getSettings().setJavaScriptEnabled(true); markdownView.getSettings().setLoadsImagesAutomatically(false); markdownView.setWebViewClient(new WebViewClient() { @TargetApi(Build.VERSION_CODES.N) @Override public void onLoadResource(WebView view, String url) { view.stopLoading(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) try { startActivity(intent); } catch (ActivityNotFoundException | FileUriExposedException e) { /* Gracefully fail */ } else try { startActivity(intent); } catch (ActivityNotFoundException e) { /* Gracefully fail */ } } @Override public void onPageFinished(WebView view, String url) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) view.evaluateJavascript(js, null); else view.loadUrl("javascript:" + js); } }); } // Load note contents try { contentsOnLoad = listener.loadNote(filename); } catch (IOException e) { showToast(R.string.error_loading_note); // Add NoteListFragment or WelcomeFragment Fragment fragment; if (getActivity().findViewById(R.id.layoutMain).getTag().equals("main-layout-normal")) fragment = new NoteListFragment(); else fragment = new WelcomeFragment(); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteListFragment") .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit(); } // Set TextView contents if (noteContents != null) noteContents.setText(contentsOnLoad); if (markdownView != null) markdownView.loadMarkdown(contentsOnLoad); // Show a toast message if this is the user's first time viewing a note final SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE); firstLoad = sharedPref.getInt("first-load", 0); if (firstLoad == 0) { // Show dialog with info DialogFragment firstLoad = new FirstViewDialogFragment(); firstLoad.show(getFragmentManager(), "firstloadfragment"); // Set first-load preference to 1; we don't need to show the dialog anymore SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("first-load", 1); editor.apply(); } // Detect single and double-taps using GestureDetector final GestureDetector detector = new GestureDetector(getActivity(), new GestureDetector.OnGestureListener() { @Override public boolean onSingleTapUp(MotionEvent e) { return false; } @Override public void onShowPress(MotionEvent e) { } @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { return false; } @Override public void onLongPress(MotionEvent e) { } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public boolean onDown(MotionEvent e) { return false; } }); detector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() { @Override public boolean onDoubleTap(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true)) { SharedPreferences.Editor editor = sharedPref.edit(); editor.putBoolean("show_double_tap_message", false); editor.apply(); } Bundle bundle = new Bundle(); bundle.putString("filename", filename); Fragment fragment = new NoteEditFragment(); fragment.setArguments(bundle); getFragmentManager().beginTransaction().replace(R.id.noteViewEdit, fragment, "NoteEditFragment") .commit(); return false; } @Override public boolean onDoubleTapEvent(MotionEvent e) { return false; } @Override public boolean onSingleTapConfirmed(MotionEvent e) { if (sharedPref.getBoolean("show_double_tap_message", true) && showMessage) { showToastLong(R.string.double_tap); showMessage = false; } return false; } }); if (noteContents != null) noteContents.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); if (markdownView != null) markdownView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { detector.onTouchEvent(event); return false; } }); }
From source file:com.android.argb.edhlc.Utils.java
public static void createRecordListElement(Activity parent, Record currentRecord, String highlightedPlayerName) { TextView textDateRecordCard = (TextView) parent.findViewById(R.id.textDateRecordCard); LinearLayout linearFirstLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearFirstLineRecordCard); TextView textFirstIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFirstIndicatorRecordCard); TextView textFirstPlayerRecordCard = (TextView) parent.findViewById(R.id.textFirstPlayerRecordCard); TextView textFirstDeckRecordCard = (TextView) parent.findViewById(R.id.textFirstDeckRecordCard); View divider1RecordCard = parent.findViewById(R.id.divider1RecordCard); LinearLayout linearSecondLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearSecondLineRecordCard); TextView textSecondIndicatorRecordCard = (TextView) parent.findViewById(R.id.textSecondIndicatorRecordCard); TextView textSecondPlayerRecordCard = (TextView) parent.findViewById(R.id.textSecondPlayerRecordCard); TextView textSecondDeckRecordCard = (TextView) parent.findViewById(R.id.textSecondDeckRecordCard); View divider2RecordCard = parent.findViewById(R.id.divider2RecordCard); LinearLayout linearThirdLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearThirdLineRecordCard); TextView textThirdIndicatorRecordCard = (TextView) parent.findViewById(R.id.textThirdIndicatorRecordCard); TextView textThirdPlayerRecordCard = (TextView) parent.findViewById(R.id.textThirdPlayerRecordCard); TextView textThirdDeckRecordCard = (TextView) parent.findViewById(R.id.textThirdDeckRecordCard); View divider3RecordCard = parent.findViewById(R.id.divider3RecordCard); LinearLayout linearFourthLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearFourthLineRecordCard); TextView textFourthIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFourthIndicatorRecordCard); TextView textFourthPlayerRecordCard = (TextView) parent.findViewById(R.id.textFourthPlayerRecordCard); TextView textFourthDeckRecordCard = (TextView) parent.findViewById(R.id.textFourthDeckRecordCard); Typeface typefaceMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL); Typeface typefaceNormal = Typeface.create("sans-serif", Typeface.NORMAL); int colorAccent = ContextCompat.getColor(parent, R.color.accent_color); int colorSecondary = ContextCompat.getColor(parent, R.color.secondary_text); textDateRecordCard.setText(String.format("Played on %s", currentRecord.getDate())); switch (currentRecord.getTotalPlayers()) { case 2://from ww w .jav a2 s. c om linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.GONE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.GONE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 3: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 4: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.VISIBLE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.VISIBLE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); textFourthDeckRecordCard.setText(currentRecord.getFourthPlace().getDeckName()); textFourthPlayerRecordCard.setText(currentRecord.getFourthPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFourthIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; } }
From source file:com.android.argb.edhlc.Utils.java
public static void createRecordListElement(View parent, Record currentRecord, String highlightedPlayerName) { RelativeLayout selectedRecord = (RelativeLayout) parent.findViewById(R.id.selectedRecord); selectedRecord.setVisibility(currentRecord.isSelected() ? View.VISIBLE : View.GONE); TextView textDateRecordCard = (TextView) parent.findViewById(R.id.textDateRecordCard); LinearLayout linearFirstLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearFirstLineRecordCard); TextView textFirstIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFirstIndicatorRecordCard); TextView textFirstPlayerRecordCard = (TextView) parent.findViewById(R.id.textFirstPlayerRecordCard); TextView textFirstDeckRecordCard = (TextView) parent.findViewById(R.id.textFirstDeckRecordCard); View divider1RecordCard = parent.findViewById(R.id.divider1RecordCard); LinearLayout linearSecondLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearSecondLineRecordCard); TextView textSecondIndicatorRecordCard = (TextView) parent.findViewById(R.id.textSecondIndicatorRecordCard); TextView textSecondPlayerRecordCard = (TextView) parent.findViewById(R.id.textSecondPlayerRecordCard); TextView textSecondDeckRecordCard = (TextView) parent.findViewById(R.id.textSecondDeckRecordCard); View divider2RecordCard = parent.findViewById(R.id.divider2RecordCard); LinearLayout linearThirdLineRecordCard = (LinearLayout) parent.findViewById(R.id.linearThirdLineRecordCard); TextView textThirdIndicatorRecordCard = (TextView) parent.findViewById(R.id.textThirdIndicatorRecordCard); TextView textThirdPlayerRecordCard = (TextView) parent.findViewById(R.id.textThirdPlayerRecordCard); TextView textThirdDeckRecordCard = (TextView) parent.findViewById(R.id.textThirdDeckRecordCard); View divider3RecordCard = parent.findViewById(R.id.divider3RecordCard); LinearLayout linearFourthLineRecordCard = (LinearLayout) parent .findViewById(R.id.linearFourthLineRecordCard); TextView textFourthIndicatorRecordCard = (TextView) parent.findViewById(R.id.textFourthIndicatorRecordCard); TextView textFourthPlayerRecordCard = (TextView) parent.findViewById(R.id.textFourthPlayerRecordCard); TextView textFourthDeckRecordCard = (TextView) parent.findViewById(R.id.textFourthDeckRecordCard); Typeface typefaceMedium = Typeface.create("sans-serif-medium", Typeface.NORMAL); Typeface typefaceNormal = Typeface.create("sans-serif", Typeface.NORMAL); int colorAccent = ContextCompat.getColor(parent.getContext(), R.color.accent_color); int colorSecondary = ContextCompat.getColor(parent.getContext(), R.color.secondary_text); textDateRecordCard.setText(String.format("Played on %s", currentRecord.getDate())); switch (currentRecord.getTotalPlayers()) { case 2://from ww w .j a v a 2 s. c o m linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.GONE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.GONE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 3: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.GONE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.GONE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; case 4: linearFirstLineRecordCard.setVisibility(View.VISIBLE); linearSecondLineRecordCard.setVisibility(View.VISIBLE); linearThirdLineRecordCard.setVisibility(View.VISIBLE); linearFourthLineRecordCard.setVisibility(View.VISIBLE); divider1RecordCard.setVisibility(View.VISIBLE); divider2RecordCard.setVisibility(View.VISIBLE); divider3RecordCard.setVisibility(View.VISIBLE); textFirstDeckRecordCard.setText(currentRecord.getFirstPlace().getDeckName()); textFirstPlayerRecordCard.setText(currentRecord.getFirstPlace().getDeckOwnerName()); textSecondDeckRecordCard.setText(currentRecord.getSecondPlace().getDeckName()); textSecondPlayerRecordCard.setText(currentRecord.getSecondPlace().getDeckOwnerName()); textThirdDeckRecordCard.setText(currentRecord.getThirdPlace().getDeckName()); textThirdPlayerRecordCard.setText(currentRecord.getThirdPlace().getDeckOwnerName()); textFourthDeckRecordCard.setText(currentRecord.getFourthPlace().getDeckName()); textFourthPlayerRecordCard.setText(currentRecord.getFourthPlace().getDeckOwnerName()); if (highlightedPlayerName != null) { textFirstDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFirstIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFirstIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFirstPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textSecondIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textSecondIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getSecondPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textThirdIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textThirdIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getThirdPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthDeckRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthPlayerRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); textFourthIndicatorRecordCard.setTextColor( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? colorAccent : colorSecondary); textFourthIndicatorRecordCard.setTypeface( highlightedPlayerName.equalsIgnoreCase(currentRecord.getFourthPlace().getDeckOwnerName()) ? typefaceMedium : typefaceNormal); } break; } }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
private void SlideExteriorLayout() { final SharedPreferences settings = getSharedPreferences("mysettings", 0); final SharedPreferences.Editor editor = settings.edit(); final Dialog exteriordialog = new Dialog(CarCheckListActivity.this, R.style.backgrounddialog); exteriordialog.requestWindowFeature(Window.FEATURE_NO_TITLE); exteriordialog.setContentView(R.layout.exteriordialoglayout); exteriordialog.getWindow().getAttributes().windowAnimations = R.style.ExteriorDialogAnimation; exteriordialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); // make everything around Dialog brightness than default WindowManager.LayoutParams lp = exteriordialog.getWindow().getAttributes(); lp.dimAmount = 0f;/* ww w . j a v a2 s. c o m*/ final CheckBox chkoutside_color = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_color); final CheckBox chkoutside_window = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_window); final CheckBox chkoutside_doorHood = (CheckBox) exteriordialog.getWindow() .findViewById(R.id.outside_doorHood); final CheckBox chkoutside_jack = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_jack); final CheckBox chkoutside_wrench = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_wrench); final CheckBox chkoutside_tires = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_tires); final CheckBox chkoutside_light = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_light); final CheckBox chkoutside_seal = (CheckBox) exteriordialog.getWindow().findViewById(R.id.outside_seal); final CheckBox chkoutside_tirePart = (CheckBox) exteriordialog.getWindow() .findViewById(R.id.outside_tirePart); // Change font chkoutside_color.setTypeface(type); chkoutside_window.setTypeface(type); chkoutside_doorHood.setTypeface(type); chkoutside_jack.setTypeface(type); chkoutside_wrench.setTypeface(type); chkoutside_tires.setTypeface(type); chkoutside_light.setTypeface(type); chkoutside_seal.setTypeface(type); chkoutside_tirePart.setTypeface(type); exteriordialog.setCanceledOnTouchOutside(true); exteriordialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400); slideoutheadexterior.setDuration(500); slideoutheadexterior.setFillAfter(true); headexterior.startAnimation(slideoutheadexterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("outside_color", chkoutside_color.isChecked()); mp.put("outside_window", chkoutside_window.isChecked()); mp.put("outside_doorHood", chkoutside_doorHood.isChecked()); mp.put("outside_jack", chkoutside_jack.isChecked()); mp.put("outside_wrench", chkoutside_wrench.isChecked()); mp.put("outside_tires", chkoutside_tires.isChecked()); mp.put("outside_light", chkoutside_light.isChecked()); mp.put("outside_seal", chkoutside_seal.isChecked()); mp.put("outside_tirePart", chkoutside_tirePart.isChecked()); filterStore("exterior", mp); save(mp); } }); TextView exterior = (TextView) exteriordialog.getWindow().findViewById(R.id.Exterior); exterior.setTypeface(type); Button exteriorback = (Button) exteriordialog.getWindow().findViewById(R.id.Exteriorback); exteriorback.setTypeface(type); exteriorback.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { exteriordialog.dismiss(); headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadexterior = new TranslateAnimation(0, 0, 380, -400); slideoutheadexterior.setDuration(500); slideoutheadexterior.setFillAfter(true); headexterior.startAnimation(slideoutheadexterior); Map<String, Boolean> mp = new HashMap<String, Boolean>(); mp.put("outside_color", chkoutside_color.isChecked()); mp.put("outside_window", chkoutside_window.isChecked()); mp.put("outside_doorHood", chkoutside_doorHood.isChecked()); mp.put("outside_jack", chkoutside_jack.isChecked()); mp.put("outside_wrench", chkoutside_wrench.isChecked()); mp.put("outside_tires", chkoutside_tires.isChecked()); mp.put("outside_light", chkoutside_light.isChecked()); mp.put("outside_seal", chkoutside_seal.isChecked()); mp.put("outside_tirePart", chkoutside_tirePart.isChecked()); filterStore("exterior", mp); save(mp); } }); chkoutside_color.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_window.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_doorHood.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_jack.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_wrench.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_tires.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_light.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_seal.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); chkoutside_tirePart.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { boolean increment = true; if (((CheckBox) v).isChecked()) { getTotalExterior(increment); } else { increment = false; getTotalExterior(increment); } ExteriorProgress.setProgress(PercenExterior); percenexterior.setText("" + PercenExterior + "%"); RatioProgress.setProgress(PercenRatio); Ratiotext.setText("Rating of the Vehicle. " + PercenRatio + " %"); CheckRatio(); } }); headexterior.setVisibility(ImageView.VISIBLE); TranslateAnimation slideheadexterior = new TranslateAnimation(0, 0, 0, 380); slideheadexterior.setDuration(500); slideheadexterior.setFillAfter(true); headexterior.startAnimation(slideheadexterior); exteriordialog.show(); WindowManager.LayoutParams params = exteriordialog.getWindow().getAttributes(); params.y = 0; params.x = 60; params.gravity = Gravity.TOP | Gravity.LEFT; exteriordialog.getWindow().setAttributes(params); chkoutside_color.setChecked(load("outside_color")); chkoutside_window.setChecked(load("outside_window")); chkoutside_doorHood.setChecked(load("outside_doorHood")); chkoutside_jack.setChecked(load("outside_jack")); chkoutside_wrench.setChecked(load("outside_wrench")); chkoutside_tires.setChecked(load("outside_tires")); chkoutside_light.setChecked(load("outside_light")); chkoutside_seal.setChecked(load("outside_seal")); chkoutside_tirePart.setChecked(load("outside_tirePart")); }