use scroll view instead of card, re-add maps intent and fix soft keyboard
This commit is contained in:
parent
85e9c15f5e
commit
56300d78a3
|
@ -33,6 +33,7 @@
|
|||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:windowSoftInputMode="stateVisible|adjustPan"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package com.akdev.nofbeventscraper;
|
|||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -9,6 +11,7 @@ import android.view.ViewGroup;
|
|||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.textfield.TextInputEditText;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -25,13 +28,34 @@ public class EventAdapter extends
|
|||
|
||||
@Override
|
||||
public EventAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int view_type) {
|
||||
Context context = parent.getContext();
|
||||
final Context context = parent.getContext();
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
|
||||
// Inflate the custom layout
|
||||
View contact_view = inflater.inflate(R.layout.item_event, parent, false);
|
||||
|
||||
|
||||
|
||||
// Return a new holder instance
|
||||
final ViewHolder holder = new ViewHolder(contact_view);
|
||||
|
||||
/*
|
||||
* Maps button: launch maps intent
|
||||
*/
|
||||
|
||||
holder.layout_event_location.setEndIconOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String map_search = "geo:0,0?q=" + holder.edit_text_event_location.getText();
|
||||
|
||||
Uri intent_uri = Uri.parse(map_search);
|
||||
Intent map_intent = new Intent(Intent.ACTION_VIEW, intent_uri);
|
||||
if (map_intent.resolveActivity(context.getPackageManager()) != null) {
|
||||
context.startActivity(map_intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return new ViewHolder(contact_view);
|
||||
}
|
||||
@Override
|
||||
|
@ -87,18 +111,18 @@ public class EventAdapter extends
|
|||
protected TextInputEditText edit_text_event_end;
|
||||
protected TextInputEditText edit_text_event_location;
|
||||
protected TextInputEditText edit_text_event_description;
|
||||
protected TextInputLayout layout_event_location;
|
||||
|
||||
|
||||
public ViewHolder(View item_view) {
|
||||
super(item_view);
|
||||
|
||||
|
||||
edit_text_event_name = (TextInputEditText) item_view.findViewById(R.id.edit_text_event_name);
|
||||
edit_text_event_start = (TextInputEditText) item_view.findViewById(R.id.edit_text_event_start);
|
||||
edit_text_event_end = (TextInputEditText) item_view.findViewById(R.id.edit_text_event_end);
|
||||
edit_text_event_location = (TextInputEditText) item_view.findViewById(R.id.edit_text_event_location);
|
||||
edit_text_event_description = (TextInputEditText) item_view.findViewById(R.id.edit_text_event_description);
|
||||
|
||||
layout_event_location = (TextInputLayout) item_view.findViewById(R.id.layout_event_location);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,5 @@
|
|||
package com.akdev.nofbeventscraper;
|
||||
|
||||
import android.app.usage.UsageEvents;
|
||||
import android.util.EventLog;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -43,14 +40,9 @@ public class FbEvent {
|
|||
this.image_url = image_url;
|
||||
}
|
||||
|
||||
public static ArrayList<FbEvent> createEventList(int num_events) {
|
||||
ArrayList<FbEvent> events = new ArrayList<FbEvent>();
|
||||
public static ArrayList<FbEvent> createEventList() {
|
||||
|
||||
for (int i = 1; i <= num_events; i++) {
|
||||
events.add(new FbEvent());
|
||||
}
|
||||
|
||||
return events;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||
FbScraper(WeakReference<MainActivity> main, String input_url) {
|
||||
this.main = main;
|
||||
this.input_url = input_url;
|
||||
this.events = createEventList(0);
|
||||
this.events = createEventList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,6 +228,10 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
|
|||
|
||||
FbEvent event = new FbEvent(url, name, start_date, end_date, description, location, image_url);
|
||||
this.events.add(event);
|
||||
this.events.add(event);
|
||||
this.events.add(new FbEvent());
|
||||
this.events.add(event);
|
||||
this.events.add(event);
|
||||
|
||||
} catch (URISyntaxException | MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -59,38 +59,27 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
edit_text_uri_input = (TextInputEditText) findViewById(R.id.edit_text_uri_input);
|
||||
layout_uri_input = (TextInputLayout) findViewById(R.id.layout_uri_input);
|
||||
// Lookup the recyclerview in activity layout
|
||||
final RecyclerView recycler_view = (RecyclerView) findViewById(R.id.recycler_view);
|
||||
|
||||
SnapHelper snap_helper = new LinearSnapHelper();
|
||||
snap_helper.attachToRecyclerView(recycler_view);
|
||||
|
||||
// Initialize contacts
|
||||
events = createEventList(3);
|
||||
|
||||
// Create adapter passing in the sample user data
|
||||
adapter = new EventAdapter(events);
|
||||
// Attach the adapter to the recyclerview to populate items
|
||||
recycler_view.setAdapter(adapter);
|
||||
// Set layout manager to position the items
|
||||
|
||||
linear_layout_manager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
|
||||
|
||||
recycler_view.setLayoutManager(linear_layout_manager);
|
||||
recycler_view.setHasFixedSize(true);
|
||||
|
||||
// That's all!
|
||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
ok_button = (Button) findViewById(R.id.ok_button);
|
||||
paste_button = (ExtendedFloatingActionButton) findViewById(R.id.paste_button);
|
||||
|
||||
ok_button.setEnabled(false);
|
||||
|
||||
/*
|
||||
* Default view settings
|
||||
* initialize recycler view with empty list of events
|
||||
* scroll horizontal with snapping
|
||||
*/
|
||||
ok_button.setEnabled(false);
|
||||
RecyclerView recycler_view = (RecyclerView) findViewById(R.id.recycler_view);
|
||||
events = createEventList();
|
||||
adapter = new EventAdapter(events);
|
||||
recycler_view.setAdapter(adapter);
|
||||
linear_layout_manager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
|
||||
recycler_view.setLayoutManager(linear_layout_manager);
|
||||
recycler_view.setHasFixedSize(true);
|
||||
SnapHelper snap_helper = new LinearSnapHelper();
|
||||
snap_helper.attachToRecyclerView(recycler_view);
|
||||
|
||||
|
||||
/*
|
||||
* Paste button: get last entry from clipboard
|
||||
|
@ -116,7 +105,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
});
|
||||
|
||||
/*
|
||||
* Clear button: delete all text in all fields
|
||||
* Clear button: delete all events
|
||||
*/
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -127,24 +116,9 @@ public class MainActivity extends AppCompatActivity {
|
|||
layout_uri_input.setEndIconOnClickListener(listener);
|
||||
layout_uri_input.setErrorIconOnClickListener(listener);
|
||||
|
||||
/*
|
||||
* Maps button: launch maps intent
|
||||
*/
|
||||
/*layout_event_location.setEndIconOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String map_search = "geo:0,0?q=" + edit_text_event_location.getText();
|
||||
|
||||
Uri intent_uri = Uri.parse(map_search);
|
||||
Intent map_intent = new Intent(Intent.ACTION_VIEW, intent_uri);
|
||||
if (map_intent.resolveActivity(getPackageManager()) != null) {
|
||||
startActivity(map_intent);
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
/*
|
||||
* Add to calendar button: launch calendar application
|
||||
* Add to calendar button: launch calendar application with current event
|
||||
*/
|
||||
ok_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -225,7 +199,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
} else {
|
||||
layout_uri_input.setError(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -240,20 +213,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
edit_text_uri_input.setText("");
|
||||
layout_uri_input.setError(null);
|
||||
}
|
||||
/*edit_text_event_name.setText("");
|
||||
edit_text_event_start.setText("");
|
||||
edit_text_event_end.setText("");
|
||||
edit_text_event_location.setText("");
|
||||
edit_text_event_description.setText("");
|
||||
|
||||
edit_text_event_name.setError(null);
|
||||
edit_text_event_start.setError(null);
|
||||
edit_text_event_end.setError(null);
|
||||
edit_text_event_location.setError(null);
|
||||
edit_text_event_description.setError(null);*/
|
||||
|
||||
this.events.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
try {
|
||||
scraper.cancel(true);
|
||||
|
@ -262,10 +221,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.events.clear();
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
ok_button.setEnabled(false);/*
|
||||
layout_event_location.setEndIconVisible(false);
|
||||
image_view_toolbar.setImageResource(R.drawable.ic_banner_foreground);*/
|
||||
ok_button.setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,11 +240,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
/*edit_text_uri_input.setText(event.url);
|
||||
|
||||
|
||||
|
||||
Picasso.get()
|
||||
/*Picasso.get()
|
||||
.load(event.image_url)
|
||||
.placeholder(R.drawable.ic_banner_foreground)
|
||||
.into(image_view_toolbar);*/
|
||||
|
@ -293,7 +248,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
ok_button.setEnabled(true);
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -104,4 +104,4 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</androidx.core.widget.NestedScrollView>
|
Loading…
Reference in New Issue