Example usage for android.support.v4.util Pair equals

List of usage examples for android.support.v4.util Pair equals

Introduction

In this page you can find the example usage for android.support.v4.util Pair equals.

Prototype

public boolean equals(Object obj) 

Source Link

Usage

From source file:com.vrem.wifianalyzer.wifi.graph.channel.ChannelGraphNavigation.java

private void makeNavigationItems(@NonNull Context context, @NonNull Configuration configuration) {
    Pair<WiFiChannel, WiFiChannel> selected = configuration.getWiFiChannelPair();
    List<Pair<WiFiChannel, WiFiChannel>> wiFiChannelPairs = WiFiBand.GHZ5.getWiFiChannels()
            .getWiFiChannelPairs(configuration.getLocale());
    if (wiFiChannelPairs.size() > 1) {
        for (Pair<WiFiChannel, WiFiChannel> pair : wiFiChannelPairs) {
            navigationItems.add(makeNavigationItem(context, configuration, pair, pair.equals(selected)));
        }/*from   www.j  a  v a  2 s  .c  om*/
    }
}

From source file:com.aqnote.app.wifianalyzer.wifi.graph.channel.ChannelGraphNavigation.java

void update() {
    List<NavigationItem> visible = getVisibleNavigationItems();

    Pair<WiFiChannel, WiFiChannel> selectedWiFiChannelPair = configuration.getWiFiChannelPair();
    for (NavigationItem navigationItem : navigationItems) {
        Button button = navigationItem.getButton();
        Pair<WiFiChannel, WiFiChannel> wiFiChannelPair = navigationItem.getWiFiChannelPair();
        if (visible.size() > 1 && visible.contains(navigationItem)) {
            button.setVisibility(View.VISIBLE);
            setSelectedButton(button, wiFiChannelPair.equals(selectedWiFiChannelPair));
        } else {//  w w  w.  j  a v  a2 s.c o  m
            button.setVisibility(View.GONE);
            setSelectedButton(button, false);
        }
    }
}

From source file:com.vrem.wifianalyzer.wifi.channelgraph.ChannelGraphNavigationTest.java

@Test
public void testUpdateWithGHZ5AndUS() throws Exception {
    // setup/*w  w w. j  av a2  s.  c  o  m*/
    final int colorSelected = ContextCompat.getColor(mainActivity, R.color.connected);
    final int colorNotSelected = ContextCompat.getColor(mainActivity, R.color.connected_background);
    final Pair<WiFiChannel, WiFiChannel> selectedKey = WiFiBand.GHZ5.getWiFiChannels().getWiFiChannelPairs()
            .get(0);
    when(configuration.getWiFiChannelPair()).thenReturn(selectedKey);
    when(settings.getCountryCode()).thenReturn(Locale.US.getCountry());
    when(settings.getWiFiBand()).thenReturn(WiFiBand.GHZ5);
    when(settings.getSortBy()).thenReturn(SortBy.CHANNEL);
    // execute
    fixture.update(WiFiData.EMPTY);
    // validate
    verify(layout).setVisibility(View.VISIBLE);
    IterableUtils.forEach(views.keySet(), new Closure<Pair<WiFiChannel, WiFiChannel>>() {
        @Override
        public void execute(Pair<WiFiChannel, WiFiChannel> key) {
            Button button = (Button) views.get(key);
            verify(button).setVisibility(View.VISIBLE);
            verify(button).setBackgroundColor(selectedKey.equals(key) ? colorSelected : colorNotSelected);
            verify(button).setSelected(selectedKey.equals(key));
        }
    });
    IterableUtils.forEach(ChannelGraphNavigation.ids.values(), new Closure<Integer>() {
        @Override
        public void execute(Integer id) {
            verify(layout, times(2)).findViewById(id);
        }
    });
    verify(settings).getCountryCode();
    verify(settings, times(2)).getWiFiBand();
    verify(settings).getSortBy();
    verify(configuration).getWiFiChannelPair();
}

From source file:org.andstatus.app.msg.TimelineData.java

