MCPcopy Index your code
hub / github.com/clemp6r/futuroid

github.com/clemp6r/futuroid @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
60 symbols 142 edges 9 files 22 documented · 37% updated 10y agov0.3.0 · 2014-05-17★ 621 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Futuroid - Android library for asynchronous tasks

Futuroid is an Android library that allows running asynchronous tasks and attaching callbacks thanks to a convenient syntax. It offers an alternative to the Android AsyncTask class.

Features

  • Future-based API (similar to Guava's ListenableFutures, Scala/Akka Futures, Javascript promises...)
  • Allows registering callbacks to be run on the Android UI/main thread
  • Provides a default ExecutorService (fixed thread pool with 5 threads) that can be replaced by a custom one
  • Each task can be run on the default ExecutorService or on a custom one
  • Allows task chaining (monad-style)

Sample code

Image download asynchronous service:

public class DownloadService {

    /**
     * Downloads an image asynchronously.
     */
    public Future<Bitmap> downloadImage(String url) {
        return Async.submit(new Callable<Bitmap>() {
            @Override
            public Bitmap call() {
                Bitmap bitmap;

                // HTTP request goes here...

                return bitmap;
            }
        });
    }
}

Client code:

// download an image from a URL
imageService.downloadImage(url).addCallback(new FutureCallback<Bitmap>() {
    @Override
    public void onSuccess(Bitmap bitmap) {
        // display the image
        imageView.setImageBitmap(bitmap);
    }

    @Override
    public void onFailure(Throwable t) {
        Log.e(TAG, "Unable to download image", t);
    }
});

Adding Futuroid to your project

Futuroid is available on the Maven Central Repository.

Maven-based configuration:

<dependency>
    <groupId>com.github.clemp6r.futuroid</groupId>
    <artifactId>futuroid</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle-based configuration:

dependencies {
    compile 'com.github.clemp6r.futuroid:futuroid:1.0.0'
}

Links

API documentation

Extension points exported contracts — how you extend this code

AsyncFunction (Interface)
A function that returns a Future. Typically used by Future#map(AsyncFunction). [3 implementers]
src/main/java/com/github/clemp6r/futuroid/AsyncFunction.java
FutureCallback (Interface)
A callback for accepting the results of a com.github.clemp6r.futuroid.Future computation asynchronously. [2 implementers]
src/main/java/com/github/clemp6r/futuroid/FutureCallback.java
FailureCallback (Interface)
A Future failure callback. See Future#addFailureCallback(FailureCallback) or {@link Future#addFailureCallback(Fa [2 implementers]
src/main/java/com/github/clemp6r/futuroid/FailureCallback.java
SuccessCallback (Interface)
A Future success callback. See Future#addSuccessCallback(SuccessCallback) or {@link Future#addSuccessCallback(Su [2 implementers]
src/main/java/com/github/clemp6r/futuroid/SuccessCallback.java
Future (Interface)
A Future represents the result of an asynchronous computation. It is returned by {@link com.github.clemp6r.futuroid.Asyn [1 …
src/main/java/com/github/clemp6r/futuroid/Future.java

Core symbols most depended-on inside this repo

from
called by 5
src/main/java/com/github/clemp6r/futuroid/FutureImpl.java
map
called by 5
src/main/java/com/github/clemp6r/futuroid/Future.java
immediate
called by 4
src/main/java/com/github/clemp6r/futuroid/Async.java
addCallback
called by 3
src/main/java/com/github/clemp6r/futuroid/Future.java
addCallback
called by 2
src/main/java/com/github/clemp6r/futuroid/FutureImpl.java
toGuavaFuture
called by 2
src/main/java/com/github/clemp6r/futuroid/FutureImpl.java
toFutureCallback
called by 2
src/main/java/com/github/clemp6r/futuroid/FutureImpl.java
onSuccess
called by 2
src/main/java/com/github/clemp6r/futuroid/FutureCallback.java

Shape

Method 50
Class 5
Interface 5

Languages

Java100%

Modules by API surface

src/test/java/com/github/clemp6r/futuroid/AsyncTest.java18 symbols
src/main/java/com/github/clemp6r/futuroid/FutureImpl.java16 symbols
src/main/java/com/github/clemp6r/futuroid/Async.java8 symbols
src/main/java/com/github/clemp6r/futuroid/Future.java6 symbols
src/main/java/com/github/clemp6r/futuroid/MainThreadExecutor.java3 symbols
src/main/java/com/github/clemp6r/futuroid/FutureCallback.java3 symbols
src/main/java/com/github/clemp6r/futuroid/SuccessCallback.java2 symbols
src/main/java/com/github/clemp6r/futuroid/FailureCallback.java2 symbols
src/main/java/com/github/clemp6r/futuroid/AsyncFunction.java2 symbols

For agents

$ claude mcp add futuroid \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page