Skip to content
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
1 change: 1 addition & 0 deletions powerspinner/api/powerspinner.api
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public final class com/skydoves/powerspinner/PowerSpinnerView : androidx/appcomp
public final fun getSpinnerPopupMaxHeight ()I
public final fun getSpinnerPopupWidth ()I
public final fun getSpinnerRecyclerView ()Landroidx/recyclerview/widget/RecyclerView;
public final fun getSpinnerWindow ()Landroid/widget/PopupWindow;
public final fun isShowing ()Z
public final fun notifyItemSelected (ILjava/lang/CharSequence;)V
public fun onDestroy (Landroidx/lifecycle/LifecycleOwner;)V
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Designed and developed by 2019 skydoves (Jaewoong Eum)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.skydoves.powerspinner

internal data class PowerSpinnerPaddings constructor(
var top: Int = 0,
var start: Int = 0,
var end: Int = 0,
var bottom: Int = 0
)
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class PowerSpinnerView : AppCompatTextView, DefaultLifecycleObserver {
PowerspinnerLayoutBodyBinding.inflate(LayoutInflater.from(context), null, false)

/** PopupWindow for creating the spinner. */
private val spinnerWindow: PopupWindow
public val spinnerWindow: PopupWindow

/** Spinner is showing or not. */
public var isShowing: Boolean = false
Expand All @@ -76,6 +76,9 @@ public class PowerSpinnerView : AppCompatTextView, DefaultLifecycleObserver {
/** An adapter for composing items of the spinner. */
private var adapter: PowerSpinnerInterface<*> = DefaultSpinnerAdapter(this)

/** A padding values for the content of the spinner. */
private val padding: PowerSpinnerPaddings = PowerSpinnerPaddings()

/** The arrow will be animated or not when show and dismiss the spinner. */
public var arrowAnimate: Boolean = true

Expand Down Expand Up @@ -342,6 +345,36 @@ public class PowerSpinnerView : AppCompatTextView, DefaultLifecycleObserver {
}
}

if (hasValue(R.styleable.PowerSpinnerView_spinner_popup_top_padding)) {
padding.top =
getDimensionPixelSize(R.styleable.PowerSpinnerView_spinner_popup_top_padding, 0)
}

if (hasValue(R.styleable.PowerSpinnerView_spinner_popup_end_padding)) {
padding.end =
getDimensionPixelSize(R.styleable.PowerSpinnerView_spinner_popup_end_padding, 0)
}

if (hasValue(R.styleable.PowerSpinnerView_spinner_popup_bottom_padding)) {
padding.bottom =
getDimensionPixelSize(R.styleable.PowerSpinnerView_spinner_popup_bottom_padding, 0)
}

if (hasValue(R.styleable.PowerSpinnerView_spinner_popup_start_padding)) {
padding.start =
getDimensionPixelSize(R.styleable.PowerSpinnerView_spinner_popup_start_padding, 0)
}

if (hasValue(R.styleable.PowerSpinnerView_spinner_popup_padding)) {
val value = getDimensionPixelSize(R.styleable.PowerSpinnerView_spinner_popup_padding, 0)
padding.apply {
top = value
end = value
bottom = value
start = value
}
}

if (hasValue(R.styleable.PowerSpinnerView_spinner_arrow_padding)) {
_arrowPadding =
getDimensionPixelSize(R.styleable.PowerSpinnerView_spinner_arrow_padding, _arrowPadding)
Expand Down Expand Up @@ -516,17 +549,12 @@ public class PowerSpinnerView : AppCompatTextView, DefaultLifecycleObserver {
}
}
binding.body.apply {
if ([email protected] == null) {
background = [email protected]
background = if ([email protected] == null) {
[email protected]
} else {
background = [email protected]
[email protected]
}
setPadding(
this.paddingLeft,
this.paddingTop,
this.paddingRight,
this.paddingBottom
)
setPaddingRelative(padding.start, padding.top, padding.end, padding.bottom)
if ([email protected]) {
val decoration = DividerItemDecoration(context, DividerItemDecoration.VERTICAL)
val shape = GradientDrawable().apply {
Expand Down
10 changes: 10 additions & 0 deletions powerspinner/src/main/res/values/attrs_powerspinner.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
<attr name="spinner_popup_height" format="dimension" />
<!-- Sets the max height of the popup. -->
<attr name="spinner_popup_max_height" format="dimension" />
<!-- Sets the top padding of the popup. -->
<attr name="spinner_popup_top_padding" format="dimension" />
<!-- Sets the end padding of the popup. -->
<attr name="spinner_popup_end_padding" format="dimension" />
<!-- Sets the bottom padding of the popup. -->
<attr name="spinner_popup_bottom_padding" format="dimension" />
<!-- Sets the left padding of the popup. -->
<attr name="spinner_popup_start_padding" format="dimension" />
<!-- Sets the paddings of the popup. -->
<attr name="spinner_popup_padding" format="dimension" />
<!-- Sets a fixed item height of the popup. -->
<attr name="spinner_item_height" format="dimension" />
<!-- Sets the elevation size of the popup. -->
Expand Down
5 changes: 5 additions & 0 deletions powerspinner/src/main/res/values/public.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<public name="spinner_popup_animation_style" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_width" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_height" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_top_padding" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_end_padding" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_bottom_padding" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_left_padding" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_padding" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_max_height" type="attr" tools:ignore="ResourceName" />
<public name="spinner_item_height" type="attr" tools:ignore="ResourceName" />
<public name="spinner_popup_elevation" type="attr" tools:ignore="ResourceName" />
Expand Down