List of usage examples for android.content Intent FLAG_ACTIVITY_CLEAR_TASK
int FLAG_ACTIVITY_CLEAR_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_CLEAR_TASK.
Click Source Link
From source file:knayi.delevadriver.JobDetailActivity.java
private void getDataFromServer(String jobid) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (jobid == null) { jobid = ""; }//from w w w.ja v a2s . com AvaliableJobsAPI.getInstance().getService().getJobDetail(jobid, sPref.getString(Config.TOKEN, ""), new Callback<String>() { @Override public void success(String s, Response response) { Log.i("Output Data", s.toString()); try { JSONObject jsonobject = new JSONObject(s); if (!jsonobject.isNull("data")) { JSONObject jsonobj = jsonobject.getJSONObject("data"); jobitem = new JobItem(); if (!jsonobj.isNull("_id")) jobitem.set_id(jsonobj.getString("_id")); JSONObject requesterobj = jsonobj.getJSONObject("requester"); if (requesterobj != null) { if (!requesterobj.isNull("name")) { jobitem.set_requester_name(requesterobj.getString("name")); } else { jobitem.set_requester_name("none"); } if (!requesterobj.isNull("email")) { jobitem.set_requester_email(requesterobj.getString("email")); } else { jobitem.set_requester_email("none"); } if (!requesterobj.isNull("mobile_number")) jobitem.set_requester_mobile_number( requesterobj.getString("mobile_number")); if (!requesterobj.isNull("address")) jobitem.set_requester_address(requesterobj.getString("address")); /* if(requesterobj.getString("business_type") != null) jobitem.set_requester_business_type(requesterobj.getString("business_type")); */ if (!requesterobj.isNull("business_address")) jobitem.set_requester_business_address( requesterobj.getString("business_address")); JSONArray requester_pictures = requesterobj.getJSONArray("pictures"); List<String> pic_list = new ArrayList<String>(); for (int j = 0; j < requester_pictures.length(); j++) { JSONObject obj = requester_pictures.getJSONObject(j); if (!obj.isNull("path")) pic_list.add(obj.getString("path")); } } /*if(!jsonobj.isNull("type")) jobitem.set_type(jsonobj.getString("type")); else jobitem.set_type("None");*/ if (!jsonobj.isNull("address")) jobitem.set_address(jsonobj.getString("address")); else jobitem.set_address("None"); if (!jsonobj.isNull("receiver_name")) jobitem.set_receiver_name(jsonobj.getString("receiver_name")); else jobitem.set_receiver_name("None"); if (!jsonobj.isNull("receiver_contact")) jobitem.set_receiver_contact(jsonobj.getString("receiver_contact")); else jobitem.set_receiver_contact("None"); if (!jsonobj.isNull("size")) { jobitem.set_size(jsonobj.getString("size")); } else { jobitem.set_size("None"); } if (!jsonobj.isNull("weight")) { jobitem.set_weight(jsonobj.getString("weight")); } else { jobitem.set_weight("None"); } if (!jsonobj.isNull("sensitivity")) { jobitem.set_sensitivity(jsonobj.getString("sensitivity")); } else { jobitem.set_sensitivity("None"); } if (!jsonobj.isNull("pickup_time")) { jobitem.set_pickuptime(jsonobj.getString("pickup_time")); } else { jobitem.set_pickuptime("None"); } if (!jsonobj.isNull("duration_text")) { jobitem.set_duration(jsonobj.getString("duration_text")); } else { jobitem.set_duration("None"); } if (!jsonobj.isNull("post_code")) jobitem.set_post_code(jsonobj.getString("post_code")); if (!jsonobj.isNull("pickup_ll")) { jobitem.set_pickup_lon((Double) jsonobj.getJSONArray("pickup_ll").get(0)); jobitem.set_pickup_lat((Double) jsonobj.getJSONArray("pickup_ll").get(1)); } if (!jsonobj.isNull("address_ll")) { jobitem.set_address_lon((Double) jsonobj.getJSONArray("address_ll").get(0)); jobitem.set_address_lat((Double) jsonobj.getJSONArray("address_ll").get(1)); } if (!jsonobj.isNull("type_express")) { jobitem.setIsExpress(String.valueOf(jsonobj.getBoolean("type_express"))); } if (!jsonobj.isNull("type_refigerated")) { jobitem.setIsRefrigerated( String.valueOf(jsonobj.getBoolean("type_refigerated"))); } //jobitem.set_reports(jsonobj.getString("reports")); //jobitem.set_rejectMessage(jsonobj.getString("rejectMessage")); if (!jsonobj.isNull("status")) jobitem.set_status(jsonobj.getString("status")); else jobitem.set_status("None"); if (!jsonobj.isNull("pictures")) { JSONArray pictures = jsonobj.getJSONArray("pictures"); List<String> pic_list1 = new ArrayList<String>(); for (int j = 0; j < pictures.length(); j++) { JSONObject obj = pictures.getJSONObject(j); if (obj.getString("path") != null) pic_list1.add(obj.getString("path")); } if (pic_list1.size() > 0) { jobitem.set_pictures(pic_list1.get(0)); imageprogress.setVisibility(View.VISIBLE); Picasso.with(JobDetailActivity.this) .load(APIConfig.DOMAIN_URL + pic_list1.get(0)) .into(imageView, new com.squareup.picasso.Callback() { @Override public void onSuccess() { imageprogress.setVisibility(View.INVISIBLE); } @Override public void onError() { } }); } } if (!jsonobj.isNull("price")) { jobitem.set_price(jsonobj.getString("price")); totalprice = Double.parseDouble(jsonobj.getString("price")); } else { jobitem.set_price("None"); } if (!jsonobj.isNull("createAt")) jobitem.set_createAt(jsonobj.getString("createAt")); else { jobitem.set_createAt("None"); } } } catch (JSONException jsonexception) { jsonexception.printStackTrace(); Log.i("APIData", "error"); } if (Integer.parseInt(jobitem.get_weight()) <= 10) { weightpos = 0; weightPricelist = Arrays.asList(new Double[] { 0.00, 4.00, 8.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 20) { weightpos = 1; weightPricelist = Arrays.asList(new Double[] { -4.00, 0.00, 4.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 30) { weightpos = 2; weightPricelist = Arrays.asList(new Double[] { -8.00, -4.00, 0.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } //Log.i("Weight", String.valueOf(Integer.parseInt(jobitem.get_weight()))); /*String type = jobitem.get_type(); if(type.equals("other")){ typepos = 0; jobtype.setText("Type: Other"); //typepricelist = Arrays.asList(new Double[]{0.00, 3.00, 3.00}); }else if(type.equals("express")){ typepos = 1; jobtype.setText("Type: Express"); //typepricelist = Arrays.asList(new Double[]{-3.00, 0.00, 0.00}); }else if(type.equals("freezen")){ typepos = 2; jobtype.setText("Type: Refrigerated"); //typepricelist = Arrays.asList(new Double[]{-3.00, 0.00, 0.00}); }else{ jobtype.setText("Type: None"); //typepricelist = Arrays.asList(new Double[]{0.00, 0.00, 0.00}); }*/ //jobtype.setText(jobitem.get_requester_name()); if (!jobitem.get_pickuptime().equals("None")) { String str = jobitem.get_pickuptime(); String datestr = str.substring(0, 10); String timestr = str.substring(11, 16); pickuptime.setText("Pick Up Time: " + timestr); pickupdate.setText("Pick Up Date: " + datestr); } else { pickuptime.setText("Pick Up Time: " + jobitem.get_pickuptime()); pickupdate.setText("Pick Up Date: " + jobitem.get_pickuptime()); } if (jobitem.get_price() != null) { jobprice.setText("SGD$ " + jobitem.get_price()); } else { jobprice.setText("None"); } if (jobitem.get_address() != null) { deliveryaddress.setText("Delivery Address: " + jobitem.get_address()); } else { deliveryaddress.setText("None"); } /*if(jobitem.get_createAt() != null) { String date = getDateFromtimeFormat(jobitem.get_createAt()); jobcreatetime.setText("" + date); } else jobcreatetime.setText("not include"); */ //requestername.setText("" + jobitem.get_requester()); //requesterbusinesstype.setText("" + jobitem.get_requester_business_type()); if (jobitem.get_requester_mobile_number() != null) { requesterphone.setText("Contact: " + jobitem.get_requester_mobile_number()); } else { requesterphone.setText("None"); } if (jobitem.get_requester_name() != null) { requestername.setText("Name: " + jobitem.get_requester_name()); } else { requestername.setText("None"); } if (jobitem.get_requester_address() != null) { requesteraddress.setText("Pick Up Address: " + jobitem.get_requester_address()); } else { requesteraddress.setText("None"); } if (jobitem.get_receiver_name() != null) { receivername.setText("Name: " + jobitem.get_receiver_name()); } else { receivername.setText("None"); } if (jobitem.get_receiver_contact() != null) { receivercontact.setText("Contact: " + jobitem.get_receiver_contact()); } else { receivercontact.setText("None"); } /*if(jobitem.get_size() != null) { size.setText("Size: " + jobitem.get_size()); }else{ size.setText("None"); }*/ if (jobitem.get_weight() != null) { weight.setText("Weight: " + jobitem.get_weight() + " Kg"); } else { weight.setText("None"); } if (jobitem.get_sensitivity() != null) { sensitivity.setText("Sensitivity: " + jobitem.get_sensitivity()); } else { sensitivity.setText("None"); } /*if(jobitem.get_duration() != null) { duration.setText("" + jobitem.get_duration()); }else{ duration.setText("None"); }*/ String status = jobitem.get_status(); if (status == null) { job_bid.setText("None"); } else if (status.equals(Config.PENDING)) { jobstatus.setText("Status: Pending"); bitLayout.setVisibility(View.VISIBLE); job_reject.setVisibility(View.INVISIBLE); job_bid.setText("Bid"); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } else if (jobitem.get_status().equals(Config.BID)) { jobstatus.setText("Status: Bid"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Agree"); job_reject.setText("Reject"); job_report.setVisibility(View.VISIBLE); } else if (jobitem.get_status().equals(Config.ACTIVE)) { jobstatus.setText("Status: Active"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Finished"); RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) bitLayout .getLayoutParams(); p.addRule(RelativeLayout.BELOW, R.id.jobdetail_showmap_layout); bitLayout.setLayoutParams(p); job_reject.setVisibility(View.INVISIBLE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } else if (jobitem.get_status().equals(Config.FINISH)) { jobstatus.setText("Status: Finish"); bitLayout.setVisibility(View.GONE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.DELETE)) { jobstatus.setText("Status: Delete"); bitLayout.setVisibility(View.GONE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.POST)) { jobstatus.setText("Status: Post"); bitLayout.setVisibility(View.GONE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.PROCESS)) { jobstatus.setText("Status: Process"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Finished"); job_reject.setVisibility(View.INVISIBLE); job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } progress.setVisibility(View.GONE); progress_background.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.GONE); progress_background.setVisibility(View.GONE); 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(); } } Intent intent = new Intent(JobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); JobDetailActivity.this.finish(); } }); }
From source file:org.wso2.emm.system.service.EMMSystemService.java
private void disableHardLock() { Intent intent = new Intent(context, MainActivity.class); intent.setFlags(//from w w w . ja v a 2 s . c o m Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:knayi.delevadriver.AvaliableJobDetailActivity.java
private void getDataFromServer(String jobid) { progress.setVisibility(View.VISIBLE); progress_background.setVisibility(View.VISIBLE); if (jobid == null) { jobid = ""; }/*from w w w . ja v a2 s. co m*/ AvaliableJobsAPI.getInstance().getService().getJobDetail(jobid, sPref.getString(Config.TOKEN, ""), new Callback<String>() { @Override public void success(String s, Response response) { Log.i("Output Data", s.toString()); try { JSONObject jsonobject = new JSONObject(s); if (!jsonobject.isNull("data")) { JSONObject jsonobj = jsonobject.getJSONObject("data"); jobitem = new JobItem(); if (!jsonobj.isNull("_id")) jobitem.set_id(jsonobj.getString("_id")); JSONObject requesterobj = jsonobj.getJSONObject("requester"); if (requesterobj != null) { if (!requesterobj.isNull("email")) { jobitem.set_requester_email(requesterobj.getString("email")); } else { jobitem.set_requester_email("none"); } if (!requesterobj.isNull("mobile_number")) jobitem.set_requester_mobile_number( requesterobj.getString("mobile_number")); if (!requesterobj.isNull("address")) jobitem.set_requester_address(requesterobj.getString("address")); /* if(requesterobj.getString("business_type") != null) jobitem.set_requester_business_type(requesterobj.getString("business_type")); */ if (!requesterobj.isNull("business_address")) jobitem.set_requester_business_address( requesterobj.getString("business_address")); JSONArray requester_pictures = requesterobj.getJSONArray("pictures"); List<String> pic_list = new ArrayList<String>(); for (int j = 0; j < requester_pictures.length(); j++) { JSONObject obj = requester_pictures.getJSONObject(j); if (!obj.isNull("path")) pic_list.add(obj.getString("path")); } } /*if(!jsonobj.isNull("type")) jobitem.set_type(jsonobj.getString("type")); else jobitem.set_type("None");*/ if (!jsonobj.isNull("address")) jobitem.set_address(jsonobj.getString("address")); else jobitem.set_address("None"); if (!jsonobj.isNull("receiver_name")) jobitem.set_receiver_name(jsonobj.getString("receiver_name")); else jobitem.set_receiver_name("None"); if (!jsonobj.isNull("receiver_contact")) jobitem.set_receiver_contact(jsonobj.getString("receiver_contact")); else jobitem.set_receiver_contact("None"); if (!jsonobj.isNull("size")) { jobitem.set_size(jsonobj.getString("size")); } else { jobitem.set_size("None"); } if (!jsonobj.isNull("weight")) { jobitem.set_weight(jsonobj.getString("weight")); } else { jobitem.set_weight("None"); } if (!jsonobj.isNull("sensitivity")) { jobitem.set_sensitivity(jsonobj.getString("sensitivity")); } else { jobitem.set_sensitivity("None"); } if (!jsonobj.isNull("pickup_time")) { jobitem.set_pickuptime(jsonobj.getString("pickup_time")); } else { jobitem.set_pickuptime("None"); } if (!jsonobj.isNull("pickup_address")) { jobitem.set_pickup_address(jsonobj.getString("pickup_address")); } else { jobitem.set_pickup_address("None"); } if (!jsonobj.isNull("duration_text")) { jobitem.set_duration(jsonobj.getString("duration_text")); } else { jobitem.set_duration("None"); } if (!jsonobj.isNull("post_code")) jobitem.set_post_code(jsonobj.getString("post_code")); if (!jsonobj.isNull("pickup_ll")) { jobitem.set_pickup_lon((Double) jsonobj.getJSONArray("pickup_ll").get(0)); jobitem.set_pickup_lat((Double) jsonobj.getJSONArray("pickup_ll").get(1)); } if (!jsonobj.isNull("address_ll")) { jobitem.set_address_lon((Double) jsonobj.getJSONArray("address_ll").get(0)); jobitem.set_address_lat((Double) jsonobj.getJSONArray("address_ll").get(1)); } if (!jsonobj.isNull("type_express")) { jobitem.setIsExpress(String.valueOf(jsonobj.getBoolean("type_express"))); } if (!jsonobj.isNull("type_refigerated")) { jobitem.setIsRefrigerated( String.valueOf(jsonobj.getBoolean("type_refigerated"))); } //jobitem.set_reports(jsonobj.getString("reports")); //jobitem.set_rejectMessage(jsonobj.getString("rejectMessage")); if (!jsonobj.isNull("status")) jobitem.set_status(jsonobj.getString("status")); else jobitem.set_status("None"); if (!jsonobj.isNull("pictures")) { JSONArray pictures = jsonobj.getJSONArray("pictures"); List<String> pic_list1 = new ArrayList<String>(); for (int j = 0; j < pictures.length(); j++) { JSONObject obj = pictures.getJSONObject(j); if (obj.getString("path") != null) pic_list1.add(obj.getString("path")); } if (pic_list1.size() > 0) { jobitem.set_pictures(pic_list1.get(0)); imageprogress.setVisibility(View.VISIBLE); Picasso.with(AvaliableJobDetailActivity.this) .load(APIConfig.DOMAIN_URL + pic_list1.get(0)) .into(mImageView, new com.squareup.picasso.Callback() { @Override public void onSuccess() { imageprogress.setVisibility(View.INVISIBLE); } @Override public void onError() { } }); } } if (!jsonobj.isNull("price")) { jobitem.set_price(jsonobj.getString("price")); totalprice = Double.parseDouble(jsonobj.getString("price")); } else { jobitem.set_price("None"); } if (!jsonobj.isNull("createAt")) jobitem.set_createAt(jsonobj.getString("createAt")); else { jobitem.set_createAt("None"); } } } catch (JSONException jsonexception) { jsonexception.printStackTrace(); Log.i("APIData", "error"); } if (jobitem.get_weight().equals("None")) { weightpos = 0; weightPricelist = Arrays.asList(new Double[] { 0.00, 4.00, 8.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 10) { weightpos = 0; weightPricelist = Arrays.asList(new Double[] { 0.00, 4.00, 8.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 20) { weightpos = 1; weightPricelist = Arrays.asList(new Double[] { -4.00, 0.00, 4.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } else if (Integer.parseInt(jobitem.get_weight()) <= 30) { weightpos = 2; weightPricelist = Arrays.asList(new Double[] { -8.00, -4.00, 0.00 }); weightlist = Arrays.asList(new String[] { "le10kg", "le20kg", "le30kg" }); weightshowlist = Arrays.asList(new String[] { "Less than and equal 10 kg", "Less than and equal 20 kg", "Less than and equal 30 kg" }); } //Log.i("Weight", String.valueOf(Integer.parseInt(jobitem.get_weight()))); //String type = jobitem.get_type(); /*if(type.equals("other")){ typepos = 0; jobtype.setText("Type: Other"); //typepricelist = Arrays.asList(new Double[]{0.00, 3.00, 3.00}); }else if(type.equals("express")){ typepos = 1; jobtype.setText("Type: Express"); //typepricelist = Arrays.asList(new Double[]{-3.00, 0.00, 0.00}); }else if(type.equals("freezen")){ typepos = 2; jobtype.setText("Type: Refrigerated"); //typepricelist = Arrays.asList(new Double[]{-3.00, 0.00, 0.00}); }else{ jobtype.setText("Type: None"); //typepricelist = Arrays.asList(new Double[]{0.00, 0.00, 0.00}); }*/ //jobtype.setText(jobitem.get_requester_name()); if (!jobitem.get_pickuptime().equals("None")) { String str = jobitem.get_pickuptime(); String datestr = str.substring(0, 10); String timestr = str.substring(11, 16); pickup_date.setText("Pick Up Date: " + datestr); pickup_time.setText("Pick Up Time: " + timestr); } else { pickup_time.setText("Pick Up Time: " + jobitem.get_pickuptime()); pickup_date.setText("Pick Up Date: " + jobitem.get_pickuptime()); } pickup_address.setText("Pick Up Address: " + jobitem.get_pickup_address()); if (jobitem.get_price() != null) { jobprice.setText("SGD$ " + jobitem.get_price()); } else { jobprice.setText("None"); } /*if(jobitem.get_address() != null) { jobaddress.setText("" + jobitem.get_address()); }else{ jobaddress.setText("None"); }*/ /*if(jobitem.get_createAt() != null) { String date = getDateFromtimeFormat(jobitem.get_createAt()); jobcreatetime.setText("" + date); } else jobcreatetime.setText("not include");*/ //requestername.setText("" + jobitem.get_requester()); //requesterbusinesstype.setText("" + jobitem.get_requester_business_type()); /*if(jobitem.get_requester_mobile_number() != null) { requesterphone.setText("Contact: " + jobitem.get_requester_mobile_number()); }else{ requesterphone.setText("None"); } if(jobitem.get_requester_email() != null) { requesteremail.setText("Email: " + jobitem.get_requester_email()); }else{ requesteremail.setText("None"); } if(jobitem.get_requester_address() != null) { requesteraddress.setText("Address: " + jobitem.get_requester_address()); }else{ requesteraddress.setText("None"); }*/ if (jobitem.get_address() != null) { delivery_address.setText("Address: " + jobitem.get_address()); } else { delivery_address.setText("None"); } /*if(jobitem.get_receiver_name() != null) { receivername.setText("" + jobitem.get_receiver_name()); }else{ receivername.setText("None"); } if(jobitem.get_receiver_contact() != null) { receivercontact.setText("" + jobitem.get_receiver_contact()); }else{ receivercontact.setText("None"); } if(jobitem.get_size() != null) { size.setText("" + jobitem.get_size()); }else{ size.setText("None"); }*/ if (jobitem.get_weight() != null) { if (jobitem.get_weight().equals("None")) { weight.setText(jobitem.get_weight()); } else { weight.setText("Weight: " + jobitem.get_weight() + " Kg"); } } else { weight.setText("None"); } if (jobitem.get_sensitivity() != null) { sensitivity.setText("Sensitivity: " + jobitem.get_sensitivity()); } else { sensitivity.setText("None"); } /*if(jobitem.get_duration() != null) { duration.setText("" + jobitem.get_duration()); }else{ duration.setText("None"); }*/ String status = jobitem.get_status(); if (status == null) { job_bid.setText("None"); } else if (status.equals(Config.PENDING)) { jobstatus.setText("Status: Pending"); bitLayout.setVisibility(View.VISIBLE); //job_reject.setVisibility(View.INVISIBLE); job_bid.setText("Bid"); //job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } else if (jobitem.get_status().equals(Config.BID)) { jobstatus.setText("Status: Bid"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Agree"); //job_reject.setText("Reject"); //job_report.setVisibility(View.VISIBLE); } else if (jobitem.get_status().equals(Config.ACTIVE)) { jobstatus.setText("Status: Active"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Finished"); //job_reject.setVisibility(View.INVISIBLE); //job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } else if (jobitem.get_status().equals(Config.FINISH)) { jobstatus.setText("Status: Finish"); bitLayout.setVisibility(View.GONE); //job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.DELETE)) { jobstatus.setText("Status: Delete"); bitLayout.setVisibility(View.GONE); //job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.POST)) { jobstatus.setText("Status: Post"); bitLayout.setVisibility(View.GONE); //job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); relativeLayout.removeView(viewforPlacing1); } else if (jobitem.get_status().equals(Config.PROCESS)) { jobstatus.setText("Status: Process"); bitLayout.setVisibility(View.VISIBLE); job_bid.setText("Finished"); //job_reject.setVisibility(View.INVISIBLE); //job_report.setVisibility(View.INVISIBLE); relativeLayout.removeView(viewforPlacing); } progress.setVisibility(View.GONE); progress_background.setVisibility(View.GONE); } @Override public void failure(RetrofitError error) { progress.setVisibility(View.GONE); progress_background.setVisibility(View.GONE); 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(); } } Intent intent = new Intent(AvaliableJobDetailActivity.this, DrawerMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); AvaliableJobDetailActivity.this.finish(); } }); }
From source file:org.wso2.iot.agent.services.operation.OperationManager.java
/** * Configure device VPN profile.//from ww w . j av a 2s .com * * @param operation - Operation object. */ public void configureVPN(org.wso2.iot.agent.beans.Operation operation) throws AndroidAgentException { String serverAddress = null; JSONObject result = new JSONObject(); try { JSONObject vpnData = new JSONObject(operation.getPayLoad().toString()); if (!vpnData.isNull(resources.getString(R.string.intent_extra_server))) { serverAddress = (String) vpnData.get(resources.getString(R.string.intent_extra_server)); } } catch (JSONException e) { operation.setStatus(resources.getString(R.string.operation_value_error)); operation.setOperationResponse("Error in parsing VPN payload."); resultBuilder.build(operation); throw new AndroidAgentException("Invalid JSON format.", e); } if (serverAddress != null) { Intent intent = new Intent(context, AlertActivity.class); intent.putExtra(resources.getString(R.string.intent_extra_message_text), resources.getString(R.string.toast_message_vpn)); intent.putExtra(resources.getString(R.string.intent_extra_operation_id), operation.getId()); intent.putExtra(resources.getString(R.string.intent_extra_payload), operation.getPayLoad().toString()); intent.putExtra(resources.getString(R.string.intent_extra_type), Constants.Operation.VPN); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(intent); } if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "VPN configured"); } operation.setStatus(resources.getString(R.string.operation_value_completed)); operation.setPayLoad(result.toString()); resultBuilder.build(operation); }
From source file:org.wso2.emm.agent.services.operation.OperationManager.java
/** * Configure device VPN profile./* w ww .ja va2 s . c o m*/ * * @param operation - Operation object. */ public void configureVPN(org.wso2.emm.agent.beans.Operation operation) throws AndroidAgentException { String serverAddress = null; JSONObject result = new JSONObject(); try { JSONObject vpnData = new JSONObject(operation.getPayLoad().toString()); if (!vpnData.isNull(resources.getString(R.string.intent_extra_server))) { serverAddress = (String) vpnData.get(resources.getString(R.string.intent_extra_server)); } } catch (JSONException e) { operation.setStatus(resources.getString(R.string.operation_value_error)); operation.setOperationResponse("Error in parsing VPN payload."); resultBuilder.build(operation); throw new AndroidAgentException("Invalid JSON format.", e); } if (serverAddress != null) { Intent intent = new Intent(context, AlertActivity.class); intent.putExtra(resources.getString(R.string.intent_extra_message_text), resources.getString(R.string.toast_message_vpn)); intent.putExtra(resources.getString(R.string.intent_extra_operation_id), operation.getId()); intent.putExtra(resources.getString(R.string.intent_extra_payload), operation.getPayLoad().toString()); intent.putExtra(resources.getString(R.string.intent_extra_type), Constants.Operation.VPN); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(intent); } if (Constants.DEBUG_MODE_ENABLED) { Log.d(TAG, "VPN configured"); } operation.setStatus(resources.getString(R.string.operation_value_completed)); operation.setPayLoad(result.toString()); resultBuilder.build(operation); }
From source file:org.openhab.habdroid.ui.OpenHABMainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, String.format("onActivityResult requestCode = %d, resultCode = %d", requestCode, resultCode)); switch (requestCode) { case SETTINGS_REQUEST_CODE: // Restart app after preferences Log.d(TAG, "Restarting after settings"); // Get launch intent for application Intent restartIntent = getBaseContext().getPackageManager() .getLaunchIntentForPackage(getBaseContext().getPackageName()); restartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); // Finish current activity finish();/* w ww . j a v a 2 s . c o m*/ // Start launch activity startActivity(restartIntent); break; case WRITE_NFC_TAG_REQUEST_CODE: Log.d(TAG, "Got back from Write NFC tag"); break; default: } }
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(); }/* ww w. ja v a2 s .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:me.willowcheng.makerthings.ui.OpenHABMainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, String.format("onActivityResult requestCode = %d, resultCode = %d", requestCode, resultCode)); switch (requestCode) { case SETTINGS_REQUEST_CODE: // Restart app after preferences Log.d(TAG, "Restarting after settings"); // Get launch intent for application // Intent restartIntent = getBaseContext().getPackageManager() // .getLaunchIntentForPackage(getBaseContext().getPackageName()); Intent restartIntent = new Intent(this, OpenHABMainActivity.class); restartIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); // Finish current activity finish();/* w ww .ja va 2 s . c o m*/ // Start launch activity startActivity(restartIntent); break; case WRITE_NFC_TAG_REQUEST_CODE: Log.d(TAG, "Got back from Write NFC tag"); break; default: } }
From source file:org.cobaltians.cobalt.fragments.CobaltFragment.java
private void replace(JSONObject data) { try {// ww w . j a v a 2 s . co m String page = data.getString(Cobalt.kJSPage); String controller = data.optString(Cobalt.kJSController, null); JSONObject bars = data.optJSONObject(Cobalt.kJSBars); JSONObject dataForReplace = data.optJSONObject(Cobalt.kJSData); boolean animated = data.optBoolean(Cobalt.kJSAnimated); boolean clearHistory = data.optBoolean(Cobalt.kJSClearHistory, false); Intent intent = Cobalt.getInstance(mContext).getIntentForController(controller, page); if (intent != null) { intent.putExtra(Cobalt.kJSAnimated, animated); if (bars != null) { Bundle configuration = intent.getBundleExtra(Cobalt.kExtras); configuration.putString(Cobalt.kBars, bars.toString()); } if (dataForReplace != null) { intent.putExtra(Cobalt.kJSData, dataForReplace.toString()); } if (clearHistory) { intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); } mContext.startActivity(intent); ((Activity) mContext).finish(); } else if (Cobalt.DEBUG) { Log.e(Cobalt.TAG, TAG + " - replace: unable to replace " + controller + " controller."); } } catch (JSONException exception) { if (Cobalt.DEBUG) { Log.e(Cobalt.TAG, TAG + " - replace: missing mandatory page field."); } exception.printStackTrace(); } }
From source file:com.oakesville.mythling.MediaActivity.java
protected void goDetailView() { if (mediaList.getMediaType() == MediaType.recordings && getAppSettings().getMediaSettings().getSortType() == SortType.byTitle) { getAppSettings().clearCache(); // refresh since we're switching to flattened hierarchy selItemIndex = 0;/*from ww w. ja va 2 s. com*/ } Uri uri = new Uri.Builder().path(getPath()).build(); Intent intent = new Intent(Intent.ACTION_VIEW, uri, getApplicationContext(), MediaPagerActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(SEL_ITEM_INDEX, selItemIndex); startActivity(intent); }