Convert Figma logo to code with AI

frakbot logoJumpingBeans

A Span-based library to make your text jump like Mexican beans. Oh, and the "..."s in Hangouts.

1,113
197
1,113
0

Top Related Projects

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

45,699

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

23,230

A Java serialization/deserialization library to convert Java Objects into JSON and back

47,834

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

42,958

A type-safe HTTP client for Android and the JVM

18,705

A powerful image downloading and caching library for Android

Quick Overview

The frakbot/JumpingBeans repository is a Java library that provides a simple and efficient way to create "jumping bean" animations, which are small, animated elements that appear to jump or move around on a web page or application. The library is designed to be easy to use and integrate into various projects.

Pros

  • Lightweight and Efficient: The library is lightweight and efficient, making it suitable for use in performance-sensitive applications.
  • Customizable: The library provides a range of options for customizing the appearance and behavior of the jumping beans, allowing developers to create unique and engaging animations.
  • Cross-Platform Compatibility: The library is written in Java and can be used in a variety of platforms and environments, including web applications, desktop applications, and mobile apps.
  • Active Development: The project is actively maintained, with regular updates and bug fixes, ensuring that it remains up-to-date and reliable.

Cons

  • Limited Documentation: The project's documentation could be more comprehensive, which may make it more difficult for new users to get started with the library.
  • Dependency on Java: As the library is written in Java, it may not be the best choice for projects that do not use Java as their primary language.
  • Potential Performance Issues: While the library is designed to be efficient, large-scale use of jumping beans may still have a noticeable impact on performance, especially on older or less powerful devices.
  • Lack of Community Support: The project does not have a large community of users and contributors, which may limit the availability of support and resources for developers.

Code Examples

Here are a few examples of how to use the JumpingBeans library:

// Create a new JumpingBean instance
JumpingBean bean = new JumpingBean();

// Set the position of the bean
bean.setPosition(100, 100);

// Set the size of the bean
bean.setSize(50, 50);

// Set the color of the bean
bean.setColor(Color.RED);

// Start the animation
bean.start();
// Create a new JumpingBean instance with custom settings
JumpingBean bean = new JumpingBean()
    .setPosition(200, 200)
    .setSize(30, 30)
    .setColor(Color.GREEN)
    .setJumpHeight(20)
    .setJumpDuration(500)
    .setJumpDelay(100);

// Start the animation
bean.start();
// Create a group of jumping beans
JumpingBeanGroup group = new JumpingBeanGroup();

// Add beans to the group
group.addBean(new JumpingBean().setPosition(50, 50).setSize(20, 20).setColor(Color.BLUE));
group.addBean(new JumpingBean().setPosition(100, 100).setSize(20, 20).setColor(Color.YELLOW));
group.addBean(new JumpingBean().setPosition(150, 150).setSize(20, 20).setColor(Color.ORANGE));

// Start the animation for the entire group
group.start();

Getting Started

To get started with the JumpingBeans library, follow these steps:

  1. Add the library to your project's dependencies. You can do this by including the following Maven dependency in your pom.xml file:
<dependency>
    <groupId>com.frakbot</groupId>
    <artifactId>jumping-beans</artifactId>
    <version>1.1.2</version>
</dependency>
  1. Import the necessary classes from the library:
import com.frakbot.jumpingbeans.JumpingBean;
import com.frakbot.jumpingbeans.JumpingBeanGroup;
  1. Create a new JumpingBean instance and customize its properties:
JumpingBean bean = new JumpingBean()
    .setPosition(100, 100)
    .setSize(50, 50)
    .setColor(Color.RED)
    .setJumpHeight(20)
    .setJumpDuration(500)
    .setJumpDelay(100);
  1. Start the

Competitor Comparisons

😍 A beautiful, fluid, and extensible dialogs API for Kotlin & Android.

Pros of material-dialogs

  • Provides a wide range of customizable dialog types, including alert, input, and list dialogs.
  • Supports Material Design guidelines and provides a consistent user interface.
  • Offers a simple and intuitive API for creating and managing dialogs.

Cons of material-dialogs

  • May have a larger footprint in your app compared to a lightweight library like JumpingBeans.
  • Requires additional dependencies, such as the AppCompat library, which can increase the overall complexity of your project.
  • May have a steeper learning curve for developers unfamiliar with the Material Design guidelines.

Code Comparison

JumpingBeans:

JumpingBeans.with(textView)
            .makeTextJump()
            .setIsWave(true)
            .setLoopDuration(1000)
            .build();

material-dialogs:

new MaterialDialog.Builder(this)
            .title("Hello, World!")
            .content("This is a simple dialog.")
            .positiveText("OK")
            .show();
45,699

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

