Skip to content

Commit

Permalink
WIP: fix cgeo#4086, cgeo#4699 offline logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pstorch committed Aug 31, 2016
1 parent b81e4a6 commit bd24b78
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
24 changes: 17 additions & 7 deletions main/src/cgeo/geocaching/LogCacheActivity.java
Expand Up @@ -14,6 +14,7 @@
import cgeo.geocaching.gcvote.GCVote;
import cgeo.geocaching.gcvote.GCVoteRatingBarUtil;
import cgeo.geocaching.gcvote.GCVoteRatingBarUtil.OnRatingChangeListener;
import cgeo.geocaching.list.StoredList;
import cgeo.geocaching.models.Geocache;
import cgeo.geocaching.models.Image;
import cgeo.geocaching.models.LogEntry;
Expand All @@ -32,18 +33,14 @@
import cgeo.geocaching.utils.LogTemplateProvider.LogContext;
import cgeo.geocaching.utils.TextUtils;

import com.github.amlcurran.showcaseview.targets.ActionItemTarget;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import android.R.string;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
Expand All @@ -68,6 +65,9 @@

import butterknife.BindView;
import butterknife.ButterKnife;
import com.github.amlcurran.showcaseview.targets.ActionItemTarget;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import rx.Observable;
import rx.android.app.AppObservable;
import rx.functions.Action1;
Expand Down Expand Up @@ -626,8 +626,18 @@ private void saveLog(final boolean force) {
// without using "Clear". This may be a manipulation mistake, and erasing
// again will be easy using "Clear" while retyping the text may not be.
if (force || (StringUtils.isNotEmpty(log) && !StringUtils.equals(log, text))) {
cache.logOffline(this, log, date, typeSelected);
Settings.setLastCacheLog(log);
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(final Void... params) {
if (!cache.isOffline()) {
cache.getLists().add(StoredList.STANDARD_LIST_ID);
cache.store();
}
cache.logOffline(LogCacheActivity.this, log, date, typeSelected);
Settings.setLastCacheLog(log);
return null;
}
}.execute();
}
text = log;
}
Expand Down
5 changes: 3 additions & 2 deletions main/src/cgeo/geocaching/storage/DataStore.java
Expand Up @@ -46,6 +46,8 @@
import android.database.sqlite.SQLiteDoneException;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import java.io.File;
import java.io.FilenameFilter;
Expand All @@ -72,8 +74,6 @@
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import rx.Observable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
Expand Down Expand Up @@ -2667,6 +2667,7 @@ public static void clearLogsOffline(final List<Geocache> caches) {
}

database.execSQL(String.format("DELETE FROM %s where %s", dbTableLogsOffline, whereGeocodeIn(Geocache.getGeocodes(caches))));
database.execSQL(String.format("UPDATE %s SET visiteddate = 0 where %s", dbTableCaches, whereGeocodeIn(Geocache.getGeocodes(caches))));
}

public static boolean hasLogOffline(final String geocode) {
Expand Down

0 comments on commit bd24b78

Please sign in to comment.