Giter Club home page Giter Club logo

pickview's Introduction

Android Arsenal

DEPRECATED

PickView

This is a helper lib for us to pick date or province like IOS system WheelView widget.

Added feature to pick time with WheelView Widget

Here is date pick effect by gif

picker

How to use

Add more custom attributes, Just see below version 1.1.1

       
      DatePickerPopWin pickerPopWin = new DatePickerPopWin.Builder(MainActivity.this, new DatePickerPopWin.OnDatePickedListener() {
                       @Override
                       public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
                           Toast.makeText(MainActivity.this, dateDesc, Toast.LENGTH_SHORT).show();
                       }
                    }).textConfirm("CONFIRM") //text of confirm button
                           .textCancel("CANCEL") //text of cancel button
                           .btnTextSize(16) // button text size
                           .viewTextSize(25) // pick view text size
                           .colorCancel(Color.parseColor("#999999")) //color of cancel button
                           .colorConfirm(Color.parseColor("#009900"))//color of confirm button
                           .minYear(1990) //min year in loop
                           .maxYear(2550) // max year in loop
                           .showDayMonthYear(true) // shows like dd mm yyyy (default is false) 
                           .dateChose("2013-11-11") // date chose when init popwindow
                           .build();
   

About LoopView

in version 1.2.0+,can use LoopView like:

   
       <com.bruce.pickerview.LoopView
           android:id="@+id/loop_view"
           android:layout_width="200dp"
           android:layout_height="180dp"
           android:layout_below="@+id/demo"
           app:canLoop="true"
           app:centerTextColor="#ff000000"
           app:drawItemCount="7" <!-- must be odd number -->
           app:initPosition="3"
           app:lineColor="@color/colorPrimary"
           app:textSize="25sp"
           app:topBottomTextColor="#ffafafaf"/>
           
           
        loopView = (LoopView) findViewById(R.id.loop_view);
               loopView.setInitPosition(2);
               loopView.setCanLoop(false);
               loopView.setLoopListener(new LoopScrollListener() {
                   @Override
                   public void onItemSelect(int item) {
                       
                   }
               });
               loopView.setTextSize(25);//must be called before setDateList
               loopView.setDataList(getList());    

TimePicker

   

       
      TimePickerPopWin timePickerPopWin=new TimePickerPopWin.Builder(MainActivity.this, new       TimePickerPopWin.OnTimePickListener() {
                 @Override
                 public void onTimePickCompleted(int hour, int minute, String AM_PM, String time) {
                     Toast.makeText(MainActivity.this, time, Toast.LENGTH_SHORT).show();
                 }
             }).textConfirm("CONFIRM")
                     .textCancel("CANCEL")
                     .btnTextSize(16)
                     .viewTextSize(25)
                     .colorCancel(Color.parseColor("#999999"))
                     .colorConfirm(Color.parseColor("#009900"))
                     .build();
             timePickerPopWin.showPopWin(MainActivity.this);
   

Dependencies

   compile 'com.brucetoo.pickview:library:1.2.3'
 

TODO

  • add Province pick PopWindow (if i have time)

  • add to Jcenter (Wait Jcenter manager verify)


THANKS

androidWheelView

License

Copyright 2015 - 2016 Bruce too

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.

See LICENSE file for details.

pickview's People

Contributors

brucetoo avatar bryant1410 avatar pedrofsn avatar pmathew92 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pickview's Issues

Month in Words?

Is there any setting to display month in words? like 01 - January ?

TimePickerPopWin cannot resolve the class.

I need to implement time picker same like this. but this show errors while importing that TimepickerPopWin cannot resolve the class.
Please tell me the reason , i need to implement this in our project

setInitPosition not working properly

Hello,
After successfully set list and setInitPosition properly, but some time i want to show different item position on loopview, than how to do it, i am trying to setInitPosition after button click but cant find solutions i dont know how to do it !

If you know than, how to clear past data on loopview and update new data?

算法

你好,你的日期计算没及时更新

错误的年月

先选择2017年3月31,点确定了以后,再选择日期,日不变,月选为2月,竟然出现了2017年2月31号,日期明显错了

首次点击弹窗空白页,无显示默认数据

在个别手机上出现空白页,不显示默认数据,例如 在华为P10上就是这样,有时候点击打开弹窗显示默认数据,有时候不显示默认数据,随机的,不知道什么时候显示默认数据,什么时候不显示

LoopView not working inside NestedScrollView

I am trying to implement loop view in a layout having a collapsible toolbar layout in the app bar and has nested scroll view as parent view.For some reason, loopview is not working inside the nested scroll view.Can you help with it

当数据list改变,通过setInitPosition和setDataList会导致位置混乱

作者你好,通过setDataList,setInitPosition方法重置数据和位置会导致位置混乱,发现决定绘制在中间的值为 mCurrentIndex = mInitPosition + mChangingItem % mDataList.size();混乱的原因就在mChangingItem ,该值大小为int mChangingItem = (int) (mTotalScrollY / (mItemHeight));从设置数据后mTotalScrollY 并没有还原,所以导致mChangingItem 不正确,所以建议作者在setDataList将mTotalScrollY 置0,暂时不知道这样改会不会引起其他的位置bug

