Skip to content

Commit

Permalink
Fix ClassCastException in takeScreenshot()
Browse files Browse the repository at this point in the history
  • Loading branch information
woesss committed Jul 14, 2024
1 parent cc87cf5 commit 177c985
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/javax/microedition/lcdui/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void onDraw(android.graphics.Canvas canvas) {
}
}

public Single<Bitmap> getScreenShot() {
public Single<Bitmap> getScreenshot() {
if (renderer != null && !screenshotRawMode) {
return renderer.takeScreenShot();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ private void handleVkOptions(int id) {

@SuppressLint("CheckResult")
private void takeScreenshot() {
microLoader.takeScreenshot((Canvas) current, new SingleObserver<>() {
microLoader.takeScreenshot(current, new SingleObserver<>() {
@Override
public void onSubscribe(@NonNull Disposable d) {
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/javax/microedition/shell/MicroLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,11 @@ void applyConfiguration() {
}
}

void takeScreenshot(Canvas canvas, SingleObserver<String> observer) {
canvas.getScreenShot()
void takeScreenshot(Object target, SingleObserver<String> observer) {
if (!(target instanceof Canvas canvas)) {
return;
}
canvas.getScreenshot()
.subscribeOn(Schedulers.computation())
.observeOn(Schedulers.io())
.map(bitmap -> {
Expand Down

0 comments on commit 177c985

Please sign in to comment.