Commit 383665c8 authored by Tanner Grehawick's avatar Tanner Grehawick
Browse files

display toast when changing favorite status of facility

closes #12
parent 4216ea5a
Pipeline #766 passed with stages
in 4 minutes and 46 seconds
......@@ -3,6 +3,7 @@ package srct.whatsopen.views.adapters;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
......@@ -12,6 +13,7 @@ import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import java.util.Calendar;
......@@ -136,6 +138,12 @@ public class FacilityListAdapter extends
@OnClick(R.id.favorite_button)
public void setFavorite() {
mPresenter.toggleFavorite(data);
Context context = getContext();
Resources res = context.getResources();
int formatName = data.isFavorited() ? R.string.toast_unset_favorite : R.string.toast_set_favorite;
String msg = String.format(res.getString(formatName), data.getName());
Toast toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
toast.show();
}
@Override
......
<resources>
<string name="app_name">What\'s Open</string>
<string name="toast_set_favorite">Added %s to Favorites</string>
<string name="toast_unset_favorite">Removed %s from Favorites</string>
</resources>
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