From c7b5a4b027d05d83c250312cc8ce113928995823 Mon Sep 17 00:00:00 2001 From: TAMARA JERINIC Date: Tue, 22 Nov 2022 09:29:12 +0100 Subject: Dodata navigacija za fragmente followers i following. --- .../brzodolokacije/Fragments/FragmentFollowers.kt | 11 ++++++++++- .../brzodolokacije/Fragments/FragmentFollowing.kt | 11 ++++++++++- .../brzodolokacije/Fragments/FragmentProfile.kt | 22 ++++++++++++++++++---- .../app/src/main/res/layout/fragment_followers.xml | 19 +++++++++++++++---- .../app/src/main/res/layout/fragment_following.xml | 16 +++++++++++++--- 5 files changed, 66 insertions(+), 13 deletions(-) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt index faa5748..f1d9321 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ImageView import android.widget.Toast import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager @@ -26,12 +27,13 @@ class FragmentFollowers : Fragment() { private lateinit var userId:String private lateinit var followers: MutableList private lateinit var followersRv:RecyclerView + private lateinit var btnBack:ImageView override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { val view= inflater.inflate(R.layout.fragment_followers, container, false) - + btnBack=view.findViewById(R.id.btnFragmentFollowersBack) followersRv=view.findViewById(R.id.rvFragmentShowFollowers) val bundle = this.arguments @@ -44,6 +46,13 @@ class FragmentFollowers : Fragment() { getFollowers() + btnBack.setOnClickListener { + val fragmentProfile = FragmentProfile() + fragmentManager?.beginTransaction() + ?.replace(com.example.brzodolokacije.R.id.flNavigationFragment,fragmentProfile) + ?.commit() + } + return view } diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowing.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowing.kt index 7fc56db..b7a40dc 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowing.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowing.kt @@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ImageView import android.widget.Toast import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView @@ -20,6 +21,7 @@ class FragmentFollowing : Fragment() { private lateinit var userId:String private lateinit var following: MutableList private lateinit var followingRv: RecyclerView + private lateinit var back:ImageView override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? @@ -27,7 +29,7 @@ class FragmentFollowing : Fragment() { val view= inflater.inflate(R.layout.fragment_following, container, false) followingRv=view.findViewById(R.id.rvFragmentShowFollowing) - + back=view.findViewById(R.id.btnFragmentFollowingBack) val bundle = this.arguments if (bundle != null) { userId= bundle.getString("userId").toString() @@ -38,6 +40,13 @@ class FragmentFollowing : Fragment() { getFollowing() + back.setOnClickListener { + val fragmentProfile = FragmentProfile() + fragmentManager + ?.beginTransaction() + ?.replace(com.example.brzodolokacije.R.id.flNavigationFragment,fragmentProfile) + ?.commit() + } return view } 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 03cb4fa..7c6d998 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 @@ -57,6 +57,7 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr private lateinit var profilePicture: ImageView private lateinit var profilePicturePlus: MaterialButton private lateinit var showFollowers: TextView + private lateinit var showFollowing: TextView var userId:String = "1" @@ -65,9 +66,9 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { - Toast.makeText( - activity, "MOJ PROFILLLLLLLLLLLLLLL", Toast.LENGTH_LONG - ).show(); +// Toast.makeText( +// activity, "MOJ PROFILLLLLLLLLLLLLLL", Toast.LENGTH_LONG +// ).show(); // Inflate the layout for this fragment val view:View= inflater.inflate(com.example.brzodolokacije.R.layout.fragment_profile, container, false) name = view.findViewById(com.example.brzodolokacije.R.id.tvFragmentProfileName) as TextView @@ -81,6 +82,7 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr profilePicture=view.findViewById(com.example.brzodolokacije.R.id.tvFragmentProfileProfilePicture) as ImageView profilePicturePlus=view.findViewById(com.example.brzodolokacije.R.id.btnFragmentProfileProfilePicturePlus) as MaterialButton showFollowers=view.findViewById(com.example.brzodolokacije.R.id.tvFragmentProfileFollowers) + showFollowing=view.findViewById(com.example.brzodolokacije.R.id.tvFragmentProfileFollow) //podaci iz baze @@ -112,7 +114,7 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr showFollowers.setOnClickListener { val bundle = Bundle() - bundle.putString("userId",userId ) // Put anything what you want + bundle.putString("userId",userId ) val fragmentFollowers = FragmentFollowers() fragmentFollowers.setArguments(bundle) @@ -121,6 +123,18 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr ?.replace(com.example.brzodolokacije.R.id.flNavigationFragment,fragmentFollowers) ?.commit() } + + 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() + } getProfileInfo() openMyPosts() return view diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml index deef1f8..6092e01 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml @@ -9,18 +9,29 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> - + + - + android:textStyle="bold" + /> + + \ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_following.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_following.xml index 81f93a8..424094f 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_following.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_following.xml @@ -9,15 +9,25 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> + + + - +