mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-17 11:32:05 +00:00
fix challenge leaving
This commit is contained in:
parent
6af6c29e3d
commit
30a88aa09d
3 changed files with 15 additions and 5 deletions
|
|
@ -7,5 +7,5 @@ public class HabitDatabase {
|
|||
|
||||
public static final String NAME = "Habitica";
|
||||
|
||||
public static final int VERSION = 31;
|
||||
public static final int VERSION = 32;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ public class ChallengeListFragment extends BaseMainFragment implements SwipeRefr
|
|||
if (userChallengesHash.contains(challenge.id) && challenge.name != null && !challenge.name.isEmpty()) {
|
||||
challenge.user_id = this.user.getId();
|
||||
userChallenges.add(challenge);
|
||||
} else {
|
||||
challenge.user_id = null;
|
||||
}
|
||||
|
||||
challenge.async().save();
|
||||
|
|
@ -153,6 +155,9 @@ public class ChallengeListFragment extends BaseMainFragment implements SwipeRefr
|
|||
}
|
||||
|
||||
private void setChallengeEntries(List<Challenge> challenges) {
|
||||
if (swipeRefreshEmptyLayout == null || swipeRefreshLayout == null) {
|
||||
return;
|
||||
}
|
||||
if (viewUserChallengesOnly && challenges.size() == 0) {
|
||||
swipeRefreshEmptyLayout.setVisibility(View.VISIBLE);
|
||||
swipeRefreshLayout.setVisibility(View.GONE);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import com.raizlabs.android.dbflow.sql.builder.Condition;
|
|||
import com.raizlabs.android.dbflow.sql.language.Select;
|
||||
import com.raizlabs.android.dbflow.structure.BaseModel;
|
||||
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -118,10 +119,14 @@ public class HabitRPGUser extends BaseModel {
|
|||
@OneToMany(methods = {OneToMany.Method.SAVE, OneToMany.Method.DELETE}, variableName = "challengeList")
|
||||
public List<Challenge> getChallengeList() {
|
||||
if (challengeList == null) {
|
||||
challengeList = new Select()
|
||||
.from(Challenge.class)
|
||||
.where(Condition.column("user_id").eq(this.id))
|
||||
.queryList();
|
||||
try {
|
||||
challengeList = new Select()
|
||||
.from(Challenge.class)
|
||||
.where(Condition.column("user_id").eq(this.id))
|
||||
.queryList();
|
||||
} catch (SQLiteException exception) {
|
||||
challengeList = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
return challengeList;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue