Commit 70855ed8 authored by Willard's avatar Willard

Hide "Add Review" button and disable favorite button when on guest mode

parent 6d8f41a2
......@@ -68,6 +68,7 @@ public class DishViewActivity extends AppCompatActivity {
}
favoriteCheckbox = (CheckBox)findViewById(R.id.favorite_checkbox);
favoriteCheckbox.setEnabled(AppUtils.isLoggedIn());
favoriteCheckbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -75,7 +76,7 @@ public class DishViewActivity extends AppCompatActivity {
favoriteCall.enqueue(new Callback<FavoriteInfo>() {
@Override
public void onResponse(Call<FavoriteInfo> call, Response<FavoriteInfo> response) {
favoriteCheckbox.setText("Favorite (" + response.body().getCount() + ")");
favoriteCheckbox.setText(response.body().getCount() + " users favorited this");
}
@Override
......@@ -91,12 +92,12 @@ public class DishViewActivity extends AppCompatActivity {
@Override
public void onResponse(Call<FavoriteInfo> call, Response<FavoriteInfo> response) {
favoriteCheckbox.setChecked(response.body().isFavorited());
favoriteCheckbox.setText("Favorite (" + response.body().getCount() + ")");
favoriteCheckbox.setText(response.body().getCount() + " users favorited this");
}
@Override
public void onFailure(Call<FavoriteInfo> call, Throwable t) {
favoriteCheckbox.setText("Favorite (-1)");
favoriteCheckbox.setText("-");
}
});
......@@ -151,7 +152,7 @@ public class DishViewActivity extends AppCompatActivity {
newReviews.remove(ownedReview);
reviews.add(ownedReview);
}
findViewById(R.id.add_review_button).setVisibility(ownedReview != null? View.INVISIBLE: View.VISIBLE);
findViewById(R.id.add_review_button).setVisibility(ownedReview != null || !AppUtils.isLoggedIn()? View.INVISIBLE: View.VISIBLE);
reviews.addAll(newReviews);
adapter.notifyDataSetChanged();
......
......@@ -9,15 +9,13 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import com.testapp.entities.Dish;
import com.testapp.entities.Stall;
import com.testapp.entities.FavoriteInfo;
import com.testapp.entities.Stall;
import com.testapp.entities.StallReview;
import java.util.ArrayList;
......@@ -85,7 +83,7 @@ public class StallViewActivity extends AppCompatActivity {
favoriteCall.enqueue(new Callback<FavoriteInfo>() {
@Override
public void onResponse(Call<FavoriteInfo> call, Response<FavoriteInfo> response) {
favoriteCheckbox.setText("Favorite (" + response.body().getCount() + ")");
favoriteCheckbox.setText(response.body().getCount() + " users favorited this");
}
@Override
......@@ -101,12 +99,12 @@ public class StallViewActivity extends AppCompatActivity {
@Override
public void onResponse(Call<FavoriteInfo> call, Response<FavoriteInfo> response) {
favoriteCheckbox.setChecked(response.body().isFavorited());
favoriteCheckbox.setText("Favorite (" + response.body().getCount() + ")");
favoriteCheckbox.setText(response.body().getCount() + " users favorited this");
}
@Override
public void onFailure(Call<FavoriteInfo> call, Throwable t) {
favoriteCheckbox.setText("Favorite (-1)");
favoriteCheckbox.setText("-");
}
});
......@@ -188,7 +186,7 @@ public class StallViewActivity extends AppCompatActivity {
newReviews.remove(ownedReview);
reviews.add(ownedReview);
}
findViewById(R.id.add_review_button).setVisibility(ownedReview != null? View.INVISIBLE: View.VISIBLE);
findViewById(R.id.add_review_button).setVisibility(ownedReview != null || !AppUtils.isLoggedIn()? View.INVISIBLE: View.VISIBLE);
reviews.addAll(newReviews);
srAdapter.notifyDataSetChanged();
......
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