Skip to content

Commit 5344395

Browse files
committed
implementing reviewer advices
1 parent 546fd29 commit 5344395

File tree

10 files changed

+36
-32
lines changed

10 files changed

+36
-32
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ apply from: '../shared_dependencies.gradle'
99

1010
android {
1111
compileSdkVersion 30
12-
buildToolsVersion "30.0.2"
12+
buildToolsVersion "30.0.3"
1313

1414
defaultConfig {
1515
applicationId "com.riyaldi.gamekuy"

app/src/main/java/com/riyaldi/gamekuy/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import android.app.Application
44
import dagger.hilt.android.HiltAndroidApp
55

66
@HiltAndroidApp
7-
open class App: Application()
7+
class App: Application()

app/src/main/java/com/riyaldi/gamekuy/explore/ExploreFragment.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ExploreFragment : Fragment() {
2929
private val exploreViewModel: ExploreViewModel by viewModels()
3030

3131
private var _binding: FragmentExploreBinding? = null
32-
private val binding get() = _binding!!
32+
private val binding get() = _binding as FragmentExploreBinding
3333

3434
private lateinit var gameAdapter: GameAdapter
3535

@@ -60,6 +60,23 @@ class ExploreFragment : Fragment() {
6060
startActivity(intent)
6161
}
6262

63+
exploreViewModel.games.observe(viewLifecycleOwner, { games ->
64+
if (games != null) {
65+
when(games) {
66+
is Resource.Loading -> showLoading(true)
67+
is Resource.Success -> {
68+
gameAdapter.setData(games.data)
69+
showLoading(false)
70+
}
71+
is Resource.Error -> {
72+
showNoGame(true)
73+
Toast.makeText(context, "error", Toast.LENGTH_SHORT).show()
74+
showLoading(false)
75+
}
76+
}
77+
}
78+
})
79+
6380
val marginVertical = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, resources.displayMetrics)
6481

6582
with(binding.rvExplore){
@@ -90,22 +107,6 @@ class ExploreFragment : Fragment() {
90107
if (query != null) {
91108
lifecycleScope.launch {
92109
exploreViewModel.searchGames(query)
93-
exploreViewModel.games.observe(viewLifecycleOwner, { games ->
94-
if (games != null) {
95-
when(games) {
96-
is Resource.Loading -> showLoading(true)
97-
is Resource.Success -> {
98-
gameAdapter.setData(games.data)
99-
showLoading(false)
100-
}
101-
is Resource.Error -> {
102-
showNoGame(true)
103-
Toast.makeText(context, "error", Toast.LENGTH_SHORT).show()
104-
showLoading(false)
105-
}
106-
}
107-
}
108-
})
109110
}
110111
}
111112
return true

app/src/main/java/com/riyaldi/gamekuy/home/HomeFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HomeFragment : Fragment() {
2525
private val homeViewModel: HomeViewModel by viewModels()
2626

2727
private var _binding: FragmentHomeBinding? = null
28-
private val binding get() = _binding!!
28+
private val binding get() = _binding as FragmentHomeBinding
2929

3030
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
3131
_binding = FragmentHomeBinding.inflate(inflater, container, false)

core/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ apply from: '../shared_dependencies.gradle'
88

99
android {
1010
compileSdkVersion 30
11-
buildToolsVersion "30.0.2"
11+
buildToolsVersion "30.0.3"
1212

1313
defaultConfig {
1414
minSdkVersion 23

core/src/main/java/com/riyaldi/core/data/source/local/entity/GameEntity.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package com.riyaldi.core.data.source.local.entity
22

3-
import android.os.Parcelable
43
import androidx.annotation.NonNull
54
import androidx.room.ColumnInfo
65
import androidx.room.Entity
76
import androidx.room.PrimaryKey
8-
import kotlinx.parcelize.Parcelize
97

10-
@Parcelize
118
@Entity(tableName = "tb_game")
129
data class GameEntity(
1310
@PrimaryKey
@@ -41,4 +38,4 @@ data class GameEntity(
4138

4239
@ColumnInfo(name = "isFavorite")
4340
var isFavorite: Boolean
44-
) : Parcelable
41+
)

core/src/main/res/layout/item_list_layout.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
android:layout_width="0dp"
2121
android:layout_height="225dp"
2222
android:adjustViewBounds="true"
23-
android:contentDescription="Description"
23+
android:contentDescription="@string/description"
2424
android:scaleType="centerCrop"
2525
app:layout_constraintEnd_toEndOf="parent"
2626
app:layout_constraintStart_toStartOf="parent"
@@ -34,7 +34,7 @@
3434
android:layout_marginStart="16dp"
3535
android:layout_marginTop="8dp"
3636
android:layout_marginEnd="16dp"
37-
android:text="TextView"
37+
android:text="@string/textview"
3838
android:textColor="@android:color/primary_text_dark"
3939
android:textSize="24sp"
4040
android:textStyle="bold"
@@ -50,7 +50,7 @@
5050
android:layout_marginTop="8dp"
5151
android:layout_marginEnd="16dp"
5252
android:layout_marginBottom="16dp"
53-
android:text="TextView"
53+
android:text="@string/textview"
5454
android:textColor="@android:color/primary_text_dark"
5555
app:layout_constraintBottom_toBottomOf="parent"
5656
app:layout_constraintEnd_toEndOf="parent"
@@ -65,7 +65,7 @@
6565
android:layout_marginEnd="16dp"
6666
android:ellipsize="end"
6767
android:maxLines="1"
68-
android:text="TextView"
68+
android:text="@string/textview"
6969
android:textColor="@android:color/primary_text_dark"
7070
app:layout_constraintBottom_toBottomOf="@+id/metascore"
7171
app:layout_constraintEnd_toStartOf="@+id/metascore"
@@ -88,7 +88,7 @@
8888
android:id="@+id/tv_item_metascore"
8989
android:layout_width="wrap_content"
9090
android:layout_height="wrap_content"
91-
android:text="99"
91+
android:text="@string/_99"
9292
android:textColor="@color/green"
9393
android:textSize="14sp"
9494
android:textStyle="bold" />
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="description">Description</string>
4+
<string name="textview">TextView</string>
5+
<string name="_99">99</string>
6+
</resources>

favorite/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ apply from: '../shared_dependencies.gradle'
88

99
android {
1010
compileSdkVersion 30
11-
buildToolsVersion "30.0.2"
11+
buildToolsVersion "30.0.3"
1212

1313
defaultConfig {
1414
applicationId "com.riyaldi.gamekuy.favorite"

favorite/src/main/java/com/riyaldi/gamekuy/favorite/ui/FavoriteFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class FavoriteFragment : Fragment() {
3131
}
3232

3333
private var _binding: FragmentFavoriteBinding? = null
34-
private val binding get() = _binding!!
34+
private val binding get() = _binding as FragmentFavoriteBinding
3535

3636
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
3737
_binding = FragmentFavoriteBinding.inflate(inflater, container, false)

0 commit comments

Comments
 (0)