Pros of OkHttp

  • OkHttp is a widely-used and well-maintained HTTP client library, with a large and active community.
  • It provides a simple and efficient API for making HTTP requests, with support for features like connection pooling, caching, and interceptors.
  • OkHttp is highly performant and optimized for use in mobile and server-side applications.

Cons of OkHttp

  • OkHttp has a larger codebase and API surface area compared to JumpingBeans, which may be overkill for some use cases.
  • The learning curve for OkHttp may be steeper than for JumpingBeans, especially for developers who are new to HTTP client libraries.

Code Comparison

OkHttp:

OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
    .url("https://api.example.com/data")
    .build();
Response response = client.newCall(request).execute();

JumpingBeans:

JumpingBeans.get("https://api.example.com/data")
    .execute(new JumpingBeansCallback() {
        @Override
        public void onSuccess(String response) {
            // Handle successful response
        }

        @Override
        public void onFailure(Exception e) {
            // Handle failure
        }
    });
23,230

A Java serialization/deserialization library to convert Java Objects into JSON and back

Pros of Google/gson

  • Widely used and well-supported JSON parsing library for Java
  • Provides a simple and intuitive API for serializing and deserializing Java objects to/from JSON
  • Supports advanced features like custom serializers/deserializers, type adapters, and more

Cons of Google/gson

  • May be overkill for simple JSON parsing needs
  • Doesn't provide the same level of animation and visual effects as frakbot/JumpingBeans
  • May have a larger footprint in your application compared to a more lightweight JSON library

Code Comparison

Google/gson:

Gson gson = new Gson();
Person person = new Person("John Doe", 30);
String json = gson.toJson(person);
Person deserializedPerson = gson.fromJson(json, Person.class);

frakbot/JumpingBeans:

JumpingBeans.with(textView)
            .makeTextJump()
            .setIsWave(true)
            .setLoopDuration(1000)
            .setLoopCount(JumpingBeans.INFINITE_LOOP)
            .build();
47,834

RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.

Pros of ReactiveX/RxJava

  • Comprehensive and well-documented library for reactive programming in Java
  • Supports a wide range of operators and functionality for working with asynchronous data streams
  • Integrates well with other popular Java libraries and frameworks

Cons of ReactiveX/RxJava

  • Steeper learning curve compared to simpler libraries like JumpingBeans
  • Can be more complex to set up and configure for smaller projects
  • May introduce overhead and complexity for simple use cases

Code Comparison

JumpingBeans (frakbot/JumpingBeans):

JumpingBeans.with(textView)
            .makeText("Hello, World!")
            .setJumpingSpeed(JumpingSpeed.SLOW)
            .setJumpingHeight(JumpingHeight.HIGH)
            .setLoopDuration(2000)
            .build()
            .start();

ReactiveX/RxJava:

Observable.just("Hello, World!")
          .delay(2, TimeUnit.SECONDS)
          .subscribe(System.out::println);
42,958

A type-safe HTTP client for Android and the JVM

Pros of Retrofit

  • Retrofit is a widely-used and well-established library for making HTTP requests in Android applications, with a large and active community.
  • It provides a clean and intuitive API for defining and making API calls, with support for a variety of response types and serialization formats.
  • Retrofit is highly extensible, with a range of built-in and third-party adapters and converters available.

Cons of Retrofit

  • Retrofit may have a steeper learning curve compared to simpler HTTP client libraries, especially for developers new to Android development.
  • The library can become more complex as the number of API endpoints and request types grows, potentially leading to a more verbose and less readable codebase.
  • Retrofit may not be the best choice for very simple HTTP requests, as the overhead of the library may outweigh the benefits.

Code Comparison

Retrofit:

public interface GitHubService {
    @GET("users/{user}/repos")
    Call<List<Repository>> listRepos(@Path("user") String user);
}

GitHubService service = retrofit.create(GitHubService.class);
Call<List<Repository>> repos = service.listRepos("square");

JumpingBeans:

JumpingBeans.with(textView)
    .makeTextJump(0, 5)
    .setIsWave(true)
    .setLoopDuration(1000)
    .build();
18,705

A powerful image downloading and caching library for Android

Pros of Picasso

  • Picasso is a widely-used and well-maintained library for image loading and caching, with a large and active community.
  • It provides a simple and consistent API for loading images from various sources, including local files, URLs, and resources.
  • Picasso has built-in support for transforming and resizing images, which can be useful for optimizing image display on different devices.

Cons of Picasso

  • Picasso may be overkill for simple image loading tasks, as it includes a lot of functionality that may not be necessary for all use cases.
  • The library can be more complex to configure and customize compared to simpler image loading libraries.

Code Comparison

Picasso:

