Prechádzať zdrojové kódy

added eventListener that redirects to event's detail screen when an item on viewList is clicked

Yiupang 9 rokov pred
rodič
commit
bd51b3637d

+ 11 - 0
app/src/main/AndroidManifest.xml

@@ -35,6 +35,17 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+
+        <activity
+            android:name=".AboutUsScreen"
+            android:label="@string/app_name"
+            android:theme="@style/AppTheme.NoActionBar">
+            <intent-filter>
+                <action android:name="android.intent.action.aboutus" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
     </application>
 
 </manifest>

+ 2 - 5
app/src/main/java/com/example/yiupang/freefoodfinder/AboutUsScreen.java

@@ -47,7 +47,7 @@ public class AboutUsScreen extends android.support.v4.app.Fragment
                         " company recruiting sessions, and campus events near your current location." +
                         " Simply select an event to get all deets.")
                 .isRTL(false)
-                .setImage(R.drawable.dummy_image2)
+                //.setImage(R.drawable.dummy_image2)
                 .addGroup("Connect with us")
                 .addEmail("contact@freefoodfinder.com")
                 .addWebsite("freefoodfinder.io")
@@ -62,9 +62,6 @@ public class AboutUsScreen extends android.support.v4.app.Fragment
                 .addItem(getCopyRightsElement())
                 .create();
 
-
-
-
         return aboutPage;
 
     }
@@ -73,7 +70,7 @@ public class AboutUsScreen extends android.support.v4.app.Fragment
         Element copyRightsElement = new Element();
         final String copyrights = String.format(getString(R.string.copy_right), Calendar.getInstance().get(Calendar.YEAR));
         copyRightsElement.setTitle(copyrights);
-        copyRightsElement.setIconDrawable(R.drawable.about_icon_copy_right);
+        //copyRightsElement.setIconDrawable(R.drawable.about_icon_copy_right);
         copyRightsElement.setIconTint(mehdi.sakout.aboutpage.R.color.about_item_icon_color);
         copyRightsElement.setIconNightTint(android.R.color.white);
         copyRightsElement.setGravity(Gravity.CENTER);

+ 16 - 1
app/src/main/java/com/example/yiupang/freefoodfinder/EventsScreen.java

@@ -1,5 +1,6 @@
 package com.example.yiupang.freefoodfinder;
 
+import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.view.LayoutInflater;
@@ -7,6 +8,7 @@ import android.view.View;
 import android.view.ViewGroup;
 
 //CODE SMELL: unused import
+import android.widget.AdapterView;
 import android.widget.ArrayAdapter;
 
 import android.widget.ListView;
@@ -22,12 +24,13 @@ import java.lang.reflect.Array;
 
 public class EventsScreen extends android.support.v4.app.Fragment
 {
+
     @Nullable
     @Override
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
     {
         View view = inflater.inflate(R.layout.events_screen, container, false);
-        ArrayList<Event> dataArray = new ArrayList();
+        ArrayList<Event> dataArray = new ArrayList<>();
         dataArray.add(new Event("Free Food 1", "Pizza", "Come !!"));
         dataArray.add(new Event("Free Food 5", "GoodPizza", "Come Again!"));
         dataArray.add(new Event("Free Food 4", "NicePizza", "Come Again"));
@@ -36,6 +39,18 @@ public class EventsScreen extends android.support.v4.app.Fragment
         EventArrayAdapter adapter = new EventArrayAdapter(view.getContext(), R.layout.events_list_item, dataArray);
         ListView listView = (ListView) view.findViewById(R.id.events_screen);
         listView.setAdapter(adapter);
+        setItemListener(listView);
         return view;
     }
+
+    public void setItemListener(ListView listView)
+    {
+        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
+            @Override
+            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
+                AboutUsScreen es = new AboutUsScreen();
+                getFragmentManager().beginTransaction().replace(R.id.frame, es).commit();
+            }
+        });
+    }
 }

+ 2 - 1
app/src/main/java/com/example/yiupang/freefoodfinder/MapScreen.java

@@ -10,6 +10,7 @@ import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.GoogleMap;
 import com.google.android.gms.maps.OnMapReadyCallback;
 import com.google.android.gms.maps.SupportMapFragment;
+import com.google.android.gms.maps.model.BitmapDescriptorFactory;
 import com.google.android.gms.maps.model.LatLng;
 import com.google.android.gms.maps.model.MarkerOptions;
 
@@ -46,7 +47,7 @@ public class MapScreen extends android.support.v4.app.Fragment implements OnMapR
         LatLng slo = new LatLng(35.2827778, -120.6586111);
         LatLng sf = new LatLng(37.774929, -122.419416);
         LatLng theP = new LatLng(35.302833, -120.651662);
-        map.addMarker(new MarkerOptions().position(slo).title("Downtown").snippet("Downtownd of slo"));
+        map.addMarker(new MarkerOptions().position(slo).title("Downtown").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)).snippet("Downtownd of slo"));
         map.addMarker(new MarkerOptions().position(theP).title("The P").snippet("The “P” is a 50-by-30 foot landmark located atop a northwestern hill of California Polytechnic State University, San Luis Obispo, California."));
         map.addMarker(new MarkerOptions().position(sf).title("Marker in sf").snippet("Golden Gate Bridge"));
         map.moveCamera(CameraUpdateFactory.newLatLngZoom(slo, 12.0f));