diff --git a/app/src/main/java/id/co/kredibel/MainActivity.java b/app/src/main/java/id/co/kredibel/MainActivity.java index 13b1ba8..63a6cf0 100644 --- a/app/src/main/java/id/co/kredibel/MainActivity.java +++ b/app/src/main/java/id/co/kredibel/MainActivity.java @@ -4,12 +4,14 @@ import android.net.Uri; import android.os.Bundle; import android.util.Log; +import android.view.View; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import io.kredibel.picker.Picker; import io.kredibel.picker.PickerListener; +import io.kredibel.picker.PickerObserver; import java.io.File; @@ -24,24 +26,20 @@ protected void onCreate(Bundle savedInstanceState) { ImageView imgResult = findViewById(R.id.imgResult); TextView txtPath = findViewById(R.id.txtPath); - findViewById(R.id.btnCamera).setOnClickListener(view -> picker.pickCamera(new PickerListener() { + PickerListener pickerListener = new PickerListener() { @Override public void onPicked(Uri uri, File file, Bitmap bitmap) { imgResult.setImageURI(uri); txtPath.setText(file.getAbsolutePath()+"(" + (file.exists()) + ")"); - Log.d("CEK", "CEK-EXIST: Bitmap|Camera: " + (bitmap != null)); - Log.d("CEK", "CEK-EXIST: File|Camera: " + (file.exists()) + "|" + file.getAbsolutePath()); + //Log.d("CEK", "CEK-EXIST: Bitmap|Camera: " + (bitmap != null)); + //Log.d("CEK", "CEK-EXIST: File|Camera: " + (file.exists()) + "|" + file.getAbsolutePath()); } - })); + }; - findViewById(R.id.btnGalery).setOnClickListener(view -> picker.pickGallery(new PickerListener() { - @Override - public void onPicked(Uri uri, File file, Bitmap bitmap) { - imgResult.setImageURI(uri); - txtPath.setText(file.getAbsolutePath()+"(" + (file.exists()) + ")"); - Log.d("CEK", "CEK-EXIST: Bitmap|Gallery: " + (bitmap != null)); - Log.d("CEK", "CEK-EXIST: File|Gallery: " + (file.exists())+ "|" + file.getAbsolutePath()); - } - })); + findViewById(R.id.btnChoose).setOnClickListener(view -> picker.pickImage(pickerListener)); + + findViewById(R.id.btnCamera).setOnClickListener(view -> picker.pickCamera(pickerListener)); + + findViewById(R.id.btnGalery).setOnClickListener(view -> picker.pickGallery(pickerListener)); } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index c117b09..a06ccf5 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -15,7 +15,7 @@ android:layout_centerHorizontal="true"/>