Fix #236
This commit is contained in:
parent
b2b4af3e29
commit
a6167b4ef9
3 changed files with 11 additions and 17 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -65,21 +65,10 @@ public class SyncItemStateService extends IntentService {
|
|||
public void onAsyncTaskCompleted(int task_id, Object task_result) {
|
||||
|
||||
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);
|
||||
|
||||
_Reader.Start_AsyncTask_PerformItemStateChange(Constants.TaskID_PerformStateChange, SyncItemStateService.this, null);
|
||||
|
|
Loading…
Reference in a new issue