Day loopview invalidate problem when month loopview scrolling

Hi,
There is a problem that i figure it out. When i try to scroll month loopview sometimes day loopview doesn't protect its position on ui layer. On the other words, ui is updated some position, but the initial position is different.

Can you help me this situation or Did you encounter this issue?

Textsize is different after convert number month to date format

I have converted number month to date format (with MMMM). But after that it is showing wired textsize for month and also separator line doesn't match with other day and year view,

// converting MM to MMMM

public String formatMonth(String month) { String formated_month = ""; SimpleDateFormat monthParse = new SimpleDateFormat("MM"); SimpleDateFormat monthDisplay = new SimpleDateFormat("MMMM"); try { formated_month = monthDisplay.format(monthParse.parse(month)); } catch (ParseException e) { e.printStackTrace(); } return formated_month; }

Also i want to apply custom font to all.

screenshot_2017-10-13-13-39-27

style attribute '@android:attr/windowEnterAnimation' not found

我项目相关的配置:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip

classpath 'com.android.tools.build:gradle:3.0.0-alpha6'

compile_sdk_version = 25
build_tools_version = "26.0.0"

报错信息:

style attribute '@android:attr/windowEnterAnimation' not found
style attribute '@android:attr/windowExitAnimation' not found

相关代码:

<style name="FadeInPopWin">
    <item name="android:backgroundDimEnabled">true</item>
    <item name="@android:windowEnterAnimation">@anim/pop_win_content_fade_in</item>
    <item name="@android:windowExitAnimation">@anim/pop_win_content_fade_out</item>
</style>

Crash on new update

Hello,
I have spent 4 hours for an issue when use this library with Android studio.
It was updated on 2016-07-09, that make LoopView constructor direct call to @TargetApi(Build.VERSION_CODES.LOLLIPOP)
public LoopView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {...}
All my devices below android 5.0 are crash, with exception about inflate layout.
You can use 1.1.1 to avoid this problem or wait a new update.

Random ClassCastException in DatePickerPopWin.java

I got this exception the other day while playing and turning the device while testing my application.

03-01 10:06:15.484 12478-12478/? E/Bebler$1[uncaughtException] - 152: java.lang.RuntimeException: Unable to resume activity
 {com.bebler.app/com.bebler.app.activity.Registration}: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.Button                                                                          at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3019)                                                                          
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3050)                                                                          
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2425)                                                                          
at android.app.ActivityThread.access$900(ActivityThread.java:154)                                                                          
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)                                                                          
at android.os.Handler.dispatchMessage(Handler.java:102)                                                                          
at android.os.Looper.loop(Looper.java:135)                                                                          
at android.app.ActivityThread.main(ActivityThread.java:5294)                                                                          
at java.lang.reflect.Method.invoke(Native Method)                                                                          
at java.lang.reflect.Method.invoke(Method.java:372)                                                                          
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)                                                                          
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)                                                                       
Caused by: java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.Button                                                                          
at com.bruce.pickerview.popwindow.DatePickerPopWin.initView(DatePickerPopWin.java:163)                                                                          
at com.bruce.pickerview.popwindow.DatePickerPopWin.<init>(DatePickerPopWin.java:154)                                                                          
at com.bruce.pickerview.popwindow.DatePickerPopWin$Builder.build(DatePickerPopWin.java:138)                                                                          
at com.bebler.app.activity.fragment.YourName.initialize(YourName.java:182)                                                                          
at com.bebler.app.activity.fragment.YourName.onCreateView(YourName.java:67)                                                                          
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1962)                                                                          
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1067)                                                                          
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)                                                                          
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:738)                                                                          
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)                                                                          
at android.support.v4.app.FragmentController.execPendingActions(FragmentController.java:330)                                                                          
at android.support.v4.app.FragmentActivity.onPostResume(FragmentActivity.java:452)                                                                          
at android.support.v7.app.AppCompatActivity.onPostResume(AppCompatActivity.java:141)                                                                          
at android.app.Activity.performResume(Activity.java:6089)                                                                          
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3008)                                                                          
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3050)                                                                           
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2425)                                                                           
at android.app.ActivityThread.access$900(ActivityThread.java:154)                                                                           
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)                                                                           
at android.os.Handler.dispatchMessage(Handler.java:102)                                                                           
at android.os.Looper.loop(Looper.java:135)                                                                           
at android.app.ActivityThread.main(ActivityThread.java:5294)                                                                           
at java.lang.reflect.Method.invoke(Native Method)                                                                           
at java.lang.reflect.Method.invoke(Method.java:372)                                                                          
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)                                                                           
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 

bug

when i set the app:drawItemCount to more then 7, then the centerText will in incorrect position.I'm trying to fix this bug, if i fixed ,can you merge my code?

