Skip to content
Snippets Groups Projects
Commit 67ff580f authored by yansans's avatar yansans
Browse files

style: progress bar when upload scan

parent daaf3746
2 merge requests!13Release,!11proper save for gmail
...@@ -103,6 +103,7 @@ class ScannerFragment : Fragment() { ...@@ -103,6 +103,7 @@ class ScannerFragment : Fragment() {
} }
uploadPhoto(tempFile) uploadPhoto(tempFile)
} catch (e: Exception) { } catch (e: Exception) {
Log.e("ImageInput", "Image Input Failed:", e) Log.e("ImageInput", "Image Input Failed:", e)
} }
...@@ -219,6 +220,9 @@ class ScannerFragment : Fragment() { ...@@ -219,6 +220,9 @@ class ScannerFragment : Fragment() {
private fun uploadPhoto(photo: File) { private fun uploadPhoto(photo: File) {
try { try {
val progressBar = binding.loading
progressBar.visibility = View.VISIBLE
val requestFile = photo.asRequestBody("image/*".toMediaTypeOrNull()) val requestFile = photo.asRequestBody("image/*".toMediaTypeOrNull())
val requestBody = MultipartBody.Part.createFormData("file", photo.name, requestFile) val requestBody = MultipartBody.Part.createFormData("file", photo.name, requestFile)
val apiCall = apiClient.getApiService(requireContext()).getBill(requestBody) val apiCall = apiClient.getApiService(requireContext()).getBill(requestBody)
...@@ -227,6 +231,8 @@ class ScannerFragment : Fragment() { ...@@ -227,6 +231,8 @@ class ScannerFragment : Fragment() {
call: Call<BillResponse>, response: Response<BillResponse> call: Call<BillResponse>, response: Response<BillResponse>
) { ) {
if (response.isSuccessful) { if (response.isSuccessful) {
progressBar.visibility = View.GONE
val billResponse = val billResponse =
response.body() ?: throw Exception("Bill Response is Empty") response.body() ?: throw Exception("Bill Response is Empty")
Log.d("BillUpload", "Server Response: $billResponse") Log.d("BillUpload", "Server Response: $billResponse")
......
...@@ -47,4 +47,17 @@ ...@@ -47,4 +47,17 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/capture_button" /> app:layout_constraintTop_toBottomOf="@id/capture_button" />
<ProgressBar
android:id="@+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/upload_button"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="@+id/upload_button"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.775" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment