Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.93 KB | None | 0 0
  1. public void showBottomSheet(String latitude, String longitude, final String address, final GoogleMap mySearchMap, String status, String message, final String location_type, final int position) {
  2. mySearchMap.clear();
  3. //google map
  4.  
  5. try {
  6.  
  7. if (status.equals("not_covered")) {
  8. Log.e("covered?", "not");
  9. Log.e("sugestListAddress", "size " + sugestListAddress.size());
  10.  
  11. if (sugestListAddress.size() > 0) {
  12.  
  13. // Click to Clicked Location
  14. CameraPosition cameraPosition = new CameraPosition.Builder()
  15. .target(new LatLng(sugestListAddress.get(position).getLatitude(), sugestListAddress.get(position).getLongitude()))
  16. .zoom(17) // Zoom levelnya (1:Dunia, 5:benua, 10:kota, 15:jalanan, 20:Gedung)
  17. .tilt(30) // Diatur kemiringan kameranya sampai 30 derajat
  18. .build();
  19.  
  20. mySearchMap.addMarker(new MarkerOptions().position(new LatLng(sugestListAddress.get(position).getLatitude(), sugestListAddress.get(position).getLongitude())));
  21. mySearchMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  22.  
  23. LAT = "" + sugestListAddress.get(position).getLatitude();
  24. LONG = "" + sugestListAddress.get(position).getLongitude();
  25.  
  26. ADDRESS = "" + tv_search.getText().toString();
  27.  
  28. String address_split[] = ADDRESS.split(",");
  29. int city_position = address_split.length - 2;
  30.  
  31. Log.e("city_value", address_split[city_position - 1]);
  32.  
  33. SESSION.setCITY_NAME_NEW(address_split[city_position]);
  34. } else {
  35. Geocoder geocoder = new Geocoder(CheckCoverage.this, Locale.getDefault());
  36. // List<Address> listAddress = geocoder.getFromLocationName(address + " Indonesia", 1);
  37. List<Address> listAddress = geocoder.getFromLocation(Double.valueOf(latitude), Double.valueOf(longitude), 1);
  38. // Click to Clicked Location
  39. if (listAddress.size() >0) {
  40. CameraPosition cameraPosition = new CameraPosition.Builder()
  41. .target(new LatLng(listAddress.get(0).getLatitude(), listAddress.get(0).getLongitude()))
  42. .zoom(17) // Zoom levelnya (1:Dunia, 5:benua, 10:kota, 15:jalanan, 20:Gedung)
  43. .tilt(30) // Diatur kemiringan kameranya sampai 30 derajat
  44. .build();
  45.  
  46. mySearchMap.addMarker(new MarkerOptions().position(new LatLng(listAddress.get(0).getLatitude(), listAddress.get(0).getLongitude())));
  47. mySearchMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  48. }
  49. LAT = "" + listAddress.get(0).getLatitude();
  50. LONG = "" + listAddress.get(0).getLongitude();
  51.  
  52. ADDRESS = "" + tv_search.getText().toString();
  53. }
  54.  
  55. } else {
  56.  
  57. Geocoder geocoder = new Geocoder(CheckCoverage.this, Locale.getDefault());
  58. // List<Address> listAddress = geocoder.getFromLocationName(address + " Indonesia", 1);
  59. List<Address> listAddress = geocoder.getFromLocation(Double.valueOf(latitude), Double.valueOf(longitude), 1);
  60. // Click to Clicked Location
  61. if (listAddress.size() >0 ) {
  62. CameraPosition cameraPosition = new CameraPosition.Builder()
  63. .target(new LatLng(listAddress.get(0).getLatitude(), listAddress.get(0).getLongitude()))
  64. .zoom(17) // Zoom levelnya (1:Dunia, 5:benua, 10:kota, 15:jalanan, 20:Gedung)
  65. .tilt(30) // Diatur kemiringan kameranya sampai 30 derajat
  66. .build();
  67.  
  68. mySearchMap.addMarker(new MarkerOptions().position(new LatLng(listAddress.get(0).getLatitude(), listAddress.get(0).getLongitude())));
  69. mySearchMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
  70. }
  71.  
  72. LAT = "" + latitude;
  73. LONG = "" + longitude;
  74.  
  75. ADDRESS = "" + address;
  76.  
  77. }
  78.  
  79. } catch (IOException e) {
  80. e.printStackTrace();
  81. }
  82.  
  83.  
  84. final TextView tv_stat_cc;
  85. final WebView tv_note_value_cc;
  86.  
  87. tv_stat_cc = (TextView)
  88.  
  89. findViewById(R.id.stat_cc);
  90.  
  91. tv_note_value_cc = (WebView)
  92.  
  93. findViewById(R.id.note_value_cc);
  94.  
  95. if (!status.equals("covered")) {
  96. //not coverage
  97. btn_confirm.setText("Get Offer");
  98. tv_stat_cc.setText("Not Covered");
  99. tv_stat_cc.setTextColor(Color.parseColor("#F15B42"));
  100. } else {
  101. btn_confirm.setText("Subscribe");
  102. tv_stat_cc.setText("Covered");
  103. tv_stat_cc.setTextColor(Color.parseColor("#28912e"));
  104. }
  105.  
  106. tv_note_value_cc.loadData("" + message, "text/html", null);
  107.  
  108. View current = CheckCoverage.this.getCurrentFocus();
  109. InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
  110. imm.hideSoftInputFromWindow(current.getWindowToken(), 0);
  111.  
  112. dialog_custom_cov.dismiss();
  113.  
  114. Handler handler = new Handler();
  115. handler.postDelayed(new
  116.  
  117. Runnable() {
  118. @Override
  119. public void run() {
  120. //animation
  121. slideup = AnimationUtils.loadAnimation(CheckCoverage.this, R.anim.slide_up);
  122. bottom_sheet.setAnimation(slideup);
  123. bottom_sheet.startAnimation(slideup);
  124. bottom_sheet.setVisibility(View.VISIBLE);
  125.  
  126. /*slideup.setAnimationListener(new Animation.AnimationListener() {
  127. @Override
  128. public void onAnimationStart(Animation animation) {
  129. bottom_sheet.startAnimation(slideup);
  130. }
  131.  
  132. @Override
  133. public void onAnimationEnd(Animation animation) {
  134. bottom_sheet.setVisibility(View.VISIBLE);
  135. }
  136.  
  137. @Override
  138. public void onAnimationRepeat(Animation animation) {
  139. }
  140. });*/
  141. }
  142. }, 500);
  143.  
  144. btn_confirm.setOnClickListener(new View.OnClickListener() {
  145. @Override
  146. public void onClick(View v) {
  147.  
  148. Log.e("location_type", "" + location_type);
  149.  
  150. if (btn_confirm.getText().toString().equals("Get Offer")) {
  151.  
  152. // SESSION.setCITY_NAME_NEW(city_not_coverage);
  153.  
  154. Intent i = new Intent(CheckCoverage.this, bd_signup.class);
  155. i.putExtra("coverage", "not");
  156. i.putExtra("long", LONG);
  157. i.putExtra("lat", LAT);
  158. i.putExtra("alamat", "" + ADDRESS);
  159. startActivity(i);
  160. } else if (btn_confirm.getText().toString().equals("Subscribe")) {
  161. Intent i = new Intent(CheckCoverage.this, bd_signup.class);
  162. i.putExtra("coverage", "yes");
  163. i.putExtra("long", LONG);
  164. i.putExtra("lat", LAT);
  165. if (location_type.equals("APART")) {
  166. i.putExtra("type", "apartment");
  167. i.putExtra("coverage_info", arList.get(position));
  168. } else if (location_type.equals("STREET") || location_type.equals("STREE")) {
  169. i.putExtra("type", "residence");
  170. i.putExtra("coverage_info", arList.get(position));
  171. } else if (location_type.equals("RESID")) {
  172. i.putExtra("type", "residence_notstreet");
  173. i.putExtra("coverage_info", arList.get(position));
  174. }
  175. startActivity(i);
  176. }
  177. }
  178. });
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement