Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package id.co.acc.www.amos.activity;
- import android.Manifest;
- import android.annotation.SuppressLint;
- import android.app.Dialog;
- import android.content.ActivityNotFoundException;
- import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.content.pm.PackageManager;
- import android.content.res.Configuration;
- import android.graphics.Typeface;
- import android.location.Location;
- import android.net.Uri;
- import android.provider.Settings;
- import android.support.design.widget.Snackbar;
- import android.support.v4.app.ActivityCompat;
- import android.support.v4.app.NavUtils;
- import android.support.v4.content.ContextCompat;
- import android.support.v4.content.res.ResourcesCompat;
- import android.support.v7.app.AlertDialog;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.support.v7.widget.CardView;
- import android.util.DisplayMetrics;
- import android.util.Log;
- import android.view.MotionEvent;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.Button;
- import android.widget.ExpandableListView;
- import android.widget.ImageView;
- import android.widget.ScrollView;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.google.android.gms.location.FusedLocationProviderClient;
- import com.google.android.gms.location.LocationServices;
- import com.google.android.gms.maps.CameraUpdate;
- import com.google.android.gms.maps.CameraUpdateFactory;
- import com.google.android.gms.maps.GoogleMap;
- import com.google.android.gms.maps.OnMapReadyCallback;
- import com.google.android.gms.maps.SupportMapFragment;
- import com.google.android.gms.maps.model.LatLng;
- import com.google.android.gms.maps.model.MarkerOptions;
- import com.google.android.gms.tasks.OnSuccessListener;
- import com.google.gson.Gson;
- import com.raizlabs.android.dbflow.sql.language.SQLite;
- import com.raizlabs.android.dbflow.sql.queriable.StringQuery;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.ArrayList;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Locale;
- import id.co.acc.www.amos.AmosApplication;
- import id.co.acc.www.amos.R;
- import id.co.acc.www.amos.adapter.CustomerDetailAdapter;
- import id.co.acc.www.amos.adapter.DialogAdapter;
- import id.co.acc.www.amos.model.CustomerPreview;
- import id.co.acc.www.amos.model.CustomerPreviewDetail;
- import id.co.acc.www.amos.model.MGlobal.Global;
- import id.co.acc.www.amos.model.MModels.DataObject_Table;
- import id.co.acc.www.amos.model.MessageReturn.MessageReturn;
- import id.co.acc.www.amos.model.ReturnAOL.ReturnAOL;
- import id.co.acc.www.amos.model.TGprs.DataObject;
- import id.co.acc.www.amos.model.UpdateProcessFlagAOL.GprsWrapper;
- import id.co.acc.www.amos.model.UpdateProcessFlagAOL.UpdateProcessFlagAOL;
- import id.co.acc.www.amos.network.APIClient;
- import id.co.acc.www.amos.network.APIInterfaceRest;
- import id.co.acc.www.amos.util.ChangeAlertMessage;
- import id.co.acc.www.amos.util.CheckFakeGPS;
- import id.co.acc.www.amos.util.CustomizedExceptionHandler;
- import id.co.acc.www.amos.util.GenerateLogError;
- import id.co.acc.www.amos.util.GetCountryUtil;
- import id.co.acc.www.amos.util.GetCurrentLocation;
- import id.co.acc.www.amos.util.GetTaskUtil;
- import id.co.acc.www.amos.util.GlobalParam;
- import id.co.acc.www.amos.util.GlobalVar;
- import id.co.acc.www.amos.util.LogoutToken;
- import id.co.acc.www.amos.util.Scheduler;
- import id.co.acc.www.amos.util.ScrollGoogleMap;
- import id.co.acc.www.amos.util.SendPendingSurveyScheduler;
- import id.co.acc.www.amos.util.SessionManagement;
- import id.co.acc.www.amos.util.SharedPreferenceUtils;
- import id.co.acc.www.amos.util.Tools;
- import id.co.acc.www.amos.util.UpdateSurveyUtil;
- import id.co.acc.www.amos.util.WriteWSLogUtil;
- import okhttp3.MediaType;
- import okhttp3.RequestBody;
- import retrofit2.Call;
- import retrofit2.Callback;
- import retrofit2.Response;
- public class CustomerDetailActivity extends AppCompatActivity implements OnMapReadyCallback {
- private GoogleMap mMap;
- private String latitude;
- private String longitude;
- private Button btnPetunjukArah,btnBatalSurvey;
- private Button btnMulaiPasswordCP;
- private ExpandableListView elvCustomerDetail;
- private List<CustomerPreview> listDataHeader;
- private HashMap<CustomerPreview,List<CustomerPreviewDetail>> listHash;
- private TextView txtNamaCustomerCP, txtAlamatCP, txtKontakNomorCP;
- private ImageView imgDetailCP, imgPhoneCP;
- private String noHp;
- private String alamat;
- private static final int MY_PERMISSIONS_REQUEST_CALL_PHONE=999;
- private CardView crdCustomerDetail;
- private String customerPosition;
- private DataObject dataCustomer;
- private CustomerPreviewDetail customerPreviewDetail;
- private FusedLocationProviderClient client;
- private String first3Char;
- private String activePage;
- private ScrollView scrCustomerDetail;
- private ImageView imgTrans;
- private SessionManagement session;
- @SuppressLint("ClickableViewAccessibility")
- private void assignView()
- {
- session = new SessionManagement(getApplicationContext());
- btnPetunjukArah=(Button)findViewById(R.id.btnPetunjukArah);
- elvCustomerDetail=(ExpandableListView)findViewById(R.id.elvCustomerDetail);
- btnMulaiPasswordCP=(Button)findViewById(R.id.btnMulaiSurveiCP);
- btnBatalSurvey =(Button)findViewById(R.id.btnBatalSurvey);
- scrCustomerDetail=(ScrollView)findViewById(R.id.scrCustomerDetail);
- imgTrans=(ImageView)findViewById(R.id.imgTrans);
- customerPosition=SharedPreferenceUtils.getSetting(CustomerDetailActivity.this, "customerPosition", "");
- if(dataCustomer.getLatitude()==null)
- latitude="0";
- else
- latitude=dataCustomer.getLatitude();
- if(dataCustomer.getLongitude()==null)
- longitude="0";
- else
- longitude=dataCustomer.getLongitude();
- String namepass[] = dataCustomer.getMessage().split(";");
- String grading = namepass[0];
- String orderNo = namepass[1];
- String cabang = namepass[2];
- String dealer = namepass[3];
- String brand= namepass[4];
- String type = namepass[5];
- String model = namepass[6];
- String kind = namepass[7];
- String namaPemohon = namepass[8];
- String namaYangDisurvey=namepass[9];
- alamat= namepass[10];
- String noTelp = namepass[11];
- noHp = namepass[12];
- String area=namepass[13];
- String kota=namepass[14];
- String kodePos=namepass[15];
- String tahunKendaraan=namepass[16];
- String oTR=namepass[17];
- String warna=namepass[18];
- String tenor = namepass[19];
- String cicilan=namepass[20];
- String notepadRd=namepass[21];
- String notepadFa=namepass[22];
- String jenisKelamin=namepass[23];
- String jabatan=namepass[24];
- String tanggalLahir=namepass[25];
- String dp=namepass[26];
- String refinancing=namepass[27];
- String namaBisnis = namepass[28];
- String tanggalOrder = namepass[29];
- String jamOrder = namepass[30];
- String tipeAplikasi = namepass[31];
- String roAo = namepass[32];
- String loanType = namepass[33];
- String dokumen="";
- try{
- dokumen=namepass[34];
- }
- catch (Exception e)
- {
- }
- String status;
- try
- {
- String statusCode = orderNo.substring(15,16);
- status = GlobalVar.status.get(statusCode);
- }
- catch (Exception e)
- {
- status="";
- }
- CustomerPreview customerPreview=new CustomerPreview(namaPemohon,alamat, noHp);
- listDataHeader=new ArrayList<>();
- listDataHeader.add(customerPreview);
- customerPreviewDetail=new CustomerPreviewDetail();
- customerPreviewDetail.setGrading(grading);
- customerPreviewDetail.setNoOrderSurvey(orderNo);
- customerPreviewDetail.setCabang(cabang);
- customerPreviewDetail.setDealer(dealer);
- customerPreviewDetail.setBrand(brand);
- customerPreviewDetail.setType(type);
- customerPreviewDetail.setModel(model);
- customerPreviewDetail.setKind(kind);
- customerPreviewDetail.setNamaPemohon(namaPemohon);
- customerPreviewDetail.setNamaYangDiSurvey(namaYangDisurvey);
- customerPreviewDetail.setAlamat(alamat);
- customerPreviewDetail.setNoTelp(noTelp);
- customerPreviewDetail.setNoHp(noHp);
- customerPreviewDetail.setArea(area);
- customerPreviewDetail.setKota(kota);
- customerPreviewDetail.setKodePos(kodePos);
- customerPreviewDetail.setTahunKend(tahunKendaraan);
- customerPreviewDetail.setoTR(oTR);
- customerPreviewDetail.setWarna(warna);
- customerPreviewDetail.setTenor(tenor);
- customerPreviewDetail.setCicilan(cicilan);
- customerPreviewDetail.setNotepadRD(notepadRd);
- customerPreviewDetail.setNotepadFA(notepadFa);
- customerPreviewDetail.setJenisKelamin(jenisKelamin);
- customerPreviewDetail.setJabatan(jabatan);
- customerPreviewDetail.setTanggalLahir(tanggalLahir);
- customerPreviewDetail.setDp(dp);
- customerPreviewDetail.setRefinancing(refinancing);
- customerPreviewDetail.setNamaBisnis(namaBisnis);
- customerPreviewDetail.setTanggalOrder(tanggalOrder);
- customerPreviewDetail.setJamOrder(jamOrder);
- customerPreviewDetail.setTipeAplikasi(tipeAplikasi);
- customerPreviewDetail.setRoAo(roAo);
- customerPreviewDetail.setLoanType(loanType);
- customerPreviewDetail.setDokumen(dokumen);
- customerPreviewDetail.setStatus(status);
- List<CustomerPreviewDetail> customerPreviewDetails=new ArrayList<>();
- customerPreviewDetails.add(customerPreviewDetail);
- Gson gson =new Gson();
- SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "customerSelectedDetail", gson.toJson(customerPreviewDetail));
- listHash = new HashMap<>();
- listHash.put(listDataHeader.get(0), customerPreviewDetails);
- CustomerDetailAdapter customerDetailAdapter=new CustomerDetailAdapter(this, listDataHeader, listHash);
- elvCustomerDetail.setAdapter(customerDetailAdapter);
- txtNamaCustomerCP=(TextView)findViewById(R.id.txtNamaCustomerCP);
- txtAlamatCP=(TextView)findViewById(R.id.txtAlamatCP);
- txtKontakNomorCP=(TextView)findViewById(R.id.txtKontakNomorCP);
- imgDetailCP=(ImageView)findViewById(R.id.imgDetailCP);
- imgPhoneCP=(ImageView)findViewById(R.id.imgPhoneCP);
- txtNamaCustomerCP.setText(namaYangDisurvey);
- txtAlamatCP.setText(alamat);
- txtKontakNomorCP.setText(noHp);
- crdCustomerDetail=(CardView)findViewById(R.id.crdCustomerDetail);
- SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
- .findFragmentById(R.id.map);
- ViewGroup.LayoutParams param = mapFragment.getView().getLayoutParams();
- int orientation = getResources().getConfiguration().orientation;
- if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
- HashMap<String,Integer> dispalySize = Tools.displaySize(this);
- param.height=dispalySize.get("width")/3;
- mapFragment.getView().setLayoutParams(param);
- } else {
- // In portrait
- }
- mapFragment.getMapAsync(this);
- SharedPreferenceUtils.setSetting(this,"isAplikasiOpen","true");
- }
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- new GenerateLogError(getApplicationContext());
- setContentView(R.layout.activity_customer_detail);
- setTitle(R.string.customer_info);
- String customerSelected=SharedPreferenceUtils.getSetting(CustomerDetailActivity.this, "customerSelected","");
- Gson gson =new Gson();
- dataCustomer=gson.fromJson(customerSelected, DataObject.class);
- dataCustomer=SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle();
- activePage=SharedPreferenceUtils.getSetting(CustomerDetailActivity.this, "activePage","");
- assignView();
- assignAction();
- sync2();
- Thread.setDefaultUncaughtExceptionHandler(new CustomizedExceptionHandler(
- getExternalFilesDir(null).getAbsolutePath()));
- }
- private void sync2()
- {
- if(dataCustomer.getSync2()==null)
- {
- //set sync2
- updateSync2();
- }
- }
- private void updateSync2()
- {
- GprsWrapper gprsWrapper=new GprsWrapper();
- gprsWrapper.setORDERNO(dataCustomer.getOrderNo());
- gprsWrapper.setPROCESSFLAG(GlobalVar.readAol);
- UpdateProcessFlagAOL updateProcessFlagAOL=new UpdateProcessFlagAOL();
- updateProcessFlagAOL.setGprsWrapper(gprsWrapper);
- Gson gson=new Gson();
- String json=gson.toJson(updateProcessFlagAOL);
- // RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
- RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), json);
- final APIInterfaceRest apiInterfaceRest=APIClient.getClientACC(getApplicationContext()).create(APIInterfaceRest.class);
- Call<ReturnAOL> call=apiInterfaceRest.updateProcessFlagToAOL(body);
- WriteWSLogUtil.writeToFile(getApplicationContext(), getString(R.string.updateProcessFlagAOL2)+" "+dataCustomer.getOrderNo(), null, null, null);
- call.enqueue(new Callback<ReturnAOL>() {
- @Override
- public void onResponse(Call<ReturnAOL> call, Response<ReturnAOL> response) {
- WriteWSLogUtil.writeToFile(getApplicationContext(), getString(R.string.updateProcessFlagAOL2)+" "+dataCustomer.getOrderNo(), response.code(), response.message(), null);
- if(response.isSuccessful())
- {
- if(response.body().getOUTSTAT().equalsIgnoreCase("T"))
- {
- dataCustomer.setSync2(1);
- dataCustomer.save();
- }
- }
- }
- @Override
- public void onFailure(Call<ReturnAOL> call, Throwable t) {
- call.cancel();
- WriteWSLogUtil.writeToFile(getApplicationContext(), getString(R.string.updateProcessFlagAOL2)+" "+dataCustomer.getOrderNo(), null, null, getString(R.string.error_connection));
- }
- });
- }
- private void assignAction()
- {
- btnPetunjukArah.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- String uri = "";
- Intent intent;
- try {
- uri = String.format(Locale.ENGLISH,"geo:" + latitude + "," +longitude + "?q=" + latitude+","+longitude+" ("+alamat+")");
- intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
- intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- } catch (ActivityNotFoundException ex) {
- try {
- Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
- startActivity(unrestrictedIntent);
- } catch (Exception e) {
- //getSnackbar(getResources().getString(R.string.map_install_application), Snackbar.LENGTH_LONG).show();
- Toast.makeText(CustomerDetailActivity.this, e.getMessage(),Toast.LENGTH_SHORT).show();
- }
- }
- }
- });
- imgPhoneCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
- getString(R.string.title_konfirmasi_dialog),
- getString(R.string.call_customer),
- getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- if(checkPermissionCallPhone())
- {
- Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", noHp, null));
- startActivity(intent);
- }
- }
- }, getString(R.string.no), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- }
- });
- imgDetailCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent=new Intent(CustomerDetailActivity.this, TabsIconCustomerDetailActivity.class);
- startActivity(intent);
- }
- });
- crdCustomerDetail.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Intent intent=new Intent(CustomerDetailActivity.this, TabsIconCustomerDetailActivity.class);
- startActivity(intent);
- }
- });
- if(GlobalParam.getValue("LockSurvey").equalsIgnoreCase("no"))
- {
- if(SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle().getProcessFlag().equals("1"))
- {
- btnMulaiPasswordCP.setText(R.string.lanjut_survey);
- btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
- alert.setMessage(R.string.yakin_lanjut_survey);
- alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
- id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
- .where(DataObject_Table.modelCode.like(first3Char + "%"))
- .and(DataObject_Table.surveyStatus.eq("K"))
- .querySingle();
- //
- SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
- Intent intent = new Intent(CustomerDetailActivity.this, Survey2Activity.class);
- startActivity(intent);
- }
- });
- alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- applyCustomFontToDialog(getApplicationContext(), alert.create());
- ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
- // alert.show();
- }
- });
- }
- else /*if
- (
- (
- SQLite.select().from(DataObject.class)
- .where(id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq("1")).queryList().size()==0
- && Integer.parseInt(customerPosition)==0
- && activePage.equalsIgnoreCase(getString(R.string.new_survey))
- )
- )*/
- {
- btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
- alert.setMessage(getString(R.string.start_survey));
- alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- first3Char=customerPreviewDetail.getNoOrderSurvey().substring(0,3);
- updateReadDate(dataCustomer.getOrderNo());
- getCoordinate(CustomerDetailActivity.this,"K","1");
- }
- });
- alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
- // alert.show();
- }
- });
- }
- /*else
- {
- btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
- alert.setMessage("Maaf anda harus menyelesaikan survey secara berurutan atau yang aktif terlebih dahulu");
- alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
- // alert.show();
- }
- });
- }*/
- }
- else
- {
- if(SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle().getProcessFlag().equals("1"))
- {
- btnMulaiPasswordCP.setText(R.string.lanjut_survey);
- btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
- alert.setMessage(R.string.yakin_lanjut_survey);
- alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
- id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
- .where(DataObject_Table.modelCode.like(first3Char + "%"))
- .and(DataObject_Table.surveyStatus.eq("K"))
- .querySingle();
- SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
- Intent intent = new Intent(CustomerDetailActivity.this, Survey2Activity.class);
- startActivity(intent);
- }
- });
- alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- applyCustomFontToDialog(getApplicationContext(), alert.create());
- ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
- }
- });
- }
- else /*if
- (
- (
- SQLite.select().from(DataObject.class)
- .where(id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq("1")).queryList().size()==0
- && activePage.equalsIgnoreCase(getString(R.string.new_survey))
- )
- )*/
- {
- btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
- alert.setMessage(getString(R.string.start_survey));
- alert.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- first3Char=customerPreviewDetail.getNoOrderSurvey().substring(0,3);
- updateReadDate(dataCustomer.getOrderNo());
- getCoordinate(CustomerDetailActivity.this,"K","1");
- }
- });
- alert.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
- // alert.show();
- }
- });
- }
- /*else
- {
- btnMulaiPasswordCP.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- AlertDialog.Builder alert = new AlertDialog.Builder(CustomerDetailActivity.this);
- alert.setMessage("Maaf anda harus menyelesaikan survey secara berurutan atau yang aktif terlebih dahulu");
- alert.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- }
- });
- ChangeAlertMessage.changeAlertMessage(alert.show(), getApplicationContext());
- // alert.show();
- }
- });
- }*/
- }
- btnBatalSurvey.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String activeSurvey = SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(dataCustomer.getOrderNo())).querySingle().getProcessFlag();
- int adaActiveSurvey = SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq("1")).queryList().size();
- String lockStatus = GlobalParam.getValue("LockSurvey");
- int customerposition = Integer.parseInt(customerPosition);
- if (lockStatus.toLowerCase().equalsIgnoreCase("no")) {
- if (activeSurvey.equalsIgnoreCase("1")) {
- DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
- null,
- getString(R.string.pesan_konfirmasi_batal_survey),
- getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
- updateReadDate(dataCustomer.getOrderNo());
- getCoordinate(CustomerDetailActivity.this, "T", "1");
- }
- }, getString(R.string.no), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey > 0) {
- DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.title_informasi_dialog),
- getString(R.string.pesan_tidak_bisa_batal_satu), getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey == 0 && customerposition == 0) {
- DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
- null,
- getString(R.string.pesan_konfirmasi_batal_survey),
- getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
- updateReadDate(dataCustomer.getOrderNo());
- getCoordinate(CustomerDetailActivity.this, "T", "1");
- }
- }, getString(R.string.no), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey == 0 && customerposition > 0) {
- DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.title_informasi_dialog),
- getString(R.string.pesan_tidak_bisa_batal_dua), getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- }
- } else if (lockStatus.toLowerCase().equalsIgnoreCase("yes")) {
- if (activeSurvey.equalsIgnoreCase("1")) {
- DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
- null,
- getString(R.string.pesan_konfirmasi_batal_survey),
- getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
- updateReadDate(dataCustomer.getOrderNo());
- getCoordinate(CustomerDetailActivity.this, "T", "1");
- }
- }, getString(R.string.no), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey > 0) {
- DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.title_informasi_dialog),
- getString(R.string.pesan_tidak_bisa_batal_satu), getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- } else if (activeSurvey.equalsIgnoreCase("0") && adaActiveSurvey == 0) {
- DialogAdapter.showDialogTwoBtn(CustomerDetailActivity.this,
- null,
- getString(R.string.pesan_konfirmasi_batal_survey),
- getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- first3Char = customerPreviewDetail.getNoOrderSurvey().substring(0, 3);
- updateReadDate(dataCustomer.getOrderNo());
- getCoordinate(CustomerDetailActivity.this, "T", "1");
- }
- }, getString(R.string.no), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- }
- });
- }
- }
- }
- });
- imgTrans.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent event) {
- int action = event.getAction();
- switch (action) {
- case MotionEvent.ACTION_DOWN:
- // Disallow ScrollView to intercept touch events.
- scrCustomerDetail.requestDisallowInterceptTouchEvent(true);
- // Disable touch on transparent view
- return false;
- case MotionEvent.ACTION_UP:
- // Allow ScrollView to intercept touch events.
- scrCustomerDetail.requestDisallowInterceptTouchEvent(false);
- return true;
- case MotionEvent.ACTION_MOVE:
- scrCustomerDetail.requestDisallowInterceptTouchEvent(true);
- return false;
- default:
- return true;
- }
- }
- });
- }
- public boolean checkPermissionCallPhone()
- {
- if (ContextCompat.checkSelfPermission(CustomerDetailActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
- ActivityCompat.requestPermissions(CustomerDetailActivity.this, new String[]{Manifest.permission.CALL_PHONE}, MY_PERMISSIONS_REQUEST_CALL_PHONE);
- return false;
- }
- return true;
- }
- private void updateReadDate(String orderNo)
- {
- Date date=new Date();
- DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
- DateFormat timeFormat = new SimpleDateFormat("HH:mm");
- final String dateRead=dateFormat.format(date);
- final String timeRead=timeFormat.format(date);
- DataObject dataObject = SQLite.select().from(DataObject.class).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(orderNo)).querySingle();
- if(dataObject.getReadDate()==null || dataObject.getReadTime()==null)
- {
- SQLite.update(DataObject.class).set(
- id.co.acc.www.amos.model.TGprs.DataObject_Table.readDate.eq(dateRead),
- id.co.acc.www.amos.model.TGprs.DataObject_Table.readTime.eq(timeRead)
- ).where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.eq(orderNo)).execute();
- }
- }
- @Override
- public void onMapReady(GoogleMap googleMap) {
- mMap = googleMap;
- mMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() {
- @Override
- public void onCameraMove() {
- }
- });
- LatLng coordinate = new LatLng( Double.parseDouble(latitude), Double.parseDouble(longitude));
- if(latitude!=null)
- {
- String country = GetCountryUtil.getCountry(getApplicationContext(), latitude, longitude);
- try {
- if(!country.equalsIgnoreCase("Indonesia"))
- {
- DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.uninstall_fake_gps),
- getString(R.string.use_in_indonesia), getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- NavUtils.navigateUpFromSameTask(CustomerDetailActivity.this);
- }
- });
- }
- } catch (Exception e)
- {
- }
- }
- else
- {
- String countryId= GetCountryUtil.getCountryBasedOnSimCardOrNetwork(getApplicationContext());
- try {
- if(countryId.equalsIgnoreCase("id"))
- {
- DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.uninstall_fake_gps),
- "Sim Card tidak terdeteksi, mohon gunakan aplikasi di Indonesia", getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- NavUtils.navigateUpFromSameTask(CustomerDetailActivity.this);
- }
- });
- }
- } catch (Exception e)
- {
- }
- }
- mMap.moveCamera(CameraUpdateFactory.newLatLng(coordinate));
- CameraUpdate yourLocation = CameraUpdateFactory.newLatLngZoom(coordinate, 10);
- mMap.animateCamera(yourLocation);
- LatLng coordinateActivity = new LatLng(Double.parseDouble(latitude), Double.parseDouble(longitude));
- String title="customer location";
- mMap.addMarker(new MarkerOptions().position(coordinateActivity).title(title));
- mMap.setMyLocationEnabled(true);
- }
- @SuppressLint("MissingPermission")
- private void getCoordinateFakeLocation(final Context act) {
- FusedLocationProviderClient client = LocationServices.getFusedLocationProviderClient(act);
- client.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
- @SuppressLint("ResourceType")
- @Override
- public void onSuccess(Location location) {
- // GPS location can be null if GPS is switched off
- if (location != null) {
- if (location.isFromMockProvider()) {
- DialogAdapter.showDialogOneBtn(CustomerDetailActivity.this, getString(R.string.uninstall_fake_gps),
- getString(R.string.disable_fake_gps), getString(R.string.yes), new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- finish();
- System.exit(0);
- }
- });
- }
- }
- }
- });
- }
- @SuppressLint("MissingPermission")
- private void getCoordinate(final Context act, final String statusTemu, final String prosesFlag) {
- client = LocationServices.getFusedLocationProviderClient(act);
- client.getLastLocation().addOnSuccessListener(new OnSuccessListener<Location>() {
- @SuppressLint("ResourceType")
- @Override
- public void onSuccess(Location location) {
- final String modelCode;
- // GPS location can be null if GPS is switched off
- if (location != null) {
- latitude = String.valueOf(location.getLatitude());
- longitude = String.valueOf(location.getLongitude());
- id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
- .where(DataObject_Table.modelCode.like(first3Char+"%"))
- .and(DataObject_Table.surveyStatus.eq(statusTemu))
- .querySingle();
- SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
- modelCode=dataObject.getModelCode();
- SQLite.update(DataObject.class).set((id.co.acc.www.amos.model.TGprs.DataObject_Table.latitude.eq(latitude))
- , id.co.acc.www.amos.model.TGprs.DataObject_Table.longitude.eq(longitude)
- , id.co.acc.www.amos.model.TGprs.DataObject_Table.processFlag.eq(prosesFlag)
- )
- .where(id.co.acc.www.amos.model.TGprs.DataObject_Table.orderNo.is(dataCustomer.getOrderNo())).execute();
- new UpdateSurveyUtil().updateProcessFlag(dataCustomer.getOrderNo(),prosesFlag, CustomerDetailActivity.this);
- if(statusTemu.matches(GlobalVar.ketemu) && prosesFlag.matches(GlobalVar.activeSurvey))
- {
- new GetCurrentLocation().sendLocation(CustomerDetailActivity.this, latitude, longitude);
- }
- }
- else
- {
- latitude = dataCustomer.getLatitude();
- longitude = dataCustomer.getLongitude();
- id.co.acc.www.amos.model.MModels.DataObject dataObject = SQLite.select().from(id.co.acc.www.amos.model.MModels.DataObject.class)
- .where(DataObject_Table.modelCode.like(first3Char+"%"))
- .and(DataObject_Table.surveyStatus.eq(statusTemu))
- .querySingle();
- SharedPreferenceUtils.setSetting(CustomerDetailActivity.this, "modelCode", dataObject.getModelCode());
- modelCode=dataObject.getModelCode();
- new UpdateSurveyUtil().updateProcessFlag(dataCustomer.getOrderNo(),prosesFlag, CustomerDetailActivity.this);
- }
- Intent intent;
- if(statusTemu.equalsIgnoreCase(GlobalVar.tidakKetemu))
- {
- intent=new Intent(CustomerDetailActivity.this, BatalSurveyActivity.class);
- intent.putExtra("modelCode", modelCode);
- }
- else
- {
- intent=new Intent(CustomerDetailActivity.this, Survey2Activity.class);
- }
- startActivity(intent);
- }
- });
- }
- @Override
- protected void onPause() {
- super.onPause();
- SharedPreferenceUtils.setSetting(getApplicationContext(),"isAplikasiOpen","true");
- AmosApplication.runTimeOutHourglass();
- if(AmosApplication.timeRemain<1l)
- {
- SessionManagement.clearSession(getApplicationContext());
- session.logoutUser();
- }
- }
- @Override
- protected void onResume() {
- super.onResume();
- SharedPreferenceUtils.setSetting(getApplicationContext(),"isAplikasiOpen","true");
- AmosApplication.pauseTimeOutHourglass();
- if(AmosApplication.timeRemain<1l)
- {
- SessionManagement.clearSession(getApplicationContext());
- session.logoutUser();
- }
- new CheckFakeGPS().getCoordinateFakeLocation(this);
- }
- public static void applyCustomFontToDialog(Context context, Dialog dialog) {
- Typeface font = ResourcesCompat.getFont(context, R.font.muli_reguler);
- if (font != null) {
- TextView titleView = dialog.findViewById(android.support.v7.appcompat.R.id.alertTitle);
- TextView messageView = dialog.findViewById(android.R.id.message);
- if (titleView != null) titleView.setTypeface(font, Typeface.BOLD);
- if (messageView != null) messageView.setTypeface(font);
- }
- }
- @Override
- public void onBackPressed() {
- NavUtils.navigateUpFromSameTask(this);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement