diff options
-rw-r--r-- | Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt | 32 | ||||
-rw-r--r-- | Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml | 555 |
2 files changed, 310 insertions, 277 deletions
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 a9858e2..73ed1fa 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 @@ -15,6 +15,8 @@ import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment 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.Activities.ActivityShowFollowersAndFollowing import com.example.brzodolokacije.Models.UserReceive @@ -41,7 +43,9 @@ private const val ARG_PARAM2 = "param2" * Use the [FragmentProfile.newInstance] factory method to * create an instance of this fragment. */ -class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_profile) { +class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_profile),OnRefreshListener { + private lateinit var swipeRefreshLayout: SwipeRefreshLayout + // TODO: Rename and change types of parameters private lateinit var username: TextView private lateinit var name: TextView @@ -132,8 +136,17 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr intent.putExtras(bundle) startActivity(intent) } - getProfileInfo() - openMyPosts() + swipeRefreshLayout = view.findViewById<View>(R.id.ProfileSwipeRefresh) as SwipeRefreshLayout + swipeRefreshLayout?.setOnRefreshListener(this@FragmentProfile) + 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 + }) return view } fun openMyPosts(){ @@ -143,6 +156,16 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr fm.commit() } + override fun onRefresh() { + onResume() + } + + override fun onResume(){ + super.onResume() + getProfileInfo() + openMyPosts() + } + private fun addProfilePicture(){ val intent= Intent(Intent.ACTION_PICK) intent.action = Intent.ACTION_GET_CONTENT @@ -194,7 +217,9 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr override fun onResponse(call: Call<UserReceive?>, response: Response<UserReceive?>) { if(response.isSuccessful()){ setUserInfo(response.body()!!) + swipeRefreshLayout.isRefreshing=false }else{ + swipeRefreshLayout.isRefreshing=false if(response.errorBody()!=null) Toast.makeText(activity, response.errorBody()!!.string(), Toast.LENGTH_LONG).show(); } @@ -203,6 +228,7 @@ class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_pr Toast.makeText( activity, t.toString(), Toast.LENGTH_LONG ).show(); + swipeRefreshLayout.isRefreshing=false } }) } diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml index 8fe6ee6..8d09153 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml @@ -6,314 +6,321 @@ android:layout_height="match_parent" tools:context=".Fragments.FragmentProfile"> - - <androidx.constraintlayout.widget.ConstraintLayout + <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:layout_width="match_parent" - android:layout_height="match_parent"> - - <ImageView - - android:id="@+id/imageView3" - android:layout_width="match_parent" - android:layout_height="190dp" - 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" /> - - <ImageView + android:layout_height="match_parent" + android:id="@+id/ProfileSwipeRefresh"> - android:id="@+id/imageView4" + <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" - android:layout_height="190dp" - app:layout_constraintBottom_toBottomOf="@+id/imageView3" - app:layout_constraintEnd_toEndOf="@id/imageView3" - app:layout_constraintHorizontal_bias="0.0" - app:layout_constraintStart_toStartOf="@+id/imageView3" - app:layout_constraintTop_toTopOf="@+id/imageView3" - app:layout_constraintVertical_bias="0.0" /> - - <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.494" - 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:elevation="10dp" - app:cardCornerRadius="250dp" - app:layout_constraintBottom_toTopOf="@+id/tableLayout" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.498" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.65999997"> + android:layout_height="match_parent"> <ImageView - android:id="@+id/tvFragmentProfileProfilePicture" - android:layout_width="120dp" - android:layout_height="120dp" - android:elevation="20dp" - android:scaleType="centerCrop" - android:src="@drawable/ic_baseline_person_24" - tools:ignore="ContentDescription" /> - </androidx.cardview.widget.CardView> - - <com.google.android.material.button.MaterialButton - android:id="@+id/btnFragmentProfileProfilePicturePlus" - android:layout_width="54dp" - android:layout_height="54dp" - android:layout_marginEnd="32dp" - android:layout_marginBottom="4dp" - app:backgroundTint="#FFFFFF" - app:cornerRadius="100dp" - app:icon="@drawable/ic_baseline_add_a_photo_24" - app:iconGravity="start" - app:iconTint="#3C5C6E" - app:layout_constraintBottom_toTopOf="@+id/tableLayout" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.72" - app:layout_constraintStart_toStartOf="parent" - tools:ignore="SpeakableTextPresentCheck" /> - - <TableLayout - android:id="@+id/tableLayout" - android:layout_width="0dp" - android:layout_height="120dp" - android:elevation="20dp" - android:gravity="center" - android:stretchColumns="1" - app:layout_constraintBottom_toBottomOf="@+id/tvFragmentProfileInfoContainer" - app:layout_constraintEnd_toEndOf="@+id/tvFragmentProfileInfoContainer" - app:layout_constraintHorizontal_bias="0.488" - app:layout_constraintStart_toStartOf="@+id/tvFragmentProfileInfoContainer" - app:layout_constraintTop_toTopOf="@+id/tvFragmentProfileInfoContainer" - app:layout_constraintVertical_bias="0.87"> - - <TableRow - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:gravity="center"> - - <TextView - android:id="@+id/tvFragmentProfileName" - android:textSize="23sp" - android:textStyle="bold" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - android:layout_marginBottom="10dp" - android:text="Petar Petrović" /> - </TableRow> - - <TableRow - android:layout_width="fill_parent" - android:layout_height="wrap_content" - - android:gravity="center"> + android:id="@+id/imageView3" + android:layout_width="match_parent" + android:layout_height="190dp" + 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" /> - <TextView - android:id="@+id/tvFragmentProfileUserName" - android:layout_width="match_parent" - android:layout_height="match_parent" - android:gravity="center" - android:text="PetarP" - android:textSize="17sp" /> - </TableRow> + <ImageView - <TableRow + android:id="@+id/imageView4" android:layout_width="match_parent" - android:layout_height="100dp"> + android:layout_height="190dp" + app:layout_constraintBottom_toBottomOf="@+id/imageView3" + app:layout_constraintEnd_toEndOf="@id/imageView3" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="@+id/imageView3" + app:layout_constraintTop_toTopOf="@+id/imageView3" + app:layout_constraintVertical_bias="0.0" /> + + <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.494" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@+id/imageView3" + app:shapeAppearanceOverlay="@style/imageViewRoundedEdge" /> - <Button - android:layout_height="8dp" - android:background="@drawable/rounded_transparent_button" - android:clickable="false" - android:visibility="invisible" /> - </TableRow> + <androidx.cardview.widget.CardView + android:id="@+id/cvFragmentHomePageProfile" + android:layout_width="120dp" + android:layout_height="120dp" + android:layout_gravity="center" + android:elevation="10dp" + app:cardCornerRadius="250dp" + app:layout_constraintBottom_toTopOf="@+id/tableLayout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.498" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.65999997"> + + <ImageView + + android:id="@+id/tvFragmentProfileProfilePicture" + android:layout_width="120dp" + android:layout_height="120dp" + android:elevation="20dp" + android:scaleType="centerCrop" + android:src="@drawable/ic_baseline_person_24" + tools:ignore="ContentDescription" /> + </androidx.cardview.widget.CardView> + + <com.google.android.material.button.MaterialButton + android:id="@+id/btnFragmentProfileProfilePicturePlus" + android:layout_width="54dp" + android:layout_height="54dp" + android:layout_marginEnd="32dp" + android:layout_marginBottom="4dp" + app:backgroundTint="#FFFFFF" + app:cornerRadius="100dp" + app:icon="@drawable/ic_baseline_add_a_photo_24" + app:iconGravity="start" + app:iconTint="#3C5C6E" + app:layout_constraintBottom_toTopOf="@+id/tableLayout" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.72" + app:layout_constraintStart_toStartOf="parent" + tools:ignore="SpeakableTextPresentCheck" /> - <TableRow - android:layout_width="match_parent" - android:layout_height="wrap_content" + <TableLayout + android:id="@+id/tableLayout" + android:layout_width="0dp" + android:layout_height="120dp" + android:elevation="20dp" android:gravity="center" - android:weightSum="1"> - - <LinearLayout - android:layout_width="wrap_content" + android:stretchColumns="1" + app:layout_constraintBottom_toBottomOf="@+id/tvFragmentProfileInfoContainer" + app:layout_constraintEnd_toEndOf="@+id/tvFragmentProfileInfoContainer" + app:layout_constraintHorizontal_bias="0.488" + app:layout_constraintStart_toStartOf="@+id/tvFragmentProfileInfoContainer" + app:layout_constraintTop_toTopOf="@+id/tvFragmentProfileInfoContainer" + app:layout_constraintVertical_bias="0.87"> + + <TableRow + android:layout_width="fill_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:weightSum="3"> + android:gravity="center"> <TextView - android:id="@+id/tvFragmentProfilePosts" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:width="100dp" - android:textSize="15dp" - android:textColor="#757471" + android:id="@+id/tvFragmentProfileName" + android:textSize="23sp" + android:textStyle="bold" + android:layout_width="match_parent" + android:layout_height="match_parent" android:gravity="center" - android:text="OBJAVE" /> + android:layout_marginBottom="10dp" + android:text="Petar Petrović" /> + </TableRow> - <TextView - android:id="@+id/tvFragmentProfileFollowers" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:width="100dp" - android:textSize="15sp" - android:clickable="true" - android:textColor="#757471" - android:gravity="center" - android:text="PRATIOCI" /> + <TableRow + android:layout_width="fill_parent" + android:layout_height="wrap_content" + + android:gravity="center"> <TextView - android:id="@+id/tvFragmentProfileFollow" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:width="100dp" + android:id="@+id/tvFragmentProfileUserName" + android:layout_width="match_parent" + android:layout_height="match_parent" android:gravity="center" - android:textSize="15sp" - android:textColor="#757471" - android:text="PRAĆENJA" /> - </LinearLayout> - </TableRow> + android:text="PetarP" + android:textSize="17sp" /> + </TableRow> - <TableRow - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:gravity="center" - android:weightSum="1"> + <TableRow + android:layout_width="match_parent" + android:layout_height="100dp"> - <LinearLayout> + <Button + android:layout_height="8dp" + android:background="@drawable/rounded_transparent_button" + android:clickable="false" + android:visibility="invisible" /> + </TableRow> - <TextView - android:id="@+id/tvFragmentProfilePostsNo" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="center" - android:text="156" - android:textSize="20dp" - android:textStyle="bold" /> - <TextView - android:id="@+id/tvFragmentProfileFollowersNo" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="center" - android:text="50" - android:textSize="20dp" - android:textStyle="bold" /> + <TableRow + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:weightSum="1"> - <TextView - android:id="@+id/tvFragmentProfileFollowNo" - android:layout_width="110dp" + <LinearLayout + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="1" - android:gravity="center" - android:text="40" - android:textSize="20dp" - android:textStyle="bold" /> - </LinearLayout> - </TableRow> - </TableLayout> - - - <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:id="@+id/btnFragmentProfileShowMyPosts" - android:layout_width="110dp" + android:orientation="horizontal" + android:weightSum="3"> + + <TextView + android:id="@+id/tvFragmentProfilePosts" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:width="100dp" + android:textSize="15dp" + android:textColor="#757471" + android:gravity="center" + android:text="OBJAVE" /> + + <TextView + android:id="@+id/tvFragmentProfileFollowers" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:width="100dp" + android:textSize="15sp" + android:clickable="true" + android:textColor="#757471" + android:gravity="center" + android:text="PRATIOCI" /> + + <TextView + android:id="@+id/tvFragmentProfileFollow" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:width="100dp" + android:gravity="center" + android:textSize="15sp" + android:textColor="#757471" + android:text="PRAĆENJA" /> + </LinearLayout> + </TableRow> + + <TableRow + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center" + android:weightSum="1"> + + <LinearLayout> + + <TextView + android:id="@+id/tvFragmentProfilePostsNo" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:text="156" + android:textSize="20dp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/tvFragmentProfileFollowersNo" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:text="50" + android:textSize="20dp" + android:textStyle="bold" /> + + <TextView + android:id="@+id/tvFragmentProfileFollowNo" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:gravity="center" + android:text="40" + android:textSize="20dp" + android:textStyle="bold" /> + </LinearLayout> + </TableRow> + </TableLayout> + + + <LinearLayout + android:id="@+id/buttons" + android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_weight="1" - android:backgroundTint="#FFFFFF" - android:stateListAnimator="@null" - android:text="Objave" - android:textColor="@color/cardview_dark_background" + android:weightSum="3" + app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer"> - <Button - android:id="@+id/btnFragmentProfileShowMyRecensions" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_gravity="end" - android:layout_weight="1" - android:backgroundTint="#FFFFFF" - android:stateListAnimator="@null" - android:text="Istorija" - android:textColor="@color/cardview_dark_background" - app:layout_constraintStart_toEndOf="@+id/btnFragmentProfileShowMyPosts" - app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> - - <Button - android:id="@+id/btnFragmentProfileShowMyData" - android:layout_width="110dp" - android:layout_height="wrap_content" - android:layout_weight="1" - android:backgroundTint="#FFFFFF" - android:stateListAnimator="@null" + <Button + android:id="@+id/btnFragmentProfileShowMyPosts" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="Objave" + android:textColor="@color/cardview_dark_background" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + + <Button + android:id="@+id/btnFragmentProfileShowMyRecensions" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_gravity="end" + android:layout_weight="1" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="Istorija" + android:textColor="@color/cardview_dark_background" + app:layout_constraintStart_toEndOf="@+id/btnFragmentProfileShowMyPosts" + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> - android:text="Nalog" - android:textColor="@color/cardview_dark_background" + <Button + android:id="@+id/btnFragmentProfileShowMyData" + android:layout_width="110dp" + android:layout_height="wrap_content" + android:layout_weight="1" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + + android:text="Nalog" + android:textColor="@color/cardview_dark_background" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" + app:layout_constraintStart_toEndOf="@+id/btnFragmentProfileShowMyRecensions" + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + + </LinearLayout> + + <FrameLayout + android:id="@+id/flFragmentProfileFragmentContainer" + android:layout_width="match_parent" + android:layout_height="0dp" + android:layout_marginTop="4dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/divider6"></FrameLayout> + + <View + android:id="@+id/divider6" + android:layout_width="409dp" + android:layout_height="1dp" + android:layout_marginTop="4dp" + android:background="?android:attr/listDivider" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="1.0" - app:layout_constraintStart_toEndOf="@+id/btnFragmentProfileShowMyRecensions" - app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/buttons" /> + </androidx.constraintlayout.widget.ConstraintLayout> - </LinearLayout> + </androidx.swiperefreshlayout.widget.SwipeRefreshLayout> - <FrameLayout - android:id="@+id/flFragmentProfileFragmentContainer" - android:layout_width="match_parent" - android:layout_height="0dp" - android:layout_marginTop="4dp" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/divider6"></FrameLayout> - - <View - android:id="@+id/divider6" - android:layout_width="409dp" - android:layout_height="1dp" - android:layout_marginTop="4dp" - android:background="?android:attr/listDivider" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/buttons" /> - </androidx.constraintlayout.widget.ConstraintLayout> </FrameLayout>
\ No newline at end of file |