Skip to content

Commit a3dadf9

Browse files
committed
cleanup
1 parent 14a0287 commit a3dadf9

File tree

7 files changed

+31
-33
lines changed

7 files changed

+31
-33
lines changed

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/data/repository/MovieRepositoryImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MovieRepositoryImpl(
4242
}
4343

4444
override suspend fun addToMyWatchlist(movie: Movie) {
45-
moviesDao.addToWatchList(movie)
45+
moviesDao.addToWatchList(movie)
4646
}
4747

4848
override suspend fun removeFromMyWatchlist(movie: Movie) {

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/ui/details/MovieDetailActivity.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import androidx.compose.foundation.lazy.LazyRowFor
1616
import androidx.compose.foundation.shape.RoundedCornerShape
1717
import androidx.compose.material.Button
1818
import androidx.compose.material.IconButton
19-
import androidx.compose.material.IconToggleButton
2019
import androidx.compose.material.MaterialTheme
2120
import androidx.compose.material.icons.Icons
2221
import androidx.compose.material.icons.filled.LibraryAdd
23-
import androidx.compose.material.icons.outlined.LibraryAdd
2422
import androidx.compose.runtime.Composable
2523
import androidx.compose.runtime.getValue
2624
import androidx.compose.runtime.livedata.observeAsState
@@ -73,6 +71,7 @@ class MovieDetailActivity : AppCompatActivity() {
7371
Intent(context, MovieDetailActivity::class.java).apply {
7472
putExtra(MOVIE, movie)
7573
}
74+
7675
fun newIntent(context: Context, movie: Movie, imageId: Int) =
7776
Intent(context, MovieDetailActivity::class.java).apply {
7877
putExtra(MOVIE, movie)

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/ui/home/MoviePagerItem.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ fun MoviePagerItem(
4646
val animateElevation = if (isSelected) 12.dp else 2.dp
4747
val posterFullPath = "https://image.tmdb.org/t/p/w500/${movie.poster_path}"
4848

49-
val movieGenres = movie.genre_ids?.let {
50-
movieGenreIds -> genres.filter { movieGenreIds.contains(it.id) }.take(3)
49+
val movieGenres = movie.genre_ids?.let { movieGenreIds ->
50+
genres.filter { movieGenreIds.contains(it.id) }.take(3)
5151
}
5252

5353
Card(
@@ -87,8 +87,10 @@ fun MoviePagerItem(
8787
asset = Icons.Default.LibraryAdd,
8888
tint = MaterialTheme.colors.primary,
8989
modifier = Modifier
90-
.drawLayer(rotationY = animate(
91-
if (clicked.value) 720f else 0f, tween(400))
90+
.drawLayer(
91+
rotationY = animate(
92+
if (clicked.value) 720f else 0f, tween(400)
93+
)
9294
)
9395
)
9496
}

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/ui/home/MoviesHomeActivity.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import androidx.compose.material.Scaffold
1616
import androidx.compose.material.icons.Icons
1717
import androidx.compose.material.icons.outlined.LibraryAdd
1818
import androidx.compose.material.icons.outlined.MovieCreation
19-
import androidx.compose.material.icons.outlined.Search
2019
import androidx.compose.material.icons.outlined.Subscriptions
2120
import androidx.compose.runtime.Composable
2221
import androidx.compose.runtime.MutableState
@@ -30,7 +29,9 @@ import com.guru.composecookbook.ui.moviesappmvi.data.models.Movie
3029
import com.guru.composecookbook.ui.moviesappmvi.ui.details.MovieDetailActivity
3130

3231
sealed class MoviesHomeInteractionEvents {
33-
data class OpenMovieDetail(val movie: Movie, val imageId: Int = 0) : MoviesHomeInteractionEvents()
32+
data class OpenMovieDetail(val movie: Movie, val imageId: Int = 0) :
33+
MoviesHomeInteractionEvents()
34+
3435
data class AddToMyWatchlist(val movie: Movie) : MoviesHomeInteractionEvents()
3536
data class RemoveFromMyWatchlist(val movie: Movie) : MoviesHomeInteractionEvents()
3637
}
@@ -59,7 +60,7 @@ class MoviesHomeActivity : AppCompatActivity() {
5960
}
6061
)
6162
MovieNavType.WATCHLIST -> WatchlistScreen(
62-
moviesHomeInteractionEvents = {
63+
moviesHomeInteractionEvents = {
6364
handleInteractionEvents(it, viewModel)
6465
}
6566
)
@@ -78,8 +79,11 @@ class MoviesHomeActivity : AppCompatActivity() {
7879
) {
7980
when (interactionEvents) {
8081
is MoviesHomeInteractionEvents.OpenMovieDetail -> {
81-
startActivity(MovieDetailActivity.newIntent(
82-
this, interactionEvents.movie, interactionEvents.imageId))
82+
startActivity(
83+
MovieDetailActivity.newIntent(
84+
this, interactionEvents.movie, interactionEvents.imageId
85+
)
86+
)
8387
overridePendingTransition(0, 0)
8488
}
8589
is MoviesHomeInteractionEvents.AddToMyWatchlist -> {

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/ui/home/MoviesHomeScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ fun MoviesPager(
8282
{ moviesHomeInteractionEvents(MoviesHomeInteractionEvents.AddToMyWatchlist(movie)) }
8383
) {
8484
moviesHomeInteractionEvents(
85-
MoviesHomeInteractionEvents.OpenMovieDetail(movie, imageId.value))
85+
MoviesHomeInteractionEvents.OpenMovieDetail(movie, imageId.value)
86+
)
8687
}
8788
}
8889
} else {
@@ -100,7 +101,6 @@ fun MoviesPager(
100101
}
101102
}
102103

103-
104104
val imageIds =
105105
listOf(
106106
R.drawable.camelia,

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/ui/home/MoviewsHomeViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class MoviesHomeViewModel(
4444
}
4545

4646
fun addToMyWatchlist(movie: Movie) = viewModelScope.launch(Dispatchers.IO) {
47-
movieRepository.addToMyWatchlist(movie)
48-
}
47+
movieRepository.addToMyWatchlist(movie)
48+
}
4949

5050
fun removeFromMyWatchlist(movie: Movie) = viewModelScope.launch(Dispatchers.IO) {
5151
movieRepository.removeFromMyWatchlist(movie)

app/src/main/java/com/guru/composecookbook/ui/moviesappmvi/ui/home/WatchlistScreen.kt

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,27 @@
11
package com.guru.composecookbook.ui.moviesappmvi.ui.home
22

3-
import androidx.compose.animation.animateContentSize
43
import androidx.compose.foundation.*
54
import androidx.compose.foundation.layout.*
6-
import androidx.compose.foundation.layout.ColumnScope.align
7-
import androidx.compose.foundation.layout.RowScope.align
8-
import androidx.compose.foundation.lazy.LazyColumnFor
95
import androidx.compose.foundation.lazy.LazyColumnForIndexed
10-
import androidx.compose.material.CircularProgressIndicator
116
import androidx.compose.material.IconButton
127
import androidx.compose.material.Surface
138
import androidx.compose.material.icons.Icons
149
import androidx.compose.material.icons.filled.RemoveCircleOutline
1510
import androidx.compose.runtime.Composable
11+
import androidx.compose.runtime.getValue
1612
import androidx.compose.runtime.livedata.observeAsState
17-
import androidx.compose.runtime.mutableStateOf
18-
import androidx.compose.runtime.remember
1913
import androidx.compose.ui.Alignment
2014
import androidx.compose.ui.Modifier
21-
import androidx.compose.runtime.getValue
22-
import androidx.compose.runtime.setValue
23-
import androidx.compose.ui.draw.drawOpacity
2415
import androidx.compose.ui.graphics.Color
2516
import androidx.compose.ui.layout.ContentScale
2617
import androidx.compose.ui.text.font.FontWeight
2718
import androidx.compose.ui.text.style.TextAlign
2819
import androidx.compose.ui.unit.dp
2920
import androidx.compose.ui.viewinterop.viewModel
30-
import com.guru.composecookbook.theme.graySurface
3121
import com.guru.composecookbook.theme.typography
3222
import com.guru.composecookbook.ui.demoui.spotify.data.SpotifyDataProvider
3323
import com.guru.composecookbook.ui.moviesappmvi.data.models.Movie
3424
import com.guru.composecookbook.ui.utils.horizontalGradientBackground
35-
import com.guru.composecookbook.ui.utils.verticalGradientBackground
3625
import dev.chrisbanes.accompanist.coil.CoilImage
3726

3827
@Composable
@@ -47,14 +36,18 @@ fun WatchlistScreen(moviesHomeInteractionEvents: (MoviesHomeInteractionEvents) -
4736
) { index, movie ->
4837
MovieWatchlistItem(
4938
movie,
50-
{ moviesHomeInteractionEvents(
51-
MoviesHomeInteractionEvents.OpenMovieDetail(movie))
39+
{
40+
moviesHomeInteractionEvents(
41+
MoviesHomeInteractionEvents.OpenMovieDetail(movie)
42+
)
5243
},
53-
{ moviesHomeInteractionEvents(
54-
MoviesHomeInteractionEvents.RemoveFromMyWatchlist(movie))
44+
{
45+
moviesHomeInteractionEvents(
46+
MoviesHomeInteractionEvents.RemoveFromMyWatchlist(movie)
47+
)
5548
}
5649
)
57-
if (index == myWatchlist.size -1) {
50+
if (index == myWatchlist.size - 1) {
5851
Spacer(modifier = Modifier.padding(30.dp))
5952
}
6053
}

0 commit comments

Comments
 (0)