aboutsummaryrefslogtreecommitdiff
path: root/Client
diff options
context:
space:
mode:
Diffstat (limited to 'Client')
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowers.kt71
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserFollowing.kt65
-rw-r--r--Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_followers.xml46
-rw-r--r--Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_following.xml46
4 files changed, 214 insertions, 14 deletions
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 376517c..fe2dce3 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
@@ -1,30 +1,37 @@
package com.example.brzodolokacije.Fragments
import android.os.Bundle
+import android.text.Editable
+import android.text.TextWatcher
import android.util.Log
-import androidx.fragment.app.Fragment
+import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.AutoCompleteTextView
+import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.brzodolokacije.Adapters.FollowersAdapter
-import com.example.brzodolokacije.Adapters.ShowPostsHomePageAdapter
-import com.example.brzodolokacije.Models.PostPreview
import com.example.brzodolokacije.Models.UserReceive
import com.example.brzodolokacije.R
import com.example.brzodolokacije.Services.RetrofitHelper
import com.example.brzodolokacije.Services.SharedPreferencesHelper
+import com.google.android.material.button.MaterialButton
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
+
class FragmentUserFollowers : Fragment() {
private lateinit var followers:MutableList<UserReceive>
+ private lateinit var searchedFollowers:MutableList<UserReceive>
private lateinit var rvFollowers:RecyclerView
private lateinit var userId:String
private lateinit var showMy:String
+ private lateinit var searchBar:AutoCompleteTextView
+ private lateinit var searchButton:MaterialButton
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
@@ -37,6 +44,8 @@ class FragmentUserFollowers : Fragment() {
userId = bundle!!.getString("userId").toString()
showMy = bundle!!.getString("showMy").toString().trim()
rvFollowers=view.findViewById(R.id.rvFragmentUserFollowers)
+ searchBar=view.findViewById(R.id.FragmentFollowersSearchBar)
+ searchButton=view.findViewById(R.id.FragmentFollowersSearchBButton)
if(showMy=="yes"){
getFollowersWithoutId()
@@ -44,9 +53,61 @@ class FragmentUserFollowers : Fragment() {
else if(showMy=="no") {
getFollowers()
}
+ searchButton.setOnClickListener {
+ searchText()
+ }
+ searchBar.setOnKeyListener(View.OnKeyListener { v1, keyCode, event -> // If the event is a key-down event on the "enter" button
+ if (event.action === KeyEvent.ACTION_DOWN &&
+ keyCode == KeyEvent.KEYCODE_ENTER
+ ) {
+ // Perform action on key press
+ searchText()
+ return@OnKeyListener true
+ }
+ false
+ })
+
+ searchBar.addTextChangedListener(object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+ searchText()
+ if(count==0)
+ if(showMy=="yes"){
+ getFollowersWithoutId()
+ }
+ else if(showMy=="no") {
+ getFollowers()
+ }
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ }
+ })
return view
}
+ fun searchText(){
+ if(searchBar.text==null || searchBar.text.isNullOrEmpty() || searchBar.text.toString().trim()=="")
+ return
+ var text=searchBar.text.toString().trim()
+ searchedFollowers= mutableListOf()
+ for(user in followers){
+ if(user.username.contains(text))
+ searchedFollowers.add(user)
+ }
+ rvFollowers.apply {
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.VERTICAL,false)
+ adapter= FollowersAdapter(searchedFollowers,requireActivity())
+
+ }
+
+
+
+
+ }
+
fun getFollowers(){
val api = RetrofitHelper.getInstance()
@@ -64,7 +125,7 @@ class FragmentUserFollowers : Fragment() {
}
followers = response.body()!!.toMutableList<UserReceive>()
rvFollowers.apply {
- layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.VERTICAL,false)
adapter= FollowersAdapter(followers,requireActivity())
}
@@ -89,7 +150,7 @@ class FragmentUserFollowers : Fragment() {
Log.d("MyFollowers","Successsssssssssssssssssssssssssssss")
followers = response.body()!!.toMutableList<UserReceive>()
rvFollowers.apply {
- layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.VERTICAL,false)
adapter= FollowersAdapter(followers,requireActivity())
}
}
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 9a78b6e..2406da8 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
@@ -1,11 +1,15 @@
package com.example.brzodolokacije.Fragments
import android.os.Bundle
+import android.text.Editable
+import android.text.TextWatcher
import android.util.Log
+import android.view.KeyEvent
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.AutoCompleteTextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.brzodolokacije.Adapters.FollowersAdapter
@@ -13,6 +17,7 @@ import com.example.brzodolokacije.Models.UserReceive
import com.example.brzodolokacije.R
import com.example.brzodolokacije.Services.RetrofitHelper
import com.example.brzodolokacije.Services.SharedPreferencesHelper
+import com.google.android.material.button.MaterialButton
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@@ -21,9 +26,12 @@ import retrofit2.Response
class FragmentUserFollowing : Fragment() {
private lateinit var following:MutableList<UserReceive>
+ private lateinit var searchedFollowing:MutableList<UserReceive>
private lateinit var rvFollowing: RecyclerView
private lateinit var userId:String
private lateinit var showMy:String
+ private lateinit var searchBar: AutoCompleteTextView
+ private lateinit var searchButton: MaterialButton
override fun onCreateView(
@@ -36,15 +44,66 @@ class FragmentUserFollowing : Fragment() {
userId = bundle!!.getString("userId").toString()
showMy = bundle!!.getString("showMy").toString().trim()
rvFollowing=view.findViewById(R.id.rvFragmentUserFollowing)
-
+ searchBar=view.findViewById(R.id.FragmentFollowingSearchBar)
+ searchButton=view.findViewById(R.id.FragmentFollowingSearchBButton)
if(showMy=="yes"){
getFollowingWithoutId()
}
else if(showMy=="no") {
getFollowing()
}
+ searchButton.setOnClickListener {
+ searchText()
+ }
+ searchBar.setOnKeyListener(View.OnKeyListener { v1, keyCode, event -> // If the event is a key-down event on the "enter" button
+ if (event.action === KeyEvent.ACTION_DOWN &&
+ keyCode == KeyEvent.KEYCODE_ENTER
+ ) {
+ // Perform action on key press
+ searchText()
+ return@OnKeyListener true
+ }
+ false
+ })
+ searchBar.addTextChangedListener(object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+ }
+
+ override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+ searchText()
+ if(count==0)
+ if(showMy=="yes"){
+ getFollowingWithoutId()
+ }
+ else if(showMy=="no") {
+ getFollowing()
+ }
+ }
+
+ override fun afterTextChanged(s: Editable) {
+ }
+ })
return view
}
+ fun searchText(){
+ if(searchBar.text==null || searchBar.text.isNullOrEmpty() || searchBar.text.toString().trim()=="")
+ return
+ var text=searchBar.text.toString().trim()
+ searchedFollowing= mutableListOf()
+ for(user in following){
+ if(user.username.contains(text))
+ searchedFollowing.add(user)
+ }
+ rvFollowing.apply {
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.VERTICAL,false)
+ adapter= FollowersAdapter(searchedFollowing,requireActivity())
+
+ }
+
+
+
+
+ }
fun getFollowing(){
val api = RetrofitHelper.getInstance()
@@ -58,7 +117,7 @@ class FragmentUserFollowing : Fragment() {
Log.d("Following","Successsssssssssssssssssssssssssssss")
following = response.body()!!.toMutableList<UserReceive>()
rvFollowing.apply {
- layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.VERTICAL,false)
adapter= FollowersAdapter(following,requireActivity())
}
}
@@ -80,7 +139,7 @@ class FragmentUserFollowing : Fragment() {
Log.d("MyFollowings","Successsssssssssssssssssssssssssssss")
following = response.body()!!.toMutableList<UserReceive>()
rvFollowing.apply {
- layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false)
+ layoutManager= LinearLayoutManager(activity, LinearLayoutManager.VERTICAL,false)
adapter= FollowersAdapter(following,requireActivity())
}
}
diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_followers.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_followers.xml
index 8b820bc..579e402 100644
--- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_followers.xml
+++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_followers.xml
@@ -1,18 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Fragments.FragmentUserFollowers">
<!-- TODO: Update blank fragment layout -->
<TextView
+ android:id="@+id/textView17"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <androidx.cardview.widget.CardView
+ android:id="@+id/FragmentBrowseCardViewSearch"
+ android:layout_width="0dp"
+ android:layout_height="40dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:elevation="10dp"
+ app:cardCornerRadius="20dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+
+ <AutoCompleteTextView
+ android:id="@+id/FragmentFollowersSearchBar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:backgroundTint="@color/white"
+ android:hint=" Pretraga"
+ android:inputType="textPersonName"
+ android:paddingLeft="15dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/FragmentFollowersSearchBButton"
+ android:layout_width="49dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="right"
+ android:background="#00FFFFFF"
+ app:backgroundTint="#00FFFFFF"
+ app:cornerRadius="16dp"
+ app:icon="@drawable/ic_baseline_search_24"
+ app:iconTint="#333D70" />
+
+ </androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvFragmentUserFollowers"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="wrap_content"
+ android:layout_marginTop="15dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/FragmentBrowseCardViewSearch" />
-</FrameLayout> \ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_following.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_following.xml
index 7558375..f7c07df 100644
--- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_following.xml
+++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_user_following.xml
@@ -1,18 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Fragments.FragmentUserFollowing">
<!-- TODO: Update blank fragment layout -->
<TextView
+ android:id="@+id/textView16"
android:layout_width="match_parent"
android:layout_height="match_parent" />
+ <androidx.cardview.widget.CardView
+ android:id="@+id/FragmentBrowseCardViewSearch"
+ android:layout_width="0dp"
+ android:layout_height="40dp"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:elevation="10dp"
+ app:cardCornerRadius="20dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+
+ <AutoCompleteTextView
+ android:id="@+id/FragmentFollowingSearchBar"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:backgroundTint="@color/white"
+ android:hint=" Pretraga"
+ android:inputType="textPersonName"
+ android:paddingLeft="15dp" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/FragmentFollowingSearchBButton"
+ android:layout_width="49dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="right"
+ android:background="#00FFFFFF"
+ app:backgroundTint="#00FFFFFF"
+ app:cornerRadius="16dp"
+ app:icon="@drawable/ic_baseline_search_24"
+ app:iconTint="#333D70" />
+
+ </androidx.cardview.widget.CardView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvFragmentUserFollowing"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="wrap_content"
+ android:layout_marginTop="15dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/FragmentBrowseCardViewSearch" />
-</FrameLayout> \ No newline at end of file
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file