aboutsummaryrefslogtreecommitdiff
path: root/Client
diff options
context:
space:
mode:
authorJelena Petrovic <jelenapetrovic.7119@gmail.com>2022-12-10 14:46:12 +0100
committerJelena Petrovic <jelenapetrovic.7119@gmail.com>2022-12-10 14:46:12 +0100
commitdba0abdae6432a2877e66c796422cabcca419a06 (patch)
tree53eda38a5ddbe573e2368b80bace3fa380e3ac1c /Client
parentb80761f7b5340841013986b8d5306fe95fcf1d25 (diff)
Refresh tudjeg profila #83
Diffstat (limited to 'Client')
-rw-r--r--Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt39
-rw-r--r--Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml452
2 files changed, 263 insertions, 228 deletions
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 b568d73..31ff8ff 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
@@ -4,16 +4,19 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.util.Log
+import android.view.View
import android.widget.*
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
-import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
+import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener
import com.bumptech.glide.Glide
import com.example.brzodolokacije.Fragments.FragmentUserPostsProfileActivity
import com.example.brzodolokacije.Models.UserReceive
import com.example.brzodolokacije.R
-import com.example.brzodolokacije.R.*
+import com.example.brzodolokacije.R.id
+import com.example.brzodolokacije.R.layout
import com.example.brzodolokacije.Services.RetrofitHelper
import com.example.brzodolokacije.Services.SharedPreferencesHelper
import com.google.gson.Gson
@@ -22,7 +25,8 @@ import retrofit2.Callback
import retrofit2.Response
-class ActivityUserProfile : AppCompatActivity() {
+class ActivityUserProfile : AppCompatActivity(),OnRefreshListener {
+ private lateinit var swipeRefreshLayout: SwipeRefreshLayout
private lateinit var name:TextView
private lateinit var postsNumber:TextView
private lateinit var followersNumber:TextView
@@ -80,8 +84,7 @@ class ActivityUserProfile : AppCompatActivity() {
}
- checkIfAlreadyFollow()
- updateUserData()
+
followUser.setOnClickListener{
val api = RetrofitHelper.getInstance()
@@ -179,6 +182,28 @@ class ActivityUserProfile : AppCompatActivity() {
fm.replace(R.id.flActivityProfileFragmentContainer, fragment)
fm.commit()
}
+
+ swipeRefreshLayout = findViewById<View>(R.id.ProfileSwipeRefresh) as SwipeRefreshLayout
+ swipeRefreshLayout.setOnRefreshListener(this@ActivityUserProfile)
+ swipeRefreshLayout.setColorSchemeResources(
+ R.color.purple_200,
+ R.color.teal_200,
+ R.color.dark_blue_transparent,
+ R.color.purple_700
+ )
+ swipeRefreshLayout.post(kotlinx.coroutines.Runnable {
+ swipeRefreshLayout.isRefreshing=true
+ })
+ }
+
+ override fun onRefresh() {
+ onResume()
+ }
+
+ override fun onResume(){
+ super.onResume()
+ checkIfAlreadyFollow()
+ updateUserData()
}
fun checkIfAlreadyFollow(){
@@ -190,6 +215,7 @@ class ActivityUserProfile : AppCompatActivity() {
override fun onFailure(call: Call<Boolean>, t: Throwable) {;
Log.d("fail","faillllllllllllllllllllllllllllllllllllllllllllllllllllllll")
Log.d("fail",t.toString())
+ swipeRefreshLayout.isRefreshing=false
}
@SuppressLint("ResourceAsColor")
@@ -199,6 +225,7 @@ class ActivityUserProfile : AppCompatActivity() {
return
}
var follow = response.body()!!
+ swipeRefreshLayout.isRefreshing=false
if(follow){
Log.d("success","follow")
@@ -250,12 +277,14 @@ class ActivityUserProfile : AppCompatActivity() {
postsNumber.text=userData.postNumber.toString()
followersNumber.text=userData.followersCount.toString()
followingNumber.text=userData.followingCount.toString()
+ swipeRefreshLayout.isRefreshing=false
}
override fun onFailure(call: Call<UserReceive>, t: Throwable) {
Toast.makeText(
this@ActivityUserProfile, t.toString(), Toast.LENGTH_LONG
).show();
+ swipeRefreshLayout.isRefreshing=false
}
})
}
diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml
index 5c0ceb8..484d2d5 100644
--- a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml
+++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml
@@ -6,254 +6,258 @@
android:layout_height="match_parent"
tools:context=".Activities.ActivityUserProfile">
-
- <androidx.constraintlayout.widget.ConstraintLayout
+ <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:id="@+id/ProfileSwipeRefresh">
- <ImageView
- android:scaleType="centerCrop"
- android:id="@+id/imageView3"
+ <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
- android:layout_height="180dp"
- android:foreground="@drawable/b3"
- android:foregroundGravity="center_vertical|center|center_horizontal|fill"
- android:src="@drawable/b3"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
-
- <com.google.android.material.imageview.ShapeableImageView
-
- android:id="@+id/tvFragmentProfileInfoContainer"
- android:layout_width="0dp"
- android:layout_height="199dp"
- android:layout_marginStart="20dp"
- android:layout_marginTop="90dp"
- android:layout_marginEnd="20dp"
- android:adjustViewBounds="true"
- android:background="#E8FFFFFF"
- android:elevation="1dp"
- android:scaleType="fitEnd"
-
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_bias="0.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="@+id/imageView3"
- app:shapeAppearanceOverlay="@style/imageViewRoundedEdge" />
-
-
- <androidx.cardview.widget.CardView
- android:id="@+id/cvFragmentHomePageProfile"
- android:layout_width="120dp"
- android:layout_height="120dp"
- android:layout_gravity="center"
- android:layout_marginTop="24dp"
- android:elevation="10dp"
- app:cardCornerRadius="250dp"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent">
+ android:layout_height="match_parent">
<ImageView
-
- android:id="@+id/tvActivityProfileProfilePicture"
+ android:scaleType="centerCrop"
+ android:id="@+id/imageView3"
android:layout_width="match_parent"
- android:layout_height="match_parent"
+ android:layout_height="180dp"
+ android:foreground="@drawable/b3"
+ android:foregroundGravity="center_vertical|center|center_horizontal|fill"
+ android:src="@drawable/b3"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
+ <com.google.android.material.imageview.ShapeableImageView
+
+ android:id="@+id/tvFragmentProfileInfoContainer"
+ android:layout_width="0dp"
+ android:layout_height="199dp"
+ android:layout_marginStart="20dp"
+ android:layout_marginTop="90dp"
+ android:layout_marginEnd="20dp"
+ android:adjustViewBounds="true"
+ android:background="#E8FFFFFF"
+ android:elevation="1dp"
+ android:scaleType="fitEnd"
+
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.0"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/imageView3"
+ app:shapeAppearanceOverlay="@style/imageViewRoundedEdge" />
+
+
+ <androidx.cardview.widget.CardView
+ android:id="@+id/cvFragmentHomePageProfile"
+ android:layout_width="120dp"
+ android:layout_height="120dp"
+ android:layout_gravity="center"
+ android:layout_marginTop="24dp"
android:elevation="10dp"
- android:scaleType="centerCrop"
- android:src="@drawable/ic_baseline_person_24"
- tools:ignore="ContentDescription" />
- </androidx.cardview.widget.CardView>
-
- <View
- android:id="@+id/divider"
- android:layout_width="409dp"
- android:layout_height="1dp"
- android:background="?android:attr/listDivider"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/buttons" />
-
- <LinearLayout
- android:id="@+id/buttons"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:weightSum="3"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer">
-
- <Button
- android:layout_weight="1"
- android:id="@+id/btnActivityUserProfileShowPosts"
- android:layout_width="120dp"
- android:layout_height="wrap_content"
- android:backgroundTint="#FFFFFF"
- android:stateListAnimator="@null"
- android:text="Objave"
- android:textColor="@color/cardview_dark_background"
- />
-
- <Button
- android:layout_weight="1"
- android:id="@+id/btnFragmentUserProfileShowData"
- android:layout_width="110dp"
- android:layout_height="wrap_content"
- android:backgroundTint="#FFFFFF"
- android:stateListAnimator="@null"
- android:text="Nalog"
- android:textColor="@color/cardview_dark_background"
- />
-
- <Button
- android:id="@+id/btnFragmentUserProfileShowRecensions"
- android:layout_width="120dp"
- android:layout_height="wrap_content"
- android:backgroundTint="#FFFFFF"
- android:stateListAnimator="@null"
- android:text="Recenzije"
- android:textColor="@color/cardview_dark_background"
- />
- </LinearLayout>
- <FrameLayout
- android:layout_weight="1"
- android:id="@+id/flActivityProfileFragmentContainer"
- android:layout_width="match_parent"
- android:layout_height="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="@+id/divider"
- app:layout_constraintVertical_bias="0.0"></FrameLayout>
-
- <TableLayout
-
- android:layout_width="350dp"
- android:layout_height="140dp"
- android:layout_marginStart="35dp"
- android:layout_marginEnd="35dp"
- android:elevation="1dp"
- android:numColumns="3"
- app:layout_constraintBottom_toBottomOf="@+id/tvFragmentProfileInfoContainer"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="@+id/tvFragmentProfileInfoContainer"
- app:layout_constraintVertical_bias="0.88">
-
- <TableRow
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_column="1"
- >
-
- <TextView
- android:id="@+id/tvActivityUserProfileName"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:layout_gravity="center"
- android:text="Petar Petrović"
- android:textSize="23sp"
- android:textStyle="bold" />
- </TableRow>
+ app:cardCornerRadius="250dp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+ <ImageView
+
+ android:id="@+id/tvActivityProfileProfilePicture"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:elevation="10dp"
+ android:scaleType="centerCrop"
+ android:src="@drawable/ic_baseline_person_24"
+ tools:ignore="ContentDescription" />
+ </androidx.cardview.widget.CardView>
+
+ <View
+ android:id="@+id/divider"
+ android:layout_width="409dp"
+ android:layout_height="1dp"
+ android:background="?android:attr/listDivider"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/buttons" />
- <TableRow
- android:gravity="center"
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_marginTop="5dp">
<LinearLayout
- android:orientation="horizontal"
+ android:id="@+id/buttons"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_width="wrap_content"
android:weightSum="3"
- >
- <TextView
- android:id="@+id/tvFragmentUserProfilePosts"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer">
+
+ <Button
android:layout_weight="1"
- android:backgroundTint="@color/white"
- android:gravity="center"
- android:layout_width="110dp"
+ android:id="@+id/btnActivityUserProfileShowPosts"
+ android:layout_width="120dp"
android:layout_height="wrap_content"
- android:textSize="14sp"
+ android:backgroundTint="#FFFFFF"
android:stateListAnimator="@null"
- android:text="OBJAVE"
-
- android:textColor="#757471" />
+ android:text="Objave"
+ android:textColor="@color/cardview_dark_background"
+ />
<Button
- android:id="@+id/tvActivityUserProfileFollowers"
- android:layout_width="110dp"
- android:layout_height="27dp"
- android:layout_margin="0dp"
- android:backgroundTint="@color/white"
- android:clickable="true"
android:layout_weight="1"
- android:gravity="center"
- android:padding="0dp"
+ android:id="@+id/btnFragmentUserProfileShowData"
+ android:layout_width="110dp"
+ android:layout_height="wrap_content"
+ android:backgroundTint="#FFFFFF"
android:stateListAnimator="@null"
- android:text="PRATIOCI"
- android:textColor="#757471"
- android:textSize="14sp"
- tools:ignore="TouchTargetSizeCheck" />
+ android:text="Nalog"
+ android:textColor="@color/cardview_dark_background"
+ />
<Button
- android:textSize="14sp"
- android:id="@+id/tvActivityUserProfileFollow"
- android:layout_width="110dp"
- android:layout_height="27dp"
- android:layout_margin="0dp"
- android:backgroundTint="@color/white"
- android:clickable="true"
- android:layout_weight="1"
- android:gravity="center"
- android:padding="0dp"
+ android:id="@+id/btnFragmentUserProfileShowRecensions"
+ android:layout_width="120dp"
+ android:layout_height="wrap_content"
+ android:backgroundTint="#FFFFFF"
android:stateListAnimator="@null"
- android:text="PRAĆENJA"
- android:textColor="#757471"
- tools:ignore="TouchTargetSizeCheck" />
+ android:text="Recenzije"
+ android:textColor="@color/cardview_dark_background"
+ />
</LinearLayout>
+ <FrameLayout
+ android:layout_weight="1"
+ android:id="@+id/flActivityProfileFragmentContainer"
+ android:layout_width="match_parent"
+ android:layout_height="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="@+id/divider"
+ app:layout_constraintVertical_bias="0.0"></FrameLayout>
+
+ <TableLayout
+
+ android:layout_width="350dp"
+ android:layout_height="140dp"
+ android:layout_marginStart="35dp"
+ android:layout_marginEnd="35dp"
+ android:elevation="1dp"
+ android:numColumns="3"
+ app:layout_constraintBottom_toBottomOf="@+id/tvFragmentProfileInfoContainer"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="@+id/tvFragmentProfileInfoContainer"
+ app:layout_constraintVertical_bias="0.88">
+
+ <TableRow
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_column="1"
+ >
- </TableRow>
-
- <TableRow
- android:layout_marginLeft="10dp"
- android:layout_marginRight="10dp"
- android:layout_gravity="center"
- android:layout_height="wrap_content">
- <LinearLayout>
- <TextView
- android:id="@+id/tvActivityUserProfilePostsNo"
- android:layout_width="110dp"
- android:layout_height="wrap_content"
- android:gravity="center"
- android:text="156"
-
- android:textSize="20dp"
- android:textStyle="bold" />
+ <TextView
+ android:id="@+id/tvActivityUserProfileName"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:text="Petar Petrović"
+ android:textSize="23sp"
+ android:textStyle="bold" />
+ </TableRow>
- <TextView
- android:layout_width="110dp"
- android:layout_height="wrap_content"
- android:id="@+id/tvActivityUserProfileFollowersNo"
- android:gravity="center"
- android:text="50"
- android:textSize="20dp"
- android:textStyle="bold" />
- <TextView
- android:id="@+id/tvActivityUserProfileFollowNo"
- android:layout_width="110dp"
- android:layout_height="wrap_content"
+ <TableRow
android:gravity="center"
- android:text="40"
- android:textSize="20dp"
- android:textStyle="bold" />
- </LinearLayout>
- </TableRow>
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:layout_marginTop="5dp">
+ <LinearLayout
+ android:orientation="horizontal"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:weightSum="3"
+ >
+ <TextView
+ android:id="@+id/tvFragmentUserProfilePosts"
+ android:layout_weight="1"
+ android:backgroundTint="@color/white"
+ android:gravity="center"
+ android:layout_width="110dp"
+ android:layout_height="wrap_content"
+ android:textSize="14sp"
+ android:stateListAnimator="@null"
+ android:text="OBJAVE"
+
+ android:textColor="#757471" />
+
+ <Button
+ android:id="@+id/tvActivityUserProfileFollowers"
+ android:layout_width="110dp"
+ android:layout_height="27dp"
+ android:layout_margin="0dp"
+ android:backgroundTint="@color/white"
+ android:clickable="true"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:padding="0dp"
+ android:stateListAnimator="@null"
+ android:text="PRATIOCI"
+ android:textColor="#757471"
+ android:textSize="14sp"
+ tools:ignore="TouchTargetSizeCheck" />
+
+ <Button
+ android:textSize="14sp"
+ android:id="@+id/tvActivityUserProfileFollow"
+ android:layout_width="110dp"
+ android:layout_height="27dp"
+ android:layout_margin="0dp"
+ android:backgroundTint="@color/white"
+ android:clickable="true"
+ android:layout_weight="1"
+ android:gravity="center"
+ android:padding="0dp"
+ android:stateListAnimator="@null"
+ android:text="PRAĆENJA"
+ android:textColor="#757471"
+ tools:ignore="TouchTargetSizeCheck" />
+ </LinearLayout>
+
+ </TableRow>
+
+ <TableRow
+ android:layout_marginLeft="10dp"
+ android:layout_marginRight="10dp"
+ android:layout_gravity="center"
+ android:layout_height="wrap_content">
+ <LinearLayout>
+ <TextView
+ android:id="@+id/tvActivityUserProfilePostsNo"
+ android:layout_width="110dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="156"
+
+ android:textSize="20dp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:layout_width="110dp"
+ android:layout_height="wrap_content"
+ android:id="@+id/tvActivityUserProfileFollowersNo"
+ android:gravity="center"
+ android:text="50"
+ android:textSize="20dp"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/tvActivityUserProfileFollowNo"
+ android:layout_width="110dp"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:text="40"
+ android:textSize="20dp"
+ android:textStyle="bold" />
+ </LinearLayout>
+ </TableRow>
@@ -319,9 +323,11 @@
tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" />
</androidx.constraintlayout.widget.ConstraintLayout>
- </TableLayout>
+ </TableLayout>
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
+ </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
- </androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout> \ No newline at end of file