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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ List<String> options = Arrays.asList(getResources().getStringArray(R.array.month

PickerUISettings pickerUISettings = new PickerUISettings.Builder()
.withItems(options)
.withPopupLocation(PickerUISettings.POPUP_AT_BOTTOM)
.withBackgroundColor(getRandomColor())
.withAutoDismiss(true)
.withItemsClickables(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ public void onClick(View v) {

int randomColor = -1;

if(mRandomColor.isChecked()){
if (mRandomColor.isChecked()) {
randomColor = getRandomColor();
}

PickerUISettings pickerUISettings =
new PickerUISettings.Builder().withItems(options)
.withBackgroundColor(randomColor)
.withAutoDismiss(mAutoDismiss.isChecked())
.withItemsClickables(
mItemsClickables.isChecked())
.withUseBlur(mUseBlur.isChecked())
.build();
.withPopupLocation(PickerUISettings.POPUP_AT_BOTTOM)
.withBackgroundColor(randomColor)
.withAutoDismiss(mAutoDismiss.isChecked())
.withItemsClickables(
mItemsClickables.isChecked())
.withUseBlur(mUseBlur.isChecked())
.build();

mPickerUI.setSettings(pickerUISettings);

if(currentPosition==-1) {
if (currentPosition == -1) {
mPickerUI.slide();
}
else{
} else {
mPickerUI.slide(currentPosition);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class PickerUI extends RelativeLayout implements PickerUIBlurHelper.BlurF

private static final String LOG_TAG = PickerUI.class.getSimpleName();

private boolean autoDismiss = PickerUISettings.DEFAULT_AUTO_DISMISS;
private boolean autoDismiss = PickerUISettings.DEFAULT_AUTO_DISMISS;
private boolean itemsClickables = PickerUISettings.DEFAULT_ITEMS_CLICKABLES;

private PickerUIItemClickListener mPickerUIListener;
Expand All @@ -55,6 +55,7 @@ public class PickerUI extends RelativeLayout implements PickerUIBlurHelper.BlurF
private int colorLines;
private int mColorTextCenterListView;
private int mColorTextNoCenterListView;
private int mPopupLocation;
private PickerUISettings mPickerUISettings;

/**
Expand Down Expand Up @@ -120,6 +121,21 @@ private void createView(AttributeSet attrs) {
mPickerUIBlurHelper.setBlurFinishedListener(this);
}

/**
* Set view popupLocation
*/
private void setViewPopupLocation(int popupLocation) {
RelativeLayout hidePanel = (RelativeLayout) findViewById(R.id.hidden_panel);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) hidePanel.getLayoutParams();
if (popupLocation == PickerUISettings.POPUP_AT_BOTTOM) {
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
hidePanel.setLayoutParams(params);
} else if (popupLocation == PickerUISettings.POPUP_AT_TOP) {
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
hidePanel.setLayoutParams(params);
}
}

/**
* Retrieve styles attributes
*/
Expand All @@ -144,7 +160,8 @@ private void getAttributes(AttributeSet attrs) {
mColorTextNoCenterListView = typedArray
.getColor(R.styleable.PickerUI_textNoCenterColor,
getResources().getColor(R.color.text_no_center_pickerui));

mPopupLocation = typedArray.getInteger(R.styleable.PickerUI_popupLocation, PickerUISettings.POPUP_AT_UNSPECIFIED);
setViewPopupLocation(mPopupLocation);
int idItems;
idItems = typedArray.getResourceId(R.styleable.PickerUI_entries, -1);
if (idItems != -1) {
Expand Down Expand Up @@ -361,7 +378,7 @@ public void setUseRenderScript(boolean useRenderScript) {

/**
* Apply custom down scale factor
*
* <p/>
* By default down scale factor is set to {@link PickerUIBlur#MIN_DOWNSCALE}
*
* @param downScaleFactor Factor customized down scale factor, must be at least 1.0
Expand All @@ -374,7 +391,7 @@ public void setDownScaleFactor(float downScaleFactor) {

/**
* Select your preferred blur radius to apply
*
* <p/>
* By default blur radius is set to {@link PickerUIBlur#MIN_BLUR_RADIUS}
*
* @param radius The radius to blur the image, radius must be at least 1
Expand Down Expand Up @@ -501,7 +518,7 @@ public void setOnClickItemPickerUIListener(final PickerUIItemClickListener liste
new PickerUIListView.PickerUIItemClickListener() {
@Override
public void onItemClickItemPickerUI(int which, int position,
String valueResult) {
String valueResult) {
if (autoDismiss) {
slide(position);
}
Expand Down Expand Up @@ -534,6 +551,7 @@ public void setSettings(PickerUISettings pickerUISettings) {
setBlurRadius(pickerUISettings.getBlurRadius());
setDownScaleFactor(pickerUISettings.getBlurDownScaleFactor());
setFilterColor(pickerUISettings.getBlurFilterColor());
setViewPopupLocation(pickerUISettings.getPopupLocation());
}

/**
Expand Down Expand Up @@ -561,7 +579,7 @@ public void onRestoreInstanceState(Parcelable state) {
Bundle bundle = (Bundle) state;
//load everything
PickerUISettings pickerUISettings = bundle.getParcelable("stateSettings");
if(pickerUISettings!=null){
if (pickerUISettings != null) {
setSettings(pickerUISettings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ public PickerUISettings[] newArray(int size) {
private int mBlurFilterColor;
private boolean mUseBlur;
private boolean mUseBlurRenderscript;
private int mPopupLocation;
public static int POPUP_AT_BOTTOM = 1;
public static int POPUP_AT_TOP = 2;
public static int POPUP_AT_UNSPECIFIED = 0;

private PickerUISettings(Builder builder) {
setItems(builder.mItems);
setPopupLocation(builder.mPopupLocation);
setColorTextCenter(builder.mColorTextCenter);
setColorTextNoCenter(builder.mColorTextNoCenter);
setBackgroundColor(builder.mBackgroundColor);
Expand Down Expand Up @@ -94,6 +99,14 @@ void setItems(List<String> items) {
mItems = items;
}

public int getPopupLocation() {
return mPopupLocation;
}

public void setPopupLocation(int mPopupLocation) {
this.mPopupLocation = mPopupLocation;
}

public int getColorTextCenter() {
return mColorTextCenter;
}
Expand Down Expand Up @@ -182,6 +195,7 @@ void setBlurFilterColor(int blurFilterColor) {
mBlurFilterColor = blurFilterColor;
}


@Override
public int describeContents() {
return 0;
Expand All @@ -206,17 +220,18 @@ public void writeToParcel(Parcel dest, int flags) {
public static final class Builder {

private List<String> mItems;
private int mColorTextCenter = R.color.text_center_pickerui;
private int mColorTextNoCenter = R.color.text_no_center_pickerui;
private int mBackgroundColor = R.color.background_panel_pickerui;
private int mLinesColor = R.color.lines_panel_pickerui;
private boolean mUseBlur = PickerUIBlur.DEFAULT_USE_BLUR;
private boolean mUseBlurRenderscript = PickerUIBlur.DEFAULT_USE_BLUR_RENDERSCRIPT;
private boolean mItemsClickables = DEFAULT_ITEMS_CLICKABLES;
private float mDownScaleFactor = PickerUIBlur.DEFAULT_DOWNSCALE_FACTOR;
private int mRadius = PickerUIBlur.DEFAULT_BLUR_RADIUS;
private boolean mAutoDismiss = DEFAULT_AUTO_DISMISS;
private int mFilterColor = -1;
private int mColorTextCenter = R.color.text_center_pickerui;
private int mColorTextNoCenter = R.color.text_no_center_pickerui;
private int mBackgroundColor = R.color.background_panel_pickerui;
private int mLinesColor = R.color.lines_panel_pickerui;
private boolean mUseBlur = PickerUIBlur.DEFAULT_USE_BLUR;
private boolean mUseBlurRenderscript = PickerUIBlur.DEFAULT_USE_BLUR_RENDERSCRIPT;
private boolean mItemsClickables = DEFAULT_ITEMS_CLICKABLES;
private float mDownScaleFactor = PickerUIBlur.DEFAULT_DOWNSCALE_FACTOR;
private int mRadius = PickerUIBlur.DEFAULT_BLUR_RADIUS;
private boolean mAutoDismiss = DEFAULT_AUTO_DISMISS;
private int mFilterColor = -1;
private int mPopupLocation = 0;

public Builder() {
}
Expand All @@ -231,6 +246,11 @@ public Builder withItems(List<String> mItems) {
return this;
}

public Builder withPopupLocation(int mPopupLocation){
this.mPopupLocation = mPopupLocation;
return this;
}

public Builder withColorTextCenter(int mColorTextCenter) {
this.mColorTextCenter = mColorTextCenter;
return this;
Expand Down
1 change: 0 additions & 1 deletion library/src/main/res/layout/pickerui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
android:layout_width="match_parent"
android:layout_height="@dimen/height_hidden_panel_pickerui"
android:visibility="gone"
android:layout_alignParentBottom="true"
android:background="@drawable/container_dropshadow"
android:animateLayoutChanges="true"
tools:visibility="visible"
Expand Down
29 changes: 17 additions & 12 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@
<resources>
<declare-styleable name="PickerUI">
<!-- to use in PickerUI in the panel -->
<attr name="backgroundColor" format="color"/>
<attr name="linesCenterColor" format="color"/>
<attr name="backgroundColor" format="color"/>
<attr name="linesCenterColor" format="color"/>
<attr name="popupLocation" format="enum">
<enum name="bottom" value="1"/>
<enum name="unspecified" value="0"/>
<enum name="top" value="2"/>
</attr>

<!-- to use in PickerUIListView -->
<attr name="autoDismiss" format="boolean"/>
<attr name="itemsClickables" format="boolean"/>
<attr name="entries" format="reference"/>
<attr name="autoDismiss" format="boolean"/>
<attr name="itemsClickables" format="boolean"/>
<attr name="entries" format="reference"/>

<!-- to use in PickerUI in the PickerUIListView by PickerUIAdapter -->
<attr name="textCenterColor" format="color"/>
<attr name="textNoCenterColor" format="color"/>
<attr name="textCenterColor" format="color"/>
<attr name="textNoCenterColor" format="color"/>

<!-- Blur Attributes -->
<attr name="blur" format="boolean"/>
<attr name="blur_downScaleFactor" format="float"/>
<attr name="blur_FilterColor" format="color"/>
<attr name="blur_radius" format="integer"/>
<attr name="blur_use_renderscript" format="boolean"/>
<attr name="blur" format="boolean"/>
<attr name="blur_downScaleFactor" format="float"/>
<attr name="blur_FilterColor" format="color"/>
<attr name="blur_radius" format="integer"/>
<attr name="blur_use_renderscript" format="boolean"/>

</declare-styleable>
</resources>