Merge branch 'dev' into dev

This commit is contained in:
B0pol 2020-01-09 10:07:22 +01:00 committed by GitHub
commit e0a39efa2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 1130 additions and 204 deletions

View file

@ -0,0 +1,43 @@
package org.schabi.newpipe.util;
import android.graphics.Bitmap;
import androidx.annotation.Nullable;
public class BitmapUtils {
@Nullable
public static Bitmap centerCrop(Bitmap inputBitmap, int newWidth, int newHeight) {
if (inputBitmap == null || inputBitmap.isRecycled()) {
return null;
}
float sourceWidth = inputBitmap.getWidth();
float sourceHeight = inputBitmap.getHeight();
float xScale = newWidth / sourceWidth;
float yScale = newHeight / sourceHeight;
float newXScale;
float newYScale;
if (yScale > xScale) {
newXScale = xScale / yScale;
newYScale = 1.0f;
} else {
newXScale = 1.0f;
newYScale = yScale / xScale;
}
float scaledWidth = newXScale * sourceWidth;
float scaledHeight = newYScale * sourceHeight;
int left = (int) ((sourceWidth - scaledWidth) / 2);
int top = (int) ((sourceHeight - scaledHeight) / 2);
int width = (int) scaledWidth;
int height = (int) scaledHeight;
return Bitmap.createBitmap(inputBitmap, left, top, width, height);
}
}

View file

@ -140,7 +140,15 @@ public class StreamItemAdapter<T extends Stream, U extends Stream> extends BaseA
if (stream instanceof SubtitlesStream) {
formatNameView.setText(((SubtitlesStream) stream).getLanguageTag());
} else {
formatNameView.setText(stream.getFormat().getName());
switch (stream.getFormat()) {
case WEBMA_OPUS:
// noinspection AndroidLintSetTextI18n
formatNameView.setText("opus");
break;
default:
formatNameView.setText(stream.getFormat().getName());
break;
}
}
qualityView.setText(qualityString);