Commit 297f5366 authored by Willard's avatar Willard

Minor refactoring, remove getAllData temporarily

parent a168d5e4
...@@ -4,9 +4,6 @@ import android.content.Context; ...@@ -4,9 +4,6 @@ import android.content.Context;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.NetworkInfo; import android.net.NetworkInfo;
/**
* Created by candy on 10/20/16.
*/
public class AppUtils { public class AppUtils {
public static boolean isNetworkAvailable(Context c) { public static boolean isNetworkAvailable(Context c) {
......
package com.testapp; package com.testapp;
import com.testapp.entities.CData;
import com.testapp.entities.Cuisine; import com.testapp.entities.Cuisine;
import com.testapp.entities.Dish; import com.testapp.entities.Dish;
import com.testapp.entities.DishType; import com.testapp.entities.DishType;
import com.testapp.entities.Location; import com.testapp.entities.Location;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import okhttp3.ResponseBody;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.Path;
import retrofit2.http.Query; import retrofit2.http.Query;
/**
* Created by candy on 10/19/16.
*/
public interface CanteeneoApiInterface { public interface CanteeneoApiInterface {
@GET("api/all")
Call<CData> getAll();
@GET("api/allBy")
Call<CData> getAllBy(@Query("date") String date);
@GET("api/search/dish") @GET("api/search/dish")
Call<List<Dish>> searchByName(@Query("name") String name, Call<List<Dish>> searchByName(@Query("name") String name,
@Query("type_filters") String types, @Query("type_filters") String types,
...@@ -43,12 +29,4 @@ public interface CanteeneoApiInterface { ...@@ -43,12 +29,4 @@ public interface CanteeneoApiInterface {
@GET("api/cuisines") @GET("api/cuisines")
Call<List<Cuisine>> getCuisines(); Call<List<Cuisine>> getCuisines();
// @GET("static/uploads/{filename}")
// Call<ResponseBody> downloadImage(@Path("filename") String filename);
// // updating favorites and reviews later on
// @POST("upload")
// Call<ResponseBody> sendAll(@Body sth sth);
} }
...@@ -4,19 +4,12 @@ import android.app.Activity; ...@@ -4,19 +4,12 @@ import android.app.Activity;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import com.testapp.entities.Dish; import com.testapp.entities.Dish;
import java.util.ArrayList; import java.util.ArrayList;
/**
* Created by candy on 10/20/16.
*/
public class DishAdapter extends BaseAdapter { public class DishAdapter extends BaseAdapter {
private Activity context; private Activity context;
ArrayList<Dish> dishes; ArrayList<Dish> dishes;
......
...@@ -5,9 +5,7 @@ import android.content.Intent; ...@@ -5,9 +5,7 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.widget.SearchView; import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
...@@ -18,7 +16,6 @@ import android.support.v7.app.AppCompatActivity; ...@@ -18,7 +16,6 @@ import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
...@@ -26,12 +23,10 @@ import android.widget.Toast; ...@@ -26,12 +23,10 @@ import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.testapp.entities.CData;
import com.testapp.entities.Cuisine; import com.testapp.entities.Cuisine;
import com.testapp.entities.Dish; import com.testapp.entities.Dish;
import com.testapp.entities.DishType; import com.testapp.entities.DishType;
import com.testapp.entities.Location; import com.testapp.entities.Location;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -195,25 +190,9 @@ public class NavDrawerActivity extends AppCompatActivity ...@@ -195,25 +190,9 @@ public class NavDrawerActivity extends AppCompatActivity
adapter = new DishAdapter(this, dishes); adapter = new DishAdapter(this, dishes);
lv.setAdapter(adapter); lv.setAdapter(adapter);
getAllData();
searchDish(dishName); searchDish(dishName);
} }
private void getAllData() {
Call<CData> call = service.getAll();
call.enqueue(new Callback<CData>() {
@Override
public void onResponse(Call<CData> call, Response<CData> response) {
int statusCode = response.code();
CData cdata = response.body();
}
@Override
public void onFailure(Call<CData> call, Throwable throwable) {
}
});
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
......
...@@ -2,11 +2,8 @@ package com.testapp; ...@@ -2,11 +2,8 @@ package com.testapp;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.LinearLayout; import android.widget.LinearLayout;
...@@ -14,20 +11,17 @@ import android.widget.ListView; ...@@ -14,20 +11,17 @@ import android.widget.ListView;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.testapp.entities.CData;
import com.testapp.entities.Dish; import com.testapp.entities.Dish;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import okhttp3.Cache; import okhttp3.Cache;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.ResponseBody;
import okhttp3.internal.Util;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -80,25 +74,9 @@ public class SearchActivity extends AppCompatActivity { ...@@ -80,25 +74,9 @@ public class SearchActivity extends AppCompatActivity {
service = retrofit.create(CanteeneoApiInterface.class); service = retrofit.create(CanteeneoApiInterface.class);
getAllData();
searchDish(dishName); searchDish(dishName);
} }
private void getAllData() {
Call<CData> call = service.getAll();
call.enqueue(new Callback<CData>() {
@Override
public void onResponse(Call<CData> call, Response<CData> response) {
int statusCode = response.code();
CData cdata = response.body();
}
@Override
public void onFailure(Call<CData> call, Throwable throwable) {
}
});
}
private String getChecked(int layoutId) { private String getChecked(int layoutId) {
LinearLayout checkboxes = (LinearLayout)findViewById(layoutId); LinearLayout checkboxes = (LinearLayout)findViewById(layoutId);
String checked = ""; String checked = "";
......
package com.testapp; package com.testapp;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View;
public class StallViewActivity extends AppCompatActivity { public class StallViewActivity extends AppCompatActivity {
...@@ -25,7 +22,6 @@ public class StallViewActivity extends AppCompatActivity { ...@@ -25,7 +22,6 @@ public class StallViewActivity extends AppCompatActivity {
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) { switch (item.getItemId()) {
case android.R.id.home: case android.R.id.home:
// app icon in action bar clicked; goto parent activity.
this.finish(); this.finish();
return true; return true;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment