infinum android talks #05 - square tape

Post on 06-Jul-2015

430 Views

Category:

Technology

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

Tape is a collection of queue-related classes for Android and Java by Square, Inc. We'll show you how to create tasks that can be paused and resumed later if the application crashes, connectivity is lost or even if the battery is drained out.

TRANSCRIPT

Square TapeIvan Kocijan

What is the problem?• Application is uploading files on our server

but Internet connection is gone or the phone is suddenly turned off !

What to do? • Can we continue? • Where to continue? • How to save our progress?

Using Square tape• Collection of queue-related classes for

Android and Java • File-based FIFO. • Created by Square, Inc.

What do you need• Add it to build.gradle

compile 'com.squareup:tape:1.2.+' • Create 4 java classes and 1 interface:

1. GsonConverter 2. TapeCallback 3. Tape task 4. TapeTaskQueue 5. TapeService

GsonConverter• Convert objects to and from JSON so that

they can be written on disk in human readable format

TapeCallback• Interface which we will use to indicate that

task is successfully finished and can be removed from Queue

TapeTask• Task which will be added to Queue for

execution

TapeTaskQueue• Queue which holds our tasks • It will take care of serialization and

deserialization of our tasks

TapeService• It will start when there are tasks in our

Queue and end when Queue is empty or there was an error

Find out more• http://square.github.io/tape/

Questions?

?

top related