1
0
mirror of https://github.com/akaessens/NoFbEventScraper synced 2025-06-05 23:29:13 +02:00

material design and image display

This commit is contained in:
akaessens
2020-08-14 23:58:29 +02:00
parent 423642f7f7
commit 7c975b8d7e
12 changed files with 318 additions and 176 deletions

View File

@ -1,6 +1,7 @@
package com.akdev.nofbeventscraper;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.content.Intent;
import android.net.Uri;
@ -14,7 +15,7 @@ public class AboutActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
this.getSupportActionBar().hide();
ImageView img = (ImageView)findViewById(R.id.paypal_image);

View File

@ -117,12 +117,23 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
String event_description = fixLinks(readFromJson(reader, "description"));
String location = fixLocation(readFromJson(reader, "location"));
String image_url = null;
try {
image_url = readFromJson(reader, "image"); // get from json
// get from event header
image_url = document.getElementsByClass("scaledImageFitWidth").first().attr("src");
} catch (Exception e) {
e.printStackTrace();
this.error = "Error: no image found";
}
if (event_name == null) {
this.event = null;
throw new Exception();
} else {
this.event = new FbEvent(event_name, event_start, event_end, event_description, location, null);
this.event = new FbEvent(event_name, event_start, event_end, event_description, location, image_url);
}
} catch (Exception e) {

View File

@ -10,5 +10,6 @@ public class HelpActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_help);
this.getSupportActionBar().hide();
}
}

View File

@ -5,6 +5,8 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.textfield.TextInputEditText;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
@ -14,8 +16,12 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.net.URI;
import java.net.URL;
import java.time.LocalDateTime;
import java.time.ZoneId;
@ -36,6 +42,8 @@ public class MainActivity extends AppCompatActivity {
private TextInputEditText field_event_end;
private TextInputEditText field_event_location;
private TextInputEditText field_event_description;
private ImageView toolbar_image_view;
private CollapsingToolbarLayout toolbar_layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -54,6 +62,8 @@ public class MainActivity extends AppCompatActivity {
field_event_end = (TextInputEditText) findViewById(R.id.field_event_end);
field_event_location = (TextInputEditText) findViewById(R.id.field_event_location);
field_event_description = (TextInputEditText) findViewById(R.id.field_event_description);
toolbar_image_view = (ImageView) findViewById(R.id.image_view);
toolbar_layout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
paste_button.setOnClickListener(new View.OnClickListener() {
@Override
@ -201,7 +211,7 @@ public class MainActivity extends AppCompatActivity {
throw new Exception();
}
String input_uri = "https://m.facebook.com/events/" + eventId;
String input_uri = "https://www.facebook.com/events/" + eventId;
str = input_uri;
}
catch (Exception e) {
@ -242,6 +252,9 @@ public class MainActivity extends AppCompatActivity {
field_event_end.setText("");
field_event_location.setText("");
field_event_description.setText("");
toolbar_image_view.setImageDrawable(null);
toolbar_layout.setTitle(getString(R.string.app_name));
}
public void update(FbEvent event) {
@ -250,6 +263,10 @@ public class MainActivity extends AppCompatActivity {
field_event_end.setText(event.end_date);
field_event_location.setText(event.location);
field_event_description.setText(event.description);
toolbar_layout.setTitle(" ");
Picasso.get().load(event.image_url).into(toolbar_image_view);
}