Search in sources :

Example 6 with RideFiltersForJson

use of br.ufrj.caronae.models.modelsforjson.RideFiltersForJson in project caronae-android by caronae.

the class MainAct method startFilterCard.

private void startFilterCard() {
    String filtersJsonString = SharedPref.getFiltersPref();
    if (!filtersJsonString.equals(SharedPref.MISSING_PREF)) {
        RideFiltersForJson filters = loadFilters(filtersJsonString);
        String resumeLocations = filters.getResumeLocation();
        String center = filters.getCenter();
        String campus = filters.getCampus();
        String zone = filters.getZone();
        String filtering = "Filtrando: ";
        SpannableString cardText;
        if (!resumeLocations.equals("")) {
            if (center.equals("")) {
                if (campus.equals("")) {
                    center = "Todos os Campi";
                } else {
                    center = campus;
                }
            }
            if (center.equals("Todos os Campi")) {
                cardText = new SpannableString(filtering + resumeLocations);
            } else if (zone.equals("Todos os Bairros")) {
                cardText = new SpannableString(filtering + center);
            } else {
                cardText = new SpannableString(filtering + center + ", " + resumeLocations);
            }
            cardText.setSpan(new StyleSpan(Typeface.BOLD), 0, filtering.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            filterText.setText(cardText);
            filterCard.setVisibility(View.VISIBLE);
        } else {
            if (zone.equals("")) {
                zone = "Todos os Bairros";
            }
            if (center.equals("")) {
                if (campus.equals("")) {
                    center = "Todos os Campi";
                } else {
                    center = campus;
                }
            }
            if (center.equals("Todos os Campi")) {
                cardText = new SpannableString(filtering + zone);
            } else if (zone.equals("Todos os Bairros")) {
                cardText = new SpannableString(filtering + center);
            } else {
                cardText = new SpannableString(filtering + center + ", " + zone);
            }
            cardText.setSpan(new StyleSpan(Typeface.BOLD), 0, filtering.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            filterText.setText(cardText);
            filterCard.setVisibility(View.VISIBLE);
        }
    }
}
Also used : SpannableString(android.text.SpannableString) RideFiltersForJson(br.ufrj.caronae.models.modelsforjson.RideFiltersForJson) StyleSpan(android.text.style.StyleSpan) SpannableString(android.text.SpannableString)

Aggregations

RideFiltersForJson (br.ufrj.caronae.models.modelsforjson.RideFiltersForJson)6 Gson (com.google.gson.Gson)4 SpannableString (android.text.SpannableString)2 StyleSpan (android.text.style.StyleSpan)2 RideOfferComparatorByDateAndTime (br.ufrj.caronae.comparators.RideOfferComparatorByDateAndTime)2 RideForJson (br.ufrj.caronae.models.modelsforjson.RideForJson)2 RideForJsonDeserializer (br.ufrj.caronae.models.modelsforjson.RideForJsonDeserializer)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Intent (android.content.Intent)1 Snackbar (android.support.design.widget.Snackbar)1 View (android.view.View)1 AllRidesFragmentPagerAdapter (br.ufrj.caronae.adapters.AllRidesFragmentPagerAdapter)1 BindView (butterknife.BindView)1 OnClick (butterknife.OnClick)1