This commit is contained in:
David Development 2014-11-29 20:30:44 +01:00
parent b2b4af3e29
commit a6167b4ef9
3 changed files with 11 additions and 17 deletions

View file

@ -24,11 +24,13 @@ package de.luhmer.owncloudnewsreader.helper;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;
import de.luhmer.owncloudnewsreader.services.SyncItemStateService;
public class PostDelayHandler {
private static Handler handlerTimer;
private static final String TAG = "PostDelayHandler";
private static Handler handlerTimer;
private final int delayTime = 5 * 60000;//60 000 = 1min
Context context;
private static boolean isDelayed = false;
@ -49,8 +51,11 @@ public class PostDelayHandler {
handlerTimer.postDelayed(new Runnable(){
public void run() {
isDelayed = false;
Log.v(TAG, "Time exceeded.. Sync state of changed items");
if((!SyncItemStateService.isMyServiceRunning(context)) && NetworkConnection.isNetworkAvailable(context))
{
Log.v(TAG, "Starting Service");
Intent iService = new Intent(context, SyncItemStateService.class);
context.startService(iService);
}

View file

@ -91,7 +91,7 @@ public class AsyncTask_PerformItemStateChange extends AsyncTask_Reader
@Override
protected void onPostExecute(Object values) {
for (OnAsyncTaskCompletedListener listenerInstance : listener) {
for (OnAsyncTaskCompletedListener listenerInstance : listener) {
if(listenerInstance != null)
listenerInstance.onAsyncTaskCompleted(task_id, values);
}

View file

@ -66,19 +66,8 @@ public class SyncItemStateService extends IntentService {
if(!(task_result instanceof Exception))
{
API api = null;
String appVersion = task_result.toString();
int versionCode = 0;
if(appVersion != null)
{
appVersion = appVersion.replace(".", "");
versionCode = Integer.parseInt(appVersion);
}
if (versionCode >= 1101) {
api = new APIv2(SyncItemStateService.this);
} else {
api = new APIv1(SyncItemStateService.this);
}
API api = API.GetRightApiForVersion(appVersion, SyncItemStateService.this);
((OwnCloud_Reader)_Reader).setApi(api);