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

Add feature: label show up on non user value changes. #12

Open
armata99 opened this issue Mar 26, 2020 · 14 comments
Open

Add feature: label show up on non user value changes. #12

armata99 opened this issue Mar 26, 2020 · 14 comments

Comments

@armata99
Copy link

Hi.
It will be very nice if You add modes for label such as showing up on setting values from code (like
when attaching it to scroll listeners) or showing up when pressed.
Let me know how are Your thoughts on this.

@hearsilent
Copy link
Owner

Hi @someAndroidDeveloper
So you want setting value from code, showing the value label? Maybe 3s?

@armata99
Copy link
Author

Yes but I think 1.5s would be optimum for it, or its much better if you define a setter for that too.
The other thing came to my mind on this subject is that You setting these modes as flags so people can combine the attributes like this example Im giving:

app:ds_labelMode="showOnPressHold | showOnProgressChange"

These are the two which Im looking for, You may like to add hidden or other behaviors as well.
Its gonna give Your code a good advantage.

@hearsilent
Copy link
Owner

@someAndroidDeveloper I've released new version 1.2.0, you can try now!

@armata99
Copy link
Author

armata99 commented Apr 10, 2020

@hearsilent I've got it running.

-the duration is ok.
-show on press hold not working
-and for the other option this happens.
sample

FYI: currently it's on showOnPressHold | showOnProgressChange or the mode 3 according to Your tutorial. I tried them in both xml and java, got same results.
You can also use a secondary seekbar to trigger the one you testing, just in case you wondering ;)

@hearsilent
Copy link
Owner

@someAndroidDeveloper Can you provide sample code to reproduce this?

@armata99
Copy link
Author

armata99 commented Apr 15, 2020

@hearsilent Sure, here is the simplest way. I tried to simulate the value change using a secondary slider:

XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    tools:context=".MainActivity">

    <hearsilent.discreteslider.DiscreteSlider
        android:id="@+id/main_slider"
        android:layout_width="wrap_content"
        android:layout_height="470dp"
        android:layout_gravity="center_vertical"
        app:ds_inactiveTrackColor="#D3D3D3"
        app:ds_orientation="vertical"
        app:ds_thumbColor="@color/colorPrimary"
        app:ds_thumbPressedColor="#1F089CF7"
        app:ds_thumbRadius="9dp"
        app:ds_trackColor="#D3D3D3"
        app:ds_valueLabelDuration="2500"
        app:ds_valueLabelMode="showOnProgressChange|showOnPressHold" />

    <hearsilent.discreteslider.DiscreteSlider
        android:id="@+id/test_slider"
        android:layout_width="wrap_content"
        android:layout_height="470dp"
        android:layout_gravity="center_vertical|end"
        app:ds_inactiveTrackColor="#D3D3D3"
        app:ds_orientation="vertical"
        app:ds_thumbColor="@color/colorPrimary"
        app:ds_thumbPressedColor="#1F089CF7"
        app:ds_thumbRadius="9dp"
        app:ds_trackColor="#D3D3D3"
        app:ds_valueLabelMode="none" />
</FrameLayout>

and the Java:

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import hearsilent.discreteslider.DiscreteSlider;

public class MainActivity extends AppCompatActivity{

    private DiscreteSlider mainSlider,testSlider;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mainSlider=findViewById(R.id.main_slider);
        testSlider=findViewById(R.id.test_slider);

        mainSlider.setCount(200);
        testSlider.setCount(200);
        mainSlider.setMinProgress(1);
        testSlider.setMinProgress(1);

        testSlider.setOnValueChangedListener(sliderListener);
    }

    private DiscreteSlider.OnValueChangedListener sliderListener=new DiscreteSlider.OnValueChangedListener(){
        @Override
        public void onValueChanged(int progress, boolean fromUser) {
            super.onValueChanged(progress, fromUser);
            mainSlider.setProgress(progress);
            Log.d("slider change: ","value: "+progress);
        }
    };
}

and again the result:

Screenshot_1586948736

The listener you have provided gets called once you release the thumb so make sure to drag it at least twice to see what I see.

@hearsilent
Copy link
Owner

@someAndroidDeveloper I've fixed this issue, and release the version 1.2.1.

@armata99
Copy link
Author

@hearsilent
It works good for me.
About the other option: it's still not working.
The current issue is the bubble should show up when you hold the thumb (not dragging it) but it doesn't till You drag it for a bit.

@hearsilent
Copy link
Owner

@someAndroidDeveloper You can call setValueChangedImmediately(true) when setup slider.

@armata99
Copy link
Author

@hearsilent I called it before setting the listener as You mentioned in docs
unfortunately it didn't work.

@hearsilent
Copy link
Owner

@someAndroidDeveloper It's must be called in right slider (Your touching slider)

@armata99
Copy link
Author

@hearsilent I understand it, and I did so. but the thing that I suspect is me explaining what I mean incorrectly.
Can You please tell me the simple logic behind the label popup so I could figure out whats missing?

@hearsilent
Copy link
Owner

@someAndroidDeveloper Only can sync by step now. I'll try to implement method to provide sync immediately.

@armata99
Copy link
Author

@hearsilent so far so good. I'll be waiting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants