use of androidx.core.util.Pair in project ExoPlayer by google.
the class SessionPlayerConnector method notifySessionPlayerCallback.
private void notifySessionPlayerCallback(SessionPlayerCallbackNotifier notifier) {
synchronized (stateLock) {
if (closed) {
return;
}
}
List<Pair<SessionPlayer.PlayerCallback, Executor>> callbacks = getCallbacks();
for (Pair<SessionPlayer.PlayerCallback, Executor> pair : callbacks) {
SessionPlayer.PlayerCallback callback = Assertions.checkNotNull(pair.first);
Executor executor = Assertions.checkNotNull(pair.second);
executor.execute(() -> notifier.callCallback(callback));
}
}
use of androidx.core.util.Pair in project android_packages_apps_crDroidSettings by crdroidandroid.
the class PagerSlidingTabStrip method getIndicatorCoordinates.
public Pair<Float, Float> getIndicatorCoordinates() {
// default: line below current tab
View currentTab = mTabsContainer.getChildAt(mCurrentPosition);
float lineLeft = currentTab.getLeft();
float lineRight = currentTab.getRight();
// if there is an offset, start interpolating left and right coordinates between current and next tab
if (mCurrentPositionOffset > 0f && mCurrentPosition < mTabCount - 1) {
View nextTab = mTabsContainer.getChildAt(mCurrentPosition + 1);
final float nextTabLeft = nextTab.getLeft();
final float nextTabRight = nextTab.getRight();
lineLeft = (mCurrentPositionOffset * nextTabLeft + (1f - mCurrentPositionOffset) * lineLeft);
lineRight = (mCurrentPositionOffset * nextTabRight + (1f - mCurrentPositionOffset) * lineRight);
}
return new Pair<>(lineLeft, lineRight);
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class AnnotateWidgetTest method whenPromptHasDefaultAnswer_showsInImageView.
@Test
public void whenPromptHasDefaultAnswer_showsInImageView() 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();
AnnotateWidget widget = createWidget();
ImageView imageView = widget.getImageView();
assertThat(imageView, notNullValue());
Drawable drawable = imageView.getDrawable();
assertThat(drawable, notNullValue());
String loadedPath = shadowOf(((BitmapDrawable) drawable).getBitmap()).getCreatedFromPath();
assertThat(loadedPath, equalTo(imagePath));
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class QRCodeViewModel method generateQRCode.
private void generateQRCode() {
scheduler.immediate(() -> {
try {
String filePath = qrCodeGenerator.generateQRCode(includedKeys, appConfigurationGenerator);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = ImageFileUtils.getBitmap(filePath, options);
return new Pair<>(filePath, bitmap);
} catch (Exception ignored) {
// Ignored
}
return null;
}, qrCode -> {
qrCodeFilePath.setValue(qrCode.first);
qrCodeBitmap.setValue(qrCode.second);
boolean serverPasswordSet = !generalSettings.getString(KEY_PASSWORD).isEmpty();
boolean adminPasswordSet = !adminSettings.getString(KEY_ADMIN_PW).isEmpty();
if (serverPasswordSet || adminPasswordSet) {
if (serverPasswordSet && includedKeys.contains(KEY_PASSWORD) && adminPasswordSet && includedKeys.contains(KEY_ADMIN_PW)) {
warning.setValue(R.string.qrcode_with_both_passwords);
} else if (serverPasswordSet && includedKeys.contains(KEY_PASSWORD)) {
warning.setValue(R.string.qrcode_with_server_password);
} else if (adminPasswordSet && includedKeys.contains(KEY_ADMIN_PW)) {
warning.setValue(R.string.qrcode_with_admin_password);
} else {
warning.setValue(R.string.qrcode_without_passwords);
}
} else {
warning.setValue(null);
}
});
}
use of androidx.core.util.Pair in project collect by opendatakit.
the class DrawWidgetTest method whenPromptHasDefaultAnswer_showsInImageView.
@Test
public void whenPromptHasDefaultAnswer_showsInImageView() 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(DEFAULT_IMAGE_ANSWER).build();
DrawWidget widget = createWidget();
ImageView imageView = widget.getImageView();
assertThat(imageView, notNullValue());
Drawable drawable = imageView.getDrawable();
assertThat(drawable, notNullValue());
String loadedPath = shadowOf(((BitmapDrawable) drawable).getBitmap()).getCreatedFromPath();
assertThat(loadedPath, equalTo(imagePath));
}
Aggregations