mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Converted MwParseResult / MwParseResponse to kotlin
This commit is contained in:
parent
3a768ead17
commit
202b6ec10b
4 changed files with 35 additions and 43 deletions
|
|
@ -1,25 +0,0 @@
|
|||
package fr.free.nrw.commons.media;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwResponse;
|
||||
|
||||
public class MwParseResponse extends MwResponse {
|
||||
@Nullable
|
||||
private MwParseResult parse;
|
||||
|
||||
@Nullable
|
||||
public MwParseResult parse() {
|
||||
return parse;
|
||||
}
|
||||
|
||||
public boolean success() {
|
||||
return parse != null;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
protected void setParse(@Nullable MwParseResult parse) {
|
||||
this.parse = parse;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package fr.free.nrw.commons.media
|
||||
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import fr.free.nrw.commons.wikidata.mwapi.MwResponse
|
||||
|
||||
class MwParseResponse : MwResponse() {
|
||||
private var parse: MwParseResult? = null
|
||||
|
||||
fun parse(): MwParseResult? = parse
|
||||
|
||||
fun success(): Boolean = parse != null
|
||||
|
||||
@VisibleForTesting
|
||||
protected fun setParse(parse: MwParseResult?) {
|
||||
this.parse = parse
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package fr.free.nrw.commons.media;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class MwParseResult {
|
||||
@SuppressWarnings("unused") private int pageid;
|
||||
@SuppressWarnings("unused") private int index;
|
||||
private MwParseText text;
|
||||
|
||||
public String text() {
|
||||
return text.text;
|
||||
}
|
||||
|
||||
|
||||
public class MwParseText{
|
||||
@SerializedName("*") private String text;
|
||||
}
|
||||
}
|
||||
18
app/src/main/java/fr/free/nrw/commons/media/MwParseResult.kt
Normal file
18
app/src/main/java/fr/free/nrw/commons/media/MwParseResult.kt
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package fr.free.nrw.commons.media
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
class MwParseResult {
|
||||
private val pageid = 0
|
||||
private val index = 0
|
||||
private val text: MwParseText? = null
|
||||
|
||||
fun text(): String? {
|
||||
return text?.text
|
||||
}
|
||||
|
||||
inner class MwParseText {
|
||||
@SerializedName("*")
|
||||
internal val text: String? = null
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue