Created
April 24, 2019 07:50
-
-
Save Cuncis/48b9904076d9081b317de38db4fe122a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.bpr.bpr.view.Beranda.pengajuan_pinjaman; | |
import android.Manifest; | |
import android.app.Activity; | |
import android.app.DatePickerDialog; | |
import android.content.DialogInterface; | |
import android.content.Intent; | |
import android.content.pm.PackageManager; | |
import android.database.Cursor; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapFactory; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.net.Uri; | |
import android.os.Build; | |
import android.provider.MediaStore; | |
import android.support.annotation.NonNull; | |
import android.support.v7.app.AlertDialog; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.support.v7.widget.Toolbar; | |
import android.view.LayoutInflater; | |
import android.view.View; | |
import android.widget.ArrayAdapter; | |
import android.widget.Button; | |
import android.widget.DatePicker; | |
import android.widget.EditText; | |
import android.widget.ImageButton; | |
import android.widget.ImageView; | |
import android.widget.LinearLayout; | |
import android.widget.RadioGroup; | |
import android.widget.TextView; | |
import android.widget.Toast; | |
import com.example.bpr.bpr.R; | |
import com.example.bpr.bpr.data.local.DBHelper; | |
import com.example.bpr.bpr.data.model.Kecamatan; | |
import com.example.bpr.bpr.data.model.Kelurahan; | |
import com.example.bpr.bpr.data.model.Kota; | |
import com.example.bpr.bpr.data.model.Provinsi; | |
import com.example.bpr.bpr.utils.Utils; | |
import java.io.FileNotFoundException; | |
import java.io.InputStream; | |
import java.util.Calendar; | |
import java.util.List; | |
public class BPKB extends AppCompatActivity { | |
ImageView imgKtp, imgKk, imgBpkb, imgPajakStnk, imgKendaraanDepan, imgKendaraanSamping, imgKendaraanBelakang; | |
ImageButton btnNext, btnNext2; | |
Button btnProsesSekarang; | |
RadioGroup rgKategori, rgAtasNama, rgTenorKredit; | |
LinearLayout linear1, linear2, linear3; | |
EditText etTglLahir, etJenisKelamin, etStatus; | |
EditText etProvinsi, etKota, etKecamatan, etKelurahan, etProvinsi2, etKota2; | |
EditText etAddCurrentLocation; | |
Calendar c; | |
DatePickerDialog datePickerDialog; | |
private static final int REQUEST_MAP_LOCATION = 2; | |
DBHelper dbHelper; | |
String sesi; | |
private static int RESULT_LOAD_IMAGE = 1; | |
private static final int CAMERA_REQUEST = 1888; | |
public static final int MY_CAMERA_PERMISSION_CODE = 100; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_bpkb); | |
Toolbar toolbar = findViewById(R.id.toolbar); | |
setSupportActionBar(toolbar); | |
initView(); | |
dbHelper = new DBHelper(this); | |
getDate(); | |
getProvinsi(); | |
initListener(); | |
setTitle("PENGAJUAN BPKB"); | |
} | |
private void getStatus() { | |
final CharSequence[] statusItem = {"Belum Menikah", "Menikah"}; | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setCancelable(false); | |
builder.setItems(statusItem, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
switch (which) { | |
case 0: | |
etStatus.setText(statusItem[0]); | |
break; | |
case 1: | |
etStatus.setText(statusItem[1]); | |
break; | |
} | |
} | |
}).create().show(); | |
} | |
private void getJenisKelamin() { | |
final CharSequence[] statusItem = {"Laki-laki", "Perempuan"}; | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setCancelable(false); | |
builder.setItems(statusItem, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
switch (which) { | |
case 0: | |
etJenisKelamin.setText(statusItem[0]); | |
break; | |
case 1: | |
etJenisKelamin.setText(statusItem[1]); | |
break; | |
} | |
} | |
}).create().show(); | |
} | |
@Override | |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |
if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) { | |
Bitmap photo = (Bitmap) data.getExtras().get("data"); | |
setImage(photo); | |
} else if (requestCode == RESULT_LOAD_IMAGE && resultCode == RESULT_OK && null != data) { | |
Uri imageUri = data.getData(); | |
try { | |
final InputStream imageStream = getContentResolver().openInputStream(imageUri); | |
final Bitmap selectedImage = BitmapFactory.decodeStream(imageStream); | |
setImage(selectedImage); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
Toast.makeText(BPKB.this, "Something went wrong", Toast.LENGTH_LONG).show(); | |
} | |
} else if (requestCode == REQUEST_MAP_LOCATION && resultCode == Activity.RESULT_OK) { | |
String address = "null"; | |
if (data != null) { | |
address = data.getStringExtra("KEY_ADDRESS"); | |
} | |
etAddCurrentLocation.setText(address); | |
} | |
} | |
private void setImage(Bitmap photo) { | |
switch (sesi) { | |
case "ktp": | |
imgKtp.setImageBitmap(photo); | |
break; | |
case "kk": | |
imgKk.setImageBitmap(photo); | |
break; | |
case "bpkb": | |
imgBpkb.setImageBitmap(photo); | |
break; | |
case "pajakstnk": | |
imgPajakStnk.setImageBitmap(photo); | |
break; | |
case "kendaraandepan": | |
imgKendaraanDepan.setImageBitmap(photo); | |
break; | |
case "kendaraansamping": | |
imgKendaraanSamping.setImageBitmap(photo); | |
break; | |
case "kendaraanbelakang": | |
imgKendaraanBelakang.setImageBitmap(photo); | |
break; | |
} | |
} | |
@Override | |
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
if (requestCode == MY_CAMERA_PERMISSION_CODE) { | |
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
Toast.makeText(this, "Camera permission granted", Toast.LENGTH_SHORT).show(); | |
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
startActivityForResult(cameraIntent, CAMERA_REQUEST); | |
} else { | |
Toast.makeText(this, "Camera permission denied", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
} | |
@Override | |
public void onBackPressed() { | |
if (linear1.getVisibility() == View.VISIBLE) { | |
finish(); | |
} else if (linear2.getVisibility() == View.VISIBLE) { | |
linear1.setVisibility(View.VISIBLE); | |
linear2.setVisibility(View.GONE); | |
linear3.setVisibility(View.GONE); | |
} else if (linear3.getVisibility() == View.VISIBLE) { | |
linear1.setVisibility(View.GONE); | |
linear2.setVisibility(View.VISIBLE); | |
linear3.setVisibility(View.GONE); | |
} | |
} | |
private void dialogPhoto() { | |
final CharSequence[] dialogItem = {"Camera", "Gallery"}; | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setItems(dialogItem, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
switch (which) { | |
case 0: | |
Toast.makeText(BPKB.this, "Camera", Toast.LENGTH_SHORT).show(); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |
if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { | |
requestPermissions(new String[]{Manifest.permission.CAMERA}, MY_CAMERA_PERMISSION_CODE); | |
} | |
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
startActivityForResult(cameraIntent, CAMERA_REQUEST); | |
} else { | |
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
startActivityForResult(cameraIntent, CAMERA_REQUEST); | |
} | |
break; | |
case 1: | |
Toast.makeText(BPKB.this, "Gallery", Toast.LENGTH_SHORT).show(); | |
Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); | |
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE); | |
break; | |
} | |
} | |
}); | |
builder.create().show(); | |
} | |
private void getKelurahan(final String idKecamatan) { | |
dbHelper.getKelurahan(idKecamatan); | |
etKelurahan.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (idKecamatan.equals(String.valueOf(0))) { | |
Toast.makeText(BPKB.this, "Kecamatan harus diisi", Toast.LENGTH_SHORT).show(); | |
etKecamatan.setError("Kecamatan harus diisi"); | |
} else { | |
dialogKelurahan(idKecamatan); | |
} | |
} | |
}); | |
} | |
private void dialogKelurahan(String id) { | |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle("Pilih Kelurahan"); | |
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); | |
final List<Kelurahan> kelurahan = dbHelper.getKelurahan(id); | |
for (int i = 0; i < kelurahan.size(); i++) { | |
arrayAdapter.add(kelurahan.get(i).getNama_kelurahan()); | |
} | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
String strName = arrayAdapter.getItem(which); | |
AlertDialog.Builder builderInner = new AlertDialog.Builder(BPKB.this); | |
builderInner.setMessage(strName); | |
etKelurahan.setText(strName); | |
} | |
}); | |
builder.show(); | |
} | |
private void getKecamatan(final String idKota) { | |
dbHelper.getKecamatan(idKota); | |
etKecamatan.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (idKota.equals(String.valueOf(0))) { | |
Toast.makeText(BPKB.this, "Kota harus diisi", Toast.LENGTH_SHORT).show(); | |
etKota2.setError("Kota harus diisi"); | |
} else { | |
etKecamatan.setError(null); | |
dialogKecamatan(idKota); | |
} | |
} | |
}); | |
} | |
private void dialogKecamatan(String id) { | |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle("Pilih Kecamatan"); | |
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); | |
final List<Kecamatan> kecamatan = dbHelper.getKecamatan(id); | |
for (int i = 0; i < kecamatan.size(); i++) { | |
arrayAdapter.add(kecamatan.get(i).getNama_kecamatan()); | |
} | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
String strName = arrayAdapter.getItem(which); | |
AlertDialog.Builder builderInner = new AlertDialog.Builder(BPKB.this); | |
builderInner.setMessage(strName); | |
etKecamatan.setText(strName); | |
getKelurahan(kecamatan.get(which).getId()); | |
etKelurahan.setText(""); | |
} | |
}); | |
builder.show(); | |
} | |
private void getKota(final String idProvinsi) { | |
dbHelper.getKota(idProvinsi); | |
etKota.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (idProvinsi.equals(String.valueOf(0))) { | |
Toast.makeText(BPKB.this, "Provinsi harus diisi", Toast.LENGTH_SHORT).show(); | |
etProvinsi.setError("Provinsi harus diisi"); | |
} else { | |
dialogKota(idProvinsi); | |
} | |
} | |
}); | |
} | |
private void getKota2(final String idProvinsi) { | |
dbHelper.getKota(idProvinsi); | |
etKota2.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (idProvinsi.equals(String.valueOf(0))) { | |
Toast.makeText(BPKB.this, "Provinsi harus diisi", Toast.LENGTH_SHORT).show(); | |
etProvinsi2.setError("Provinsi harus diisi"); | |
} else { | |
etKota2.setError(null); | |
dialogKota2(idProvinsi); | |
} | |
} | |
}); | |
} | |
private void dialogKota2(String id) { | |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle("Pilih Kota"); | |
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); | |
final List<Kota> kota = dbHelper.getKota(id); | |
for (int i = 0; i < kota.size(); i++) { | |
arrayAdapter.add(kota.get(i).getNama_kota()); | |
} | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
String strName = arrayAdapter.getItem(which); | |
AlertDialog.Builder builderInner = new AlertDialog.Builder(BPKB.this); | |
builderInner.setMessage(strName); | |
etKota2.setText(strName); | |
getKecamatan(kota.get(which).getId()); | |
etKecamatan.setText(""); | |
etKelurahan.setText(""); | |
} | |
}); | |
builder.show(); | |
} | |
private void dialogKota(String id) { | |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle("Pilih Kota"); | |
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); | |
final List<Kota> kota = dbHelper.getKota(id); | |
for (int i = 0; i < kota.size(); i++) { | |
arrayAdapter.add(kota.get(i).getNama_kota()); | |
} | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
String strName = arrayAdapter.getItem(which); | |
AlertDialog.Builder builderInner = new AlertDialog.Builder(BPKB.this); | |
builderInner.setMessage(strName); | |
etKota.setText(strName); | |
} | |
}); | |
builder.show(); | |
} | |
private void getProvinsi() { | |
dbHelper.getProvinsi(); | |
getKota(String.valueOf(0)); | |
getKota2(String.valueOf(0)); | |
getKecamatan(String.valueOf(0)); | |
getKelurahan(String.valueOf(0)); | |
etProvinsi.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogProvinsi(); | |
etProvinsi.setError(null); | |
} | |
}); | |
etProvinsi2.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogProvinsi2(); | |
etProvinsi2.setError(null); | |
} | |
}); | |
} | |
private void dialogProvinsi2() { | |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle("Pilih Provinsi"); | |
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); | |
final List<Provinsi> provinsi = dbHelper.getProvinsi(); | |
for (int i = 0; i < provinsi.size(); i++) { | |
arrayAdapter.add(provinsi.get(i).getName_provinsi()); | |
} | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
String strName = arrayAdapter.getItem(which); | |
AlertDialog.Builder builderInner = new AlertDialog.Builder(BPKB.this); | |
builderInner.setMessage(strName); | |
etProvinsi2.setText(strName); | |
etKota2.setText(""); | |
etKecamatan.setText(""); | |
etKelurahan.setText(""); | |
getKota2(provinsi.get(which).getId()); | |
} | |
}); | |
builder.show(); | |
} | |
private void dialogProvinsi() { | |
final AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
builder.setTitle("Pilih Provinsi"); | |
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(this, android.R.layout.select_dialog_singlechoice); | |
final List<Provinsi> provinsi = dbHelper.getProvinsi(); | |
for (int i = 0; i < provinsi.size(); i++) { | |
arrayAdapter.add(provinsi.get(i).getName_provinsi()); | |
} | |
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
dialog.dismiss(); | |
} | |
}); | |
builder.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int which) { | |
String strName = arrayAdapter.getItem(which); | |
AlertDialog.Builder builderInner = new AlertDialog.Builder(BPKB.this); | |
builderInner.setMessage(strName); | |
etProvinsi.setText(strName); | |
etKota.setText(""); | |
getKota(provinsi.get(which).getId()); | |
} | |
}); | |
builder.show(); | |
} | |
private void dialogSuccess() { | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
LayoutInflater layoutInflater = getLayoutInflater(); | |
View view = layoutInflater.inflate(R.layout.dialog_success, null); | |
LinearLayout linear1 = view.findViewById(R.id.linear1); | |
TextView tvTitleDialog = view.findViewById(R.id.tv_titleDialog); | |
builder.setView(view); | |
builder.setCancelable(true); | |
tvTitleDialog.setText("Kami telah menerima Permintaan Pinjaman Dana BPKB Anda. Terima Kasih"); | |
linear1.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
finish(); | |
} | |
}); | |
builder.setOnCancelListener(new DialogInterface.OnCancelListener() { | |
@Override | |
public void onCancel(DialogInterface dialog) { | |
finish(); | |
} | |
}); | |
builder.show(); | |
} | |
private void getDate() { | |
etTglLahir.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View view) { | |
c = Calendar.getInstance(); | |
final int year = c.get(Calendar.YEAR); | |
final int month = c.get(Calendar.MONTH); | |
final int day = c.get(Calendar.DAY_OF_MONTH); | |
datePickerDialog = new DatePickerDialog(BPKB.this, new DatePickerDialog.OnDateSetListener() { | |
@Override | |
public void onDateSet(DatePicker datePicker, int mYear, int mMonth, int mDay) { | |
String date = mYear + "-" + (mMonth + 1) + "-" + mDay; | |
etTglLahir.setText(Utils.getDateEvent(date)); | |
} | |
}, year, month, day); | |
datePickerDialog.show(); | |
} | |
}); | |
} | |
private void initListener() { | |
etStatus.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
getStatus(); | |
} | |
}); | |
etJenisKelamin.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
getJenisKelamin(); | |
} | |
}); | |
rgKategori.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | |
@Override | |
public void onCheckedChanged(RadioGroup group, int checkedId) { | |
if (checkedId == R.id.rb_mobil) { | |
Toast.makeText(BPKB.this, "Mobil", Toast.LENGTH_SHORT).show(); | |
} else if (checkedId == R.id.rb_motor) { | |
Toast.makeText(BPKB.this, "Motor", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
rgAtasNama.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | |
@Override | |
public void onCheckedChanged(RadioGroup group, int checkedId) { | |
if (checkedId == R.id.rb_ya) { | |
Toast.makeText(BPKB.this, "Ya", Toast.LENGTH_SHORT).show(); | |
} else if (checkedId == R.id.rb_tidak) { | |
Toast.makeText(BPKB.this, "Tidak", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
rgTenorKredit.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { | |
@Override | |
public void onCheckedChanged(RadioGroup group, int checkedId) { | |
if (checkedId == R.id.rb_satu) { | |
Toast.makeText(BPKB.this, "Satu", Toast.LENGTH_SHORT).show(); | |
} else if (checkedId == R.id.rb_satuSet) { | |
Toast.makeText(BPKB.this, "Satu Setengah", Toast.LENGTH_SHORT).show(); | |
} else if (checkedId == R.id.rb_dua) { | |
Toast.makeText(BPKB.this, "Dua", Toast.LENGTH_SHORT).show(); | |
} else if (checkedId == R.id.rb_tiga) { | |
Toast.makeText(BPKB.this, "Tiga", Toast.LENGTH_SHORT).show(); | |
} else if (checkedId == R.id.rb_empat) { | |
Toast.makeText(BPKB.this, "Empat", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
}); | |
btnNext.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (etProvinsi.getText().toString().length() < 1) { | |
Toast.makeText(BPKB.this, "Provinsi harus diisi", Toast.LENGTH_SHORT).show(); | |
etProvinsi.setError("Provinsi harus diisi"); | |
} else { | |
linear1.setVisibility(View.GONE); | |
linear2.setVisibility(View.VISIBLE); | |
linear3.setVisibility(View.GONE); | |
} | |
} | |
}); | |
btnNext2.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
if (etProvinsi2.getText().toString().length() < 1) { | |
Toast.makeText(BPKB.this, "Provinsi harus diisi", Toast.LENGTH_SHORT).show(); | |
etProvinsi2.setError("Provinsi harus diisi"); | |
} else { | |
linear1.setVisibility(View.GONE); | |
linear2.setVisibility(View.GONE); | |
linear3.setVisibility(View.VISIBLE); | |
} | |
} | |
}); | |
imgKtp.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "ktp"; | |
} | |
}); | |
imgKk.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "kk"; | |
} | |
}); | |
imgBpkb.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "bpkb"; | |
} | |
}); | |
imgPajakStnk.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "pajakstnk"; | |
} | |
}); | |
imgKendaraanDepan.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "kendaraandepan"; | |
} | |
}); | |
imgKendaraanSamping.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "kendaraansamping"; | |
} | |
}); | |
imgKendaraanBelakang.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
dialogPhoto(); | |
sesi = "kendaraanbelakang"; | |
} | |
}); | |
etAddCurrentLocation.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
Intent i = new Intent(BPKB.this, Maps.class); | |
startActivityForResult(i, REQUEST_MAP_LOCATION); | |
} | |
}); | |
btnProsesSekarang.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
hasImage(imgKtp); | |
} | |
}); | |
} | |
private void hasImage(ImageView imageView) { | |
Drawable drawable = imageView.getDrawable(); | |
boolean hasImage = (drawable != null); | |
if (hasImage && (drawable instanceof BitmapDrawable)) { | |
// hasImage = ((BitmapDrawable)drawable).getBitmap() != null; | |
Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show(); | |
dialogSuccess(); | |
} else { | |
Toast.makeText(BPKB.this, "Mohon Foto KTP Harus dilengkapi", Toast.LENGTH_SHORT).show(); | |
} | |
} | |
private void initView() { | |
btnProsesSekarang = findViewById(R.id.btn_prosesSekarang); | |
btnNext = findViewById(R.id.btn_next); | |
btnNext2 = findViewById(R.id.btn_next2); | |
rgKategori = findViewById(R.id.radioGroup); | |
rgAtasNama = findViewById(R.id.radioGroup1); | |
rgTenorKredit = findViewById(R.id.radioGroup2); | |
linear1 = findViewById(R.id.linear1); | |
linear2 = findViewById(R.id.linear2); | |
linear3 = findViewById(R.id.linear3); | |
etTglLahir = findViewById(R.id.et_tglLahir); | |
etJenisKelamin = findViewById(R.id.et_jenisKelamin); | |
etStatus = findViewById(R.id.et_status); | |
etProvinsi = findViewById(R.id.et_provinsi); | |
etKota = findViewById(R.id.et_kota); | |
etKecamatan = findViewById(R.id.et_kecamatan); | |
etKelurahan = findViewById(R.id.et_kelurahan); | |
etProvinsi2 = findViewById(R.id.et_provinsi2); | |
etKota2 = findViewById(R.id.et_kota2); | |
etAddCurrentLocation = findViewById(R.id.et_addCurrentLocation); | |
imgKtp = findViewById(R.id.img_gambarKtp); | |
imgKk = findViewById(R.id.img_gambarKk); | |
imgBpkb = findViewById(R.id.img_gambarBpkb); | |
imgPajakStnk = findViewById(R.id.img_pajakStnk); | |
imgKendaraanDepan = findViewById(R.id.img_kendaraanDepan); | |
imgKendaraanSamping = findViewById(R.id.img_kendaraanSamping); | |
imgKendaraanBelakang = findViewById(R.id.img_kendaraanBelakang); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment