Skip to content
This repository was archived by the owner on Mar 30, 2025. It is now read-only.

Commit d523f47

Browse files
committed
- Fix upload response status parsing
1 parent 8115067 commit d523f47

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

app/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ android {
3636
applicationId "de.bahnhoefe.deutschlands.bahnhofsfotos"
3737
minSdk 26
3838
targetSdk 33
39-
versionCode 77
40-
versionName "14.4.0"
39+
versionCode 78
40+
versionName "14.4.1"
4141
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4242
multiDexEnabled true
4343

@@ -131,7 +131,7 @@ dependencies {
131131
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
132132
implementation 'androidx.cardview:cardview:1.0.0'
133133
implementation 'androidx.appcompat:appcompat:1.6.1'
134-
implementation 'com.google.android.material:material:1.8.0'
134+
implementation 'com.google.android.material:material:1.9.0'
135135
implementation 'androidx.browser:browser:1.5.0'
136136
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
137137
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'

app/src/main/java/de/bahnhoefe/deutschlands/bahnhofsfotos/ProblemReportActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ public void onResponse(@NonNull Call<InboxResponse> call, @NonNull Response<Inbo
210210
upload.setRemoteId(inboxResponse.getId());
211211
upload.setUploadState(inboxResponse.getState().getUploadState());
212212
baseApplication.getDbAdapter().updateUpload(upload);
213-
SimpleDialogs.confirmOk(ProblemReportActivity.this, inboxResponse.getState().getMessageId());
214-
if (response.isSuccessful()) {
215-
finish();
213+
if (inboxResponse.getState() == InboxResponse.InboxResponseState.ERROR) {
214+
SimpleDialogs.confirmOk(ProblemReportActivity.this,
215+
getString(InboxResponse.InboxResponseState.ERROR.getMessageId(), inboxResponse.getMessage()));
216+
} else {
217+
SimpleDialogs.confirmOk(ProblemReportActivity.this, inboxResponse.getState().getMessageId());
216218
}
217219
}
218220

app/src/main/kotlin/de/bahnhoefe/deutschlands/bahnhofsfotos/model/InboxResponse.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import com.google.gson.JsonDeserializationContext
44
import com.google.gson.JsonDeserializer
55
import com.google.gson.JsonElement
66
import com.google.gson.annotations.JsonAdapter
7+
import com.google.gson.annotations.SerializedName
78
import de.bahnhoefe.deutschlands.bahnhofsfotos.R
89
import java.lang.reflect.Type
910

1011
data class InboxResponse @JvmOverloads constructor(
11-
var _state: InboxResponseState? = InboxResponseState.ERROR,
12+
@SerializedName("state") var _state: InboxResponseState? = InboxResponseState.ERROR,
1213
var message: String? = null,
1314
var id: Long? = null,
1415
var filename: String? = null,

app/src/test/java/de/bahnhoefe/deutschlands/bahnhofsfotos/model/InboxResponseTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static org.assertj.core.api.Assertions.assertThat;
44

5+
import com.google.gson.Gson;
6+
57
import org.junit.jupiter.api.Test;
68

79
class InboxResponseTest {
@@ -27,4 +29,20 @@ void defaultConstructorWithState() {
2729
assertThat(inboxResponse.getState()).isSameAs(InboxResponse.InboxResponseState.REVIEW);
2830
}
2931

32+
@Test
33+
void fromJsonWithoutState() {
34+
var inboxResponse = new Gson().fromJson("{'message':'some message'}", InboxResponse.class);
35+
36+
assertThat(inboxResponse.getState()).isSameAs(InboxResponse.InboxResponseState.ERROR);
37+
assertThat(inboxResponse.getMessage()).isEqualTo("some message");
38+
}
39+
40+
@Test
41+
void fromJsonWithState() {
42+
var inboxResponse = new Gson().fromJson("{'state': 'REVIEW', 'message':'some message'}", InboxResponse.class);
43+
44+
assertThat(inboxResponse.getState()).isSameAs(InboxResponse.InboxResponseState.REVIEW);
45+
assertThat(inboxResponse.getMessage()).isEqualTo("some message");
46+
}
47+
3048
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fehler beim interpretieren des Upload Status
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix upload response status parsing

0 commit comments

Comments
 (0)