Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve addSettings method #191

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/java/ru/dgis/sdk/demo/GesturesActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class GesturesActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.addSettingsLayout().apply {
settingsDrawerInnerLayout.addView(settingsBinding.root)
binding.addSettingsLayout {
addView(settingsBinding.root)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class GesturesMapPointActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.addSettingsLayout().apply {
settingsDrawerInnerLayout.addView(settingsBinding.root)
binding.addSettingsLayout {
addView(settingsBinding.root)
}

/**
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/ru/dgis/sdk/demo/MapFpsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class MapFpsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.addSettingsLayout().apply {
settingsDrawerInnerLayout.addView(prepareSettingsListView())
binding.addSettingsLayout {
addView(prepareSettingsListView())
}

mapView.getMapAsync {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class MutuallyExclusiveGesturesActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.addSettingsLayout().apply {
settingsDrawerInnerLayout.addView(settingsBinding.root)
binding.addSettingsLayout {
addView(settingsBinding.root)
}

/**
Expand Down
9 changes: 7 additions & 2 deletions app/src/main/java/ru/dgis/sdk/demo/common/Common.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ fun MapView.updateMapCopyrightPosition(rootView: View, bottomSheet: View) {
setCopyrightMargins(0, 0, 0, rootView.height + rootView.globalY - bottomSheet.globalY)
}

// Helper method for adding BottomSheet to main layout.
fun ViewBinding.addSettingsLayout(): SettingsLayoutView {
/**
* Provides generic BottomSheet to layout. Should be used as parent layout for some useful view / layout, such as settings.
* Takes lambda as a parameter, in which child layout should be added
* @param init lambda which configures BottomSheet, adding child layout, etc
*/
fun ViewBinding.addSettingsLayout(init: ViewGroup.() -> Unit): SettingsLayoutView {
val settingsView = SettingsLayoutView(root.context)
val innerLayoutView = settingsView.findViewById<LinearLayout>(R.id.settingsDrawerInnerLayout)
(root as ViewGroup).addView(settingsView)
Expand All @@ -36,6 +40,7 @@ fun ViewBinding.addSettingsLayout(): SettingsLayoutView {
}
})
}
innerLayoutView.init()
return settingsView
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SettingsLayoutView(
defStyle: Int = 0
) : CoordinatorLayout(context, attrs, defStyle) {

val settingsDrawerInnerLayout: LinearLayout
private val settingsDrawerInnerLayout: LinearLayout
init {
inflate(context, R.layout.bottom_settings_layout, this)
settingsDrawerInnerLayout = findViewById(R.id.settingsDrawerInnerLayout)
Expand Down