Picasso.get()
    .load("https://example.com/image.jpg")
    .into(imageView);

JumpingBeans:

JumpingBeans.with(textView)
    .makeTextJump(0, textView.length())
    .setIsWave()
    .setLoopDuration(1000)
    .build();

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

JumpingBeans icon

JumpingBeans Download

The JumpingBeans make your test jump to the eye. Literally!

What are the JumpingBeans

Have you ever used Hangouts? If not, do it and then come back here. Go. Go, I said!

Good. With that under our belt, we can be confident you've seen at least once those fancy, nice jumping suspension dots that Hangouts uses to indicate that someone is typing, or some other kind of ongoing activity (e.g., connecting to a video hangout).

Well, since there's no official naming for them, and since they remind me of the jumping Mexican beans, the name for a library that emulates their behaviour has come to be exactly that: JumpingBeans.

See them in action

Please come closer, ladies and gentlemen! Here you have, for your own amusement, the amazing JumpingBeans:

Jumping dots

Animated first word

Make your project jump around

In order to use JumpingBeans in your own project, you can use the wonderous remote dependencies capabilities that Gradle offers you (if you're not using Gradle and Android Studio/IntelliJ offer you, I'm sorry for you.) (No, I mean it, I'm really sorry for you!)

Just make sure you have jcenter() in your root build.gradle:

allprojects {
    repositories {
        jcenter()
    }
}

And then just add the JumpingBeans dependency to your module's build.gradle:

dependencies {
    compile 'net.frakbot:jumpingbeans:1.3.0'
}

What you can do

The library supports two main operation modes: appending three jumping dots, Hangouts-style, or making any arbitrary subsection of a CharSequence jump, either as a wave or as a single block.

Append jumping dots

This method takes the trailing ... (or appends them, if the given TextView's text doesn't end in three dots), and makes them jump like it was -the 70s- Hangouts.

The defaults emulate the Hangouts L&F as closely as possible, but you can easily change the animation properties to suit your needs.

Make text jumping

This method takes the specified subsection a the TextView text and animates it as to make it jump.

Usage

Just create a JumpingBeans by using its Builder and call the method you want:

// Append jumping dots
final TextView textView1 = (TextView) findViewById(R.id.jumping_text_1);
jumpingBeans1 = JumpingBeans.with(textView1)
        .appendJumpingDots()
        .build();
        
// Make the first word's letters jump
final TextView textView2 = (TextView) findViewById(R.id.jumping_text_2);
jumpingBeans2 = JumpingBeans.with(textView2)
        .makeTextJump(0, textView2.getText().toString().indexOf(' '))
        .setIsWave(false)
        .setLoopDuration(1000)  // ms
        .build();

Customising the jumpin' beans

Just act on the Builder. Don't want the dots to jump in a wave? Call setIsWave(false). Don't like the default loop duration? setLoopDuration(int) is here to help. Fancy different per-char delays in waves? Well, ya know that setWavePerCharDelay(int) is the one you want. Maybe you wanted to have a shorter pause between jumping cycles? BAM, setAnimatedDutyCycle(float) and you're all set.

Being a responsible citizen

Since Spans were not really designed to be animated, there's some trickery going on behind the scenes to make this happen. You needn't be concerned with it, but make sure you call the stopJumping() method on your JumpingBeans object whenever you stop using the TextView (it's detaching from the view tree, or the container Activity or Fragment is going in paused state, ...).

This allows a deeper cleanup than what the JumpingBeans library is trying to perform if you forget to. Don't leave stuff lying around if you can!

Also, a few caveats

Please note that you:

  • Must not try to change a jumping beans text in a textview before calling stopJumping() as to avoid unnecessary invalidation calls; the JumpingBeans class cannot know when this happens and will keep animating the textview (well, try to, anyway), wasting resources
  • Must not try to use a jumping beans text in another view; it will not animate. Just create another jumping beans animation for each new view
  • Must not use more than one JumpingBeans instance on a single TextView, as the first cleanup operation called on any of these JumpingBeans will also cleanup all other JumpingBeans' stuff. This is most likely not what you want to happen in some cases.
  • Should not use JumpingBeans on large chunks of text. Ideally this should be done on small views with just a few words. We've strived to make it as inexpensive as possible to use JumpingBeans but invalidating and possibly relayouting a large TextView can be pretty expensive.
  • Must not use JumpingBeans in conjunction with code and attributes that strip away spans or change them. This includes the deeply flawed textAllCaps.

Demo app

You can find the JumpingBeans demo app on the Google Play Store.

JumpingBeans Demo on Google Play Store

License

This library was written by Sebastiano Poggi and released by Frakbot under the Apache 2.0 License.

Please see the NOTICE file for details.