Runtime Error while loading ColinTreeListView (MediaUtil getBitmapDrawableAsync)

After studying the code also when @iamwsumit comes in with

I decided to install FAST-CLI on Android Termux. Luckily i successful add modifies in the extension,

Changes i made

Around line 883-920


// ADDED: New helper method to handle async image loading with fallback
private void loadBitmapDrawableAsync(final Form form, final String path, 
                                    final AsyncCallbackPair<BitmapDrawable> callback) {
    try {
        // Try to use the async method if it exists
        MediaUtil.getBitmapDrawableAsync(form, path, new AsyncCallbackPair<BitmapDrawable>() {
            @Override
            public void onFailure(String message) {
                callback.onFailure(message);
            }

            @Override
            public void onSuccess(BitmapDrawable result) {
                callback.onSuccess(result);
            }
        });
    } catch (NoSuchMethodError e) {
        // Fallback to synchronous loading in a background thread
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    final BitmapDrawable bd = MediaUtil.getBitmapDrawable(form, path);
                    form.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            callback.onSuccess(bd);
                        }
                    });
                } catch (final IOException e) {
                    form.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            callback.onFailure(e.getMessage());
                        }
                    });
                }
            }
        }).start();
    }
}`

Element class - Around line 1140

// CHANGED: From direct MediaUtil.getBitmapDrawableAsync() call to our helper method
if (asyncImageLoad) {
    // OLD: MediaUtil.getBitmapDrawableAsync(form, path, ...)
    // NEW: Using our fixed helper method
    loadBitmapDrawableAsync(form, path, new AsyncCallbackPair<BitmapDrawable>() {
        @Override
        public void onFailure(String message) {}

        @Override
        public void onSuccess(final BitmapDrawable result) {
            container.$context().runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ViewUtil.setBackgroundDrawable(icon.getView(), result);
                }
            });
        }
    });
}

CachedImage class - Around line 1345

// CHANGED: Same fix in CachedImage constructor
if (asyncImageLoad) {
    // OLD: MediaUtil.getBitmapDrawableAsync(form, path, ...)
    // NEW: Using our fixed helper method
    loadBitmapDrawableAsync(form, path, new AsyncCallbackPair<BitmapDrawable>() {
        @Override
        public void onFailure(String message) {
        }

        @Override
        public void onSuccess(BitmapDrawable result) {
            gotBitmapDrawable(result);
        }
    });
}

It still throw some error, that am not able to bypass in mean time but it works, the error comes when i enabled AsyncImageLoad in designer property, so you can ignore it just enable CachImage

Screenshot 2026-01-19 at 21-14-35 Kodular Creator

If anyone can step in, i will attach the modified java below

ColinTreeListView.java (61.2 KB)

Aix

cn.colintree.aix.colintreelistview.aix (31.7 KB)

Note

Am not the owner of the extension, i respect the owner Colin

Happy :kodular:oding

2 Likes