@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_CANCELED) { if (requestCode == REQUEST_CODE_LOCATION) { startLocation(); } } }
@Override public void onResume() { super.onResume(); // GTM String usuario_id; if (PortoSeguroAutoApp.loginAuto.isLogged()) { usuario_id = PortoSeguroAutoApp.loginAuto.getCliente().getNumeroCpfCnpj(); } else { usuario_id = ""; } setGTMAppView("Sinistro/Centro de atendimento rápido", usuario_id); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); codigoTipoEstabelecimento = getIntent().getExtras().getInt(Extras.CODIGO_TIPO_ESTABELECIMENTO); textViewHeaderWhiteLabel = (TextView) findViewById(R.id.text_view_header_white_label); textViewHeaderWhiteLabel.setText(R.string.label_location_service_bebefits); linearLayoutList = (LinearLayout) findViewById(R.id.linear_layout_list); // Location Layout LinearLayout linearLayoutLocation = InflaterUtil.inflateRowDoubleLineImageProgress( this, R.drawable.icone_my_location, "Sua localização atual.", "Carregando...", new View.OnClickListener() { @Override public void onClick(View v) { if (PortoSeguroAutoApp.myLocation.hasValidCoordinates()) { Intent intent = new Intent( LocationServiceBenefitsActivity.this, EstablishmentListActivity.class); intent.putExtra(Extras.ENDERECO, PortoSeguroAutoApp.myLocation); intent.putExtra(Extras.CODIGO_TIPO_ESTABELECIMENTO, codigoTipoEstabelecimento); startActivityForResult(intent, REQUEST_CODE_SERVICE_BENEFITIS_ESTABLISHMENT_LIST); } } }); progressBarLocation = (ProgressBar) linearLayoutLocation.findViewById(R.id.progress_bar_list_row_loading); imageViewLocation = (ImageView) linearLayoutLocation.findViewById(R.id.image_view_icone_list_row); textViewLocation = (TextView) linearLayoutLocation.findViewById(R.id.text_view_label_list_row); linearLayoutList.addView(linearLayoutLocation); InflaterUtil.inflateRowParagraph( this, linearLayoutList, "Se prefirir, busque de outra forma:", true, null, false); InflaterUtil.inflateRowSeparator(this, linearLayoutList, R.color.blue_dark_light_bg); InflaterUtil.inflateRowLine(this, linearLayoutList, R.color.blue_light_line); InflaterUtil.inflateRowHome( this, linearLayoutList, R.drawable.icone_find_by_name, "Digitar um endereço", false, new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(LocationServiceBenefitsActivity.this, OtherAddressActivity.class); intent.putExtra( Extras.FLOW_ACTIVITY, OtherAddressActivity.FLOW_ACTIVITY_SERVICES_BENEFITS); intent.putExtra(Extras.CODIGO_TIPO_ESTABELECIMENTO, codigoTipoEstabelecimento); startActivityForResult(intent, REQUEST_CODE_OTHER_ADDRESS); } }); InflaterUtil.inflateRowHome( this, linearLayoutList, R.drawable.icone_find_by_location, "Cidade", false, new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent( LocationServiceBenefitsActivity.this, EstablishmentFindByStateCityActivity.class); intent.putExtra( Extras.TYPE_SELECT_STATE_CITY, EstablishmentFindByStateCityActivity.SELECT_UF); intent.putExtra(Extras.CODIGO_TIPO_ESTABELECIMENTO, codigoTipoEstabelecimento); intent.putExtra(Extras.REQUEST_CODE, REQUEST_CODE_SERVICE_BENEFITIS_CITY); startActivityForResult(intent, REQUEST_CODE_ESTABLISHMENT); } }); // LOC SERVISE locationService = new LocationService(this) { @Override public void onLocationBetterChanged(Location location) { PortoSeguroAutoApp.myLocation.setLocation(location); updateLocationFromGps(); } @Override public void onLocationStarted() {} @Override public void erroOnLocation(String message) { // TODO GPS progressBarLocation.setVisibility(View.GONE); AlertUtil alertUtil = new AlertUtil( LocationServiceBenefitsActivity.this, getString(R.string.label_alert), getString(R.string.msg_erro_gps_location), getString(R.string.label_close)); alertUtil.showAlert(); } @Override public void onProviderDisabled() { progressBarLocation.setVisibility(View.GONE); } }; startLocation(); }