LoopView:因List内无元素,便没有setDataList,滑动LoopView区域,会有异常(传入无元素List也会有异常);

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.util.ArrayList.size()' on a null object reference
at com.bruce.pickerview.LoopView$LoopViewGestureListener.onScroll(LoopView.java:433)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:611)
at com.bruce.pickerview.LoopView.onTouchEvent(LoopView.java:334)
at android.view.View.dispatchTouchEvent(View.java:11776)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:448)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1829)
at android.app.Dialog.dispatchTouchEvent(Dialog.java:815)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:410)
at android.view.View.dispatchPointerEvent(View.java:12015)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4795)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4609)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4293)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4350)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4200)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4166)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4174)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4147)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6661)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6635)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6596)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6764)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:186)
at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:177)
at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6735)
at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6787)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:652)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

目前我在无元素时LoopView区域INVISIBLE,期待源码早日修复;

PickView is not working in Android 3.0

Hy,
I am Muhammad Umer and i am using pickview in my android studio version 3.0
but when I sync my project it show style.xml file error.
When I comment this library and sync it works fine but with this it shows error and it is shown in this attached screenshot.
Any one please help me to sort it out.

cats

How Can I set TimePicker similarly like this ?

I am using this date picker, Now I also want to use time picker with same spinwheel layout how can I set it. Please Help. also tell if there is any option for sound while moving wheel

have any better way to calculate the mMaxTextHeight

if i have 2 pickView, one is used for display Chinese year like "2016年",another is used for display the Chinese Month like "9月", i need two pickView's TopLine to keep in one line,but the two pickView 's mMaxTextHeight is diff,because of "年" and "月" 's Height is diff.So,the mTopLineY, and mBottomLineY will be diff in the two pickView. have any advice for me?

如何使LoopView恢复到初始位置

你好,我第一次使用PopupWindow弹出一个LoopView将它滑动到位置3,然后我并没有销毁这个PopupWindow,而是让它隐藏,然后我再次弹出这个PopupWindow,这时直接让它显示出来了。这时候LoopView的位置还是3,如何让它弹出时默认选中到第一个
我尝试使用下面的代码:
loopviewTime.setInitPosition(0);
loopviewTime.invalidate();
但是好像没有起到效果,能否指点下该如何做

切换不同的list

我要通过切换分钟、小时、天等选项,使用loopView保存每个滑动的list,最后会错乱,可以清除loopView的数据吗

LoopView - Does not work with dynamic values from server

LoopView is not refreshing itself:

  1. Never shows rows in loopview, when i pass a arraylist from server, after fetching it.
  2. Once i put app in background and bring it back, it shows the rows.

P.S: I tried invalidate() , postinvalidate() , recreate() . Nothing works.

Below is my code:

public void refreshcategoryloop(){
    categoryLoop = (LoopView)findViewById(R.id.categoryLoop);
    categoryView.setVisibility(View.VISIBLE);
    categoryLoop.setInitPosition(0);
    categoryLoop.setCanLoop(false);
    categoryLoop.setLoopListener(new LoopScrollListener() {
        @Override
        public void onItemSelect(int item) {

        }
    });
    categoryLoop.setTextSize(15);
    categories = new ArrayList<String>();

    for (int l = 0; l < servicesArr.length(); l++) {
        try {
            categories.add(servicesArr.getJSONObject(l).getString("Performance").toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
    categoryLoop.setDataList(categories);


}

And find attached the screenshots.
3e1cc379-a2e8-4862-88b3-4d6b0ec5c7ac
d087a820-29c0-43d5-8e17-5976e204ff4d

how could I just show only two selection

我怎么才能只显示两个选项呢?
OptionsPickerView pvGenderOption = new OptionsPickerView(mContext); ArrayList<String> genderStr = new ArrayList<>(); genderStr.add("male"); genderStr.add("female"); pvGenderOption.setCyclic(false, true, true); pvGenderOption.setPicker(genderStr); pvGenderOption.setSelectOptions(1); pvGenderOption.setOnoptionsSelectListener((options1, option2, options3) -> { String s = genderStr.get(options1); mTvGender.setText(s); }); pvGenderOption.show();
image

java.lang.ArrayIndexOutOfBoundsException: at ... at com.bruce.pickerview.LoopView.onDraw(LoopView.java:258) #81

java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
at java.util.ArrayList.get(ArrayList.java:310)
at com.bruce.pickerview.LoopView.onDraw(LoopView.java:258)

The issue is cause by the looping
if (templateItem < 0) {
templateItem = templateItem + mDataList.size();
}
if (templateItem > mDataList.size() - 1) {
templateItem = templateItem - mDataList.size();
}
// at this point the templateItem could still be a negative number if the items are really small say 2 and the number of items to be displayed is say 10, for the templateItem to be positive this would need to be looped 5 times.
itemCount[count] = (String) mDataList.get(templateItem);

// i fixed the error by adding
// if (templateItem < 0) continue; just before the itemCount[count] = ...

//It should be corrected as
if (templateItem < 0) continue; // to prevent futher looping after the first loop
itemCount[count] = (String) mDataList.get(templateItem);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.