Skip to content

Commit

Permalink
Merge pull request CatVodTVOfficial#92 from CatVodTVOfficial/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DreamDSTR authored Jun 28, 2022
2 parents 730de45 + 4853774 commit c58d07d
Show file tree
Hide file tree
Showing 25 changed files with 2,071 additions and 183 deletions.
6 changes: 6 additions & 0 deletions app/src/main/java/com/github/tvbox/osc/api/ApiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ public void onSuccess(Response<File> response) {
callback.error("");
}
}

@Override
public void onError(Response<File> response) {
super.onError(response);
callback.error("");
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static List<VodInfo> getAllVodRecord() {
}.getType());
info.sourceKey = record.sourceKey;
SourceBean sourceBean = ApiConfig.get().getSource(info.sourceKey);
if (sourceBean == null || info.name == null || info.type == null)
if (sourceBean == null || info.name == null)
info = null;
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Shader;

Expand All @@ -25,7 +26,7 @@
* @since 2020/12/22
*/
public class RoundTransformation implements Transformation {
private int viewWidth, viewHeight;
private int viewWidth, viewHeight, bottomShapeHeight = 0;
@RoundType
private int mRoundType = RoundType.NONE;
private int diameter;
Expand All @@ -48,6 +49,11 @@ public RoundTransformation centerCorp(boolean centerCorp) {
return this;
}

public RoundTransformation bottomShapeHeight(int shapeHeight) {
this.bottomShapeHeight = shapeHeight;
return this;
}

public RoundTransformation roundRadius(int radius, @RoundType int mRoundType) {
this.radius = radius;
this.diameter = radius * 2;
Expand Down Expand Up @@ -92,6 +98,63 @@ public Bitmap transform(Bitmap source) {
return bitmap;
}

static Path RoundedRect(float left, float top, float right, float bottom, float rx, float ry, boolean tl, boolean tr, boolean br, boolean bl) {
Path path = new Path();
if (rx < 0) rx = 0;
if (ry < 0) ry = 0;
float width = right - left;
float height = bottom - top;
if (rx > width / 2) rx = width / 2;
if (ry > height / 2) ry = height / 2;
float widthMinusCorners = (width - (2 * rx));
float heightMinusCorners = (height - (2 * ry));

path.moveTo(right, top + ry);
if (tr)
path.rQuadTo(0, -ry, -rx, -ry);//top-right corner
else {
path.rLineTo(0, -ry);
path.rLineTo(-rx, 0);
}
path.rLineTo(-widthMinusCorners, 0);
if (tl)
path.rQuadTo(-rx, 0, -rx, ry); //top-left corner
else {
path.rLineTo(-rx, 0);
path.rLineTo(0, ry);
}
path.rLineTo(0, heightMinusCorners);

if (bl)
path.rQuadTo(0, ry, rx, ry);//bottom-left corner
else {
path.rLineTo(0, ry);
path.rLineTo(rx, 0);
}

path.rLineTo(widthMinusCorners, 0);
if (br)
path.rQuadTo(rx, 0, rx, -ry); //bottom-right corner
else {
path.rLineTo(rx, 0);
path.rLineTo(0, -ry);
}

path.rLineTo(0, -heightMinusCorners);

path.close();//Given close, last lineto can be removed.

return path;
}

private void drawBottomLabel(Canvas mCanvas, Paint mPaint, float left, float top, float right, float bottom) {
if (bottomShapeHeight <= 0)
return;
mPaint.setShader(null);
mPaint.setColor(0x99000000);
mCanvas.drawPath(RoundedRect(left, bottom - bottomShapeHeight * 2, right, bottom, radius, radius, false, false, true, true), mPaint);
}

private void drawRoundRect(Canvas mCanvas, Paint mPaint, float width, float height) {
switch (mRoundType) {
case RoundType.NONE:
Expand All @@ -116,18 +179,22 @@ private void drawRoundRect(Canvas mCanvas, Paint mPaint, float width, float heig
case RoundType.ALL:
if (viewWidth == width && viewHeight == height) {
mCanvas.drawRoundRect(new RectF(0, 0, viewWidth, viewHeight), radius, radius, mPaint);
drawBottomLabel(mCanvas, mPaint, 0, 0, viewWidth, viewHeight);
} else if (viewWidth == width && viewHeight != height) {
float dis = (height - viewHeight) / 2f;
if (isCenterCorp) {
mCanvas.translate(0, -dis);
mCanvas.drawRoundRect(new RectF(0, dis, viewWidth, viewHeight + dis), radius, radius, mPaint);
drawBottomLabel(mCanvas, mPaint, 0, dis, viewWidth, viewHeight + dis);
} else {
mCanvas.drawRoundRect(new RectF(0, 0, viewWidth, viewHeight), radius, radius, mPaint);
drawBottomLabel(mCanvas, mPaint, 0, 0, viewWidth, viewHeight);
}
} else {
float dis = (width - viewWidth) / 2f;
mCanvas.translate(-dis, 0);
mCanvas.drawRoundRect(new RectF(dis, 0, viewWidth + dis, viewHeight), radius, radius, mPaint);
drawBottomLabel(mCanvas, mPaint, dis, 0, viewWidth + dis, viewHeight);
}
break;
case RoundType.TOP:
Expand Down
Loading

0 comments on commit c58d07d

Please sign in to comment.