app/src/main/java/com/jarvislin/producepricechecker/database/DatabaseController.java
public class DatabaseController {

    public static String getUpdateDate(String category, String marketNumber) {
        ArrayList<Produce> list = new ArrayList<>(new Select().from(Produce.class)
                .where(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .and(Condition.column(Produce$Table.MARKETNUMBER).is(marketNumber))
                .queryList());

            return (list.size() > 0) ? list.get(0).transactionDate : "";

    }

    public static ArrayList<Produce> getProduces(String category) {
        return new ArrayList<Produce>(new Select().from(Produce.class)
                .where(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .queryList());
    }

    public static ArrayList<Produce> getProduces(String category, String marketNumber) {
        return new ArrayList<Produce>(new Select().from(Produce.class)
                .where(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .and(Condition.column(Produce$Table.MARKETNUMBER).is(marketNumber))
                .queryList());
    }

    public static boolean isBookmark(String name, String category) {
        if (TextUtils.isEmpty(name)) {
            return false;
        }
        return !new ArrayList<Produce>(new Select().from(Produce.class)
                .where(Condition.column(Produce$Table.PRODUCENAME).is(name))
                .and(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .queryList()).isEmpty();
    }

    public static ArrayList<Produce> getBookmarks(String category) {
        return new ArrayList<Produce>(new Select().from(Produce.class)
                .where(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .queryList());
    }

    public static void clearTable() {
        Delete.table(Produce.class);
    }

    public static void clearTable(String category) {
        new Delete()
                .from(Produce.class)
                .where(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .query();
    }

    public static void clearTable(String category, String marketNumber) {
        new Delete()
                .from(Produce.class)
                .where(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .and(Condition.column(Produce$Table.MARKETNUMBER).is(marketNumber))
                .query();
    }

    public static void delete(String name, String category) {
        new Delete()
                .from(Produce.class)
                .where(Condition.column(Produce$Table.PRODUCENAME).is(name))
                .and(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                .query();
    }

    public static void insertBookmark(Produce object, String category) {
        Produce bookmark = new Produce();
        bookmark.produceName = object.produceName;
        bookmark.topPrice = object.topPrice;
        bookmark.middlePrice = object.middlePrice;
        bookmark.lowPrice = object.lowPrice;
        bookmark.averagePrice = object.averagePrice;
        bookmark.transactionDate = object.transactionDate;
        bookmark.mainCategory = category;
        bookmark.save();
    }

    public static void updateBookmark(ArrayList<Produce> produces, String category) {
        ArrayList<Produce> bookmarks = getProduces(category);
        for (Produce bookmark : bookmarks) {
            for (Produce produce : produces) {
                if (bookmark.produceName.equals(produce.produceName)) {
                    Condition[] conditions = {
                            Condition.column(Produce$Table.TOPPRICE).eq(produce.topPrice)
                            , Condition.column(Produce$Table.MIDDLEPRICE).eq(produce.middlePrice)
                            , Condition.column(Produce$Table.LOWPRICE).eq(produce.lowPrice)
                            , Condition.column(Produce$Table.AVERAGEPRICE).eq(produce.averagePrice)
                            , Condition.column(Produce$Table.TRANSACTIONDATE).eq(produce.transactionDate)
                    };

                    new Update(Produce.class)
                            .set(conditions)
                            .where(Condition.column(Produce$Table.PRODUCENAME).is(produce.produceName))
                            .and(Condition.column(Produce$Table.MAINCATEGORY).is(category))
                            .queryClose();
                }
            }
        }

    }
}
app/src/main/java/com/jarvislin/producepricechecker/model/HistoryDirectory.java
public class HistoryDirectory implements Serializable {
    private History[] history;

    public History[] getHistory() {
        return history;
    }

    public void setHistory(History[] history) {
        this.history = history;
    }

    public Date getMinDate() {
        int minYearOfIndex = 0;
        int min = Integer.parseInt(history[0].getYear());
        for (int i = 0; i < history.length; i++) {
            if (min > Integer.parseInt(history[i].getYear())) {
                min = Integer.parseInt(history[i].getYear());
                minYearOfIndex = i;
            }
        }
        return history[minYearOfIndex].getDate().get(0);
    }

    public Date getMaxDate() {
        int maxYearOfIndex = 0;
        int max = Integer.parseInt(history[0].getYear());
        for (int i = 0; i < history.length; i++) {
            if (max < Integer.parseInt(history[i].getYear())) {
                max = Integer.parseInt(history[i].getYear());
                maxYearOfIndex = i;
            }
        }
        int size = history[maxYearOfIndex].getDate().size();
        return history[maxYearOfIndex].getDate().get(size - 1);
    }

    public ArrayList<Date> getAllDates() {
        ArrayList<Date> list = new ArrayList<>();
        for (History history : this.history) {
            list.addAll(history.getDate());
            break;
        }
        return list;
    }

    public boolean exist(int year, int month, int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(year,month,day,0,0,0);
        for (History history : this.history) {
            if (Integer.parseInt(history.getYear()) == year - 1911) {
                for(Date date : history.getDate()) {
                    if(date.getTime() /1000 == calendar.getTime().getTime() / 1000) return true;
                }
            }
        }
        return false;
    }

    @Override
    public String toString() {
        return "ClassPojo [history = " + history + "]";
    }

    public class History {
        private List<Date> list;
        private String year;

        private String[] date;

        public String getYear() {
            return year;
        }

        public void setYear(String year) {
            this.year = year;
        }

        public List<Date> getDate() {
            if (list != null) return list;
            list = new ArrayList<>();
            Calendar calendar = Calendar.getInstance();
            String[] dateArray;
            for (String dateText : date) {
                dateArray = dateText.split("\\.");
                if (dateArray.length == 2) {
                    calendar.set(Integer.valueOf(year) + 1911, Integer.valueOf(dateArray[0]) - 1, Integer.valueOf(dateArray[1]), 0, 0, 0);
                    list.add(calendar.getTime());
                }
            }
            calendar.clear();
            Collections.sort(list);
            return list;
        }

        public void setDate(String[] date) {
            this.date = date;
        }

        @Override
        public String toString() {
            return "ClassPojo [year = " + year + ", date = " + date + "]";
        }
    }
}
app/src/main/java/com/jarvislin/producepricechecker/adapter/CustomerAdapter.java
public class CustomerAdapter extends BaseAdapter {

    protected ArrayList<Produce> list;
    protected Context context;
    protected Preferences_ prefs;
    protected String category;

    public CustomerAdapter(Context context, ArrayList<Produce> list, Preferences_ pref, String category) {
        this.list = list;
        prefs = pref;
        this.context = context;
        this.category = category;
    }


    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        ViewHolder holder;

        if (convertView == null) {
            view = LayoutInflater.from(context).inflate(R.layout.cell_data_customer, parent, false);
            holder = new ViewHolder();
            holder.cell = (LinearLayout) view.findViewById(R.id.cell);
            holder.type = (TextView) view.findViewById(R.id.type);
            holder.name = (TextView) view.findViewById(R.id.name);
            holder.avgPrice = (TextView) view.findViewById(R.id.avgPrice);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        Produce data = list.get(position);

        holder.cell.setBackgroundColor(context.getResources().getColor(
                DatabaseController.isBookmark(data.produceName, this.category) ? R.color.highlight : (position % 2 == 0) ? R.color.white : R.color.odd_row));

        //set views
        String[] name = data.produceName.split("-");
        if(name.length > 1) {
            holder.name.setText(name[0]);
            holder.type.setText(name[1]);
        } else {
            holder.name.setText(data.produceName);
            holder.type.setText(null);
        }

        float avg = Float.valueOf(data.averagePrice);
        int low = Math.round(avg * prefs.unit().get() * (1 + prefs.lowProfit().get()));
        int high = Math.round(avg * prefs.unit().get() * (1 + prefs.hightProfit().get()));
        holder.avgPrice.setText(low + " - " + high);

        return view;
    }

    public void updateList(ArrayList<Produce> newlist) {
        list.clear();
        list.addAll(newlist);
        this.notifyDataSetChanged();
    }

    private class ViewHolder {
        LinearLayout cell;
        TextView type;
        TextView name;
        TextView avgPrice;
    }
}
app/src/main/java/com/jarvislin/producepricechecker/util/Constants.java
public class Constants {
    public static final String FRUIT = "fruit";
    public static final String VEGETABLE = "vegetable";
    public static final String FRUIT_BOOKMARK = "fruit_bookmark";
    public static final String VEGETABLE_BOOKMARK = "vegetable_bookmark";
    public static final String FRUIT_URL = "http://amis.afa.gov.tw/t-asp/v102r.asp";
    public static final String VEGETABLE_URL = "http://amis.afa.gov.tw/v-asp/v102r.asp";
    public static final String CUSTOMER = "customer";
    public static final String MERCHANT = "merchant";
}
app/src/main/java/com/jarvislin/producepricechecker/database/Produce.java
@ModelContainer
@Table(databaseName = ProduceDatabase.NAME)
public class Produce extends BaseModel implements Serializable, Comparable<Produce> {

    @PrimaryKey(autoincrement = true)
    @Column
    public int id;

    @Column
    public String produceName;

    @Column
    public String produceNumber;

    @Column
    public String topPrice;

    @Column
    public String middlePrice;

    @Column
    public String lowPrice;

    @Column
    public String averagePrice;

    @Column
    public String transactionDate;

    @Column
    public String transactionAmount;

    @SerializedName("main_category")
    @Column
    public String mainCategory;

    @SerializedName("sub_category")
    @Column
    public String subCategory;

    @Column
    public String marketNumber;

    @Column
    public String marketName;

    @Override
    public int compareTo(Produce another) {
        return Float.compare(Float.valueOf(this.averagePrice), Float.valueOf(another.averagePrice));
    }
}
app/src/main/java/com/jarvislin/producepricechecker/page/PageListener.java
public interface PageListener {
    void onPageStart(ActivityComponentHelper componentHelper);

    void onCreateOptionsMenu(ActivityComponentHelper componentHelper, Menu menu);
}
app/src/main/java/com/jarvislin/producepricechecker/model/ProduceData.java
public class ProduceData implements Serializable{
    private String defaultMarketNumber;
    private int marketNumbersResId;
    private int marketsTitleResId;
    private String bookmarkCategory;
    private String category;

    public ProduceData(String defaultMarketNumber, int marketNumbersResId, int marketsTitleResId, String bookmarkCategory, String category) {
        this.defaultMarketNumber = defaultMarketNumber;
        this.marketNumbersResId = marketNumbersResId;
        this.marketsTitleResId = marketsTitleResId;
        this.bookmarkCategory = bookmarkCategory;
        this.category = category;
    }

    public  int getMarketNumbersResId(){return marketNumbersResId;}
    public  int getMarketsTitleResId(){return marketsTitleResId;}

    public  String getBookmarkCategory(){return bookmarkCategory;}
    public  String getCategory(){return category;}

    public String getUpdateDate(String marketNumber) {
        return DatabaseController.getUpdateDate(getCategory(), marketNumber);
    }

    public String getDefaultMarketNumber(){
        return defaultMarketNumber;
    }

    public String getMarketName(Context context, String marketNumber) {
        String [] numbers = context.getResources().getStringArray(getMarketNumbersResId());
        String [] markets = context.getResources().getStringArray(getMarketsTitleResId());
        for (int i = 0; i < numbers.length; i++) {
            if(marketNumber.equals(numbers[i])) {
                return markets[i];
            }
        }
        return "無法顯示";
    }

    public int getMarketTitlePosition(Context context, String number) {
        if(TextUtils.isEmpty(number)) {
            number = defaultMarketNumber;
        }
        String [] numbers = context.getResources().getStringArray(getMarketNumbersResId());
        for (int i = 0; i < numbers.length; i++) {
            if(number.equals(numbers[i])) {
                return i;
            }
        }
        return 0;
    }
    public void updateDatabase(ArrayList<Produce> produces, String category) {
        DatabaseController.updateBookmark(produces, category);
    }


}
app/src/main/java/com/jarvislin/producepricechecker/util/DateUtil.java
public class DateUtil {
    public static String getCurrentDate() {
        DateFormat dateFormat = new SimpleDateFormat("MM.dd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date(System.currentTimeMillis()));
        int year = cal.get(Calendar.YEAR) - 1911;
        String date = year +"."+ dateFormat.format(cal.getTime());
        return date;
    }

    public static String getOffsetInWords(int offset) {
        return (offset > 0) ? String.valueOf(offset) + "天前" : "今天";
    }

    public static int getOffset(String date) {
        DateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
        try {
            Date beginDate = dateFormat.parse(date);
            Date endDate = dateFormat.parse(getCurrentDate());
            return (int) (endDate.getTime() - beginDate.getTime()) / (24 * 60 * 60 * 1000);
        } catch (ParseException e) {
            e.printStackTrace();
            return -1;
        }
    }
}
app/src/main/java/com/jarvislin/producepricechecker/ActivityComponentHelper.java
public interface ActivityComponentHelper {

    AppCompatActivity getActivity();

    Toolbar getToolbar();

    void hideToolbar();

    void showToolbar(boolean showSpinner);

    void showHamburger();

    void showArrow();
}
app/src/main/java/com/jarvislin/producepricechecker/custom/CalendarDialog.java
public class CalendarDialog implements OnDateSelectedListener {
    private Context context;
    private HistoryDirectory historyDirectory;
    private AlertDialog dialog;
    private MaterialCalendarView calendarView;
    private OnClickDateListener listener;

    public CalendarDialog(Context context, HistoryDirectory historyDirectory, OnClickDateListener listener) {
        this.context = context;
        this.historyDirectory = historyDirectory;
        this.listener = listener;
        init();
    }

    private void init() {
        View item = LayoutInflater.from(context).inflate(R.layout.dialog_calendar, null);
        dialog = new AlertDialog.Builder(context)
                .setNegativeButton("關閉", null)
                .setView(item).create();

    }

    public void show() {
        if (!dialog.isShowing()) {
            dialog.show();
            calendarView = (MaterialCalendarView) dialog.findViewById(R.id.material_calendar);
            calendarView.setOnDateChangedListener(this);
            calendarView.setMinimumDate(historyDirectory.getMinDate());
            calendarView.setMaximumDate(new Date());
            calendarView.addDecorator(new DisableDecorator());
        }
    }

    @Override
    public void onDateSelected(MaterialCalendarView widget, CalendarDay date, boolean selected) {
        listener.onDateClicked(date);
    }

    public void setHistory(HistoryDirectory directory) {
        historyDirectory = directory;
    }


    private class DisableDecorator implements DayViewDecorator {

        public DisableDecorator() {
        }

        @Override
        public boolean shouldDecorate(CalendarDay day) {
            return !historyDirectory.exist(day.getYear(), day.getMonth(), day.getDay());
        }

        @Override
        public void decorate(DayViewFacade view) {
            view.setDaysDisabled(true);
        }

    }

    public interface OnClickDateListener {
        void onDateClicked(CalendarDay date);
    }

    public void resetDate() {
        calendarView.setCurrentDate(new Date());
    }
}
app/src/main/java/com/jarvislin/producepricechecker/Events.java
public class Events {
    public static class onHistoryClicked {
        public void onHistoryClicked(){}
    }
}
app/src/main/java/com/jarvislin/producepricechecker/util/ToolsHelper.java
public class ToolsHelper {
    private static ProgressDialog progressDialog;
    private static Handler handler = new Handler(Looper.getMainLooper());

    public static Toast showToast(Toast toast, Context context, String string, int duration) {
        if (toast == null) {
            toast = Toast.makeText(context, string, duration);
        } else {
            toast.setText(string);
            toast.setDuration(duration);
        }
        toast.show();
        return toast;
    }

    public static void shareText(Context context, String title, String text) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, title);
        intent.putExtra(Intent.EXTRA_TEXT, text);
        context.startActivity(Intent.createChooser(intent, title));
    }

    public static boolean isNetworkAvailable(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
        return activeNetworkInfo != null && activeNetworkInfo.isConnected();
    }

    public static ProgressDialog getProgressDialog(Context context) {
        progressDialog = new ProgressDialog(context);
        progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progressDialog.setMessage(context.getString(R.string.loading));
        progressDialog.setIndeterminate(true);
        progressDialog.setCancelable(false);
        progressDialog.setCanceledOnTouchOutside(false);
        return progressDialog;
    }

    public static void showProgressDialog(final Context context, boolean isNowOnUiThread) {
        if (isNowOnUiThread) {
            showProgressDialog(context);
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    showProgressDialog(context);
                }
            });
        }
    }

    public static void closeProgressDialog(boolean isNowOnUiThread) {
        if (isNowOnUiThread) {
            closeProgressDialog();
        } else {
            handler.post(new Runnable() {
                @Override
                public void run() {
                    closeProgressDialog();
                }
            });
        }
    }

    private static void showProgressDialog(Context context) {
        closeProgressDialog();
        getProgressDialog(context).show();
    }

    private static void closeProgressDialog() {
        if (progressDialog != null && progressDialog.isShowing()) {
            try {
                progressDialog.dismiss();
            } catch (Exception e) {
            }
        }
    }

    public static void showDialog(Context context, String titleText, String messageText){
        final Dialog dialog = new Dialog(context, R.style.alertDialog);
        dialog.setContentView(R.layout.dialog_info);
        TextView title = (TextView) dialog.findViewById(R.id.title);
        TextView message = (TextView) dialog.findViewById(R.id.info_text);

        title.setText(titleText);
        message.setText(messageText);

        Button dismiss = (Button) dialog.findViewById(R.id.info_dismiss);
        dismiss.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialog.isShowing())
                    dialog.dismiss();
            }
        });

        dialog.show();
    }

