-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
main setting
- Loading branch information
Showing
24 changed files
with
479 additions
and
36 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,44 @@ | ||
object Versions { | ||
|
||
// AndroidX | ||
const val APP_COMPAT = "1.4.1" | ||
const val MATERIAL = "1.5.0" | ||
const val CONSTRAINT_LAYOUT = "2.1.3" | ||
|
||
// KTX | ||
const val CORE = "1.7.0" | ||
|
||
// TEST | ||
const val JUNIT = "1.1.3" | ||
|
||
// Android Test | ||
const val ESPRESSO_CORE = "3.4.0" | ||
object Kotlin { | ||
const val COROUTINES_CORE = "org.jetbrains.kotlinx:kotlinx-coroutines-core:${Version.KOTLINX_COROUTINES}" | ||
const val COROUTINES_ANDROID = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Version.KOTLINX_COROUTINES}" | ||
} | ||
|
||
object Libraries { | ||
|
||
object AndroidX { | ||
const val APP_COMPAT = "androidx.appcompat:appcompat:${Versions.APP_COMPAT}" | ||
const val MATERIAL = "com.google.android.material:material:${Versions.MATERIAL}" | ||
const val CONSTRAINT_LAYOUT = "androidx.constraintlayout:constraintlayout:${Versions.CONSTRAINT_LAYOUT}" | ||
const val APP_COMPAT = "androidx.appcompat:appcompat:${Version.APP_COMPAT}" | ||
const val MATERIAL = "com.google.android.material:material:${Version.MATERIAL}" | ||
const val CONSTRAINT_LAYOUT = "androidx.constraintlayout:constraintlayout:${Version.CONSTRAINT_LAYOUT}" | ||
|
||
const val NAVIGATION = "androidx.navigation:navigation-fragment-ktx:${Version.NAVIGATION}" | ||
const val NAVIGATION_UI_KTX = "androidx.navigation:navigation-ui-ktx:${Version.NAVIGATION}" | ||
|
||
const val RUNTIME = "androidx.lifecycle:lifecycle-runtime-ktx:${Version.RUNTIME}" | ||
const val VIEWMODEL = "androidx.lifecycle:lifecycle-viewmodel:${Version.VIEWMODEL}" | ||
const val VIEWMODEL_KTX = "androidx.lifecycle:lifecycle-viewmodel-ktx:${Version.VIEWMODEL}" | ||
const val FRAGMENT_KTX = "androidx.fragment:fragment-ktx:${Version.FRAGMENT}" | ||
|
||
const val ROOM_RUNTIME = "androidx.room:room-runtime:${Version.ROOM}" | ||
const val ROOM_KTX = "androidx.room:room-ktx:${Version.ROOM}" | ||
const val ROOM_COMPILER = "androidx.room:room-compiler:${Version.ROOM}" | ||
} | ||
|
||
object KTX { | ||
const val CORE = "androidx.core:core-ktx:${Versions.CORE}" | ||
const val CORE = "androidx.core:core-ktx:${Version.CORE}" | ||
} | ||
|
||
object Test { | ||
const val JUNIT = "androidx.test.ext:junit:${Versions.JUNIT}" | ||
const val JUNIT = "androidx.test.ext:junit:${Version.JUNIT}" | ||
} | ||
|
||
object AndroidTest { | ||
const val ESPRESSO_CORE = "androidx.test.espresso:espresso-core:${Versions.ESPRESSO_CORE}" | ||
const val ESPRESSO_CORE = "androidx.test.espresso:espresso-core:${Version.ESPRESSO_CORE}" | ||
} | ||
|
||
} | ||
|
||
object Google { | ||
const val HILT_ANDROID = "com.google.dagger:hilt-android:${Version.HILT}" | ||
const val HILT_ANDROID_COMPILER = "com.google.dagger:hilt-android-compiler:${Version.HILT}" | ||
const val HILT_ANDROID_PLUGIN = "com.google.dagger:hilt-android-gradle-plugin:${Version.HILT}" | ||
const val MATERIAL = "com.google.android.material:material:${Version.MATERIAL}" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
object Plugin { | ||
const val application = "com.android.application" | ||
const val kotlin = "kotlin-android" | ||
const val library = "com.android.library" | ||
|
||
const val kotlin = "kotlin-android" | ||
const val kotlinKapt = "kotlin-kapt" | ||
const val kotlinParcelize = "kotlin-parcelize" | ||
const val daggerPlugin = "dagger.hilt.android.plugin" | ||
|
||
const val jetbrains = "org.jetbrains.kotlin.android" | ||
const val jetbrainsJvm = "org.jetbrains.kotlin.jvm" | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
object Version { | ||
// const val ANDROID = "8.0.0-alpha11" | ||
// const val JETBRAINS = "1.8.0" | ||
const val KOTLINX_COROUTINES = "1.6.0" | ||
// AndroidX | ||
const val APP_COMPAT = "1.4.1" | ||
const val MATERIAL = "1.5.0" | ||
const val CONSTRAINT_LAYOUT = "2.1.3" | ||
|
||
// KTX | ||
const val CORE = "1.7.0" | ||
|
||
// TEST | ||
const val JUNIT = "1.1.3" | ||
|
||
// Android Test | ||
const val ESPRESSO_CORE = "3.4.0" | ||
|
||
const val ANDROID = "7.4.0" | ||
const val JETBRAINS = "1.7.21" | ||
|
||
const val NAVIGATION = "2.4.2" | ||
|
||
const val FRAGMENT = "1.5.5" | ||
|
||
const val ROOM = "2.4.3" | ||
const val RUNTIME = "2.5.1" | ||
const val VIEWMODEL = "2.5.1" | ||
|
||
const val HILT = "2.44" | ||
} |
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
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
35 changes: 35 additions & 0 deletions
35
presentation/src/main/java/co/dasa/dasarang/base/BaseActivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package co.dasa.dasarang.base | ||
|
||
import android.os.Bundle | ||
import androidx.annotation.LayoutRes | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
import co.dasa.dasarang.BR | ||
|
||
abstract class BaseActivity<B : ViewDataBinding, VM : BaseViewModel>( | ||
@LayoutRes private val layoutRes: Int | ||
) : AppCompatActivity() { | ||
|
||
protected lateinit var binding: B | ||
protected abstract val viewModel: VM | ||
|
||
protected abstract fun start() | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
prepareDataBinding() | ||
start() | ||
} | ||
|
||
private fun prepareDataBinding() { | ||
binding = DataBindingUtil.setContentView(this, layoutRes) | ||
binding.setVariable(BR.vm, viewModel) | ||
binding.lifecycleOwner = this | ||
binding.executePendingBindings() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
if (::binding.isInitialized) binding.unbind() | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
presentation/src/main/java/co/dasa/dasarang/base/BaseFragment.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package co.dasa.dasarang.base | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.annotation.LayoutRes | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
import androidx.fragment.app.Fragment | ||
import co.dasa.dasarang.features.main.activity.MainActivity | ||
import co.dasa.dasarang.BR | ||
|
||
abstract class BaseFragment<B : ViewDataBinding, VM : BaseViewModel>( | ||
@LayoutRes private val layoutRes: Int | ||
) : Fragment() { | ||
|
||
protected lateinit var binding: B | ||
protected abstract val viewModel: VM | ||
protected open val hasBottomNavigation: Boolean = false | ||
|
||
protected abstract fun start() | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View? { | ||
binding = DataBindingUtil.inflate(inflater, layoutRes, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
prepareDataBinding() | ||
(activity as? MainActivity)?.setNavVisible(hasBottomNavigation) | ||
start() | ||
} | ||
|
||
private fun prepareDataBinding() { | ||
binding.setVariable(BR.vm, viewModel) | ||
binding.lifecycleOwner = this | ||
binding.executePendingBindings() | ||
} | ||
|
||
override fun onDestroy() { | ||
super.onDestroy() | ||
if (::binding.isInitialized) binding.unbind() | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
presentation/src/main/java/co/dasa/dasarang/base/BaseListAdapter.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package co.dasa.dasarang.base | ||
|
||
import androidx.annotation.LayoutRes | ||
import androidx.databinding.ViewDataBinding | ||
import androidx.recyclerview.widget.DiffUtil | ||
import androidx.recyclerview.widget.ListAdapter | ||
import androidx.recyclerview.widget.RecyclerView | ||
|
||
abstract class BaseListAdapter<T, B : ViewDataBinding>( | ||
@LayoutRes private val itemLayoutRes: Int, | ||
diffUtil: DiffUtil.ItemCallback<T> | ||
) : ListAdapter<T, BaseListAdapter<T, B>.BaseViewHolder>(diffUtil) { | ||
|
||
abstract fun action(item: T, binding: B) | ||
|
||
inner class BaseViewHolder(private val binding: B) : RecyclerView.ViewHolder(binding.root) { | ||
fun bind(item: T) { | ||
action(item, binding) | ||
} | ||
} | ||
|
||
override fun onBindViewHolder(holder: BaseViewHolder, position: Int) { | ||
return holder.bind(getItem(position)) | ||
} | ||
} |
Empty file.
12 changes: 12 additions & 0 deletions
12
presentation/src/main/java/co/dasa/dasarang/extensions/LifecycleExtension.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package co.dasa.dasarang.extensions | ||
|
||
import androidx.lifecycle.Lifecycle | ||
import androidx.lifecycle.LifecycleOwner | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.lifecycle.repeatOnLifecycle | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.launch | ||
|
||
fun LifecycleOwner.repeatOnStarted(block: suspend CoroutineScope.() -> Unit) = lifecycleScope.launch { | ||
lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED, block) | ||
} |
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
29 changes: 29 additions & 0 deletions
29
presentation/src/main/java/co/dasa/dasarang/features/plaza/fragment/PlazaFragment.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package co.dasa.dasarang.features.plaza.fragment | ||
|
||
import android.widget.Toast | ||
import androidx.fragment.app.viewModels | ||
import co.dasa.dasarang.R | ||
import co.dasa.dasarang.base.BaseFragment | ||
import co.dasa.dasarang.databinding.FragmentPlazaBinding | ||
import co.dasa.dasarang.extensions.repeatOnStarted | ||
import co.dasa.dasarang.features.plaza.viewmodel.PlazaViewModel | ||
import dagger.hilt.android.AndroidEntryPoint | ||
|
||
@AndroidEntryPoint | ||
class PlazaFragment : BaseFragment<FragmentPlazaBinding, PlazaViewModel>(R.layout.fragment_plaza) { | ||
|
||
override val viewModel: PlazaViewModel by viewModels() | ||
override val hasBottomNavigation: Boolean = true | ||
|
||
override fun start() { | ||
repeatOnStarted { | ||
viewModel.eventFlow.collect { event -> handleEvent(event) } | ||
} | ||
} | ||
|
||
private fun handleEvent(event: PlazaViewModel.Event) { | ||
when (event) { | ||
is PlazaViewModel.Event.ShowToast -> Toast.makeText(requireContext(), event.text, Toast.LENGTH_SHORT).show() | ||
} | ||
} | ||
} |
Oops, something went wrong.