diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt b/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt index 3f7be22..44cb609 100644 --- a/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt +++ b/app/src/main/java/it/danieleverducci/subitobeers/MainActivity.kt @@ -2,13 +2,7 @@ package it.danieleverducci.subitobeers import androidx.appcompat.app.AppCompatActivity import android.os.Bundle -import android.util.Log -import android.widget.Toast import it.danieleverducci.subitobeers.entities.Beer -import it.danieleverducci.subitobeers.networking.RetrofitProvider -import retrofit2.Call -import retrofit2.Callback -import retrofit2.Response class MainActivity : AppCompatActivity() { diff --git a/app/src/main/java/it/danieleverducci/subitobeers/BeerRecyclerAdapter.kt b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerRecyclerAdapter.kt similarity index 86% rename from app/src/main/java/it/danieleverducci/subitobeers/BeerRecyclerAdapter.kt rename to app/src/main/java/it/danieleverducci/subitobeers/ui/BeerRecyclerAdapter.kt index fcf61da..574e3a2 100644 --- a/app/src/main/java/it/danieleverducci/subitobeers/BeerRecyclerAdapter.kt +++ b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeerRecyclerAdapter.kt @@ -1,12 +1,14 @@ -package it.danieleverducci.subitobeers +package it.danieleverducci.subitobeers.ui import androidx.recyclerview.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.ImageView +import android.widget.ProgressBar import android.widget.TextView import com.squareup.picasso.Picasso +import it.danieleverducci.subitobeers.R import it.danieleverducci.subitobeers.databinding.FragmentBeersListitemBinding import it.danieleverducci.subitobeers.entities.Beer @@ -55,8 +57,12 @@ class BeerRecyclerAdapter : RecyclerView.Adapter .into(holder.pic) // If we are drawing the last element, notify - if (position == items.size - 1) + if (position == items.size - 1) { + holder.progress.visibility = View.VISIBLE listener?.OnLastItemScrolled() + } else { + holder.progress.visibility = View.GONE + } } fun addItems(ni: List) { @@ -71,6 +77,7 @@ class BeerRecyclerAdapter : RecyclerView.Adapter val name: TextView = binding.beerItemName val descr: TextView = binding.beerItemDescr val pic: ImageView = binding.beerItemPic + val progress: ProgressBar = binding.beerItemProgress } interface Listener { diff --git a/app/src/main/java/it/danieleverducci/subitobeers/BeersFragment.kt b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt similarity index 93% rename from app/src/main/java/it/danieleverducci/subitobeers/BeersFragment.kt rename to app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt index d4f8918..c4597fd 100644 --- a/app/src/main/java/it/danieleverducci/subitobeers/BeersFragment.kt +++ b/app/src/main/java/it/danieleverducci/subitobeers/ui/BeersFragment.kt @@ -1,4 +1,4 @@ -package it.danieleverducci.subitobeers +package it.danieleverducci.subitobeers.ui import android.os.Bundle import androidx.fragment.app.Fragment @@ -8,6 +8,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import it.danieleverducci.subitobeers.BeersRepository +import it.danieleverducci.subitobeers.R import it.danieleverducci.subitobeers.entities.Beer /** diff --git a/app/src/main/res/layout/fragment_beers_list.xml b/app/src/main/res/layout/fragment_beers_list.xml index 8971108..bab864d 100644 --- a/app/src/main/res/layout/fragment_beers_list.xml +++ b/app/src/main/res/layout/fragment_beers_list.xml @@ -9,5 +9,5 @@ android:layout_marginLeft="16dp" android:layout_marginRight="16dp" app:layoutManager="LinearLayoutManager" - tools:context=".BeersFragment" + tools:context=".ui.BeersFragment" tools:listitem="@layout/fragment_beers_listitem" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_beers_listitem.xml b/app/src/main/res/layout/fragment_beers_listitem.xml index 314ba57..d33cdf0 100644 --- a/app/src/main/res/layout/fragment_beers_listitem.xml +++ b/app/src/main/res/layout/fragment_beers_listitem.xml @@ -12,7 +12,6 @@ android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:src="@mipmap/ic_launcher" - app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" @@ -47,9 +46,21 @@ android:ellipsize="end" android:maxLines="3" android:text="Beer description lorem ipsum dolor sit amet" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toBottomOf="@+id/beer_item_pic" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@+id/beer_item_pic" app:layout_constraintTop_toBottomOf="@+id/beer_item_name" /> + + + \ No newline at end of file