spierce7
04/12/2018, 6:16 PMChris Margonis
04/13/2018, 10:26 AMradityagumay
04/15/2018, 3:44 PM<https://kotlinlang.org/docs/reference/coding-conventions.html>
they desire to make class layout looks like this.
Property declarations and initializer blocks
Secondary constructors
Method declarations
Companion object
in other hand google also have they own style guide. here <https://android.github.io/kotlin-guides/style.html>
in google style guide, they are not mention about class layout. this weird but, that the truth. so, i came along to find what googler
did in they project structure.
so, i found this. <https://github.com/googlesamples/android-architecture-components/blob/master/PagingSample/app/src/main/java/paging/android/example/com/pagingsample/CheeseViewModel.kt>
^ this sample from google sample architecture component
by yigit boyar and team.
This quite difference. but, i think structure from yigit much better.
as we have difference for this structure. we came over with this structure.
class LifeIncrementScreen @JvmOverloads constructor(context: Context,
attributeSet: AttributeSet? = null,
defStyle: Int = 0,
val componentType: String? = null) :
LifeBaseScreen<LifeIncrementScreenPresenter.View, LifeIncrementScreenPresenter>(context, attributeSet, defStyle),
LifeIncrementScreenPresenter.View,
LifeOptionInfoActionListener {
init {
LayoutInflater.from(context).inflate(R.layout.component_incremental, this, true)
}
private var isAttached = false
private var hasSelectedItem = false
private var title by Delegates.notNull<String>()
private var increment: List<LifeIncrementItem>? = null
private lateinit var listener: MandatoryListener
private lateinit var adapter: LifeAdapter<LifeIncrementItem, LifeIncrementViewHolder>
override fun onAttachedToWindow() {}
override fun onDetachedFromWindow() {}
override fun setupInjection() {}
override fun setupEvent() {}
override fun setupView() {}
override fun setupData() {}
override fun onLoadIncrement(title: String, increment: List<LifeIncrementItem>) {}
override fun onProductSelectedFromInfo(position: Int) {}
@Subscribe
fun lifeScreenStateEvent(event: BusStateMachine.LifeScreenState) {}
private fun setupInfoDialog(position: Int, imageUrl: String?, name: String?, price: String?,
description: String?) {}
private fun setOnClickListener(adapter: LifeAdapter<LifeIncrementItem,LifeIncrementViewHolder>, holder: LifeIncrementViewHolder) {}
private fun precondition() {}
}
radityagumay
04/15/2018, 3:45 PM