blob: 04d3496715dc3b98e3e7b1a3ce7a074fac49de21 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package de.danoeh.antennapod.asynctask;
import android.content.Context;
import android.util.Log;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.storage.DBWriter;
import de.danoeh.antennapod.util.flattr.FlattrUtils;
import org.shredzone.flattr4j.exception.FlattrException;
import org.shredzone.flattr4j.model.Flattr;
import java.util.List;
import java.util.concurrent.ExecutionException;
/**
* Fetch list of flattred things and flattr status in database in a background thread.
*/
public class FlattrStatusFetcher extends Thread {
protected static final String TAG = "FlattrStatusFetcher";
protected Context context;
public FlattrStatusFetcher(Context context) {
super();
this.context = context;
}
@Override
public void run() {
if (BuildConfig.DEBUG) Log.d(TAG, "Starting background work: Retrieving Flattr status");
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
try {
List<Flattr> flattredThings = FlattrUtils.retrieveFlattredThings();
DBWriter.setFlattredStatus(context, flattredThings).get();
} catch (FlattrException e) {
e.printStackTrace();
Log.d(TAG, "flattrQueue exception retrieving list with flattred items " + e.getMessage());
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
if (BuildConfig.DEBUG) Log.d(TAG, "Finished background work: Retrieved Flattr status");
}
}
|