-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5738fc1
commit 2784ce5
Showing
8 changed files
with
187 additions
and
141 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/example/autocapture/RecyclerAdapter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.example.autocapture | ||
|
||
import android.graphics.BitmapFactory | ||
import android.util.Base64 | ||
import android.util.Log | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
|
||
class RecyclerAdapter(var users: MutableList<ImageResponseItem>) : | ||
RecyclerView.Adapter<MyHolder>() { | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, position: Int): MyHolder { | ||
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_row, parent, false) | ||
return MyHolder(view) | ||
} | ||
|
||
override fun getItemCount(): Int { | ||
return users.size | ||
} | ||
|
||
override fun onBindViewHolder(myHolder: MyHolder, position: Int) { | ||
val user = users.get(position) | ||
myHolder.name.text = user.date | ||
|
||
// val decodedByteArray: ByteArray = Base64.decode(user, Base64.DEFAULT) | ||
val decodedByteArray: ByteArray = Base64.decode(user.image, Base64.DEFAULT) | ||
|
||
val decodedBitmap = | ||
BitmapFactory.decodeByteArray(decodedByteArray, 0, decodedByteArray.size) | ||
|
||
myHolder.image.setImageBitmap(decodedBitmap) | ||
|
||
Log.d("MYTAG", "onBindViewHolder: " + user) | ||
} | ||
} | ||
|
||
class MyHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { | ||
val name = itemView.findViewById<TextView>(R.id.tvText) | ||
val image = itemView.findViewById<ImageView>(R.id.ivImage) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
package com.example.autocapture | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import retrofit2.Call | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
|
||
import retrofit2.http.POST | ||
|
||
|
||
interface RetrofitApi { | ||
|
||
@POST("uploadImage") | ||
fun uploadImage(@Body dataModal: DataModal): Call<String?>? | ||
fun uploadImage(@Body dataModal: DataModal): Call<UploadResponse> | ||
|
||
@GET("GetImages") | ||
fun fetchImage():Call<ImageResponse> | ||
} | ||
|
||
class DataModal { | ||
var image: String? = null | ||
var date: String? = null | ||
fun fetchImage(): Call<ImageResponse> | ||
} | ||
|
||
class DataModal internal constructor( | ||
val image: String, | ||
val date: String | ||
) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.example.autocapture | ||
|
||
data class UploadResponse( | ||
val `data`: Any, | ||
val message: String, | ||
val status: Int | ||
) |
Oops, something went wrong.