rayzone107 / SegmentedProgressBar

Segmented Progress Bar allows you to create progress bars with Segments.
https://www.rachitgoyal.com
6 stars 4 forks source link

can we have doubles instead of only integers ? #1

Open RawanHamad opened 6 years ago

RawanHamad commented 6 years ago

Hello Ray, great library , but I'm wondering if we can have list of doubles as values not only integers. to represent 1.5 and so on ?

rayzone107 commented 6 years ago

Hi Rawan,

Thats a great question, however my recommendation would be to increase the max value in that case.

So, for example, instead of setting a max value of 10, and progressing in bunch's of 1, you could set a max value of 100 and progress in a bunch of 10's. In this case, if you want to set a value of 1.5/10, you could use 15/100.

Thanks and Regards, Rachit Goyal

On Tue, 14 Aug 2018, 7:20 pm Rawan Hamad, notifications@github.com wrote:

Hello Ray, great library , but I'm wondering if we can have list of doubles as values not only integers. to represent 1.5 and so on ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebLTNP45dTTN_1sP83Vh_RDYbDa7aks5uQtWrgaJpZM4V8eaU .

RawanHamad commented 6 years ago

so it's doable using your library ? what do you mean by max value ? the divisions ?

rayzone107 commented 6 years ago

Yes, this can be done using my library.

So, for starters, there is a property of the view called "divisions". This property defines the maximum number of divisions. You can set it as below within the XML (bold line):

<com.rachitgoyal.segmented.SegmentedProgressBar android:id="@+id/segmented_progress_bar" android:layout_width="match_parent" android:layout_height="10dp"

Or you could set it programmatically as below:

SegmentedProgressBar spb = findViewById(R.id.segmented_progress_bar);

    spb.setDivisions(100);

Now that your maximum divisions are defined, it's a simple matter of enabling the divisions you want.

So say suppose you want to enable the first 1.5 divisions out of 10, you can set them programmatically like below:

spb.setEnabledDivisions(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15));

But the true power of the library is that it allows you to enable non-contiguous sections of the progress bar.

So you don't have to enable the sections in a sequential order. You just have to maintain a list of values, and only the sections that you want enabled.

So for instance, if you wanted to enable sections 3, 6, 8 and 9, you could do it like below:

spb.setEnabledDivisions(Arrays.asList(3, 6, 8, 9));

The above code would only enable the above sections, and the rest would remain disabled.

I hope I was able to explain it properly. If you have any further questions, feel free to ask me anytime.

Thanks and Regards, Rachit Goyal

On Tue, Aug 14, 2018 at 7:33 PM Rawan Hamad notifications@github.com wrote:

so it's doable using your library ? what do you mean by max value ? the divisions ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1#issuecomment-412882893, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebEGZUk3NJBSobKtweIg1YA9SYkXFks5uQtiogaJpZM4V8eaU .

RawanHamad commented 6 years ago

I see I see , but using that way, it will no longer shows the divisions , it will not be segmented right ?

rayzone107 commented 6 years ago

Yes yes, it can be.

That totally depends on which sections you enable.

Instead of enabling the 1 to 15 divisions, you can enable any set of sections.

For example, if you want the 3rd and half of the 5th section to be enabled, you can put values 30 - 40 and 50 - 55 in your enabled list. The logic at the end is just which sections you enable and how.

On Tue, 14 Aug 2018, 7:47 pm Rawan Hamad, notifications@github.com wrote:

I see I see , but using that way, it will no longer shows the divisions , it will not be segmented right ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1#issuecomment-412887753, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebG8X9F99ktFfMrKH1nWsN4JC7OjRks5uQtwHgaJpZM4V8eaU .

RawanHamad commented 6 years ago

sorry for bothering, but I don't seem to get your answers , can we see an example together, for example I want the bar to have 10 division , and I want to highlight 6.5

how can I implement it :)

rayzone107 commented 6 years ago

Ok, I'll give you the code for that, but what do you mean by enabling 6.5?

Do you mean like enabling sections from 1 to 6 and half of the 7th section?

On Tue, 14 Aug 2018, 8:00 pm Rawan Hamad, notifications@github.com wrote:

sorry for bothering, but I don't seem to get your answers , can we see an example together, for example I want the bar to have 10 division , and I want to highlight 6.5

how can I implement it :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1#issuecomment-412891999, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebA9Et4xG0obLg48JX5bELLsxImsiks5uQt7ugaJpZM4V8eaU .

RawanHamad commented 6 years ago

screenshot_2018-08-14-17-30-56

RawanHamad commented 6 years ago

I want it like this for example

screen shot 2018-08-14 at 5 35 10 pm

rayzone107 commented 6 years ago

I think there is some confusion in how the library functions.

Let me explain, this library is like a normal android progress bar, with the added benefit that you can enable and disable any segment.

How an android progress bar works is that you give it a max value and a progress value. So for example, if you set the max value as 10 and the current progress as 4, the progress bar would be created in such a way that the first 40% of it would be enabled, while the last 60% would be disabled.

In my library, however, you have the added benefit that the sections don't have to be enabled sequentially and can be enabled in any order. So for instance, if you wanted a progress bar where there are 10 sections but you want the 3rd and 6th section to be enabled, you can do that with this library.

Does that help?

On Tue, 14 Aug 2018, 8:03 pm Rachit Goyal, rachitgoy@gmail.com wrote:

Ok, I'll give you the code for that, but what do you mean by enabling 6.5?

Do you mean like enabling sections from 1 to 6 and half of the 7th section?

On Tue, 14 Aug 2018, 8:00 pm Rawan Hamad, notifications@github.com wrote:

sorry for bothering, but I don't seem to get your answers , can we see an example together, for example I want the bar to have 10 division , and I want to highlight 6.5

how can I implement it :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1#issuecomment-412891999, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebA9Et4xG0obLg48JX5bELLsxImsiks5uQt7ugaJpZM4V8eaU .

RawanHamad commented 6 years ago

so we can't achieve the above result using this library ?

rayzone107 commented 6 years ago

Ok, so this can't be done using my library yet. Let me see if I can do some work on this when I get some time.

Otherwise, you can fork my library and try and update the code yourself. I've no problems with that.

On Tue, 14 Aug 2018, 8:06 pm Rawan Hamad, notifications@github.com wrote:

I want it like this for example

[image: screen shot 2018-08-14 at 5 35 10 pm] https://user-images.githubusercontent.com/7834987/44098286-774dd430-9fe8-11e8-924b-6dd4711cd8aa.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1#issuecomment-412894181, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebBBfahDWY3QZHD194TB-nL8xvDZfks5uQuBOgaJpZM4V8eaU .

RawanHamad commented 6 years ago

thanks for your time and quick responses.

rayzone107 commented 6 years ago

Not a problem buddy. If I do update the library, I'll let you know.

On Tue, 14 Aug 2018, 8:12 pm Rawan Hamad, notifications@github.com wrote:

thanks for your time and quick responses.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rayzone107/SegmentedProgressBar/issues/1#issuecomment-412896519, or mute the thread https://github.com/notifications/unsubscribe-auth/AGcebJLGkv-RZiVErsMR2O8fNKGHwW04ks5uQuHYgaJpZM4V8eaU .