aboutsummaryrefslogtreecommitdiff
path: root/Client
diff options
context:
space:
mode:
authorTAMARA JERINIC <tamara.jerinic@gmail.com>2022-12-06 11:15:11 +0100
committerTAMARA JERINIC <tamara.jerinic@gmail.com>2022-12-06 11:15:11 +0100
commit5cef3f0d894034eade424bff5c1fef5fe0c44b39 (patch)
tree50e27d5beeba20e1dd4115a0fd8e2aff984e6ae1 /Client
parent287662ae7ad688229c222d5d81d1c4386faf0e71 (diff)
Omogućen prikaz pratilaca ulogovanog korisnika. Dodate povratne vrednosti funkcijama na back-u.
Diffstat (limited to 'Client')
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityShowFollowersAndFollowing.kt5
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt2
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt48
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowers.kt36
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowing.kt34
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt3
6 files changed, 96 insertions, 32 deletions
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityShowFollowersAndFollowing.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityShowFollowersAndFollowing.kt
index 4cc662e..dbc7299 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityShowFollowersAndFollowing.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityShowFollowersAndFollowing.kt
@@ -22,6 +22,7 @@ class ActivityShowFollowersAndFollowing : AppCompatActivity() {
private lateinit var fragmentContainer:FrameLayout
private lateinit var followersOrFollowing:String
private lateinit var userId:String
+ private lateinit var showMy:String
private lateinit var text:TextView
private lateinit var back: ImageView
@@ -33,6 +34,8 @@ class ActivityShowFollowersAndFollowing : AppCompatActivity() {
if (bundle != null){
userId= bundle.getString("userId").toString().trim()
followersOrFollowing=bundle.get("show").toString().trim()
+ showMy=bundle.get("showMy").toString().trim()
+
}
fragmentContainer=findViewById(R.id.flActivityShowFollowerAndFollowing)
@@ -46,6 +49,7 @@ class ActivityShowFollowersAndFollowing : AppCompatActivity() {
val mFragment = FragmentUserFollowers()
val mBundle = Bundle()
mBundle.putString("userId",userId)
+ mBundle.putString("showMy",showMy)
mFragment.arguments = mBundle
mFragmentTransaction.replace(R.id.flActivityShowFollowerAndFollowing, mFragment).commit()
}
@@ -57,6 +61,7 @@ class ActivityShowFollowersAndFollowing : AppCompatActivity() {
val mFragment = FragmentUserFollowing()
val mBundle = Bundle()
mBundle.putString("userId",userId)
+ mBundle.putString("showMy",showMy)
mFragment.arguments = mBundle
mFragmentTransaction.replace(R.id.flActivityShowFollowerAndFollowing, mFragment).commit()
}
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt
index 61a5db1..d0b86cb 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt
@@ -145,6 +145,7 @@ class ActivityUserProfile : AppCompatActivity() {
val bundle = Bundle()
bundle.putString("userId", userObject._id.toString())
bundle.putString("show","followers")
+ bundle.putString("showMy","no")
val intent = Intent(this@ActivityUserProfile,ActivityShowFollowersAndFollowing::class.java)
intent.putExtras(bundle)
startActivity(intent)
@@ -155,6 +156,7 @@ class ActivityUserProfile : AppCompatActivity() {
val bundle = Bundle()
bundle.putString("userId", userObject._id.toString())
bundle.putString("show","following")
+ bundle.putString("showMy","no")
val intent = Intent(this@ActivityUserProfile,ActivityShowFollowersAndFollowing::class.java)
intent.putExtras(bundle)
startActivity(intent)
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt
index 669b978..6fe4678 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt
@@ -4,6 +4,7 @@ package com.example.brzodolokacije.Fragments
import android.content.Intent
import android.net.Uri
import android.os.Bundle
+import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -15,6 +16,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.bumptech.glide.Glide
+import com.example.brzodolokacije.Activities.ActivityShowFollowersAndFollowing
import com.example.brzodolokacije.Models.UserReceive
import com.example.brzodolokacije.R
import com.example.brzodolokacije.Services.RetrofitHelper
@@ -44,8 +46,8 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr
private lateinit var username: TextView
private lateinit var name: TextView
private lateinit var postsCount: TextView
- private lateinit var followersCount: TextView
- private lateinit var followingCount:TextView
+ private lateinit var followersNumber: TextView
+ private lateinit var followingNumber:TextView
private lateinit var usernameString: String
private lateinit var nameString: String
private lateinit var postsCountString: String
@@ -59,8 +61,6 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr
private lateinit var showFollowers: TextView
private lateinit var showFollowing: TextView
- var userId:String = "1"
-
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -74,8 +74,8 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr
name = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileName) as TextView
username = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileUserName) as TextView
postsCount = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfilePostsNo) as TextView
- followersCount = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileFollowersNo) as TextView
- followingCount = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileFollowNo) as TextView
+ followersNumber = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileFollowersNo) as TextView
+ followingNumber = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileFollowNo) as TextView
showMyPosts=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileShowMyPosts) as Button
showMyData=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileShowMyData) as Button
showMyRecensions=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileShowMyRecensions) as Button
@@ -114,26 +114,22 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr
showFollowers.setOnClickListener {
val bundle = Bundle()
- bundle.putString("userId",userId )
- val fragmentFollowers = FragmentFollowers()
- fragmentFollowers.setArguments(bundle)
-
- fragmentManager
- ?.beginTransaction()
- ?.replace(com.example.brzodolokacije.R.id.flNavigationFragment,fragmentFollowers)
- ?.commit()
+ bundle.putString("userId","error")
+ bundle.putString("show","followers")
+ bundle.putString("showMy","yes")
+ val intent = Intent(activity, ActivityShowFollowersAndFollowing::class.java)
+ intent.putExtras(bundle)
+ startActivity(intent)
}
showFollowing.setOnClickListener {
val bundle = Bundle()
- bundle.putString("userId",userId)
- val fragmentFollowing = FragmentFollowing()
- fragmentFollowing.setArguments(bundle)
-
- fragmentManager
- ?.beginTransaction()
- ?.replace(com.example.brzodolokacije.R.id.flNavigationFragment,fragmentFollowing)
- ?.commit()
+ bundle.putString("userId","error")
+ bundle.putString("show","following")
+ bundle.putString("showMy","yes")
+ val intent = Intent(activity,ActivityShowFollowersAndFollowing::class.java)
+ intent.putExtras(bundle)
+ startActivity(intent)
}
getProfileInfo()
openMyPosts()
@@ -213,11 +209,11 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr
name.setText(user.name)
username.setText("@"+user.username)
postsCount.setText(user.postcount.toString())
+ Log.d("follno",user.followersCount.toString())
+ Log.d("follno","helllllllllllllllllllllppppppppppppppppppppppppppppppp")
+ followersNumber.text=user.followersCount.toString()
+ followingNumber.text=user.followingCount.toString()
- followersCount.setText(user.followersCount.toString())
- followingCount.setText(user.followingCount.toString())
-
- userId=user._id
//Add Profile image
if(user.pfp!=null) {
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowers.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowers.kt
index 09920dc..376517c 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowers.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowers.kt
@@ -24,6 +24,8 @@ class FragmentUserFollowers : Fragment() {
private lateinit var followers:MutableList<UserReceive>
private lateinit var rvFollowers:RecyclerView
private lateinit var userId:String
+ private lateinit var showMy:String
+
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
@@ -33,12 +35,17 @@ class FragmentUserFollowers : Fragment() {
val bundle = arguments
userId = bundle!!.getString("userId").toString()
-
+ showMy = bundle!!.getString("showMy").toString().trim()
rvFollowers=view.findViewById(R.id.rvFragmentUserFollowers)
- getFollowers()
-
+ if(showMy=="yes"){
+ getFollowersWithoutId()
+ }
+ else if(showMy=="no") {
+ getFollowers()
+ }
return view
+
}
fun getFollowers(){
@@ -68,4 +75,27 @@ class FragmentUserFollowers : Fragment() {
}
})
}
+
+ fun getFollowersWithoutId(){
+ val api = RetrofitHelper.getInstance()
+ val token= SharedPreferencesHelper.getValue("jwt", requireActivity())
+ val data=api.getMyFollowers("Bearer "+token)
+
+ data.enqueue(object : Callback<MutableList<UserReceive>> {
+ override fun onResponse(call: Call<MutableList<UserReceive>>, response: Response<MutableList<UserReceive>>) {
+ if (response.body() == null) {
+ return
+ }
+ Log.d("MyFollowers","Successsssssssssssssssssssssssssssss")
+ followers = response.body()!!.toMutableList<UserReceive>()
+ rvFollowers.apply {
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
+ adapter= FollowersAdapter(followers,requireActivity())
+ }
+ }
+ override fun onFailure(call: Call<MutableList<UserReceive>>, t: Throwable) {
+ Log.d("MyFollowers","Faillllllllllllllllllllllllll")
+ }
+ })
+ }
} \ No newline at end of file
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowing.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowing.kt
index 0f6323f..9a78b6e 100644
--- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowing.kt
+++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowing.kt
@@ -23,6 +23,7 @@ class FragmentUserFollowing : Fragment() {
private lateinit var following:MutableList<UserReceive>
private lateinit var rvFollowing: RecyclerView
private lateinit var userId:String
+ private lateinit var showMy:String
override fun onCreateView(
@@ -33,10 +34,15 @@ class FragmentUserFollowing : Fragment() {
var view=inflater.inflate(R.layout.fragment_user_following, container, false)
val bundle = arguments
userId = bundle!!.getString("userId").toString()
+ showMy = bundle!!.getString("showMy").toString().trim()
rvFollowing=view.findViewById(R.id.rvFragmentUserFollowing)
- getFollowing()
-
+ if(showMy=="yes"){
+ getFollowingWithoutId()
+ }
+ else if(showMy=="no") {
+ getFollowing()
+ }
return view
}
@@ -49,7 +55,7 @@ class FragmentUserFollowing : Fragment() {
if (response.body() == null) {
return
}
- Log.d("Following","Sucesssssssssssssssssssssssssssssss")
+ Log.d("Following","Successsssssssssssssssssssssssssssss")
following = response.body()!!.toMutableList<UserReceive>()
rvFollowing.apply {
layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
@@ -62,4 +68,26 @@ class FragmentUserFollowing : Fragment() {
})
}
+ fun getFollowingWithoutId(){
+ val api = RetrofitHelper.getInstance()
+ val token= SharedPreferencesHelper.getValue("jwt", requireActivity())
+ val data=api.getMyFollowings("Bearer "+token)
+ data.enqueue(object : Callback<MutableList<UserReceive>> {
+ override fun onResponse(call: Call<MutableList<UserReceive>>, response: Response<MutableList<UserReceive>>) {
+ if (response.body() == null) {
+ return
+ }
+ Log.d("MyFollowings","Successsssssssssssssssssssssssssssss")
+ following = response.body()!!.toMutableList<UserReceive>()
+ rvFollowing.apply {
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
+ adapter= FollowersAdapter(following,requireActivity())
+ }
+ }
+ override fun onFailure(call: Call<MutableList<UserReceive>>, t: Throwable) {
+ Log.d("MyFollowings","Faillllllllllllllllllllllllll")
+ }
+ })
+ }
+
} \ No newline at end of file
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 7ddf047..19b1bb5 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
@@ -48,8 +48,10 @@ interface IBackendApi {
@Multipart
@POST("/api/user/profile/pfp")
fun setPfp(@Header("Authorization") authHeader:String, @Part image: MultipartBody.Part):Call<ResponseBody>
+
@GET("/api/user/profile")
fun selfProfile(@Header("Authorization") authHeader:String):Call<UserReceive>
+
@GET("/api/user/{username}/profile")
fun getProfile(@Header("Authorization") authHeader:String,@Path("username") username:String):Call<UserReceive>
@@ -109,6 +111,7 @@ interface IBackendApi {
@GET("/api/user/{id}/myFollowers")
fun getMyFollowers(@Header("Authorization") authHeader:String):Call <MutableList<UserReceive>>
+
@GET("/api/Post/favourite/{id}")
fun addRemoveFavourite(@Header("Authorization") authHeader:String,@Path("id") id:String):Call <Boolean>