This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<com.google.android.material.bottomappbar.BottomAppBar | |
android:id="@+id/bottomAppBar" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_gravity="bottom" | |
app:fabAlignmentMode="center" | |
app:fabCradleRoundedCornerRadius="20dp" | |
app:fabCradleMargin="8dp" | |
app:contentInsetStart="0dp" | |
app:contentInsetStartWithNavigation="0dp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".ui.view.activity.MainActivity"> | |
<androidx.fragment.app.FragmentContainerView | |
android:id="@+id/navHostFragment" | |
android:name="androidx.navigation.fragment.NavHostFragment" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AndroidEntryPoint | |
class MainActivity : AppCompatActivity() { | |
private lateinit var binding: ActivityMainBinding | |
private lateinit var navController: NavController | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".ui.view.fragment.HomeFragment"> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
xmlns:tools="http://schemas.android.com/tools"> | |
<androidx.appcompat.widget.AppCompatTextView | |
android:id="@+id/name" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="150dp" | |
android:layout_height="230dp" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_marginTop="10dp" | |
android:layout_marginBottom="10dp" | |
android:layout_marginStart="10dp" | |
android:layout_marginEnd="10dp" | |
android:clickable="true" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BrandsHomeDataSource @Inject constructor( | |
private val apiHelper: ApiHelper | |
) : PagingSource<Int, Brand>() { | |
override suspend fun load(params: LoadParams<Int>): LoadResult<Int, Brand> { | |
val currentLoadingPageKey = params.key ?: 1 | |
return try { | |
val response = apiHelper.getBrands(currentLoadingPageKey, 5) | |
val data = response.body()?.data?.brands ?: emptyList() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BrandsHomeAdapter( | |
private val moreListener: (Brand) -> Unit, | |
private val phoneListener: (String, String) -> Unit | |
) : PagingDataAdapter<Brand, BrandsHomeAdapter.ViewHolder>(DataDifferentiator) { | |
private lateinit var binding: ItemBrandHomeBinding | |
private lateinit var phonesHomeAdapter: PhonesHomeAdapter | |
private val rvViewPool = RecyclerView.RecycledViewPool() | |
object DataDifferentiator : DiffUtil.ItemCallback<Brand>() { | |
override fun areItemsTheSame(oldItem: Brand, newItem: Brand): Boolean { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhonesHomeAdapter( | |
private val phonesHomeList: List<Phone>?, | |
private val listener: (String) -> Unit | |
) : RecyclerView.Adapter<PhonesHomeAdapter.ViewHolder>() { | |
private lateinit var binding: ItemPhoneHomeBinding | |
class ViewHolder(private val binding: ItemPhoneHomeBinding) : | |
RecyclerView.ViewHolder(binding.root) { | |
fun bind(phone: Phone?, listener: (String) -> Unit) { |