Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seekbar with variable Max #49

Closed
XxGoliathusxX opened this issue Apr 4, 2016 · 13 comments
Closed

Seekbar with variable Max #49

XxGoliathusxX opened this issue Apr 4, 2016 · 13 comments

Comments

@XxGoliathusxX
Copy link

In my app the seekbar's Max is variable. For example: The current max is 4, and after pressing a button it shall be 5. I tried invalidate() but that didnt work. How can I do that?

@XxGoliathusxX XxGoliathusxX changed the title Seek Seekbar with variable Max Apr 4, 2016
@qiujuer
Copy link
Owner

qiujuer commented Apr 5, 2016

Thank you feedback. I will check it.

@qiujuer
Copy link
Owner

qiujuer commented Apr 5, 2016

In my test:

        SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
        seekBar.setMax(3);
        seekBar.setMin(1);
        // we try change progress to 0 value
        seekBar.setProgress(0);
        // the progress < min value, so progress auto change to 1 value

        findViewById(R.id.opt).setOnClickListener(new View.OnClickListener() {
            int optCount = 0;

            @Override
            public void onClick(View v) {
                SeekBar seekBar = (SeekBar) findViewById(R.id.seekBar);
                Log.e(MainActivity.this.getClass().getName(),
                        String.format("Before: progress:%s max:%s min:%s", seekBar.getProgress(), seekBar.getMax(), seekBar.getMin()));

                int progress = seekBar.getProgress();
                Log.e(MainActivity.this.getClass().getName(),
                        String.format("Running: try change progress:%s to %s, optCount:%s", progress, ++progress, ++optCount));

                seekBar.setProgress(progress);

                Log.e(MainActivity.this.getClass().getName(),
                        String.format("After: progress:%s max:%s min:%s", seekBar.getProgress(), seekBar.getMax(), seekBar.getMin()));

                // if onclick count > 10
                // we will change the SeekBar max value
                if (optCount == 5) {
                    Log.e(MainActivity.this.getClass().getName(), "Change SeekBar max value to 10.");
                    seekBar.setMax(10);
                    // in this, the SeekBar not refresh progress bar
                    // ....

                    // if you need refresh the widget, you can call
                    seekBar.setProgress(seekBar.getProgress());
                    // or wait me update the SeekBar widget, I fixed quickly
                }
            }
        });

This is bug, I will fix it.

qiujuer added a commit that referenced this issue Apr 5, 2016
@XxGoliathusxX
Copy link
Author

When will there be an update?

@qiujuer
Copy link
Owner

qiujuer commented Apr 5, 2016

Now, you can set compile 'net.qiujuer.genius:ui:1.5.1' to use new version.

@XxGoliathusxX
Copy link
Author

Thanks a lot!!!

@XxGoliathusxX
Copy link
Author

How can I refresh the view the best way?

@qiujuer
Copy link
Owner

qiujuer commented Apr 6, 2016

In ui:1.5.1 , the view will auto refresh the draw on call setMax() or setMin().
If you only call invalidate() , the view will refresh draw; but the draw parameters not correct.

The view have some logical operations on call setMax() or setMin().

@XxGoliathusxX
Copy link
Author

It doesnt work for me. I think it has something to do with genius:gAllowTrackClickToDrag="false".

@XxGoliathusxX
Copy link
Author

Here is my code:

 <net.qiujuer.genius.ui.widget.SeekBar
        android:id="@+id/seekBarSatz"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="@dimen/custom_margin_left_and_right"
        android:layout_marginRight="@dimen/custom_margin_left_and_right"
        android:layout_marginEnd="@dimen/custom_margin_left_and_right"
        android:layout_marginStart="@dimen/custom_margin_left_and_right"
        genius:gAllowTrackClickToDrag="false"
        genius:gIndicator="auto"
        genius:gIndicatorBackgroundColor="@color/primary_dark"
        genius:gIndicatorSeparation="30dp"
        genius:gIndicatorTextAppearance="@style/Genius.Widget.BalloonMarker.TextAppearance"
        genius:gRippleColor="@color/primary_light"
        genius:gScrubberColor="@color/primary_light"
        genius:gScrubberStroke="4dp"
        genius:gThumbColor="@color/primary_dark"
        genius:gThumbSize="6dp"
        genius:gTickSize="5dp"
        genius:gTouchSize="12dp"
        genius:gTrackColor="@color/grey_light"
        genius:gTrackStroke="2dp" />
 seekBarSatz = (SeekBar) findViewById(R.id.seekBarSatz);
        seekBarSatz.setMin(1);
        if(parents.get(0).getChildItemList() == null){
           seekBarSatz.setMax(1);
        }else{
            seekBarSatz.setMax(parents.get(0).getChildItemList().size());
        }

void next(View v){ //This is called by a button
if(child != null){
            seekBarSatz.setMax(parent.getChildItemList().size());
        }else{
            seekBarSatz.setMax(1);
        }}

@qiujuer
Copy link
Owner

qiujuer commented Apr 7, 2016

Oh, ok I know. I will test it. Thanks.

@qiujuer
Copy link
Owner

qiujuer commented Apr 7, 2016

Now you can try to use compile 'net.qiujuer.genius:ui:1.5.2' version.

@XxGoliathusxX
Copy link
Author

Now it works. Thx a lot!

@qiujuer
Copy link
Owner

qiujuer commented Apr 8, 2016

You’re welcome!

qiujuer added a commit that referenced this issue Apr 8, 2016
@qiujuer qiujuer closed this as completed Apr 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants