Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianscar authored and Tianscar committed Jul 1, 2021
1 parent 1ea47a1 commit f25f947
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ android {
applicationId "com.ansdoship.pixelarteditor"
minSdkVersion 16
targetSdkVersion 30
versionCode 16
versionName "0.0.3.6-beta"
versionCode 17
versionName "0.0.3.7-beta"
vectorDrawables {
useSupportLibrary = true
}
Expand Down
65 changes: 37 additions & 28 deletions app/src/main/java/com/ansdoship/pixelarteditor/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,42 +185,51 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private boolean readOnlyMode;

private void loadData() {

if (toolBufferPool == null) {
String cacheBitmapPathname = getCurrentBitmapPathname();
Bitmap bitmap = null;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Bitmap bitmap = BitmapDecoder.decodeFile(getCurrentBitmapPathname());
if (bitmap == null) {
bitmap = Bitmap.createBitmap(IMAGE_WIDTH_DEFAULT,
IMAGE_HEIGHT_DEFAULT, Bitmap.Config.ARGB_8888);
}
replaceCacheBitmap(bitmap);
setBitmap(cacheBitmap);
}
});
thread.start();
try {
bitmap = BitmapDecoder.decodeFile(cacheBitmapPathname);
thread.join();
}
finally {
if (bitmap == null) {
bitmap = Bitmap.createBitmap(IMAGE_WIDTH_DEFAULT,
IMAGE_HEIGHT_DEFAULT, Bitmap.Config.ARGB_8888);
}
replaceCacheBitmap(bitmap);
setBitmap(bitmap);
catch (InterruptedException e) {
e.printStackTrace();
}
}
else {
String cacheBitmapPathname = getCacheBitmapPathname();
Bitmap bitmap = null;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Bitmap bitmap = BitmapDecoder.decodeFile(getCacheBitmapPathname());
if (bitmap == null) {
bitmap = Bitmap.createBitmap(IMAGE_WIDTH_DEFAULT,
IMAGE_HEIGHT_DEFAULT, Bitmap.Config.ARGB_8888);
replaceCacheBitmap(bitmap);
setBitmap(cacheBitmap);
}
else {
replaceCacheBitmap(bitmap);
toolBufferPool.setCacheBitmap(cacheBitmap);
toolBufferPool.flushCurrentBitmap();
}
}
});
thread.start();
try {
bitmap = BitmapDecoder.decodeFile(cacheBitmapPathname);
thread.join();
}
finally {
if (bitmap == null) {
bitmap = Bitmap.createBitmap(IMAGE_WIDTH_DEFAULT,
IMAGE_HEIGHT_DEFAULT, Bitmap.Config.ARGB_8888);
replaceCacheBitmap(bitmap);
setBitmap(bitmap);
}
else {
replaceCacheBitmap(bitmap);
toolBufferPool.setCacheBitmap(bitmap);
toolBufferPool.flushCurrentBitmap();
}
replaceCacheBitmap(bitmap);
setBitmap(bitmap);
catch (InterruptedException e) {
e.printStackTrace();
}
}

Expand Down

0 comments on commit f25f947

Please sign in to comment.