    public static void hideSoftKeyboard(Activity activity) {
        View view = activity.getCurrentFocus();
        if (view != null) {
            InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    }

    public static void rating(Context context) {
        final String appPackageName = context.getPackageName();
        try {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
        } catch (android.content.ActivityNotFoundException anfe) {
            context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
        }
    }

    public static void openUrl(Context context, String url) {
        Uri uri = Uri.parse(url);
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        Intent chooser = Intent.createChooser(intent, context.getString(R.string.choose_service));
        context.startActivity(chooser);
    }



}
app/src/main/java/com/jarvislin/producepricechecker/util/GoogleAnalyticsSender.java
public class GoogleAnalyticsSender {
    private static final String PROPERTY_ID = "";
    private static GoogleAnalyticsSender mSender;
    private static Tracker mTracker;

    public static GoogleAnalyticsSender getInstance(Context context){
        if(null == mSender){
            GoogleAnalytics analytics = GoogleAnalytics.getInstance(context);
            mTracker = analytics.newTracker(PROPERTY_ID);
            mTracker.enableAdvertisingIdCollection(true);
            mSender = new GoogleAnalyticsSender();
        }
        return mSender;
    }

    private GoogleAnalyticsSender(){}

    public void send(String path){
        mTracker.setScreenName(path);
        mTracker.send(new HitBuilders.AppViewBuilder().build());
    }

}


Question: import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.SearchManager;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.ColorDrawable;
import android.os.Handler;
import android.support.v7.widget.SearchView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.getbase.floatingactionbutton.FloatingActionButton;
import com.getbase.floatingactionbutton.FloatingActionsMenu;
import com.jarvislin.producepricechecker.ActivityComponentHelper;
import com.jarvislin.producepricechecker.Events;
import com.jarvislin.producepricechecker.R;
import com.jarvislin.producepricechecker.adapter.CustomerAdapter;
import com.jarvislin.producepricechecker.custom.CalendarDialog;
import com.jarvislin.producepricechecker.database.DatabaseController;
import com.jarvislin.producepricechecker.database.Produce;
import com.jarvislin.producepricechecker.model.HistoryDirectory;
import com.jarvislin.producepricechecker.model.ProduceData;
import com.jarvislin.producepricechecker.page.PageListener;
import com.jarvislin.producepricechecker.util.Constants;
import com.jarvislin.producepricechecker.util.DateUtil;
import com.jarvislin.producepricechecker.util.GoogleAnalyticsSender;
import com.jarvislin.producepricechecker.util.Preferences_;
import com.jarvislin.producepricechecker.util.ToolsHelper;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EView;
import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById;
import org.androidannotations.annotations.sharedpreferences.Pref;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import de.greenrobot.event.EventBus;
import flow.Flow;
import static android.widget.Toast.LENGTH_SHORT;

