use of androidx.core.util.Pair in project xabber-android by redsolution.
the class XTokenManager method parseSessions.
private static Pair<SessionVO, List<SessionVO>> parseSessions(String currentSessionUID, SessionsIQ iq) {
SessionVO currentSession = null;
List<SessionVO> result = new ArrayList<>();
List<Session> sessions = iq.getSessions();
Collections.sort(sessions, Collections.reverseOrder(new Comparator<Session>() {
@Override
public int compare(Session session, Session t1) {
return (int) (session.getLastAuth() - t1.getLastAuth());
}
}));
for (Session session : sessions) {
if (session.getUid().equals(currentSessionUID)) {
currentSession = new SessionVO(session.getClient(), session.getDevice(), session.getUid(), session.getIp(), "online");
} else {
result.add(new SessionVO(session.getClient(), session.getDevice(), session.getUid(), session.getIp(), StringUtils.getSmartTimeTextForRoster(Application.getInstance(), new Date(session.getLastAuth()))));
}
}
return new Pair<>(currentSession, result);
}
use of androidx.core.util.Pair in project Douya by DreaminginCodeZH.
the class BaseItemIntroductionFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
AppCompatActivity activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(mToolbar);
TintHelper.onSetSupportActionBar(mToolbar);
activity.setTitle(mItem.title);
mIntroductionText.setText(!TextUtils.isEmpty(mItem.introduction) ? mItem.getPrettyIntroduction() : activity.getString(R.string.item_introduction_empty));
List<Pair<String, String>> informationData = makeInformationData();
boolean hasInformationData = !informationData.isEmpty();
ViewUtils.setVisibleOrGone(mInformationLayout, hasInformationData);
if (hasInformationData) {
ItemIntroductionPairListAdapter informationAdapter = new ItemIntroductionPairListAdapter();
informationAdapter.replace(informationData);
mInformationLayout.setColumnCount(2);
// HACK: Disabled for looking weird; anyway we always have the space from word break.
// mInformationLayout.setHorizontalDivider(R.drawable.transparent_divider_vertical_16dp);
mInformationLayout.setAdapter(informationAdapter);
}
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class ImageWidgetTest method whenPromptHasDefaultAnswer_doesNotShow.
@Test
public void whenPromptHasDefaultAnswer_doesNotShow() throws Exception {
String imagePath = File.createTempFile("default", ".bmp").getAbsolutePath();
ReferenceManager referenceManager = setupFakeReferenceManager(singletonList(new Pair<>(DrawWidgetTest.DEFAULT_IMAGE_ANSWER, imagePath)));
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
@Override
public ImageLoader providesImageLoader() {
return new SynchronousImageLoader();
}
});
formEntryPrompt = new MockFormEntryPromptBuilder().withAnswerDisplayText(DrawWidgetTest.DEFAULT_IMAGE_ANSWER).build();
ImageWidget widget = createWidget();
ImageView imageView = widget.getImageView();
assertThat(imageView, nullValue());
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class SelectImageMapWidgetTest method overrideDependencyModule.
private void overrideDependencyModule() throws Exception {
ReferenceManager referenceManager = setupFakeReferenceManager(asList(new Pair<>("jr://images/body.svg", "body.svg")));
CollectHelpers.overrideAppDependencyModule(new AppDependencyModule() {
@Override
public ReferenceManager providesReferenceManager() {
return referenceManager;
}
});
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class SelectOneWidgetTest method whenChoicesHaveAudio_audioButtonUsesIndexAsClipID.
@Test
public void whenChoicesHaveAudio_audioButtonUsesIndexAsClipID() throws Exception {
formEntryPrompt = new MockFormEntryPromptBuilder().withIndex("i am index").withSelectChoices(asList(new SelectChoice("1", "1"), new SelectChoice("2", "2"))).withSpecialFormSelectChoiceText(asList(new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(0).first), new Pair<>(FormEntryCaption.TEXT_FORM_AUDIO, REFERENCES.get(1).first))).build();
populateRecyclerView(getWidget());
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 0", REFERENCES.get(0).second)));
verify(audioHelper).setAudio(any(AudioButton.class), eq(new Clip("i am index 1", REFERENCES.get(1).second)));
}
Aggregations