Skip to content

Commit

Permalink
Merge branch 'develop-compose' into feat/search_compose_paging
Browse files Browse the repository at this point in the history
  • Loading branch information
junhyeongleeee authored Jul 24, 2023
2 parents e6b4eab + 63ebe2c commit 984f062
Show file tree
Hide file tree
Showing 33 changed files with 5,391 additions and 104 deletions.
8 changes: 8 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
def pagingVersion = "3.1.1"
def glide_version = "4.14.2"
def glide_compose_version = "1.0.0-alpha.1"
def lottieComposeVersion = "6.0.0"

// Compose
def composeBom = platform('androidx.compose:compose-bom:2023.04.01')
Expand All @@ -88,6 +89,8 @@ dependencies {
implementation 'androidx.compose.runtime:runtime-livedata'
// collectAsStateWithLifecycle()
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
// Compose Text Effect
implementation "me.saket.extendedspans:extendedspans:1.3.0"

// Navigation
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
Expand Down Expand Up @@ -121,6 +124,8 @@ dependencies {
implementation "androidx.paging:paging-compose:$pagingComposeVersion"

// Exoplayer
implementation 'androidx.media3:media3-exoplayer:1.1.0-alpha01'
implementation "androidx.media3:media3-ui:1.1.0-alpha01"
implementation 'com.google.android.exoplayer:exoplayer:2.18.7'
// Coordinator-layout
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.2.0'
Expand All @@ -129,6 +134,7 @@ dependencies {
implementation 'com.arthenica:mobile-ffmpeg-min-gpl:4.4'
// lottie
implementation 'com.airbnb.android:lottie:5.0.2'
implementation "com.airbnb.android:lottie-compose:$lottieComposeVersion"
// dataStore
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("androidx.datastore:datastore-core:1.0.0")
Expand All @@ -140,6 +146,8 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
// mockito
testImplementation 'org.mockito:mockito-inline:2.21.0'

implementation "com.airbnb.android:lottie-compose:5.0.2"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
android:supportsRtl="true"
android:theme="@style/Theme.DailyFilm"
tools:targetApi="31">
<activity
android:name=".presentation.totalfilm.TotalFilmComposeActivity"
android:exported="false"
android:label="@string/title_activity_total_compose"
android:theme="@style/Theme.DailyFilm">
</activity>
<activity
android:name=".presentation.searchfilm.SearchFilmComposeActivity"
android:exported="false" />
Expand All @@ -38,6 +44,9 @@
<activity
android:name=".presentation.totalfilm.TotalFilmActivity"
android:exported="false" />
<activity android:name=".presentation.uploadfilm.UploadFilmComposeActivity"
android:exported="false"
android:theme="@style/Theme.DailyFilm"/>
<activity
android:name=".presentation.uploadfilm.UploadFilmActivity"
android:exported="false" />
Expand All @@ -60,7 +69,8 @@
<activity
android:name=".presentation.trimvideo.TrimVideoActivity"
android:exported="false" />
<activity android:name=".presentation.settings.compose.SettingComposeActivity"
<activity
android:name=".presentation.settings.compose.SettingComposeActivity"
android:exported="false" />
</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import com.boostcamp.dailyfilm.presentation.playfilm.model.EditState
import com.boostcamp.dailyfilm.presentation.searchfilm.SearchFilmComposeActivity
import com.boostcamp.dailyfilm.presentation.selectvideo.SelectVideoActivity
import com.boostcamp.dailyfilm.presentation.settings.compose.SettingComposeActivity
import com.boostcamp.dailyfilm.presentation.totalfilm.TotalFilmActivity
import com.boostcamp.dailyfilm.presentation.totalfilm.TotalFilmComposeActivity
import com.boostcamp.dailyfilm.presentation.trimvideo.TrimVideoActivity
import com.boostcamp.dailyfilm.presentation.uploadfilm.model.DateAndVideoModel
import com.boostcamp.dailyfilm.presentation.util.network.NetworkManager
Expand Down Expand Up @@ -144,7 +144,7 @@ class CalendarActivity : BaseActivity<ActivityCalendarBinding>(R.layout.activity
return@setOnMenuItemClickListener true
}
startActivity(
Intent(this@CalendarActivity, TotalFilmActivity::class.java).apply {
Intent(this@CalendarActivity, TotalFilmComposeActivity::class.java).apply {
putParcelableArrayListExtra(
KEY_FILM_ARRAY,
ArrayList(viewModel.filmFlow.value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@ import androidx.fragment.app.viewModels
import com.boostcamp.dailyfilm.R
import com.boostcamp.dailyfilm.databinding.FragmentPlayFilmBinding
import com.boostcamp.dailyfilm.presentation.BaseFragment
import com.boostcamp.dailyfilm.presentation.calendar.CalendarActivity
import com.boostcamp.dailyfilm.presentation.calendar.DateFragment.Companion.KEY_CALENDAR_INDEX
import com.boostcamp.dailyfilm.presentation.calendar.model.DateModel
import com.boostcamp.dailyfilm.presentation.util.network.NetworkManager
import com.boostcamp.dailyfilm.presentation.util.network.NetworkState
import com.boostcamp.dailyfilm.presentation.util.PlayState
import com.google.android.material.snackbar.Snackbar
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
Expand Down Expand Up @@ -97,7 +93,7 @@ class PlayFilmFragment : BaseFragment<FragmentPlayFilmBinding>(R.layout.fragment
}
}*/

viewModel.playState.observe(viewLifecycleOwner) {
/*viewModel.playState.observe(viewLifecycleOwner) {
when(it) {
is PlayState.Uninitialized -> {}
is PlayState.Loading -> {}
Expand All @@ -121,7 +117,7 @@ class PlayFilmFragment : BaseFragment<FragmentPlayFilmBinding>(R.layout.fragment
}
}
}
}
}*/
}

private fun initListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@ package com.boostcamp.dailyfilm.presentation.playfilm

import android.net.Uri
import android.util.Log
import androidx.lifecycle.*
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.boostcamp.dailyfilm.data.delete.DeleteFilmRepository
import com.boostcamp.dailyfilm.data.model.Result
import com.boostcamp.dailyfilm.data.playfilm.PlayFilmRepository
import com.boostcamp.dailyfilm.presentation.calendar.model.DateModel
import com.boostcamp.dailyfilm.presentation.util.network.NetworkManager
import com.boostcamp.dailyfilm.presentation.util.network.NetworkState
import com.boostcamp.dailyfilm.presentation.playfilm.base.ContentShowState
import com.boostcamp.dailyfilm.presentation.playfilm.base.MuteState
import com.boostcamp.dailyfilm.presentation.util.PlayState
import com.boostcamp.dailyfilm.presentation.util.UiState
import com.boostcamp.dailyfilm.presentation.util.network.NetworkManager
import com.boostcamp.dailyfilm.presentation.util.network.NetworkState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand All @@ -31,27 +39,33 @@ class PlayFilmViewModel @Inject constructor(
private val _videoUri = MutableLiveData<Uri?>()
val videoUri: LiveData<Uri?> get() = _videoUri

private val _isContentShowed = MutableLiveData(true)
val isContentShowed: LiveData<Boolean> get() = _isContentShowed
private val _contentShowState = MutableStateFlow(ContentShowState(true))
val contentShowState: StateFlow<ContentShowState> get() = _contentShowState

private val _isMuted = MutableLiveData(false)
val isMuted: LiveData<Boolean> get() = _isMuted
private val _muteState = MutableStateFlow(MuteState(false))
val muteState: StateFlow<MuteState> get() = _muteState

private val _playState = MutableLiveData<PlayState>(PlayState.Uninitialized)
val playState: LiveData<PlayState> get() = _playState
private val _playState = MutableStateFlow<PlayState>(PlayState.Uninitialized)
val playState: StateFlow<PlayState> get() = _playState

private val _networkState = MutableLiveData(NetworkManager.checkNetwork())
val networkState: LiveData<NetworkState> get() = _networkState

private val _isNetworkConnectShowed = MutableLiveData(true)
val isNetworkConnectShowed: LiveData<Boolean> get() = _isNetworkConnectShowed

private val _isProgressed = MutableLiveData(false)
val isProgressed: LiveData<Boolean> get() = _isProgressed
private val _isProgressed = MutableStateFlow(false)
val isProgressed: StateFlow<Boolean> get() = _isProgressed

private val _openDialog = MutableStateFlow(false)
val openDialog : StateFlow<Boolean> get() = _openDialog

init {
loadVideo()
}
fun setDialog(value: Boolean) {
_openDialog.value = value
}

private fun checkNetwork() {
_networkState.value = NetworkManager.checkNetwork()
Expand All @@ -62,14 +76,6 @@ class PlayFilmViewModel @Inject constructor(
_text.value = text
}

fun changeShowState() {
_isContentShowed.value = _isContentShowed.value?.not()
}

fun changeMuteState() {
_isMuted.value = _isMuted.value?.not()
}

fun setNetworkState(state: NetworkState) {
viewModelScope.launch {
// isNetworkConnected 는 연결 여부를 떠나 Playing 중이면 보여 주지 않는다.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.boostcamp.dailyfilm.presentation.calendar.model.DateModel
import com.boostcamp.dailyfilm.presentation.playfilm.PlayFilmFragment
import com.boostcamp.dailyfilm.presentation.playfilm.compose.PlayFilmComposeFragment

class PlayFilmPageAdapter(
private val dateList: ArrayList<DateModel>,
Expand All @@ -13,7 +14,7 @@ class PlayFilmPageAdapter(

override fun getItemCount(): Int = dateList.size

override fun createFragment(position: Int): PlayFilmFragment {
return PlayFilmFragment.newInstance(dateList[position])
override fun createFragment(position: Int): PlayFilmComposeFragment {
return PlayFilmComposeFragment.newInstance(dateList[position])
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.boostcamp.dailyfilm.presentation.playfilm.base

import com.airbnb.lottie.compose.LottieClipSpec

class ContentShowState(init: Boolean): LottieState(init) {
override val clipSpec: LottieClipSpec
get() = if (state) {
LottieClipSpec.Progress(START, MID)
} else {
LottieClipSpec.Progress(MID, FINISH)
}

companion object {
const val START = 0.67f
const val MID = 0.25f
const val FINISH = 0.67f
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.boostcamp.dailyfilm.presentation.playfilm.base

import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.airbnb.lottie.compose.LottieClipSpec

abstract class LottieState(initial: Boolean) {
var state by mutableStateOf(initial)

abstract val clipSpec: LottieClipSpec

fun updateState() {
state = !state
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.boostcamp.dailyfilm.presentation.playfilm.base

import com.airbnb.lottie.compose.LottieClipSpec

class MuteState(init: Boolean): LottieState(init) {

override val clipSpec: LottieClipSpec
get() = if (state) {
LottieClipSpec.Progress(START, MID)
} else {
LottieClipSpec.Progress(MID, FINISH)
}

companion object {
const val START = 0.0f
const val MID = 0.5f
const val FINISH = 1.0f
}
}
Loading

0 comments on commit 984f062

Please sign in to comment.