Advertisement
Eplayer

Customer Detail No Maaf

Jul 23rd, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.47 KB | None | 0 0
  1. package id.co.acc.www.amos.activity;
  2.  
  3. import android.Manifest;
  4. import android.annotation.SuppressLint;
  5. import android.app.Dialog;
  6. import android.content.ActivityNotFoundException;
  7. import android.content.Context;
  8. import android.content.DialogInterface;
  9. import android.content.Intent;
  10. import android.content.SharedPreferences;
  11. import android.content.pm.PackageManager;
  12. import android.content.res.Configuration;
  13. import android.graphics.Typeface;
  14. import android.location.Location;
  15. import android.net.Uri;
  16. import android.provider.Settings;
  17. import android.support.design.widget.Snackbar;
  18. import android.support.v4.app.ActivityCompat;
  19. import android.support.v4.app.NavUtils;
  20. import android.support.v4.content.ContextCompat;
  21. import android.support.v4.content.res.ResourcesCompat;
  22. import android.support.v7.app.AlertDialog;
  23. import android.support.v7.app.AppCompatActivity;
  24. import android.os.Bundle;
  25. import android.support.v7.widget.CardView;
  26. import android.util.DisplayMetrics;
  27. import android.util.Log;
  28. import android.view.MotionEvent;
  29. import android.view.View;
  30. import android.view.ViewGroup;
  31. import android.widget.Button;
  32. import android.widget.ExpandableListView;
  33. import android.widget.ImageView;
  34. import android.widget.ScrollView;
  35. import android.widget.TextView;
  36. import android.widget.Toast;
  37.  
  38. import com.google.android.gms.location.FusedLocationProviderClient;
  39. import com.google.android.gms.location.LocationServices;
  40. import com.google.android.gms.maps.CameraUpdate;
  41. import com.google.android.gms.maps.CameraUpdateFactory;
  42. import com.google.android.gms.maps.GoogleMap;
  43. import com.google.android.gms.maps.OnMapReadyCallback;
  44. import com.google.android.gms.maps.SupportMapFragment;
  45. import com.google.android.gms.maps.model.LatLng;
  46. import com.google.android.gms.maps.model.MarkerOptions;
  47. import com.google.android.gms.tasks.OnSuccessListener;
  48. import com.google.gson.Gson;
  49. import com.raizlabs.android.dbflow.sql.language.SQLite;
  50. import com.raizlabs.android.dbflow.sql.queriable.StringQuery;
  51.  
  52. import java.text.DateFormat;
  53. import java.text.SimpleDateFormat;
  54. import java.util.ArrayList;
  55. import java.util.Date;
  56. import java.util.HashMap;
  57. import java.util.List;
  58. import java.util.Locale;
  59.  
  60. import id.co.acc.www.amos.AmosApplication;
  61. import id.co.acc.www.amos.R;
  62. import id.co.acc.www.amos.adapter.CustomerDetailAdapter;
  63. import id.co.acc.www.amos.adapter.DialogAdapter;
  64. import id.co.acc.www.amos.model.CustomerPreview;
  65. import id.co.acc.www.amos.model.CustomerPreviewDetail;
  66. import id.co.acc.www.amos.model.MGlobal.Global;
  67. import id.co.acc.www.amos.model.MModels.DataObject_Table;
  68. import id.co.acc.www.amos.model.MessageReturn.MessageReturn;
  69. import id.co.acc.www.amos.model.ReturnAOL.ReturnAOL;
  70. import id.co.acc.www.amos.model.TGprs.DataObject;
  71. import id.co.acc.www.amos.model.UpdateProcessFlagAOL.GprsWrapper;
  72. import id.co.acc.www.amos.model.UpdateProcessFlagAOL.UpdateProcessFlagAOL;
  73. import id.co.acc.www.amos.network.APIClient;
  74. import id.co.acc.www.amos.network.APIInterfaceRest;
  75. import id.co.acc.www.amos.util.ChangeAlertMessage;
  76. import id.co.acc.www.amos.util.CheckFakeGPS;
  77. import id.co.acc.www.amos.util.CustomizedExceptionHandler;
  78. import id.co.acc.www.amos.util.GenerateLogError;
  79. import id.co.acc.www.amos.util.GetCountryUtil;
  80. import id.co.acc.www.amos.util.GetCurrentLocation;
  81. import id.co.acc.www.amos.util.GetTaskUtil;
  82. import id.co.acc.www.amos.util.GlobalParam;
  83. import id.co.acc.www.amos.util.GlobalVar;
  84. import id.co.acc.www.amos.util.LogoutToken;
  85. import id.co.acc.www.amos.util.Scheduler;
  86. import id.co.acc.www.amos.util.ScrollGoogleMap;
  87. import id.co.acc.www.amos.util.SendPendingSurveyScheduler;
  88. import id.co.acc.www.amos.util.SessionManagement;
  89. import id.co.acc.www.amos.util.SharedPreferenceUtils;
  90. import id.co.acc.www.amos.util.Tools;
  91. import id.co.acc.www.amos.util.UpdateSurveyUtil;
  92. import id.co.acc.www.amos.util.WriteWSLogUtil;
  93. import okhttp3.MediaType;
  94. import okhttp3.RequestBody;
  95. import retrofit2.Call;
  96. import retrofit2.Callback;
  97. import retrofit2.Response;
  98.  
  99. public class CustomerDetailActivity extends AppCompatActivity implements OnMapReadyCallback {
  100.  
  101. private GoogleMap mMap;
  102. private String latitude;
  103. private String longitude;
  104. private Button btnPetunjukArah,btnBatalSurvey;
  105. private Button btnMulaiPasswordCP;
  106. private ExpandableListView elvCustomerDetail;
  107.  
  108. private List<CustomerPreview> listDataHeader;
  109. private HashMap<CustomerPreview,List<CustomerPreviewDetail>> listHash;
  110. private TextView txtNamaCustomerCP, txtAlamatCP, txtKontakNomorCP;
  111. private ImageView imgDetailCP, imgPhoneCP;
  112. private String noHp;
  113. private String alamat;
  114. private static final int MY_PERMISSIONS_REQUEST_CALL_PHONE=999;
  115. private CardView crdCustomerDetail;
  116. private String customerPosition;
  117.  
  118. private DataObject dataCustomer;
  119. private CustomerPreviewDetail customerPreviewDetail;
  120. private FusedLocationProviderClient client;
  121. private String first3Char;
  122. private String activePage;
  123. private ScrollView scrCustomerDetail;
  124. private ImageView imgTrans;
  125.  
  126. private SessionManagement session;
  127.  
  128. @SuppressLint("ClickableViewAccessibility")
  129. private void assignView()
  130. {
  131. session = new SessionManagement(getApplicationContext());
  132. btnPetunjukArah=(Button)findViewById(R.id.btnPetunjukArah);
  133. elvCustomerDetail=(ExpandableListView)findViewById(R.id.elvCustomerDetail);
  134. btnMulaiPasswordCP=(Button)findViewById(R.id.btnMulaiSurveiCP);
  135. btnBatalSurvey =(Button)findViewById(R.id.btnBatalSurvey);
  136. scrCustomerDetail=(ScrollView)findViewById(R.id.scrCustomerDetail);
  137. imgTrans=(ImageView)findViewById(R.id.imgTrans);
  138.  
  139. customerPosition=SharedPreferenceUtils.getSetting(CustomerDetailActivity.this, "customerPosition", "");
  140.  
  141.  
  142. if(dataCustomer.getLatitude()==null)
  143. latitude="0";
  144. else
  145. latitude=dataCustomer.getLatitude();
  146.  
  147. if(dataCustomer.getLongitude()==null)
  148. longitude="0";
  149. else
  150. longitude=dataCustomer.getLongitude();
  151.  
  152. String namepass[] = dataCustomer.getMessage().split(";");
  153. String grading = namepass[0];
  154. String orderNo = namepass[1];
  155. String cabang = namepass[2];
  156. String dealer = namepass[3];
  157. String brand= namepass[4];
  158. String type = namepass[5];
  159. String model = namepass[6];
  160. String kind = namepass[7];
  161. String namaPemohon = namepass[8];
  162. String namaYangDisurvey=namepass[9];
  163. alamat= namepass[10];
  164. String noTelp = namepass[11];
  165. noHp = namepass[12];
  166. String area=namepass[13];
  167. String kota=namepass[14];
  168. String kodePos=namepass[15];
  169. String tahunKendaraan=namepass[16];
  170. String oTR=namepass[17];
  171. String warna=namepass[18];
  172. String tenor = namepass[19];
  173. String cicilan=namepass[20];
  174. String notepadRd=namepass[21];
  175. String notepadFa=namepass[22];
  176. String jenisKelamin=namepass[23];
  177. String jabatan=namepass[24];
  178. String tanggalLahir=namepass[25];
  179. String dp=namepass[26];
  180. String refinancing=namepass[27];
  181. String namaBisnis = namepass[28];
  182. String tanggalOrder = namepass[29];
  183. String jamOrder = namepass[30];
  184. String tipeAplikasi = namepass[31];
  185. String roAo = namepass[32];
  186. String loanType = namepass[33];
  187.  
  188. String dokumen="";
  189. try{
  190. dokumen=namepass[34];
  191. }
  192. catch (Exception e)
  193. {
  194.  
  195. }
  196. String status;
  197. try
  198. {
  199. String statusCode = orderNo.substring(15,16);
  200. status = GlobalVar.status.get(statusCode);
  201. }
  202. catch (Exception e)
  203. {
  204. status="";
  205. }
  206.  
  207.  
  208.  
  209.  
  210. CustomerPreview customerPreview=new CustomerPreview(namaPemohon,alamat, noHp);
  211. listDataHeader=new ArrayList<>();
  212. listDataHeader.add(customerPreview);
  213.  
  214. customerPreviewDetail=new CustomerPreviewDetail();
  215. customerPreviewDetail.setGrading(grading);
  216. customerPreviewDetail.setNoOrderSurvey(orderNo);
  217. customerPreviewDetail.setCabang(cabang);
  218. customerPreviewDetail.setDealer(dealer);
  219. customerPreviewDetail.setBrand(brand);
  220. customerPreviewDetail.setType(type);
  221. customerPreviewDetail.setModel(model);
  222. customerPreviewDetail.setKind(kind);
  223. customerPreviewDetail.setNamaPemohon(namaPemohon);
  224. customerPreviewDetail.setNamaYangDiSurvey(namaYangDisurvey);
  225. customerPreviewDetail.setAlamat(alamat);
  226. customerPreviewDetail.setNoTelp(noTelp);
  227. customerPreviewDetail.setNoHp(noHp);
  228. customerPreviewDetail.setArea(area);
  229. customerPreviewDetail.setKota(kota);
  230. customerPreviewDetail.setKodePos(kodePos);
  231. customerPreviewDetail.setTahunKend(tahunKendaraan);
  232. customerPreviewDetail.setoTR(oTR);
  233. customerPreviewDetail.setWarna(warna);
  234. customerPreviewDetail.setTenor(tenor);
  235. customerPreviewDetail.setCicilan(cicilan);
  236. customerPreviewDetail.setNotepadRD(notepadRd);
  237. customerPreviewDetail.setNotepadFA(notepadFa);
  238. customerPreviewDetail.setJenisKelamin(jenisKelamin);
  239. customerPreviewDetail.setJabatan(jabatan);
  240. customerPreviewDetail.setTanggalLahir(tanggalLahir);
  241. customerPreviewDetail.setDp(dp);
  242. customerPreviewDetail.setRefinancing(refinancing);
  243. customerPreviewDetail.setNamaBisnis(namaBisnis);
  244. customerPreviewDetail.setTanggalOrder(tanggalOrder);
  245. customerPreviewDetail.setJamOrder(jamOrder);
  246. customerPreviewDetail.setTipeAplikasi(tipeAplikasi);
  247. customerPreviewDetail.setRoAo(roAo);
  248. customerPreviewDetail.setLoanType(loanType);
  249. customerPreviewDetail.setDokumen(dokumen);
  250. customerPreviewDetail.setStatus(status);
  251. List<CustomerPreviewDetail> customerPreviewDetails=new ArrayList<>();
  252. customerPreviewDetails.add(customerPreviewDetail);
  253.  
  254. Gson gson =new Gson();
  255.  
  256. SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "customerSelectedDetail", gson.toJson(customerPreviewDetail));
  257.  
  258. listHash = new HashMap<>();
  259. listHash.put(listDataHeader.get(0), customerPreviewDetails);
  260. CustomerDetailAdapter customerDetailAdapter=new CustomerDetailAdapter(this, listDataHeader, listHash);
  261. elvCustomerDetail.setAdapter(customerDetailAdapter);
  262.  
  263.  
  264. txtNamaCustomerCP=(TextView)findViewById(R.id.txtNamaCustomerCP);
  265. txtAlamatCP=(TextView)findViewById(R.id.txtAlamatCP);
  266. txtKontakNomorCP=(TextView)findViewById(R.id.txtKontakNomorCP);
  267. imgDetailCP=(ImageView)findViewById(R.id.imgDetailCP);
  268. imgPhoneCP=(ImageView)findViewById(R.id.imgPhoneCP);
  269.  
  270. txtNamaCustomerCP.setText(namaYangDisurvey);
  271. txtAlamatCP.setText(alamat);
  272. txtKontakNomorCP.setText(noHp);
  273.  
  274. crdCustomerDetail=(CardView)findViewById(R.id.crdCustomerDetail);
  275.  
  276. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
  277. .findFragmentById(R.id.map);
  278.  
  279. ViewGroup.LayoutParams param = mapFragment.getView().getLayoutParams();
  280. int orientation = getResources().getConfiguration().orientation;
  281. if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
  282. HashMap<String,Integer> dispalySize = Tools.displaySize(this);
  283. param.height=dispalySize.get("width")/3;
  284. mapFragment.getView().setLayoutParams(param);
  285. } else {
  286. // In portrait
  287. }
  288.  
  289. mapFragment.getMapAsync(this);
  290. SharedPreferenceUtils.setSetting(this,"isAplikasiOpen","true");
  291. }
  292.  
  293. @Override
  294. protected void onCreate(Bundle savedInstanceState) {
  295. super.onCreate(savedInstanceState);
  296. new GenerateLogError(getApplicationContext());
  297. setContentView(R.layout.activity_customer_detail);
  298. setTitle(R.string.customer_info);
  299. String customerSelected=SharedPreferenceUtils.getSetting(CustomerDetailActivity.this, "customerSelected","");
  300. Gson gson =new Gson();
  301. dataCustomer=gson.fromJson(customerSelected, DataObject.class);
  302. dataCustomer=SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle();
  303. activePage=SharedPreferenceUtils.getSetting(CustomerDetailActivity.this, "activePage","");
  304.  
  305. assignView();
  306. assignAction();
  307. sync2();
  308. Thread.setDefaultUncaughtExceptionHandler(new CustomizedExceptionHandler(
  309. getExternalFilesDir(null).getAbsolutePath()));
  310.  
  311. }
  312.  
  313. private void sync2()
  314. {
  315. if(dataCustomer.getSync2()==null)
  316. {
  317. //set sync2
  318. updateSync2();
  319. }
  320. }
  321.  
  322. private void updateSync2()
  323. {
  324. GprsWrapper gprsWrapper=new GprsWrapper();
  325. gprsWrapper.setORDERNO(dataCustomer.getOrderNo());
  326. gprsWrapper.setPROCESSFLAG(GlobalVar.readAol);
  327. UpdateProcessFlagAOL updateProcessFlagAOL=new UpdateProcessFlagAOL();
  328. updateProcessFlagAOL.setGprsWrapper(gprsWrapper);
  329.  
  330. Gson gson=new Gson();
  331. String json=gson.toJson(updateProcessFlagAOL);
  332. // RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
  333. RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
  334.  
  335. final APIInterfaceRest apiInterfaceRest=APIClient.getClientACC(getApplicationContext()).create(APIInterfaceRest.class);
  336. Call<ReturnAOL> call=apiInterfaceRest.updateProcessFlagToAOL(body);
  337. WriteWSLogUtil.writeToFile(getApplicationContext(), getString(R.string.updateProcessFlagAOL2)+" "+dataCustomer.getOrderNo(), null, null, null);
  338. call.enqueue(new Callback<ReturnAOL>() {
  339. @Override
  340. public void onResponse(Call<ReturnAOL> call, Response<ReturnAOL> response) {
  341. WriteWSLogUtil.writeToFile(getApplicationContext(), getString(R.string.updateProcessFlagAOL2)+" "+dataCustomer.getOrderNo(), response.code(), response.message(), null);
  342. if(response.isSuccessful())
  343. {
  344. if(response.body().getOUTSTAT().equalsIgnoreCase("T"))
  345. {
  346. dataCustomer.setSync2(1);
  347. dataCustomer.save();
  348. }
  349. }
  350. }
  351.  
  352. @Override
  353. public void onFailure(Call<ReturnAOL> call, Throwable t) {
  354. call.cancel();
  355. WriteWSLogUtil.writeToFile(getApplicationContext(), getString(R.string.updateProcessFlagAOL2)+" "+dataCustomer.getOrderNo(), null, null, getString(R.string.error_connection));
  356. }
  357. });
  358. }
  359.  
  360. private void assignAction()
  361. {
  362. btnPetunjukArah.setOnClickListener(new View.OnClickListener() {
  363. @Override
  364. public void onClick(View view) {
  365. String uri = "";
  366. Intent intent;
  367. try {
  368. uri = String.format(Locale.ENGLISH,"geo:" + latitude + "," +longitude + "?q=" + latitude+","+longitude+" ("+alamat+")");
  369. intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
  370. intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  371. startActivity(intent);
  372. } catch (ActivityNotFoundException ex) {
  373. try {
  374. Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
  375. startActivity(unrestrictedIntent);
  376. } catch (Exception e) {
  377. //getSnackbar(getResources().getString(R.string.map_install_application), Snackbar.LENGTH_LONG).show();
  378. Toast.makeText(CustomerDetailActivity.this, e.getMessage(),Toast.LENGTH_SHORT).show();
  379. }
  380. }
  381. }
  382. });
  383.  
  384. imgPhoneCP.setOnClickListener(new View.OnClickListener() {
  385. @Override
  386. public void onClick(View view) {
  387. DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
  388. getString(R.string.title_konfirmasi_dialog),
  389. getString(R.string.call_customer),
  390. getString(R.string.yes), new DialogInterface.OnClickListener() {
  391. @Override
  392. public void onClick(DialogInterface dialog, int which) {
  393. if(checkPermissionCallPhone())
  394. {
  395. Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", noHp, null));
  396. startActivity(intent);
  397. }
  398. }
  399. }, getString(R.string.no), new DialogInterface.OnClickListener() {
  400. @Override
  401. public void onClick(DialogInterface dialog, int which) {
  402.  
  403. }
  404. });
  405. }
  406. });
  407.  
  408. imgDetailCP.setOnClickListener(new View.OnClickListener() {
  409. @Override
  410. public void onClick(View view) {
  411. Intent intent=new Intent(CustomerDetailActivity.this, TabsIconCustomerDetailActivity.class);
  412. startActivity(intent);
  413. }
  414. });
  415.  
  416. crdCustomerDetail.setOnClickListener(new View.OnClickListener() {
  417. @Override
  418. public void onClick(View view) {
  419. Intent intent=new Intent(CustomerDetailActivity.this, TabsIconCustomerDetailActivity.class);
  420. startActivity(intent);
  421. }
  422. });
  423.  
  424. if(GlobalParam.getValue("LockSurvey").equalsIgnoreCase("no"))
  425. {
  426. if(SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle().getProcessFlag().equals("1"))
  427. {
  428. btnMulaiPasswordCP.setText(R.string.lanjut_survey);
  429. btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
  430. @Override
  431. public void onClick(View view) {
  432. AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
  433. alert.setMessage(R.string.yakin_lanjut_survey);
  434. alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
  435. @Override
  436. public void onClick(DialogInterface dialogInterface, int i) {
  437. first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
  438. id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
  439. .where(DataObject_Table.modelCode.like(first3Char + "%"))
  440. .and(DataObject_Table.surveyStatus.eq("K"))
  441. .querySingle();
  442. //
  443. SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
  444.  
  445.  
  446. Intent intent = new Intent(CustomerDetailActivity.this, Survey2Activity.class);
  447. startActivity(intent);
  448.  
  449.  
  450. }
  451. });
  452. alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
  453. @Override
  454. public void onClick(DialogInterface dialogInterface, int i) {
  455.  
  456. }
  457. });
  458.  
  459. applyCustomFontToDialog(getApplicationContext(), alert.create());
  460. ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
  461. // alert.show();
  462. }
  463. });
  464. }
  465. else /*if
  466. (
  467. (
  468. SQLite.select().from(DataObject.class)
  469. .where(id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq("1")).queryList().size()==0
  470. && Integer.parseInt(customerPosition)==0
  471. && activePage.equalsIgnoreCase(getString(R.string.new_survey))
  472. )
  473. )*/
  474. {
  475. btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
  476. @Override
  477. public void onClick(View view) {
  478. AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
  479. alert.setMessage(getString(R.string.start_survey));
  480. alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
  481. @Override
  482. public void onClick(DialogInterface dialogInterface, int i) {
  483. first3Char=customerPreviewDetail.getNoOrderSurvey().substring(0,3);
  484. updateReadDate(dataCustomer.getOrderNo());
  485. getCoordinate(CustomerDetailActivity.this,"K","1");
  486.  
  487. }
  488. });
  489. alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
  490. @Override
  491. public void onClick(DialogInterface dialogInterface, int i) {
  492.  
  493. }
  494. });
  495. ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
  496. // alert.show();
  497. }
  498. });
  499. }
  500. /*else
  501. {
  502. btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
  503. @Override
  504. public void onClick(View view) {
  505. AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
  506. alert.setMessage("Maaf anda harus menyelesaikan survey secara berurutan atau yang aktif terlebih dahulu");
  507. alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
  508. @Override
  509. public void onClick(DialogInterface dialogInterface, int i) {
  510.  
  511. }
  512. });
  513.  
  514. ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
  515. // alert.show();
  516. }
  517. });
  518. }*/
  519. }
  520. else
  521. {
  522. if(SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle().getProcessFlag().equals("1"))
  523. {
  524. btnMulaiPasswordCP.setText(R.string.lanjut_survey);
  525. btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
  526. @Override
  527. public void onClick(View view) {
  528. AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
  529. alert.setMessage(R.string.yakin_lanjut_survey);
  530. alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
  531. @Override
  532. public void onClick(DialogInterface dialogInterface, int i) {
  533. first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
  534. id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
  535. .where(DataObject_Table.modelCode.like(first3Char + "%"))
  536. .and(DataObject_Table.surveyStatus.eq("K"))
  537. .querySingle();
  538. SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
  539.  
  540.  
  541. Intent intent = new Intent(CustomerDetailActivity.this, Survey2Activity.class);
  542. startActivity(intent);
  543.  
  544.  
  545. }
  546. });
  547. alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
  548. @Override
  549. public void onClick(DialogInterface dialogInterface, int i) {
  550.  
  551. }
  552. });
  553. applyCustomFontToDialog(getApplicationContext(), alert.create());
  554. ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
  555. }
  556. });
  557. }
  558. else /*if
  559. (
  560. (
  561. SQLite.select().from(DataObject.class)
  562. .where(id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq("1")).queryList().size()==0
  563. && activePage.equalsIgnoreCase(getString(R.string.new_survey))
  564. )
  565. )*/
  566. {
  567. btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
  568. @Override
  569. public void onClick(View view) {
  570. AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
  571. alert.setMessage(getString(R.string.start_survey));
  572. alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
  573. @Override
  574. public void onClick(DialogInterface dialogInterface, int i) {
  575. first3Char=customerPreviewDetail.getNoOrderSurvey().substring(0,3);
  576. updateReadDate(dataCustomer.getOrderNo());
  577. getCoordinate(CustomerDetailActivity.this,"K","1");
  578. }
  579. });
  580. alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
  581. @Override
  582. public void onClick(DialogInterface dialogInterface, int i) {
  583.  
  584. }
  585. });
  586.  
  587. ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
  588. // alert.show();
  589. }
  590. });
  591. }
  592. /*else
  593. {
  594. btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
  595. @Override
  596. public void onClick(View view) {
  597. AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
  598. alert.setMessage("Maaf anda harus menyelesaikan survey secara berurutan atau yang aktif terlebih dahulu");
  599. alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
  600. @Override
  601. public void onClick(DialogInterface dialogInterface, int i) {
  602.  
  603. }
  604. });
  605.  
  606. ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
  607. // alert.show();
  608. }
  609. });
  610. }*/
  611. }
  612.  
  613. btnBatalSurvey.setOnClickListener(new View.OnClickListener() {
  614. @Override
  615. public void onClick(View v) {
  616. String activeSurvey = SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle().getProcessFlag();
  617. int adaActiveSurvey = SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq("1")).queryList().size();
  618. String lockStatus = GlobalParam.getValue("LockSurvey");
  619. int customerposition = Integer.parseInt(customerPosition);
  620. if (lockStatus.toLowerCase().equalsIgnoreCase("no")) {
  621. if (activeSurvey.equalsIgnoreCase("1")) {
  622. DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
  623. null,
  624. getString(R.string.pesan_konfirmasi_batal_survey),
  625. getString(R.string.yes), new DialogInterface.OnClickListener() {
  626. @Override
  627. public void onClick(DialogInterface dialog, int which) {
  628. first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
  629. updateReadDate(dataCustomer.getOrderNo());
  630. getCoordinate(CustomerDetailActivity.this, "T", "1");
  631. }
  632. }, getString(R.string.no), new DialogInterface.OnClickListener() {
  633. @Override
  634. public void onClick(DialogInterface dialog, int which) {
  635.  
  636. }
  637. });
  638.  
  639. } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey > 0) {
  640. DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.title_informasi_dialog),
  641. getString(R.string.pesan_tidak_bisa_batal_satu), getString(R.string.yes), new DialogInterface.OnClickListener() {
  642. @Override
  643. public void onClick(DialogInterface dialog, int which) {
  644.  
  645. }
  646. });
  647.  
  648. } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey == 0 && customerposition == 0) {
  649. DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
  650. null,
  651. getString(R.string.pesan_konfirmasi_batal_survey),
  652. getString(R.string.yes), new DialogInterface.OnClickListener() {
  653. @Override
  654. public void onClick(DialogInterface dialog, int which) {
  655. first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
  656. updateReadDate(dataCustomer.getOrderNo());
  657. getCoordinate(CustomerDetailActivity.this, "T", "1");
  658. }
  659. }, getString(R.string.no), new DialogInterface.OnClickListener() {
  660. @Override
  661. public void onClick(DialogInterface dialog, int which) {
  662.  
  663. }
  664. });
  665.  
  666. } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey == 0 && customerposition > 0) {
  667. DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.title_informasi_dialog),
  668. getString(R.string.pesan_tidak_bisa_batal_dua), getString(R.string.yes), new DialogInterface.OnClickListener() {
  669. @Override
  670. public void onClick(DialogInterface dialog, int which) {
  671.  
  672. }
  673. });
  674.  
  675. }
  676. } else if (lockStatus.toLowerCase().equalsIgnoreCase("yes")) {
  677. if (activeSurvey.equalsIgnoreCase("1")) {
  678. DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
  679. null,
  680. getString(R.string.pesan_konfirmasi_batal_survey),
  681. getString(R.string.yes), new DialogInterface.OnClickListener() {
  682. @Override
  683. public void onClick(DialogInterface dialog, int which) {
  684. first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
  685. updateReadDate(dataCustomer.getOrderNo());
  686. getCoordinate(CustomerDetailActivity.this, "T", "1");
  687.  
  688. }
  689. }, getString(R.string.no), new DialogInterface.OnClickListener() {
  690. @Override
  691. public void onClick(DialogInterface dialog, int which) {
  692.  
  693. }
  694. });
  695.  
  696. } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey > 0) {
  697. DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.title_informasi_dialog),
  698. getString(R.string.pesan_tidak_bisa_batal_satu), getString(R.string.yes), new DialogInterface.OnClickListener() {
  699. @Override
  700. public void onClick(DialogInterface dialog, int which) {
  701.  
  702. }
  703. });
  704.  
  705. } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey == 0) {
  706. DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
  707. null,
  708. getString(R.string.pesan_konfirmasi_batal_survey),
  709. getString(R.string.yes), new DialogInterface.OnClickListener() {
  710. @Override
  711. public void onClick(DialogInterface dialog, int which) {
  712. first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
  713. updateReadDate(dataCustomer.getOrderNo());
  714. getCoordinate(CustomerDetailActivity.this, "T", "1");
  715. }
  716. }, getString(R.string.no), new DialogInterface.OnClickListener() {
  717. @Override
  718. public void onClick(DialogInterface dialog, int which) {
  719.  
  720. }
  721. });
  722.  
  723. }
  724. }
  725. }
  726. });
  727.  
  728. imgTrans.setOnTouchListener(new View.OnTouchListener() {
  729. @Override
  730. public boolean onTouch(View view, MotionEvent event) {
  731. int action = event.getAction();
  732. switch (action) {
  733. case MotionEvent.ACTION_DOWN:
  734. // Disallow ScrollView to intercept touch events.
  735. scrCustomerDetail.requestDisallowInterceptTouchEvent(true);
  736. // Disable touch on transparent view
  737. return false;
  738.  
  739. case MotionEvent.ACTION_UP:
  740. // Allow ScrollView to intercept touch events.
  741. scrCustomerDetail.requestDisallowInterceptTouchEvent(false);
  742. return true;
  743.  
  744. case MotionEvent.ACTION_MOVE:
  745. scrCustomerDetail.requestDisallowInterceptTouchEvent(true);
  746. return false;
  747.  
  748. default:
  749. return true;
  750. }
  751. }
  752. });
  753. }
  754.  
  755. public boolean checkPermissionCallPhone()
  756. {
  757. if (ContextCompat.checkSelfPermission(CustomerDetailActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
  758.  
  759. ActivityCompat.requestPermissions(CustomerDetailActivity.this, new String[]{Manifest.permission.CALL_PHONE}, MY_PERMISSIONS_REQUEST_CALL_PHONE);
  760. return false;
  761. }
  762. return true;
  763. }
  764.  
  765. private void updateReadDate(String orderNo)
  766. {
  767. Date date=new Date();
  768. DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
  769. DateFormat timeFormat = new SimpleDateFormat("HH:mm");
  770. final String dateRead=dateFormat.format(date);
  771. final String timeRead=timeFormat.format(date);
  772. DataObject dataObject = SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(orderNo)).querySingle();
  773. if(dataObject.getReadDate()==null || dataObject.getReadTime()==null)
  774. {
  775. SQLite.update(DataObject.class).set(
  776. id.co.acc.www.amos.model.TGprs.DataObject_Table.readDate.eq(dateRead),
  777. id.co.acc.www.amos.model.TGprs.DataObject_Table.readTime.eq(timeRead)
  778. ).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(orderNo)).execute();
  779. }
  780. }
  781.  
  782. @Override
  783. public void onMapReady(GoogleMap googleMap) {
  784. mMap = googleMap;
  785.  
  786. mMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() {
  787. @Override
  788. public void onCameraMove() {
  789.  
  790. }
  791. });
  792.  
  793. LatLng coordinate = new LatLng( Double.parseDouble(latitude), Double.parseDouble(longitude));
  794. if(latitude!=null)
  795. {
  796. String country = GetCountryUtil.getCountry(getApplicationContext(), latitude, longitude);
  797. try {
  798. if(!country.equalsIgnoreCase("Indonesia"))
  799. {
  800. DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.uninstall_fake_gps),
  801. getString(R.string.use_in_indonesia), getString(R.string.yes), new DialogInterface.OnClickListener() {
  802. @Override
  803. public void onClick(DialogInterface dialog, int which) {
  804. NavUtils.navigateUpFromSameTask(CustomerDetailActivity.this);
  805. }
  806. });
  807. }
  808. } catch (Exception e)
  809. {
  810.  
  811. }
  812. }
  813. else
  814. {
  815. String countryId= GetCountryUtil.getCountryBasedOnSimCardOrNetwork(getApplicationContext());
  816. try {
  817. if(countryId.equalsIgnoreCase("id"))
  818. {
  819. DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.uninstall_fake_gps),
  820. "Sim Card tidak terdeteksi, mohon gunakan aplikasi di Indonesia", getString(R.string.yes), new DialogInterface.OnClickListener() {
  821. @Override
  822. public void onClick(DialogInterface dialog, int which) {
  823. NavUtils.navigateUpFromSameTask(CustomerDetailActivity.this);
  824. }
  825. });
  826. }
  827. } catch (Exception e)
  828. {
  829.  
  830. }
  831. }
  832.  
  833. mMap.moveCamera(CameraUpdateFactory.newLatLng(coordinate));
  834. CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 10);
  835. mMap.animateCamera(yourLocation);
  836.  
  837. LatLng coordinateActivity = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));
  838. String title="customer location";
  839. mMap.addMarker(new MarkerOptions().position(coordinateActivity).title(title));
  840.  
  841. mMap.setMyLocationEnabled(true);
  842. }
  843.  
  844. @SuppressLint("MissingPermission")
  845. private void getCoordinateFakeLocation(final Context act) {
  846. FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient(act);
  847. client.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
  848. @SuppressLint("ResourceType")
  849. @Override
  850. public void onSuccess(Location location) {
  851. // GPS location can be null if GPS is switched off
  852. if (location != null) {
  853. if (location.isFromMockProvider()) {
  854. DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.uninstall_fake_gps),
  855. getString(R.string.disable_fake_gps), getString(R.string.yes), new DialogInterface.OnClickListener() {
  856. @Override
  857. public void onClick(DialogInterface dialog, int which) {
  858. finish();
  859. System.exit(0);
  860. }
  861. });
  862. }
  863.  
  864.  
  865. }
  866. }
  867. });
  868. }
  869.  
  870. @SuppressLint("MissingPermission")
  871. private void getCoordinate(final Context act, final String statusTemu, final String prosesFlag) {
  872. client = LocationServices.getFusedLocationProviderClient(act);
  873. client.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
  874. @SuppressLint("ResourceType")
  875. @Override
  876. public void onSuccess(Location location) {
  877. final String modelCode;
  878. // GPS location can be null if GPS is switched off
  879. if (location != null) {
  880. latitude = String.valueOf(location.getLatitude());
  881. longitude = String.valueOf(location.getLongitude());
  882.  
  883. id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
  884. .where(DataObject_Table.modelCode.like(first3Char+"%"))
  885. .and(DataObject_Table.surveyStatus.eq(statusTemu))
  886. .querySingle();
  887. SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
  888. modelCode=dataObject.getModelCode();
  889.  
  890. SQLite.update(DataObject.class).set((id.co.acc.www.amos.model.TGprs.DataObject_Table.latitude.eq(latitude))
  891. , id.co.acc.www.amos.model.TGprs.DataObject_Table.longitude.eq(longitude)
  892. , id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq(prosesFlag)
  893. )
  894. .where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.is(dataCustomer.getOrderNo())).execute();
  895. new UpdateSurveyUtil().updateProcessFlag(dataCustomer.getOrderNo(),prosesFlag, CustomerDetailActivity.this);
  896.  
  897. if(statusTemu.matches(GlobalVar.ketemu) && prosesFlag.matches(GlobalVar.activeSurvey))
  898. {
  899. new GetCurrentLocation().sendLocation(CustomerDetailActivity.this, latitude, longitude);
  900. }
  901. }
  902. else
  903. {
  904. latitude = dataCustomer.getLatitude();
  905. longitude = dataCustomer.getLongitude();
  906.  
  907. id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
  908. .where(DataObject_Table.modelCode.like(first3Char+"%"))
  909. .and(DataObject_Table.surveyStatus.eq(statusTemu))
  910. .querySingle();
  911. SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
  912. modelCode=dataObject.getModelCode();
  913.  
  914. new UpdateSurveyUtil().updateProcessFlag(dataCustomer.getOrderNo(),prosesFlag, CustomerDetailActivity.this);
  915.  
  916. }
  917.  
  918. Intent intent;
  919. if(statusTemu.equalsIgnoreCase(GlobalVar.tidakKetemu))
  920. {
  921. intent=new Intent(CustomerDetailActivity.this, BatalSurveyActivity.class);
  922. intent.putExtra("modelCode", modelCode);
  923. }
  924. else
  925. {
  926. intent=new Intent(CustomerDetailActivity.this, Survey2Activity.class);
  927. }
  928.  
  929. startActivity(intent);
  930.  
  931. }
  932. });
  933. }
  934.  
  935. @Override
  936. protected void onPause() {
  937. super.onPause();
  938. SharedPreferenceUtils.setSetting(getApplicationContext(),"isAplikasiOpen","true");
  939. AmosApplication.runTimeOutHourglass();
  940. if(AmosApplication.timeRemain<1l)
  941. {
  942. SessionManagement.clearSession(getApplicationContext());
  943. session.logoutUser();
  944. }
  945. }
  946.  
  947. @Override
  948. protected void onResume() {
  949. super.onResume();
  950. SharedPreferenceUtils.setSetting(getApplicationContext(),"isAplikasiOpen","true");
  951. AmosApplication.pauseTimeOutHourglass();
  952. if(AmosApplication.timeRemain<1l)
  953. {
  954. SessionManagement.clearSession(getApplicationContext());
  955. session.logoutUser();
  956. }
  957.  
  958. new CheckFakeGPS().getCoordinateFakeLocation(this);
  959. }
  960.  
  961. public static void applyCustomFontToDialog(Context context, Dialog dialog) {
  962. Typeface font = ResourcesCompat.getFont(context, R.font.muli_reguler);
  963. if (font != null) {
  964. TextView titleView = dialog.findViewById(android.support.v7.appcompat.R.id.alertTitle);
  965. TextView messageView = dialog.findViewById(android.R.id.message);
  966. if (titleView != null) titleView.setTypeface(font, Typeface.BOLD);
  967. if (messageView != null) messageView.setTypeface(font);
  968. }
  969. }
  970.  
  971. @Override
  972. public void onBackPressed() {
  973. NavUtils.navigateUpFromSameTask(this);
  974. }
  975. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement