Page MenuHomeGitPull.it

D17.1781818572.diff
No OneTemporary

Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None

D17.1781818572.diff

diff --git a/res/drawable/ic_star_filled.xml b/res/drawable/ic_star_filled.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/ic_star_filled.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@color/orange_500"
+ android:pathData="M12,17.27L18.18,21L16.54,13.97L22,9.24L14.81,8.62L12,2L9.19,8.62L2,9.24L7.45,13.97L5.82,21L12,17.27Z"/>
+</vector>
diff --git a/res/drawable/ic_star_outline.xml b/res/drawable/ic_star_outline.xml
new file mode 100644
--- /dev/null
+++ b/res/drawable/ic_star_outline.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="@color/orange_500"
+ android:pathData="M12,15.39L8.24,17.66L9.23,13.38L5.91,10.5L10.29,10.13L12,6.09L13.71,10.13L18.09,10.5L14.77,13.38L15.76,17.66M22,9.24L14.81,8.63L12,2L9.19,8.63L2,9.24L7.45,13.97L5.82,21L12,17.27L18.18,21L16.54,13.97L22,9.24Z"/>
+</vector>
diff --git a/res/layout/fragment_list_view.xml b/res/layout/fragment_list_view.xml
--- a/res/layout/fragment_list_view.xml
+++ b/res/layout/fragment_list_view.xml
@@ -4,18 +4,36 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
>
+
<TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_marginEnd="16dp"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
- android:layout_marginStart="16dp"
- android:layout_marginTop="10dp"
- android:id="@+id/messageTextView" android:gravity="center_vertical"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:minHeight="48dp"
- android:layout_marginBottom="10dp" />
+ android:id="@+id/messageTextView"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="16dp"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginEnd="307dp"
+ android:layout_marginRight="10dp"
+ android:layout_marginBottom="10dp"
+ android:layout_toStartOf="@+id/addToFavorites"
+ android:layout_toLeftOf="@+id/addToFavorites"
+ android:gravity="center_vertical"
+ android:minHeight="48dp"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <ImageButton
+ android:id="@+id/addToFavorites"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_above="@+id/resultsListView"
+ android:layout_alignParentRight="true"
+ android:layout_marginLeft="16dp"
+ android:layout_marginTop="10dp"
+ android:layout_marginRight="16dp"
+ android:layout_marginBottom="16dp"
+ android:background="@android:color/transparent"
+ fab:srcCompat="@drawable/ic_star_outline" />
+
<ListView
android:layout_below="@id/messageTextView"
android:id="@+id/resultsListView"
diff --git a/src/it/reyboz/bustorino/fragments/ResultListFragment.java b/src/it/reyboz/bustorino/fragments/ResultListFragment.java
--- a/src/it/reyboz/bustorino/fragments/ResultListFragment.java
+++ b/src/it/reyboz/bustorino/fragments/ResultListFragment.java
@@ -20,6 +20,7 @@
package it.reyboz.bustorino.fragments;
import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
@@ -32,12 +33,13 @@
import android.widget.*;
import android.support.design.widget.FloatingActionButton;
-
+import it.reyboz.bustorino.ActivityMain;
import it.reyboz.bustorino.R;
import it.reyboz.bustorino.backend.FiveTNormalizer;
import it.reyboz.bustorino.backend.Palina;
import it.reyboz.bustorino.backend.Route;
import it.reyboz.bustorino.backend.Stop;
+import it.reyboz.bustorino.middleware.UserDB;
/**
* This is a generalized fragment that can be used both for
@@ -57,6 +59,7 @@
private boolean adapterSet = false;
protected FragmentListener mListener;
private TextView messageTextView;
+ private ImageButton addToFavorites;
private FloatingActionButton fabutton;
private ListView resultsListView;
@@ -102,11 +105,28 @@
}
}
+ /**
+ * Check if the last Bus Stop is in the favorites
+ * @return
+ */
+ public boolean isStopInFavorites(String busStopId) {
+ boolean found = false;
+
+ // no stop no party
+ if(busStopId != null) {
+ SQLiteDatabase userDB = new UserDB(getContext()).getReadableDatabase();
+ found = UserDB.isStopinFavorites(userDB, busStopId);
+ }
+
+ return found;
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_list_view, container, false);
messageTextView = (TextView) root.findViewById(R.id.messageTextView);
+ addToFavorites = (ImageButton) root.findViewById(R.id.addToFavorites);
if (adapterKind != null) {
resultsListView = (ListView) root.findViewById(R.id.resultsListView);
@@ -275,20 +295,21 @@
messageTextView.setText(message);
switch (adapterKind) {
case ARRIVALS:
- messageTextView.setClickable(true);
- messageTextView.setOnClickListener(new View.OnClickListener() {
+ final ActivityMain activ = (ActivityMain) getActivity();
+ addToFavorites.setClickable(true);
+ addToFavorites.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- // add/remove the stop in the favorites
- mListener.toggleLastStopToFavorites();
+ mListener.addLastStopToFavorites();
}
});
break;
case STOPS:
- messageTextView.setClickable(false);
+ addToFavorites.setClickable(false);
break;
}
+
messageTextView.setVisibility(View.VISIBLE);
}
-}
+}
\ No newline at end of file

File Metadata

Mime Type
text/plain
Expires
Thu, Jun 18, 23:36 (5 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1966588
Default Alt Text
D17.1781818572.diff (6 KB)

Event Timeline