forked from Adamantcheese/Kuroba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b10115
commit aa4f22d
Showing
5 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ain/java/com/github/adamantcheese/chan/core/site/sites/lynxchan/LynxChanIndexRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Kuroba - *chan browser https://github.com/TheStranjer/Kuroba (fork of https://github.com/Adamantcheese/Kuroba) | ||
* Copyright (C) 2019 TheStranjer | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.github.adamantcheese.chan.core.site.sites.lynxchan; | ||
|
||
import com.android.volley.Response.ErrorListener; | ||
import com.android.volley.Response.Listener; | ||
|
||
import com.github.adamantcheese.chan.core.net.JsonReaderRequest; | ||
import android.util.JsonReader; | ||
import android.util.JsonToken; | ||
|
||
import okhttp3.HttpUrl; | ||
|
||
public class LynxChanIndexRequest extends JsonReaderRequest<LynxChanIndexResult> { | ||
private static final String TAG = "LynxChanInstanceCheck"; | ||
public LynxChanIndexRequest(String hostname, Listener<LynxChanIndexResult> listener, ErrorListener errorListener) { | ||
super(new HttpUrl.Builder().scheme("https").host(hostname).addPathSegment("index.json").build().toString(), listener, errorListener); | ||
} | ||
|
||
@Override | ||
public LynxChanIndexResult readJson(JsonReader reader) throws Exception { | ||
reader.beginObject(); | ||
while (reader.hasNext()) { | ||
if (reader.peek() != JsonToken.NAME) { | ||
reader.skipValue(); | ||
continue; | ||
} | ||
|
||
String key = reader.nextName(); | ||
switch (key) { | ||
case "version": | ||
String nextString = reader.nextString(); | ||
return new LynxChanIndexResult(nextString); | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
return new LynxChanIndexResult(); | ||
} | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...main/java/com/github/adamantcheese/chan/core/site/sites/lynxchan/LynxChanIndexResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.adamantcheese.chan.core.site.sites.lynxchan; | ||
|
||
public class LynxChanIndexResult { | ||
public String version; | ||
|
||
public LynxChanIndexResult(String version) { | ||
this.version = version; | ||
} | ||
|
||
public LynxChanIndexResult() {} | ||
|
||
public boolean IsLynxChanInstance() { | ||
return version != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters