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 {
@DELETE("api/stalls/{id}/reviews/{review_id}")
Call<ResponseBody> deleteStallReview(@Path("id") int id, @Path("review_id") int review_id);
@GET("api/stalls/{id}/dishes")
Call<List<Dish>> getDishesByStall(@Path("id") int id);
......
......@@ -9,6 +9,8 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
......@@ -17,6 +19,7 @@ import com.canteeneo.entities.Dish;
import com.canteeneo.entities.FavoriteInfo;
import com.canteeneo.entities.Stall;
import com.canteeneo.entities.StallReview;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import java.util.List;
......@@ -119,28 +122,9 @@ public class StallViewActivity extends AppCompatActivity {
}
});
ListView lvDishes = (ListView) findViewById(R.id.stall_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);
lvReviews.setAdapter(srAdapter);
getStallDishes(id);
getStallReviews(id);
}
......@@ -160,7 +144,13 @@ public class StallViewActivity extends AppCompatActivity {
dishes.clear();
dishes.addAll(newDishes);
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
......@@ -191,7 +181,13 @@ public class StallViewActivity extends AppCompatActivity {
findViewById(R.id.add_review_button).setVisibility(ownedReview != null || !AppUtils.isLoggedIn() ? View.INVISIBLE : View.VISIBLE);
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
......
......@@ -129,12 +129,6 @@
android:paddingTop="10dp"
android:weightSum="14">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -142,18 +136,17 @@
android:text="Dishes:"
android:textSize="18sp"/>
<ListView
<LinearLayout
android:id="@+id/stall_dishes"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_weight="6.45"
android:fadeScrollbars="false"/>
android:layout_height="wrap_content"
android:orientation="vertical"
android:weightSum="1">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
......@@ -173,10 +166,12 @@
</LinearLayout>
<ListView
<LinearLayout
android:id="@+id/stall_reviews"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content">
</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