Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,91 +12,91 @@ import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

findViewById<View>(R.id.showDialogButton).setOnClickListener { v -> showDialogPlus() }
}

private fun showDialogPlus() {
val holderId = holderRadioGroup.checkedRadioButtonId
val showHeader = headerCheckBox.isChecked
val showFooter = footerCheckBox.isChecked
val fixedHeader = fixedHeaderCheckBox.isChecked
val fixedFooter = fixedFooterCheckBox.isChecked
val expanded = expandedCheckBox.isChecked
val gravity: Int = when (positionRadioGroup!!.checkedRadioButtonId) {
R.id.topPosition -> Gravity.TOP
R.id.centerPosition -> Gravity.CENTER
else -> Gravity.BOTTOM
findViewById<View>(R.id.showDialogButton).setOnClickListener { v -> showDialogPlus() }
}

val isGrid: Boolean
val holder: Holder
when (holderId) {
R.id.basic_holder_radio_button -> {
holder = ViewHolder(R.layout.content)
isGrid = false
}
R.id.list_holder_radio_button -> {
holder = ListHolder()
isGrid = false
}
else -> {
holder = GridHolder(3)
isGrid = true
}
}
private fun showDialogPlus() {
val holderId = holderRadioGroup.checkedRadioButtonId
val showHeader = headerCheckBox.isChecked
val showFooter = footerCheckBox.isChecked
val fixedHeader = fixedHeaderCheckBox.isChecked
val fixedFooter = fixedFooterCheckBox.isChecked
val expanded = expandedCheckBox.isChecked
val gravity: Int = when (positionRadioGroup!!.checkedRadioButtonId) {
R.id.topPosition -> Gravity.TOP
R.id.centerPosition -> Gravity.CENTER
else -> Gravity.BOTTOM
}

val adapter = SimpleAdapter(this@MainActivity, isGrid, listCountInput.text.toString().toInt())
val builder = DialogPlus.newDialog(this).apply {
setContentHolder(holder)
val isGrid: Boolean
val holder: Holder
when (holderId) {
R.id.basic_holder_radio_button -> {
holder = ViewHolder(R.layout.content)
isGrid = false
}
R.id.list_holder_radio_button -> {
holder = ListHolder()
isGrid = false
}
else -> {
holder = GridHolder(3)
isGrid = true
}
}

val header = if (showHeader) R.layout.header else -1
if (header != -1) {
setHeader(R.layout.header, fixedHeader)
}
val adapter = SimpleAdapter(this@MainActivity, isGrid, listCountInput.text.toString().toInt())
val builder = DialogPlus.newDialog(this).apply {
setContentHolder(holder)

val footer = if (showFooter) R.layout.footer else -1
if (footer != -1) {
setFooter(R.layout.footer, fixedFooter)
}
val header = if (showHeader) R.layout.header else -1
if (header != -1) {
setHeader(R.layout.header, fixedHeader)
}

setCancelable(true)
setGravity(gravity)
setAdapter(adapter)
setOnClickListener { dialog, view ->
if (view is TextView) {
toast(view.text.toString())
}
}
setOnItemClickListener { dialog, item, view, position ->
val textView = view.findViewById<TextView>(R.id.text_view)
toast(textView.text.toString())
}
// .setOnDismissListener(dismissListener)
setExpanded(expanded)
val footer = if (showFooter) R.layout.footer else -1
if (footer != -1) {
setFooter(R.layout.footer, fixedFooter)
}
setShouldRequestFocus(true)
setCancelable(true)
setGravity(gravity)
setAdapter(adapter)
setOnClickListener { dialog, view ->
if (view is TextView) {
toast(view.text.toString())
}
}
setOnItemClickListener { dialog, item, view, position ->
val textView = view.findViewById<TextView>(R.id.text_view)
toast(textView.text.toString())
}
// .setOnDismissListener(dismissListener)
setExpanded(expanded)

if (contentHeightInput.text.toString().toInt() != -1) {
setContentHeight(contentHeightInput.text.toString().toInt())
} else {
setContentHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
}
if (contentHeightInput.text.toString().toInt() != -1) {
setContentHeight(contentHeightInput.text.toString().toInt())
} else {
setContentHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
}

if (contentWidthInput.text.toString().toInt() != -1) {
setContentWidth(800)
}
if (contentWidthInput.text.toString().toInt() != -1) {
setContentWidth(800)
}

setOnCancelListener { dialog -> toast("cancelled") }
setOverlayBackgroundResource(android.R.color.transparent)
// .setContentBackgroundResource(R.drawable.corner_background)
// .setOutMostMargin(0, 100, 0, 0)
setOnCancelListener { dialog -> toast("cancelled") }
setOverlayBackgroundResource(android.R.color.transparent)
// .setContentBackgroundResource(R.drawable.corner_background)
// .setOutMostMargin(0, 100, 0, 0)
}
builder.create().show()
}
builder.create().show()
}

private fun toast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
private fun toast(message: String) {
Toast.makeText(this, message, Toast.LENGTH_SHORT).show()
}
}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
buildscript {
ext.kotlin_version = '1.2.51'
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down Expand Up @@ -54,7 +54,7 @@ ext {
ext.deps = [
junit : 'junit:junit:4.12',
truth : 'com.google.truth:truth:0.28',
robolectric : 'org.robolectric:robolectric:3.3',
robolectric : 'org.robolectric:robolectric:4.3.1',
mockito : "org.mockito:mockito-core:2.8.9",
supportAnnotations: 'androidx.annotation:annotation:1.0.0',
kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Expand Down
Loading