mirror of
https://github.com/akaessens/NoFbEventScraper
synced 2025-02-17 20:10:37 +01:00
add high res image preview, fix reset on activity return
This commit is contained in:
parent
1570742462
commit
7a44e467f0
@ -32,8 +32,10 @@
|
|||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
|
android:launchMode="singleTop"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
|
@ -192,8 +192,8 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String url = fixURI(input_url);
|
String url = fixURI(input_url);
|
||||||
// use correct system user agent because of facebook ToS
|
// use default android user agent
|
||||||
String user_agent = System.getProperty("http.agent");
|
String user_agent = "Mozilla/5.0 (X11; Linux x86_64)";
|
||||||
Document document = Jsoup.connect(url).userAgent(user_agent).get();
|
Document document = Jsoup.connect(url).userAgent(user_agent).get();
|
||||||
|
|
||||||
if (document == null) {
|
if (document == null) {
|
||||||
@ -205,15 +205,26 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||||||
|
|
||||||
JSONObject reader = new JSONObject(json);
|
JSONObject reader = new JSONObject(json);
|
||||||
|
|
||||||
event = new FbEvent(
|
|
||||||
url,
|
String name = readFromJson(reader, "name");
|
||||||
readFromJson(reader, "name"),
|
ZonedDateTime start_date = toZonedDateTime(readFromJson(reader, "startDate"));
|
||||||
toZonedDateTime(readFromJson(reader, "startDate")),
|
ZonedDateTime end_date = toZonedDateTime(readFromJson(reader, "endDate"));
|
||||||
toZonedDateTime(readFromJson(reader, "endDate")),
|
String description = fixDescriptionLinks(readFromJson(reader, "description"));
|
||||||
fixDescriptionLinks(readFromJson(reader, "description")),
|
String location = fixLocation(readFromJson(reader, "location"));
|
||||||
fixLocation(readFromJson(reader, "location")),
|
|
||||||
readFromJson(reader, "image")
|
String image_url = readFromJson(reader, "image"); // get from json
|
||||||
);
|
|
||||||
|
try {
|
||||||
|
// possibly get higher res image from event header
|
||||||
|
image_url = document.getElementsByClass("scaledImageFitWidth")
|
||||||
|
.first().attr("src");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
event = new FbEvent(url, name,start_date, end_date, description, location, image_url);
|
||||||
|
|
||||||
|
|
||||||
} catch (URISyntaxException | MalformedURLException e) {
|
} catch (URISyntaxException | MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user