Loading indicator in list
This commit is contained in:
parent
d470f7e968
commit
c4f1415b94
10
.idea/runConfigurations.xml
Normal file
10
.idea/runConfigurations.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -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() {
|
||||
|
||||
|
@ -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<BeerRecyclerAdapter.ViewHolder>
|
||||
.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<Beer>) {
|
||||
@ -71,6 +77,7 @@ class BeerRecyclerAdapter : RecyclerView.Adapter<BeerRecyclerAdapter.ViewHolder>
|
||||
val name: TextView = binding.beerItemName
|
||||
val descr: TextView = binding.beerItemDescr
|
||||
val pic: ImageView = binding.beerItemPic
|
||||
val progress: ProgressBar = binding.beerItemProgress
|
||||
}
|
||||
|
||||
interface Listener {
|
@ -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
|
||||
|
||||
/**
|
@ -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" />
|
@ -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" />
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/beer_item_progress"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/beer_item_pic" />
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
Loading…
Reference in New Issue
Block a user