Commit 510ef2a4 authored by Willard's avatar Willard

Remove scrolling listview from StallView, use LayoutInflater instead

parent 6e56a9bf
...@@ -84,7 +84,6 @@ public interface CanteeneoApiInterface { ...@@ -84,7 +84,6 @@ public interface CanteeneoApiInterface {
@DELETE("api/stalls/{id}/reviews/{review_id}") @DELETE("api/stalls/{id}/reviews/{review_id}")
Call<ResponseBody> deleteStallReview(@Path("id") int id, @Path("review_id") int review_id); Call<ResponseBody> deleteStallReview(@Path("id") int id, @Path("review_id") int review_id);
@GET("api/stalls/{id}/dishes") @GET("api/stalls/{id}/dishes")
Call<List<Dish>> getDishesByStall(@Path("id") int id); Call<List<Dish>> getDishesByStall(@Path("id") int id);
......
...@@ -9,6 +9,8 @@ import android.view.View; ...@@ -9,6 +9,8 @@ import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -17,6 +19,7 @@ import com.canteeneo.entities.Dish; ...@@ -17,6 +19,7 @@ import com.canteeneo.entities.Dish;
import com.canteeneo.entities.FavoriteInfo; import com.canteeneo.entities.FavoriteInfo;
import com.canteeneo.entities.Stall; import com.canteeneo.entities.Stall;
import com.canteeneo.entities.StallReview; import com.canteeneo.entities.StallReview;
import com.squareup.picasso.Picasso;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -119,28 +122,9 @@ public class StallViewActivity extends AppCompatActivity { ...@@ -119,28 +122,9 @@ public class StallViewActivity extends AppCompatActivity {
} }
}); });
ListView lvDishes = (ListView) findViewById(R.id.stall_dishes);
dAdapter = new DishAdapter(StallViewActivity.this, dishes); dAdapter = new DishAdapter(StallViewActivity.this, dishes);
getStallDishes(id);
lvDishes.setAdapter(dAdapter);
lvDishes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent i = new Intent(StallViewActivity.this, DishViewActivity.class);
Dish d = dishes.get(position);
i.putExtra("ID", d.getId());
i.putExtra("NAME", d.getName());
i.putExtra("PRICE", d.getPrice());
i.putExtra("IMAGE", d.getImagePath());
i.putExtra("DESCRIPTION", d.getDescription());
i.putExtra("STALLNAME", d.getStallName());
startActivity(i);
}
});
ListView lvReviews = (ListView) findViewById(R.id.stall_reviews);
srAdapter = new StallReviewAdapter(StallViewActivity.this, reviews); srAdapter = new StallReviewAdapter(StallViewActivity.this, reviews);
lvReviews.setAdapter(srAdapter); getStallDishes(id);
getStallReviews(id); getStallReviews(id);
} }
...@@ -160,7 +144,13 @@ public class StallViewActivity extends AppCompatActivity { ...@@ -160,7 +144,13 @@ public class StallViewActivity extends AppCompatActivity {
dishes.clear(); dishes.clear();
dishes.addAll(newDishes); dishes.addAll(newDishes);
dAdapter.defaultFilter(); dAdapter.defaultFilter();
dAdapter.notifyDataSetChanged();
LinearLayout stallDishes = (LinearLayout) findViewById(R.id.stall_dishes);
stallDishes.removeAllViews();
for (int i = 0; i < dAdapter.getCount(); i++) {
stallDishes.addView(dAdapter.getView(i, null, stallDishes));
}
} }
@Override @Override
...@@ -191,7 +181,13 @@ public class StallViewActivity extends AppCompatActivity { ...@@ -191,7 +181,13 @@ public class StallViewActivity extends AppCompatActivity {
findViewById(R.id.add_review_button).setVisibility(ownedReview != null || !AppUtils.isLoggedIn() ? View.INVISIBLE : View.VISIBLE); findViewById(R.id.add_review_button).setVisibility(ownedReview != null || !AppUtils.isLoggedIn() ? View.INVISIBLE : View.VISIBLE);
reviews.addAll(newReviews); reviews.addAll(newReviews);
srAdapter.notifyDataSetChanged();
LinearLayout stallReviews = (LinearLayout) findViewById(R.id.stall_reviews);
stallReviews.removeAllViews();
for (int i = 0; i < srAdapter.getCount(); i++) {
stallReviews.addView(srAdapter.getView(i, null, stallReviews));
}
} }
@Override @Override
......
...@@ -129,31 +129,24 @@ ...@@ -129,31 +129,24 @@
android:paddingTop="10dp" android:paddingTop="10dp"
android:weightSum="14"> android:weightSum="14">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Dishes:"
android:textSize="18sp"/>
<LinearLayout <LinearLayout
android:id="@+id/stall_dishes"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:weightSum="1"> android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Dishes:"
android:textSize="18sp"/>
<ListView
android:id="@+id/stall_dishes"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_weight="6.45"
android:fadeScrollbars="false"/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal"> android:orientation="horizontal">
<TextView <TextView
...@@ -173,10 +166,12 @@ ...@@ -173,10 +166,12 @@
</LinearLayout> </LinearLayout>
<ListView <LinearLayout
android:id="@+id/stall_reviews" android:id="@+id/stall_reviews"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout> </LinearLayout>
......
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