An open API service indexing awesome lists of open source software.

https://github.com/transloadit/android-sdk

Transloadit's official Android SDK
https://github.com/transloadit/android-sdk

Last synced: 9 months ago
JSON representation

Transloadit's official Android SDK

Awesome Lists containing this project

README

          

[![CI](https://github.com/transloadit/android-sdk/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/transloadit/android-sdk/actions/workflows/CI.yml)

# android-sdk

An **Android** Integration for [Transloadit](https://transloadit.com)'s file uploading and encoding service

## Intro

[Transloadit](https://transloadit.com) is a service that helps you handle file uploads, resize, crop and watermark your images, make GIFs, transcode your videos, extract thumbnails, generate audio waveforms, and so much more. In short, [Transloadit](https://transloadit.com) is the Swiss Army Knife for your files.

This is an **Android** SDK to make it easy to talk to the [Transloadit](https://transloadit.com) REST API.

## Install

The JARs can be downloaded manually from [Maven Central](https://search.maven.org/artifact/com.transloadit.android.sdk/transloadit-android).

**Gradle:**

```groovy
implementation 'com.transloadit.android.sdk:transloadit-android:0.0.10'
```

**Maven:**

```xml

com.transloadit.android.sdk
transloadit-android
0.0.10

```

## Usage

All interactions with the SDK begin with the `com.transloadit.android.sdk.Transloadit` class.

### Create an Assembly

To create an assembly, you use the `newAssembly` method.

To use this functionality in it's full glory, you need implement the `AssemblyProgressListener`
interface.

```java

public class MyAssemblyProgressListener implements AssemblyProgressListener {
@Override
public void onUploadFinished() {
System.out.println("upload finished!!! waiting for execution ...");
}

@Override
public void onUploadProgress(long uploadedBytes, long totalBytes) {
System.out.println("uploaded: " + uploadedBytes + " of: " + totalBytes);
}

@Override
public void onAssemblyFinished(AssemblyResponse response) {
System.out.println("Assembly finished with status: " + response.json().getString("ok"));
}

@Override
public void onUploadFailed(Exception exception) {
System.out.println("upload failed :(");
exception.printStackTrace();
}

@Override
public void onAssemblyStatusUpdateFailed(Exception exception) {
System.out.println("unable to fetch status update :(");
exception.printStackTrace();
}
}

```

And in your activity you can have something like this

```java
public class MainActivity extends AppCompatActivity {
private ProgressBar progressBar;

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

progressBar = (ProgressBar) findViewById(R.id.progressBar);

AssemblyProgressListener listener = new MyAssemblyProgressListener();

AndroidTransloadit transloadit = new AndroidTransloadit("key", "secret");
AndroidAsyncAssembly assembly = transloadit.newAssembly(listener);
assembly.addFile(new File("path/to/file.jpg"), "file");

Map stepOptions = new HashMap<>();
stepOptions.put("width", 75);
stepOptions.put("height", 75);
stepOptions.put("resize_strategy", "pad");
assembly.addStep("resize", "/image/resize", stepOptions);

assembly.save();
}
}

```

## Example

For fully working examples take a look at [examples/](https://github.com/transloadit/android-sdk/tree/main/examples).

## Documentation

See [Javadoc](https://javadoc.io/doc/com.transloadit.android.sdk/transloadit-android/latest/index.html) for full API documentation.

## License

[The MIT License](LICENSE).