Selaa lähdekoodia

Remove smells

Yiupang 9 vuotta sitten
vanhempi
commit
089e24b815

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

@@ -27,7 +27,6 @@ import java.util.List;
 
 public class EventsScreen extends Fragment
 {
-
     @Nullable
     @Override
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)

+ 0 - 3
app/src/main/java/com/example/yiupang/freefoodfinder/HttpCall.java

@@ -2,9 +2,6 @@ package com.example.yiupang.freefoodfinder;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-
-import java.util.HashMap;
 
 /**
  * Created by yiupang on 5/27/2017.

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

@@ -1,7 +1,5 @@
 package com.example.yiupang.freefoodfinder;
 
-//CODE SMELL: unused import
-
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
@@ -18,7 +16,6 @@ import java.util.ArrayList;
  * Created by yiupang on 5/6/2017.
  *
  */
-
 public class MyEventScreen extends android.support.v4.app.Fragment
 {
     public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
@@ -51,7 +48,7 @@ public class MyEventScreen extends android.support.v4.app.Fragment
         button.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 Intent details = new Intent(getContext(), CreateEventScreen1.class);
-                /* Intent details = new Intent(getContext(), EventDetailsScreen.class);
+                /* Intent details = new Intent(getContext(), EventDetailsScreen1.class);
 
                 details.putExtra("selectedEventName", "name");
                 details.putExtra("selectedEventTime", "time");
@@ -82,7 +79,7 @@ public class MyEventScreen extends android.support.v4.app.Fragment
 
     public void switchActivity(Event selectedEvent)
     {
-        Intent details = new Intent(getContext(), EventDetailsScreen.class);
+        Intent details = new Intent(getContext(), EventDetailsScreen1.class);
 
         details.putExtra("selectedEventName", selectedEvent.getName());
         details.putExtra("selectedEventTime", selectedEvent.getTime());

+ 8 - 9
app/src/main/res/layout/activity_create_event_screen1.xml

@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -10,7 +9,7 @@
         android:id = "@+id/creatorTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Creator:"
+        android:text="@string/createor"
         android:layout_column="0"
         android:layout_row="0"/>
 
@@ -18,7 +17,7 @@
         android:id = "@+id/titleTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Title:"
+        android:text="@string/title"
         android:layout_column="0"
         android:layout_row="1"/>
 
@@ -26,7 +25,7 @@
         android:id="@+id/dateTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Date:"
+        android:text="@string/date"
         android:ems="10"
         android:layout_column="0"
         android:layout_row="2"
@@ -36,7 +35,7 @@
         android:id="@+id/timeTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Time:"
+        android:text="@string/time"
         android:layout_column="0"
         android:layout_row="3" />
 
@@ -44,7 +43,7 @@
         android:id="@+id/placeTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Place:"
+        android:text="@string/place"
         android:layout_column="0"
         android:layout_row="4" />
 
@@ -52,7 +51,7 @@
         android:id="@+id/foodTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Food:"
+        android:text="@string/food"
         android:layout_column="0"
         android:layout_row="5" />
 
@@ -60,7 +59,7 @@
         android:id="@+id/descTitle"
         android:layout_width="80dp"
         android:layout_height="wrap_content"
-        android:text="Description:"
+        android:text="@string/description"
         android:layout_column="0"
         android:layout_row="6" />
 
@@ -133,6 +132,6 @@
         android:layout_height="wrap_content"
         android:layout_column="1"
         android:layout_row="7"
-        android:text = "Create Event" />
+        android:text="@string/create_event" />
 
 </GridLayout>

+ 1 - 0
app/src/main/res/layout/activity_login.xml

@@ -42,6 +42,7 @@
         android:adjustViewBounds="true"
         android:cropToPadding="false"
         android:src="@drawable/loginlogo"
+         android:contentDescription="@string/events"
         android:layout_alignParentTop="true"
         android:layout_centerHorizontal="true" />
 

+ 11 - 0
app/src/main/res/values/strings.xml

@@ -17,4 +17,15 @@
     <string name="host">Host </string>
 
     <string name="home">Home</string>
+
+    <!--Strings on create event screen-->
+    <string name="createor">Creator: </string>
+    <string name="title">Title: </string>
+    <string name="date">Date: </string>
+    <string name="time">Time: </string>
+    <string name="place">Place: </string>
+    <string name="food">Food: </string>
+    <string name="create_event">Create Event</string>
+
+
 </resources>

+ 21 - 3
app/src/test/java/com/example/yiupang/freefoodfinder/TestHttpRequest.java

@@ -1,16 +1,34 @@
 package com.example.yiupang.freefoodfinder;
 
+import org.junit.Before;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
 
+import static org.junit.Assert.assertEquals;
 /**
  * Created by yiupang on 6/1/2017.
  *
  */
 public class TestHttpRequest
 {
+    private EventsScreen eventsScreen;
+
+    @Mock
+    private HttpRequest httpRequest;
+
+    @Captor
+    private ArgumentCaptor<HttpRequest> httpRequestArgumentCaptor;
+
+    @Before
+    public void setUp()
+    {
+        MockitoAnnotations.initMocks(this);
+        eventsScreen = new EventsScreen();
+    }
+
     @Test
     public void testGetCall()
     {