Skip to content

Commit

Permalink
UPDATE: sample app, readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vipulasri committed Oct 21, 2018
1 parent 2c3794f commit 5059c67
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ For information : checkout [Sample App Code](https://github.com/vipulasri/Ticket

``` gradle
dependencies {
compile 'com.vipulasri:ticketview:1.0.5'
compile 'com.vipulasri:ticketview:1.0.7'
}
```

Expand Down
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android {
applicationId "com.vipulasri.ticketview.sample"
minSdkVersion versions.minSdk
targetSdkVersion versions.targetSdk
versionCode 3
versionCode 4
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import kotlinx.android.synthetic.main.item_corner_options.*

class MainActivity : BaseActivity() {

private lateinit var mBottomSheetBehavior: BottomSheetBehavior<View>

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
Expand All @@ -54,17 +56,17 @@ class MainActivity : BaseActivity() {


private fun initOptionsBottomSheet() {
val behavior = BottomSheetBehavior.from<View>(bottomSheet)
mBottomSheetBehavior = BottomSheetBehavior.from<View>(bottomSheet)

view_options_header.setOnClickListener({
if (behavior!!.state == BottomSheetBehavior.STATE_COLLAPSED) {
behavior.state = BottomSheetBehavior.STATE_EXPANDED
view_options_header.setOnClickListener {
if (mBottomSheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) {
mBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
} else {
behavior.state = BottomSheetBehavior.STATE_COLLAPSED
mBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
}
})
}

behavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
mBottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(@NonNull bottomSheet: View, newState: Int) {
when(newState) {
BottomSheetBehavior.STATE_COLLAPSED -> image_toggle.setImageResource(R.drawable.ic_expand_less_black_24dp)
Expand All @@ -89,21 +91,21 @@ class MainActivity : BaseActivity() {
TicketView.Orientation.VERTICAL -> radioButton_vertical.isChecked = true
}

radioGroup_orientation.setOnCheckedChangeListener(RadioGroup.OnCheckedChangeListener { group, checkedId ->
radioGroup_orientation.setOnCheckedChangeListener { group, checkedId ->
when(checkedId) {
R.id.radioButton_horizontal -> ticketView.orientation = TicketView.Orientation.HORIZONTAL
R.id.radioButton_vertical -> ticketView.orientation = TicketView.Orientation.VERTICAL
else -> {
ticketView.orientation = TicketView.Orientation.HORIZONTAL
}
}
})
}

//background properties

image_background_color.setOnClickListener({
image_background_color.setOnClickListener {
showColorPicker(ticketView.backgroundColor, image_background_color)
})
}

seekBar_elevation.setOnProgressChangeListener(progressChangeListener)

Expand All @@ -128,28 +130,28 @@ class MainActivity : BaseActivity() {

ticketView.isShowBorder = false
checkbox_show_border.isChecked = false
checkbox_show_border.setOnCheckedChangeListener({ compoundButton, checked ->
checkbox_show_border.setOnCheckedChangeListener { compoundButton, checked ->
ticketView.isShowBorder = checked
})
}

seekBar_border_width.progress = Utils.pxToDp(ticketView.borderWidth.toFloat(), this)
seekBar_border_width.setOnProgressChangeListener(progressChangeListener)

image_border_color.setOnClickListener({
image_border_color.setOnClickListener {
showColorPicker(ticketView.borderColor, image_border_color)
})
}

//divider properties

ticketView.isShowDivider = true
checkbox_show_divider.isChecked = true
checkbox_show_divider.setOnCheckedChangeListener({ compoundButton, checked ->
checkbox_show_divider.setOnCheckedChangeListener { compoundButton, checked ->
ticketView.isShowDivider = checked
})
}

image_divider_color.setOnClickListener({
image_divider_color.setOnClickListener {
showColorPicker(ticketView.dividerColor, image_divider_color)
})
}

spinner_divider_type.setSelection(1)
spinner_divider_type.onItemSelectedListener = object : OnItemSelectedListener {
Expand Down Expand Up @@ -213,7 +215,7 @@ class MainActivity : BaseActivity() {
.setSelectedColor(selectedColor)
.setDismissOnColorSelected(true)
.setOutlineWidth(1)
.setOnColorSelectedListener({ positiveResult, color ->
.setOnColorSelectedListener { positiveResult, color ->
if (positiveResult) {
colorView.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP)

Expand All @@ -227,7 +229,7 @@ class MainActivity : BaseActivity() {
}

}
}).build().show(supportFragmentManager, "ColorPicker")
}.build().show(supportFragmentManager, "ColorPicker")
}

private var progressChangeListener: DiscreteSeekBar.OnProgressChangeListener = object : DiscreteSeekBar.OnProgressChangeListener {
Expand Down Expand Up @@ -256,4 +258,12 @@ class MainActivity : BaseActivity() {

}
}

override fun onBackPressed() {
if(mBottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) {
mBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
} else {
super.onBackPressed()
}
}
}

0 comments on commit 5059c67

Please sign in to comment.