private boolean collapseThisGroup(long itemId, Pair<TimelinePage, TimelineViewItem> parent,
        Set<Pair<TimelinePage, TimelineViewItem>> group,
        Collection<Pair<TimelinePage, TimelineViewItem>> toCollapse) {
    if (group.isEmpty()) {
        return false;
    }// w  ww.j a v  a 2s. c o  m

    boolean groupOfSelectedItem = false;
    if (itemId != 0) {
        for (Pair<TimelinePage, TimelineViewItem> itemPair : group) {
            if (itemId == itemPair.second.getMsgId()) {
                groupOfSelectedItem = true;
                break;
            }
        }
    }
    if (groupOfSelectedItem) {
        for (Pair<TimelinePage, TimelineViewItem> itemPair : group) {
            setIndividualCollapsedStatus(true, itemPair.second.getMsgId());
        }
    }

    boolean hasIndividualCollapseState = false;
    if (!groupOfSelectedItem && !individualCollapsedStateIds.isEmpty()) {
        for (Pair<TimelinePage, TimelineViewItem> itemPair : group) {
            if (individualCollapsedStateIds.contains(itemPair.second.getMsgId())) {
                hasIndividualCollapseState = true;
                break;
            }
        }
    }
    if (!hasIndividualCollapseState) {
        for (Pair<TimelinePage, TimelineViewItem> itemPair : group) {
            if (!parent.equals(itemPair)) {
                parent.second.collapse(itemPair.second);
                toCollapse.add(itemPair);
            }
        }
    }
    return groupOfSelectedItem;
}

From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java

public CharSequence getBestDayText() {

    final List<PickupInfo> urgent = pickupUtils.urgentMeds();
    Pair<LocalDate, List<PickupInfo>> best = pickupUtils.getBestDay();

    final List<PickupInfo> next = (best == null || best.first == null) ? new ArrayList<PickupInfo>()
            : best.second;/*from ww  w.  j  a va  2s  .c om*/

    CharSequence msg = new SpannableString("No hai medicinas que recoger");
    LocalDate today = LocalDate.now();

    // there are not urgent meds, but there are others to pickup
    if (urgent.isEmpty() && best != null) {

        //            Log.d("Calendar", "Urgent: " + urgent.size());
        //            Log.d("Calendar", "Next: " + next.size());

        Log.d("Calendar", "there are not urgent meds, but there are others to pickup");
        if (next.size() > 1) {
            msg = new SpannableString(getString(R.string.best_single_day_messge,
                    best.first.toString(getString(R.string.best_date_format)), next.size()) + "\n\n");
        } else {
            msg = new SpannableString(getString(R.string.best_single_day_messge_one_med,
                    best.first.toString(getString(R.string.best_date_format))) + "\n\n");
        }
        msg = addPickupList(msg, next);
    }

    // there are urgent meds
    Log.d("Calendar", "there are urgent meds");
    if (!urgent.isEmpty()) {
        // and others
        Log.d("Calendar", "and others");
        if (best != null) {

            String bestStr = best.equals(LocalDate.now().plusDays(1))
                    ? getString(R.string.calendar_date_tomorrow)
                    : best.first.toString(getString(R.string.best_date_format));

            // and the others date is near
            Log.d("Calendar", "and the others date is near");
            if (today.plusDays(3).isAfter(best.first)) {
                List<PickupInfo> all = new ArrayList<>();
                all.addAll(urgent);
                all.addAll(next);
                msg = new SpannableString(
                        getString(R.string.best_single_day_messge, bestStr, all.size()) + "\n\n");
                msg = addPickupList(msg, all);
            }
            // and the others date is not near
            else {

                Log.d("Calendar", "and the others date is not near");
                msg = addPickupList(new SpannableString(getString(R.string.pending_meds_msg) + "\n\n"), urgent);

                msg = TextUtils.concat(msg, new SpannableString("\n"));
                if (next.size() > 1) {
                    Log.d("Calendar", " size > 1");
                    msg = TextUtils.concat(msg,
                            getString(R.string.best_single_day_messge_after_pending, bestStr, next.size())
                                    + "\n\n");
                } else {
                    Log.d("Calendar", " size <= 1");
                    msg = TextUtils.concat(msg,
                            getString(R.string.best_single_day_messge_after_pending_one_med, bestStr) + "\n\n");
                }
                msg = addPickupList(msg, next);
            }
        } else {
            Log.d("Calendar", " there are only urgent meds");
            // there are only urgent meds
            msg = addPickupList(getString(R.string.pending_meds_msg) + "\n\n", urgent);
        }
    }

    Log.d("BEST_DAY", msg.toString());
    return msg;
}