diff options
author | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-10 15:16:51 +0100 |
---|---|---|
committer | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-10 15:16:51 +0100 |
commit | 3e3bb454481318b1efe0068760394fe177a61245 (patch) | |
tree | 1a32723c08cc3c564b1bd9fe3aff4498f64bd1ec /Client | |
parent | dba0abdae6432a2877e66c796422cabcca419a06 (diff) |
Refresh objave, prikaz objava korisnika odmah nakon otvaranja strane profila #83
Diffstat (limited to 'Client')
3 files changed, 271 insertions, 235 deletions
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt index 623b670..c2f5d12 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt @@ -18,6 +18,8 @@ import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.PagerSnapHelper import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.SnapHelper +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener import com.auth0.android.jwt.JWT import com.example.brzodolokacije.Adapters.CommentsAdapter import com.example.brzodolokacije.Adapters.PostImageAdapter @@ -41,7 +43,8 @@ import retrofit2.Call import retrofit2.Response -class ActivitySinglePost : AppCompatActivity() { +class ActivitySinglePost : AppCompatActivity(),OnRefreshListener { + private lateinit var swipeRefreshLayout: SwipeRefreshLayout private lateinit var binding: ActivitySinglePostBinding private var layoutManagerImages: RecyclerView.LayoutManager? = null private var layoutManagerComments: RecyclerView.LayoutManager? = null @@ -102,21 +105,13 @@ class ActivitySinglePost : AppCompatActivity() { recyclerViewImages?.layoutManager = layoutManagerImages recyclerViewImages?.adapter = adapterImages - loadTextComponents() - var fm: FragmentTransaction =supportFragmentManager.beginTransaction() - val fragment = FragmentSinglePostDescription() - val b = Bundle() - b.putString("post", Gson().toJson(post)) - fragment.arguments = b - fm.replace(R.id.flSinglePostFragmentContainer, fragment) - fm.commit() + setUpFirstFragment() favouriteImage=binding.ivFavourite tagLayout = binding.llTags - loadTags() - loadFavourite() + // set recyclerView attributes @@ -185,8 +180,39 @@ class ActivitySinglePost : AppCompatActivity() { fm.commit() } + swipeRefreshLayout = binding.PostSwipeRefresh + swipeRefreshLayout.setOnRefreshListener(this@ActivitySinglePost) + swipeRefreshLayout.setColorSchemeResources( + R.color.purple_200, + R.color.teal_200, + R.color.dark_blue_transparent, + R.color.purple_700 + ) + } + fun setUpFirstFragment(){ + var fm: FragmentTransaction =supportFragmentManager.beginTransaction() + val fragment = FragmentSinglePostDescription() + val b = Bundle() + b.putString("post", Gson().toJson(post)) + fragment.arguments = b + fm.replace(R.id.flSinglePostFragmentContainer, fragment) + fm.commit() + } + + override fun onRefresh(){ + onResume() } + + override fun onResume(){ + super.onResume() + loadTextComponents() + loadTags() + loadFavourite() + setUpFirstFragment() + swipeRefreshLayout.isRefreshing=false + } + fun loadTags(){ 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 31ff8ff..f7761ce 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 @@ -174,13 +174,7 @@ class ActivityUserProfile : AppCompatActivity(),OnRefreshListener { showUserPosts.setOnClickListener { - var fm: FragmentTransaction =supportFragmentManager.beginTransaction() - val fragment = FragmentUserPostsProfileActivity() - val b = Bundle() - b.putString("userId", userObject._id.toString()) - fragment.arguments = b - fm.replace(R.id.flActivityProfileFragmentContainer, fragment) - fm.commit() + showUserPostsFragment() } swipeRefreshLayout = findViewById<View>(R.id.ProfileSwipeRefresh) as SwipeRefreshLayout @@ -204,6 +198,17 @@ class ActivityUserProfile : AppCompatActivity(),OnRefreshListener { super.onResume() checkIfAlreadyFollow() updateUserData() + showUserPostsFragment() + } + fun showUserPostsFragment(){ + var fm: FragmentTransaction =supportFragmentManager.beginTransaction() + val fragment = FragmentUserPostsProfileActivity() + val b = Bundle() + b.putString("userId", userObject._id.toString()) + fragment.arguments = b + fm.replace(R.id.flActivityProfileFragmentContainer, fragment) + fm.commit() + swipeRefreshLayout.isRefreshing=false } fun checkIfAlreadyFollow(){ diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml index 4924a1f..ca57739 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml @@ -1,253 +1,258 @@ <?xml version="1.0" encoding="utf-8"?> - -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" + tools:context=".Activities.ActivitySinglePost" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - tools:context=".Activities.ActivitySinglePost"> - - <androidx.recyclerview.widget.RecyclerView - android:id="@+id/rvMain" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_margin="0dp" - android:paddingBottom="@dimen/component_padding" - app:layout_constraintBottom_toTopOf="@+id/linearLayout2" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.0" /> + android:id="@+id/PostSwipeRefresh"> <androidx.constraintlayout.widget.ConstraintLayout - android:id="@+id/linearLayout2" android:layout_width="match_parent" - android:textSize="15dp" - android:layout_height="330dp" - android:background="@drawable/view_top_corner_radius" - android:elevation="30dp" - android:paddingHorizontal="16dp" - android:paddingTop="16dp" - android:paddingBottom="0dp" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" - app:layout_constraintStart_toStartOf="parent" - tools:backgroundTint="@color/white"> - - - <TextView - android:id="@+id/tvTitle" - style="@style/title" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="24dp" - android:gravity="top|start" - android:padding="@dimen/text_padding" - android:text="Naslov" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + android:layout_height="match_parent" + android:orientation="vertical"> - <ImageView - android:id="@+id/imageView12" - android:layout_width="30dp" - android:layout_height="30dp" - android:src="@drawable/ic_baseline_location_on_24" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> - - <TextView - android:id="@+id/tvLocationParent" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:gravity="top|start" - android:padding="@dimen/text_padding" - android:textSize="15dp" - android:text="Drzava, grad" - app:layout_constraintStart_toEndOf="@+id/imageView12" - app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> - - <TextView - android:id="@+id/tvLocationType" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:gravity="top|start" - android:padding="@dimen/text_padding" - android:text="Tip lokacije" + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/rvMain" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_margin="0dp" + android:paddingBottom="@dimen/component_padding" + app:layout_constraintBottom_toTopOf="@+id/linearLayout2" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> - - <TextView - android:id="@+id/tvUser" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="4dp" - android:clickable="true" - android:gravity="top|start" - android:padding="@dimen/text_padding" - android:text="User" - android:textSize="20dp" - android:textStyle="bold" - android:textColor="#FF03DAC5" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvLocationType" /> - - <TextView - android:id="@+id/tvDatePosted" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:gravity="top|start" - android:padding="@dimen/text_padding" - android:text="Timestamp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvLocationType" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" /> - <LinearLayout - android:id="@+id/llTags" + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/linearLayout2" android:layout_width="match_parent" - android:layout_height="20dp" - android:orientation="horizontal" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvUser"></LinearLayout> - - <ImageView - android:id="@+id/ivFavourite" - android:layout_width="30dp" - android:layout_height="30dp" - android:clickable="true" - android:layout_marginRight="5dp" - android:src="@drawable/ic_baseline_favorite_border_24" - app:layout_constraintBottom_toBottomOf="@+id/tvRating" - app:layout_constraintEnd_toStartOf="@+id/tvRating" - app:layout_constraintTop_toTopOf="@+id/tvRating" /> - - <TextView - android:id="@+id/tvRating" android:textSize="15dp" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="24dp" - android:layout_marginEnd="4dp" - android:padding="@dimen/text_padding" - android:text="4.2" - android:textStyle="bold" - app:layout_constraintEnd_toStartOf="@+id/tvNumberOfRatings" - app:layout_constraintTop_toTopOf="parent" /> - - <TextView - android:id="@+id/tvNumberOfRatings" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="24dp" - android:padding="@dimen/text_padding" - android:textSize="15dp" - android:text="(10,500)" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - <ImageView - android:id="@+id/activitySinglePostChangeHeightUp" - android:layout_width="100dp" - android:layout_height="30dp" - android:clickable="true" - android:src="@drawable/ic_round_keyboard_arrow_up_24" - android:text="Button" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - <ImageView - android:id="@+id/activitySinglePostChangeHeightDown" - android:layout_width="100dp" - android:layout_height="30dp" - android:clickable="true" - android:src="@drawable/ic_round_keyboard_arrow_down_24" - android:text="Button" + android:layout_height="330dp" + android:background="@drawable/view_top_corner_radius" + android:elevation="30dp" + android:paddingHorizontal="16dp" + android:paddingTop="16dp" + android:paddingBottom="0dp" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + tools:backgroundTint="@color/white"> - <androidx.cardview.widget.CardView - android:id="@+id/MapDialogueMapView" - android:layout_width="match_parent" - android:layout_height="150dp" - android:layout_marginTop="8dp" - app:cardCornerRadius="10dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/llTags"> - <org.osmdroid.views.MapView - android:id="@+id/MapDialogueMap" - android:layout_width="match_parent" - android:layout_height="match_parent" /> + <TextView + android:id="@+id/tvTitle" + style="@style/title" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:gravity="top|start" + android:padding="@dimen/text_padding" + android:text="Naslov" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> - </androidx.cardview.widget.CardView> + <ImageView + android:id="@+id/imageView12" + android:layout_width="30dp" + android:layout_height="30dp" + android:src="@drawable/ic_baseline_location_on_24" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> - <androidx.constraintlayout.widget.ConstraintLayout - android:id="@+id/singlePostDetail" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_marginTop="8dp" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/MapDialogueMapView"> + <TextView + android:id="@+id/tvLocationParent" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="top|start" + android:padding="@dimen/text_padding" + android:textSize="15dp" + android:text="Drzava, grad" + app:layout_constraintStart_toEndOf="@+id/imageView12" + app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> - <Button - android:id="@+id/btnActivitySinglePostDescription" - android:layout_width="150dp" + <TextView + android:id="@+id/tvLocationType" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:layout_marginBottom="8dp" - android:backgroundTint="#FFFFFF" - android:stateListAnimator="@null" - android:text="opis" - android:textColor="@color/cardview_dark_background" + android:layout_marginEnd="16dp" + android:gravity="top|start" + android:padding="@dimen/text_padding" + android:text="Tip lokacije" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> + + <TextView + android:id="@+id/tvUser" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:clickable="true" + android:gravity="top|start" + android:padding="@dimen/text_padding" + android:text="User" + android:textSize="20dp" + android:textStyle="bold" + android:textColor="#FF03DAC5" app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvLocationType" /> + + <TextView + android:id="@+id/tvDatePosted" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:gravity="top|start" + android:padding="@dimen/text_padding" + android:text="Timestamp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvLocationType" /> + + <LinearLayout + android:id="@+id/llTags" + android:layout_width="match_parent" + android:layout_height="20dp" + android:orientation="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvUser"></LinearLayout> + + <ImageView + android:id="@+id/ivFavourite" + android:layout_width="30dp" + android:layout_height="30dp" + android:clickable="true" + android:layout_marginRight="5dp" + android:src="@drawable/ic_baseline_favorite_border_24" + app:layout_constraintBottom_toBottomOf="@+id/tvRating" + app:layout_constraintEnd_toStartOf="@+id/tvRating" + app:layout_constraintTop_toTopOf="@+id/tvRating" /> + + <TextView + android:id="@+id/tvRating" + android:textSize="15dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="24dp" + android:layout_marginEnd="4dp" + android:padding="@dimen/text_padding" + android:text="4.2" + android:textStyle="bold" + app:layout_constraintEnd_toStartOf="@+id/tvNumberOfRatings" app:layout_constraintTop_toTopOf="parent" /> - <Button - android:id="@+id/btnActivitySinglePostComments" - android:layout_width="150dp" + <TextView + android:id="@+id/tvNumberOfRatings" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="8dp" - android:layout_marginEnd="8dp" - android:layout_marginBottom="8dp" - android:backgroundTint="#FFFFFF" - android:stateListAnimator="@null" - android:text="Komentari" - android:textColor="@color/cardview_dark_background" + android:layout_marginTop="24dp" + android:padding="@dimen/text_padding" + android:textSize="15dp" + android:text="(10,500)" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> - <FrameLayout - android:id="@+id/flSinglePostFragmentContainer" + <ImageView + android:id="@+id/activitySinglePostChangeHeightUp" + android:layout_width="100dp" + android:layout_height="30dp" + android:clickable="true" + android:src="@drawable/ic_round_keyboard_arrow_up_24" + android:text="Button" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <ImageView + android:id="@+id/activitySinglePostChangeHeightDown" + android:layout_width="100dp" + android:layout_height="30dp" + android:clickable="true" + android:src="@drawable/ic_round_keyboard_arrow_down_24" + android:text="Button" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <androidx.cardview.widget.CardView + android:id="@+id/MapDialogueMapView" android:layout_width="match_parent" - android:layout_height="0dp" - android:paddingHorizontal="16dp" - app:layout_constraintBottom_toBottomOf="parent" + android:layout_height="150dp" + android:layout_marginTop="8dp" + app:cardCornerRadius="10dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/divider5" - app:layout_constraintVertical_bias="1.0"></FrameLayout> - - <View - android:id="@+id/divider5" - android:layout_width="376dp" - android:layout_height="1dp" - android:background="?android:attr/listDivider" - android:elevation="10dp" + app:layout_constraintTop_toBottomOf="@+id/llTags"> + + <org.osmdroid.views.MapView + android:id="@+id/MapDialogueMap" + android:layout_width="match_parent" + android:layout_height="match_parent" /> + + </androidx.cardview.widget.CardView> + + <androidx.constraintlayout.widget.ConstraintLayout + android:id="@+id/singlePostDetail" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginTop="8dp" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/btnActivitySinglePostDescription" /> + app:layout_constraintTop_toBottomOf="@+id/MapDialogueMapView"> + + <Button + android:id="@+id/btnActivitySinglePostDescription" + android:layout_width="150dp" + android:layout_height="wrap_content" + android:layout_marginStart="8dp" + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="opis" + android:textColor="@color/cardview_dark_background" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <Button + android:id="@+id/btnActivitySinglePostComments" + android:layout_width="150dp" + android:layout_height="wrap_content" + android:layout_marginTop="8dp" + android:layout_marginEnd="8dp" + android:layout_marginBottom="8dp" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="Komentari" + android:textColor="@color/cardview_dark_background" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <FrameLayout + android:id="@+id/flSinglePostFragmentContainer" + android:layout_width="match_parent" + android:layout_height="0dp" + android:paddingHorizontal="16dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/divider5" + app:layout_constraintVertical_bias="1.0"></FrameLayout> + + <View + android:id="@+id/divider5" + android:layout_width="376dp" + android:layout_height="1dp" + android:background="?android:attr/listDivider" + android:elevation="10dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/btnActivitySinglePostDescription" /> + </androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout> - </androidx.constraintlayout.widget.ConstraintLayout> -</androidx.constraintlayout.widget.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> +</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |