diff options
author | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-09 13:20:50 +0100 |
---|---|---|
committer | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-09 13:20:50 +0100 |
commit | df1a35cf86998b412aef39d36380204cdd616540 (patch) | |
tree | 38dbda9780efc319e332eb6022fd1eab96c017d4 /Client | |
parent | b590f8f22f3f6368da22dbfc4708dd51b698f17b (diff) |
Refresh pocetne strane #83
Diffstat (limited to 'Client')
2 files changed, 259 insertions, 230 deletions
diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt index 82c78a1..df41b3a 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt @@ -8,11 +8,11 @@ import android.widget.Button import android.widget.ImageButton import android.widget.LinearLayout import android.widget.Toast -import androidx.core.view.isVisible import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentTransaction import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout.OnRefreshListener import com.example.brzodolokacije.Adapters.ShowPostsHomePageAdapter import com.example.brzodolokacije.Interfaces.IBackendApi import com.example.brzodolokacije.Models.LocationType @@ -20,15 +20,15 @@ import com.example.brzodolokacije.Models.PostPreview import com.example.brzodolokacije.R import com.example.brzodolokacije.Services.RetrofitHelper import com.example.brzodolokacije.Services.SharedPreferencesHelper -import kotlinx.android.synthetic.main.fragment_home_page_main_scroll.* import retrofit2.Call import retrofit2.Callback import retrofit2.Response import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory -class FragmentHomePageMainScroll : Fragment() { +class FragmentHomePageMainScroll : Fragment(),OnRefreshListener { + private lateinit var swipeRefreshLayout: SwipeRefreshLayout private lateinit var posts : MutableList<PostPreview> private lateinit var mostViewedPosts : MutableList<PostPreview> private lateinit var newestPosts : MutableList<PostPreview> @@ -79,7 +79,7 @@ private lateinit var change:Button location_waterfall=view.findViewById(R.id.btnFragmentHomePagelocation_waterfall) //pokupi sve objave iz baze' - getAllPosts() + //getAllPosts() var bundle=Bundle() var fragment=FragmentShowPostsByLocation() @@ -190,9 +190,29 @@ private lateinit var change:Button } */ + swipeRefreshLayout = view.findViewById<View>(R.id.swipeContainer) as SwipeRefreshLayout + swipeRefreshLayout.setOnRefreshListener(this) + 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 } + override fun onRefresh() { + getAllPosts() + } + + override fun onResume() { + super.onResume() + getAllPosts() + } + private fun getAllPosts(){ Toast.makeText( activity," get all", Toast.LENGTH_LONG @@ -289,6 +309,7 @@ private lateinit var change:Button layoutManager= LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL,false) adapter= ShowPostsHomePageAdapter(newestposts,requireActivity()) } + swipeRefreshLayout.isRefreshing=false } override fun onFailure(call: Call<MutableList<PostPreview>>, t: Throwable) { diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_home_page_main_scroll.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_home_page_main_scroll.xml index 07d34a3..b64eb0f 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_home_page_main_scroll.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_home_page_main_scroll.xml @@ -1,240 +1,248 @@ <?xml version="1.0" encoding="utf-8"?> -<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.swiperefreshlayout.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" + tools:context=".Fragments.FragmentHomePageMainScroll" android:layout_width="match_parent" android:layout_height="match_parent" - xmlns:app="http://schemas.android.com/apk/res-auto" - tools:context=".Fragments.FragmentHomePageMainScroll"> - -<LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="vertical"> + android:id="@+id/swipeContainer"> + <ScrollView - <androidx.cardview.widget.CardView - android:backgroundTint="#f6f6f6" - android:layout_marginStart="10dp" - android:layout_marginEnd="16dp" -app:cardElevation="0dp" - android:id="@+id/cvFragmentHomePageText2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:stateListAnimator="@null" - android:elevation="0dp" - android:layout_marginTop="16dp"> - - <TextView - android:id="@+id/tvFragmentHomePageNewest" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="left" - android:text="Najnovije" - android:clickable="true" - android:textStyle="bold" /> - - - <TextView - android:id="@+id/tvFragmentHomePageNewestShowAll" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="right" - android:clickable="true" - android:text="Prikaži sve" /> - </androidx.cardview.widget.CardView> - - <androidx.recyclerview.widget.RecyclerView - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:id="@+id/rvFragmentHomePageNewest" - android:layout_marginBottom="20dp" android:layout_width="match_parent" - android:layout_height="wrap_content" /> - - <HorizontalScrollView - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:id="@+id/hsvFragmentHomePageLocationButtonScroll" - android:layout_width="match_parent" - android:layout_height="wrap_content" - + android:layout_height="match_parent" + xmlns:app="http://schemas.android.com/apk/res-auto" > <LinearLayout - android:id="@+id/llFragmentHomePageLocationButtonLayout" - android:layout_width="wrap_content" - android:layout_height="match_parent"> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_city" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_city" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_beach" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_beach" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_mountain" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_mountain" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_lake" - android:layout_width="60dp" - android:layout_height="match_parent" - android:layout_marginRight="10dp" - android:background="@drawable/location_lake" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_spa" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_spa" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_waterfall" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_waterfall" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_amusement_park" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_amusement_park" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_attraction" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_attraction" - tools:ignore="SpeakableTextPresentCheck" /> - - <ImageButton - android:id="@+id/btnFragmentHomePagelocation_landmark" - android:layout_width="60dp" - android:layout_height="60dp" - android:layout_marginRight="10dp" - android:background="@drawable/location_landmark" - tools:ignore="SpeakableTextPresentCheck" /> - - </LinearLayout> - </HorizontalScrollView> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:orientation="horizontal"> - - <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> -<LinearLayout - android:orientation="vertical" - android:id="@+id/ll1" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <androidx.cardview.widget.CardView - android:backgroundTint="#f6f6f6" - android:layout_marginTop="16dp" - android:id="@+id/cvFragmentHomePageText1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:elevation="0dp" - app:cardElevation="0dp" - > - - <TextView - android:id="@+id/tvFragmentHomePagePopular" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:layout_gravity="left" - android:text="Popularno" - android:textStyle="bold" /> - - <TextView - android:id="@+id/tvFragmentHomePagePopularShowAll" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="right" - android:clickable="true" - android:text="Prikaži sve" - - tools:ignore="TouchTargetSizeCheck" /> - </androidx.cardview.widget.CardView> - - <androidx.recyclerview.widget.RecyclerView - android:id="@+id/rvFragmentHomePagePopular" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:layout_marginBottom="16dp" /> - - </LinearLayout> - <LinearLayout - android:id="@+id/ll2" - - android:orientation="vertical" - android:layout_width="match_parent" - android:layout_height="wrap_content"> - <androidx.cardview.widget.CardView - android:backgroundTint="#f6f6f6" -app:cardElevation="0dp" - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:id="@+id/cvFragmentHomePageText3" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginTop="16dp"> - <TextView - android:id="@+id/tvFragmentHomePageBestRated" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="left" - android:text="Najbolje ocenjeno" - android:textStyle="bold" /> - - <TextView - android:id="@+id/tvFragmentHomePageBestRatedShowAll" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="right" - android:clickable="true" - android:text="Prikaži sve" /> - </androidx.cardview.widget.CardView> - - <androidx.recyclerview.widget.RecyclerView - android:layout_marginStart="16dp" - android:layout_marginEnd="16dp" - android:id="@+id/rvFragmentHomePageBestRated" - android:layout_width="match_parent" - android:layout_height="wrap_content" /> - -</LinearLayout></LinearLayout> -</LinearLayout> -</LinearLayout> -</ScrollView>
\ No newline at end of file + <androidx.cardview.widget.CardView + android:backgroundTint="#f6f6f6" + android:layout_marginStart="10dp" + android:layout_marginEnd="16dp" + app:cardElevation="0dp" + android:id="@+id/cvFragmentHomePageText2" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:stateListAnimator="@null" + android:elevation="0dp" + android:layout_marginTop="16dp"> + + <TextView + android:id="@+id/tvFragmentHomePageNewest" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="left" + android:text="Najnovije" + android:clickable="true" + android:textStyle="bold" /> + + + <TextView + android:id="@+id/tvFragmentHomePageNewestShowAll" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:clickable="true" + android:text="Prikaži sve" /> + </androidx.cardview.widget.CardView> + + <androidx.recyclerview.widget.RecyclerView + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:id="@+id/rvFragmentHomePageNewest" + android:layout_marginBottom="20dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + <HorizontalScrollView + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:id="@+id/hsvFragmentHomePageLocationButtonScroll" + android:layout_width="match_parent" + android:layout_height="wrap_content" + + > + + <LinearLayout + android:id="@+id/llFragmentHomePageLocationButtonLayout" + android:layout_width="wrap_content" + android:layout_height="match_parent"> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_city" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_city" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_beach" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_beach" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_mountain" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_mountain" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_lake" + android:layout_width="60dp" + android:layout_height="match_parent" + android:layout_marginRight="10dp" + android:background="@drawable/location_lake" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_spa" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_spa" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_waterfall" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_waterfall" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_amusement_park" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_amusement_park" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_attraction" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_attraction" + tools:ignore="SpeakableTextPresentCheck" /> + + <ImageButton + android:id="@+id/btnFragmentHomePagelocation_landmark" + android:layout_width="60dp" + android:layout_height="60dp" + android:layout_marginRight="10dp" + android:background="@drawable/location_landmark" + tools:ignore="SpeakableTextPresentCheck" /> + + </LinearLayout> + </HorizontalScrollView> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="horizontal"> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical"> + <LinearLayout + android:orientation="vertical" + android:id="@+id/ll1" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <androidx.cardview.widget.CardView + android:backgroundTint="#f6f6f6" + android:layout_marginTop="16dp" + android:id="@+id/cvFragmentHomePageText1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:elevation="0dp" + app:cardElevation="0dp" + > + + <TextView + android:id="@+id/tvFragmentHomePagePopular" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="left" + android:text="Popularno" + android:textStyle="bold" /> + + <TextView + android:id="@+id/tvFragmentHomePagePopularShowAll" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:clickable="true" + android:text="Prikaži sve" + + tools:ignore="TouchTargetSizeCheck" /> + + </androidx.cardview.widget.CardView> + + <androidx.recyclerview.widget.RecyclerView + android:id="@+id/rvFragmentHomePagePopular" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:layout_marginBottom="16dp" /> + + </LinearLayout> + <LinearLayout + android:id="@+id/ll2" + + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <androidx.cardview.widget.CardView + android:backgroundTint="#f6f6f6" + app:cardElevation="0dp" + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:id="@+id/cvFragmentHomePageText3" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="16dp"> + + <TextView + android:id="@+id/tvFragmentHomePageBestRated" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="left" + android:text="Najbolje ocenjeno" + android:textStyle="bold" /> + + <TextView + android:id="@+id/tvFragmentHomePageBestRatedShowAll" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="right" + android:clickable="true" + android:text="Prikaži sve" /> + </androidx.cardview.widget.CardView> + + <androidx.recyclerview.widget.RecyclerView + android:layout_marginStart="16dp" + android:layout_marginEnd="16dp" + android:id="@+id/rvFragmentHomePageBestRated" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + </LinearLayout></LinearLayout> + </LinearLayout> + </LinearLayout> + </ScrollView> +</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> |