    protected ArrayList<Produce> getSearchList(String newText) {
        ArrayList<Produce> list = new ArrayList<>();
        for (Produce data : filterList) {
            if (data.produceName.contains(newText))
                list.add(data);
        }
        return list;
    }

    @Click
    protected void convertUnit() {
        GoogleAnalyticsSender.getInstance(getContext()).send("click_convert_unit");
        float unit = prefs.unit().get();
        prefs.unit().put(unit < 1 ? 1.0f : 0.6f);
        adapter.notifyDataSetInvalidated();
        String unitText = (prefs.unit().get() < 1 ? "台斤" : "公斤");
        Toast.makeText(getContext(), "目前重量單位為：" + unitText, Toast.LENGTH_SHORT).show();
        setBottomInfo();
        fab.collapse();
    }

    @Click
    protected void update() {
        GoogleAnalyticsSender.getInstance(getContext()).send("click_update");
        presenter.loadData();
        fab.collapse();
    }

    @Click
    protected void subcategoryFilter() {
        GoogleAnalyticsSender.getInstance(getContext()).send("click_filter");
        // show filter dialog
        if (dialog == null) {
            dialog = new Dialog(getContext(), R.style.alertDialog);
            dialog.setContentView(R.layout.dialog_filter);
            Button submit = (Button) dialog.findViewById(R.id.dismiss);
            submit.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (dialog.isShowing()) {
                        dialog.dismiss();
                    }
                }
            });
        }
        CheckBox root = (CheckBox) dialog.findViewById(R.id.root);
        CheckBox leaf = (CheckBox) dialog.findViewById(R.id.leaf);
        CheckBox flowerFruit = (CheckBox) dialog.findViewById(R.id.flower_fruit);
        CheckBox mushroom = (CheckBox) dialog.findViewById(R.id.mushroom);
        CheckBox pickle = (CheckBox) dialog.findViewById(R.id.pickle);

        root.setOnCheckedChangeListener(this);
        leaf.setOnCheckedChangeListener(this);
        flowerFruit.setOnCheckedChangeListener(this);
        mushroom.setOnCheckedChangeListener(this);
        pickle.setOnCheckedChangeListener(this);

        checkBoxes.clear();
        checkBoxes.add(root);
        checkBoxes.add(leaf);
        checkBoxes.add(flowerFruit);
        checkBoxes.add(mushroom);
        checkBoxes.add(pickle);

        dialog.show();
        fab.collapse();
    }

    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        filterList.clear();
        for (CheckBox checkBox : checkBoxes) {
            if (checkBox.isChecked()) {
                filterList.addAll(getListBySubcategory(checkBox.getId()));
            }
        }
        Collections.sort(filterList);
        adapter = getAdapter(getContext(), filterList, prefs, presenter.getProduceData().getBookmarkCategory());
        dataList.setAdapter(adapter);
    }

    @AfterViews
    protected void initFooter() {
        uiHandler = new Handler(getContext().getMainLooper());
        View footer = LayoutInflater.from(getContext()).inflate(R.layout.price_footer, null);
        footer.setOnClickListener(null);
        dataList.addFooterView(footer);
        dataList.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                if (scrollState == SCROLL_STATE_IDLE && fab.getVisibility() == GONE) {
                    uiHandler.postDelayed(showButton, 600);
                } else if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
                    uiHandler.removeCallbacks(showButton);
                    if (fab.getVisibility() == VISIBLE) {
                        uiHandler.post(hideButton);
                    }
                }
            }

            @Override
            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
            }
        });
    }

    @UiThread
    protected void handleData(ArrayList<Produce> list) {
        if (list == null || list.size() == 0) {
            Toast.makeText(getContext(), R.string.error_network, Toast.LENGTH_SHORT).show();
            Flow.get(getContext()).goBack();
        } else {
            Collections.sort(list);
            produces = list;
            filterList = new ArrayList<>(list);
            adapter = getAdapter(getContext(), list, prefs, presenter.getProduceData().getBookmarkCategory());
            dataList.setAdapter(adapter);
            dataList.setOnItemClickListener(itemClickListener(presenter.getProduceData()));
            setBottomInfo();
Answer:             subcategoryFilter.setVisibility(presenter.getProduceData().getCategory().equals(Constants.VEGETABLE) ? VISIBLE : GONE);