Skip to content

Commit

Permalink
Merge branch 'hotfix/6.5.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
ccomeaux committed Oct 21, 2017
2 parents 8c51111 + 26ec241 commit 0874cbb
Show file tree
Hide file tree
Showing 24 changed files with 171 additions and 143 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Release Notes
=============

Version 6.5.6
-------------
* Bug fixes

Version 6.5.5
-------------
* Bug fixes
Expand Down
32 changes: 16 additions & 16 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ buildscript {

def versionMajor = 6
def versionMinor = 5
def versionPatch = 5
def versionBuild = 2
def versionPatch = 6
def versionBuild = 3

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
Expand Down Expand Up @@ -106,15 +106,15 @@ android {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')

compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:cardview-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
compile 'com.android.support:palette-v7:26.0.2'
compile 'com.android.support:percent:26.0.2'
compile 'com.android.support:recyclerview-v7:26.0.2'
implementation 'com.android.support:support-annotations:26.0.2'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:palette-v7:26.1.0'
compile 'com.android.support:percent:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:support-annotations:26.1.0'

compile 'com.google.code.gson:gson:2.8.1'
compile 'com.google.code.gson:gson:2.8.2'

compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
Expand All @@ -124,8 +124,8 @@ dependencies {
exclude group: 'xpp3', module: 'xpp3'
}

compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.1'
compile 'com.squareup.okhttp3:okhttp:3.9.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'

compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

Expand All @@ -140,7 +140,7 @@ dependencies {

compile 'com.github.chrisbanes.photoview:library:1.2.4'

compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
compile('com.crashlytics.sdk.android:crashlytics:2.7.1@aar') {
transitive = true
}

Expand All @@ -164,11 +164,11 @@ dependencies {

compile 'org.jsoup:jsoup:1.10.3'

provided "com.google.auto.value:auto-value:1.5"
annotationProcessor "com.google.auto.value:auto-value:1.5"
provided "com.google.auto.value:auto-value:1.5.2"
annotationProcessor "com.google.auto.value:auto-value:1.5.2"

compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.3.0'
compile 'io.reactivex:rxjava:1.3.3'

compile 'frankiesardo:icepick:3.2.0'
provided 'frankiesardo:icepick-processor:3.2.0'
Expand Down
45 changes: 0 additions & 45 deletions app/src/main/java/com/boardgamegeek/io/ThingRequest.java

This file was deleted.

40 changes: 0 additions & 40 deletions app/src/main/java/com/boardgamegeek/io/ThingResponse.java

This file was deleted.

3 changes: 3 additions & 0 deletions app/src/main/java/com/boardgamegeek/model/ThingResponse.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.boardgamegeek.model;

import android.support.annotation.NonNull;

import org.simpleframework.xml.ElementList;

import java.util.ArrayList;
Expand All @@ -11,6 +13,7 @@ public class ThingResponse {
@ElementList(name = "items", inline = true, required = false)
private List<Game> games;

@NonNull
public List<Game> getGames() {
if (games == null) {
return new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public int save(List<Game> games, String debugMessage) {
boolean avoidBatching = PreferencesUtils.getAvoidBatching(context);
int recordCount = 0;
ArrayList<ContentProviderOperation> batch = new ArrayList<>();
if (games != null) {
if (games != null && games.size() > 0) {

DesignerPersister designerPersister = new DesignerPersister();
ArtistPersister artistPersister = new ArtistPersister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ protected SelectionBuilder buildExpandedSelection(Uri uri, String[] projection)
GameSuggestedPlayerCountPollPollResults.GAME_ID,
playerCount));
}
if (TextUtils.isEmpty(groupBy)) {
groupBy = Collection.GAME_ID;
}
if (TextUtils.isEmpty(groupBy)) groupBy = Collection.GAME_ID;
}
}

if (!TextUtils.isEmpty(groupBy)) {
builder.groupBy(groupBy);
} else {
builder.groupBy(Collection.COLLECTION_ID);
}
if (!TextUtils.isEmpty(groupBy)) builder.groupBy(groupBy);

String having = uri.getQueryParameter(BggContract.QUERY_KEY_HAVING);
builder.having(having);
Expand Down
98 changes: 87 additions & 11 deletions app/src/main/java/com/boardgamegeek/service/SyncGames.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@

import com.boardgamegeek.R;
import com.boardgamegeek.io.BggService;
import com.boardgamegeek.io.ThingRequest;
import com.boardgamegeek.io.ThingResponse;
import com.boardgamegeek.model.Game;
import com.boardgamegeek.model.ThingResponse;
import com.boardgamegeek.model.persister.GamePersister;
import com.boardgamegeek.provider.BggContract.Games;
import com.boardgamegeek.service.model.GameList;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import retrofit2.Call;
import retrofit2.Response;
import timber.log.Timber;

public abstract class SyncGames extends SyncTask {
Expand Down Expand Up @@ -43,17 +49,54 @@ public void execute(Account account, @NonNull SyncResult syncResult) {
}
updateProgressNotification(detail);

ThingResponse response = new ThingRequest(service, gameList.getIds()).execute();
if (response.hasError()) {
showError(response.getError());
Call<ThingResponse> call = service.thing(gameList.getIds(), 1);
try {
Response<ThingResponse> response = call.execute();
if (response.isSuccessful()) {
final List<Game> games = response.body() == null ? new ArrayList<Game>(0) : response.body().getGames();
if (games.size() > 0) {
int count = new GamePersister(context).save(games, detail);
syncResult.stats.numUpdates += games.size();
Timber.i("...saved %,d rows for %,d games", count, games.size());
} else {
Timber.i("...no games returned");
break;
}
} else {
Timber.w("Received response %s while syncing games.", response.code());
if (response.code() >= 500) {
showError(context.getString(R.string.msg_sync_response_500, response.code()));
return;
} else if (response.code() == 429) {
showError(context.getString(R.string.msg_sync_response_429));
if (wasSleepInterrupted(5000)) return;
} else {
showError(context.getString(R.string.msg_sync_unsuccessful_response,
context.getString(R.string.game),
response.code()));
return;
}
}
} catch (IOException e) {
showError(e.getLocalizedMessage());
syncResult.stats.numIoExceptions++;
break;
} else if (response.getNumberOfGames() > 0) {
int count = new GamePersister(context).save(response.getGames(), detail);
syncResult.stats.numUpdates += response.getNumberOfGames();
Timber.i("...saved %,d rows for %,d games", count, response.getNumberOfGames());
} else {
Timber.i("...no games returned ");
} catch (RuntimeException e) {
Throwable cause = e.getCause();
if (cause instanceof ClassNotFoundException &&
cause.getMessage().startsWith("Didn't find class \"messagebox error\" on path")) {
syncResult.stats.numParseExceptions++;
Timber.i("Invalid list of game IDs: %s", gameList.getIds());
for (int i = 0; i < gameList.getSize(); i++) {
final boolean shouldBreak = syncGame(gameList.getId(i), syncResult, gameList.getName(i));
if (shouldBreak) break;
}
} else {
Timber.w(e);
showError(e.getLocalizedMessage());
syncResult.stats.numParseExceptions++;
break;
}
}
} else {
Timber.i(getExitLogMessage());
Expand All @@ -65,6 +108,39 @@ public void execute(Account account, @NonNull SyncResult syncResult) {
}
}

private boolean syncGame(Integer id, @NonNull SyncResult syncResult, String gameName) {
Call<ThingResponse> call = service.thing(id, 1);
try {
Response<ThingResponse> response = call.execute();
if (response.isSuccessful()) {
final List<Game> games = response.body() == null ? new ArrayList<Game>(0) : response.body().getGames();
String detail = context.getResources().getQuantityString(R.plurals.sync_notification_games, 1, 1, gameName);
int count = new GamePersister(context).save(games, detail);
syncResult.stats.numUpdates += games.size();
Timber.i("...saved %,d rows for %,d games", count, games.size());
} else {
Timber.w("Received response %s while syncing games.", response.code());
if (response.code() >= 500) {
showError(context.getString(R.string.msg_sync_response_500, response.code()));
return true;
} else if (response.code() == 429) {
showError(context.getString(R.string.msg_sync_response_429));
if (wasSleepInterrupted(5000)) return true;
} else {
showError(context.getString(R.string.msg_sync_unsuccessful_response,
context.getString(R.string.game),
response.code()));
return true;
}
}
} catch (IOException e) {
showError(e.getLocalizedMessage());
syncResult.stats.numIoExceptions++;
return true;
}
return false;
}

protected int getMaxFetchCount() {
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ public String getIds() {
public List<Integer> getIdList() {
return gameIds;
}

public Integer getId(int i) {
return gameIds.get(i);
}

public String getName(int i) {
return gameNames.get(i);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,8 @@ private String buildDefaultWhereClause() {
}
StringBuilder where = new StringBuilder();
for (String status : statuses) {
if (TextUtils.isEmpty(status)) {
continue;
}
if (where.length() > 0) {
where.append(" OR ");
}
if (TextUtils.isEmpty(status)) continue;
if (where.length() > 0) where.append(" OR ");
switch (status) {
case "own":
where.append(Collection.STATUS_OWN).append("=1");
Expand Down
9 changes: 6 additions & 3 deletions app/src/main/java/com/boardgamegeek/ui/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,14 @@ private void createAccount(BggCookieJar bggCookieJar) {
if (isRequestingNewAccount) {
if (!accountManager.addAccountExplicitly(account, password, userData)) {
Account existingAccount = Authenticator.getAccount(accountManager);
if (existingAccount != null && existingAccount.name.equals(account.name)) {
accountManager.setPassword(account, password);
} else {
if (existingAccount == null) {
passwordContainer.setError(getString(R.string.error_account_not_added));
return;
} else if (!existingAccount.name.equals(account.name)) {
passwordContainer.setError(getString(R.string.error_account_name_mismatch, existingAccount.name, account.name));
return;
} else {
accountManager.setPassword(account, password);
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_geeklist_description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

<FrameLayout style="@style/WebViewContainer">

<WebView
<com.boardgamegeek.ui.widget.NestedScrollWebView
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Expand Down
Loading

0 comments on commit 0874cbb

Please sign in to comment.