aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Backend/Api/Api/Controllers/PostController.cs2
-rw-r--r--Client/BrzoDoLokacije/app/build.gradle3
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt33
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt3
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Services/MyAppGlideModule.kt7
5 files changed, 17 insertions, 31 deletions
diff --git a/Backend/Api/Api/Controllers/PostController.cs b/Backend/Api/Api/Controllers/PostController.cs
index 27823bc..3857ce0 100644
--- a/Backend/Api/Api/Controllers/PostController.cs
+++ b/Backend/Api/Api/Controllers/PostController.cs
@@ -58,7 +58,7 @@ namespace Api.Controllers
}
[HttpGet("image/{id}")]
- [Authorize(Roles = "User")]
+ //[Authorize(Roles = "User")]
public async Task<ActionResult> getImage(string id)
{
Models.File f =await _fileService.getById(id);
diff --git a/Client/BrzoDoLokacije/app/build.gradle b/Client/BrzoDoLokacije/app/build.gradle
index fa85692..72f1f0d 100644
--- a/Client/BrzoDoLokacije/app/build.gradle
+++ b/Client/BrzoDoLokacije/app/build.gradle
@@ -56,4 +56,7 @@ dependencies {
//JWT
implementation 'com.auth0.android:jwtdecode:2.0.1'
+ //Glide
+ implementation 'com.github.bumptech.glide:glide:4.12.0'
+ annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
} \ No newline at end of file
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt
index 134b665..bbcf9e4 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt
@@ -9,6 +9,7 @@ import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
+import com.bumptech.glide.Glide
import com.example.brzodolokacije.Activities.ActivitySinglePost
import com.example.brzodolokacije.Interfaces.IBackendApi
import com.example.brzodolokacije.Models.LocationType
@@ -61,33 +62,11 @@ class ShowPostsAdapter (val activity:Activity,val items : MutableList<PostPrevie
tvTitle.text = item.location.name
tvLocationParent.text = item.location.country
tvLocationType.text = "TODO"
-
- val request=imageApi.getImage("Bearer "+token,item.images[0]._id)
-
- request.enqueue(object : retrofit2.Callback<ResponseBody?> {
- override fun onResponse(call: Call<ResponseBody?>, response: Response<ResponseBody?>) {
- if (response.isSuccessful) {
- val image: ResponseBody = response.body()!!
- binding.locationImage.setImageBitmap(BitmapFactory.decodeStream(image.byteStream()))
- Toast.makeText(
- activity, "prosao zahtev", Toast.LENGTH_LONG
- ).show()
- } else {
- if (response.errorBody() != null)
- Toast.makeText(
- activity,
- response.errorBody()!!.string(),
- Toast.LENGTH_LONG
- ).show();
- }
- }
-
- override fun onFailure(call: Call<ResponseBody?>, t: Throwable) {
- Toast.makeText(
- activity, t.toString(), Toast.LENGTH_LONG
- ).show();
- }
- })
+ if(item.images.isNotEmpty()) {
+ Glide.with(activity)
+ .load(RetrofitHelper.baseUrl + "/api/post/image/" + item.images[0]._id)
+ .into(locationImage)
+ }
}
}
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt
index 49dda46..131233c 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt
@@ -22,9 +22,6 @@ interface IBackendApi {
fun resetpass(@Body obj:ResetPass):Call<ResponseBody>
@GET("/api/post")
fun getPosts(@Header("Authorization") authHeader:String):Call<MutableList<PostPreview>>
- @Streaming
- @GET("/api/post/image/{id}")
- fun getImage(@Header("Authorization") authHeader:String,@Path("id") obj:String):Call<ResponseBody>
//@POST("putanja")
//fun add(@Body obj:Post,@Header("Authorization") authHeader:String):Call<Post>
} \ No newline at end of file
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Services/MyAppGlideModule.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Services/MyAppGlideModule.kt
new file mode 100644
index 0000000..95171cb
--- /dev/null
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Services/MyAppGlideModule.kt
@@ -0,0 +1,7 @@
+package com.example.brzodolokacije.Services
+
+import com.bumptech.glide.module.AppGlideModule
+
+class MyAppGlideModule: AppGlideModule() {
+
+} \ No newline at end of file