Jelly Toggle Button

Features


Min SDK : 14
Price : Free
Language : Java

 

Download


Link : Github
Owner : Nightonke
Source Code : Download

 

Usage

Gradle

dependencies {
...
compile 'com.nightonke:jellytogglebutton:1.0.2'
...
}

xml Code :

<com.nightonke.jellytogglebutton.JellyToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:jtbJelly="itself"
/>

Use in setter:

jtb.setJelly(Jelly.ITSELF);
app:jtbJelly=”” setJelly() Effect
itself ITSELF
lazy_tremble_head_fatty LAZY_TREMBLE_HEAD_FATTY
lazy_tremble_head_slim_jim LAZY_TREMBLE_HEAD_SLIM_JIM
lazy_tremble_tail_fatty LAZY_TREMBLE_TAIL_FATTY
lazy_tremble_tail_slim_jim LAZY_TREMBLE_TAIL_SLIM_JIM
lazy_tremble_body_fatty LAZY_TREMBLE_BODY_FATTY
lazy_tremble_body_slim_jim LAZY_TREMBLE_BODY_SLIM_JIM
lazy_stiff_fatty LAZY_STIFF_FATTY
lazy_stiff_slim_jim LAZY_STIFF_SLIM_JIM
active_tremble_head_fatty ACTIVE_TREMBLE_HEAD_FATTY
active_tremble_head_slim_jim ACTIVE_TREMBLE_HEAD_SLIM_JIM
active_tremble_tail_fatty ACTIVE_TREMBLE_TAIL_FATTY
active_tremble_tail_slim_jim ACTIVE_TREMBLE_TAIL_SLIM_JIM
active_tremble_body_fatty ACTIVE_TREMBLE_BODY_FATTY
active_tremble_body_slim_jim ACTIVE_TREMBLE_BODY_SLIM_JIM
active_stiff_fatty ACTIVE_STIFF_FATTY
active_stiff_slim_jim ACTIVE_STIFF_SLIM_JIM
random RANDOM All Above

Notice that random type will change the jelly among the other 17 types randomly.

 

You can define you own jelly easily. But you need sometime to understand what happens in the source code of Jelly enum. All the jelly type are the sub types of JellyStyle.class.
To extend the abstract class, you have to override 3 methods:

public class MyJelly extends JellyStyle {
@Override
public void changeShape(PointWithHorizontalPoints p1, PointWithVerticalPoints p2, PointWithHorizontalPoints p3, PointWithVerticalPoints p4, float stretchDistance, float bezierControlValue, float bezierScaleRatioValue, float thumbRadius, float process, State state) {
// Change the shape of the thumb.
// Notice that we use 12 points to form 4 bezier lines to draw the thumb.
// We can control the shape of the thumb by controling the 12 points.
}
@Override
public void changeOffset(PointWithHorizontalPoints p1, PointWithVerticalPoints p2, PointWithHorizontalPoints p3, PointWithVerticalPoints p4, float totalLength, float extractLength, float process, State state, EaseType easeType) {
// Change the offset of the thumb.
}
@Override
public float extractLength(float stretchDistance, float bezierControlValue, float bezierScaleRatioValue, float thumbRadius) {
// Return the extract length.
}
}

License :

Copyright 2016 Nightonke
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.

[/vc_column_text][/vc_column][/vc_row]