Android Question Compile Error

Declan

Well-Known Member
Licensed User
Longtime User
I have combined two separate apps.
Both have a "#If JAVA.......#End If code sub.
When I combine them into a single sub, I get the following error on compile:
B4X:
B4A version: 6.50
Parsing code.    (0.01s)
Compiling code.    (0.07s)
Compiling layouts code.    (0.01s)
Organizing libraries.    (0.00s)
Generating R file.    (0.04s)
Compiling debugger engine code.    (1.04s)
Compiling generated Java code.    Error
javac 1.8.0_111
src\com\rob\ebuki\main.java:859: error: illegal start of expression
    public void _onResume() {
    ^
1 error

The combined "#If JAVA....#End If" :
B4X:
#If Java

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.Path.FillType;
import android.graphics.Paint;
import android.graphics.Color;
import android.view.View;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.BitmapShader;
import android.graphics.Shader;
import android.graphics.PorterDuffXfermode;
import android.graphics.PorterDuff.Mode;


public static Bitmap getRoundBitmap(Bitmap scaleBitmapImage, int borderColor, int borderWidth) {
    int targetWidth = 1000;
    int targetHeight = 1000;
    int radius = Math.min((targetHeight - 5)/2, (targetWidth - 5)/2);  
   
    Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight,
            Bitmap.Config.ARGB_8888);

    Canvas canvas = new Canvas(targetBitmap);
    Path path = new Path();
    path.addCircle(((float) targetWidth - 1) / 2,
            ((float) targetHeight - 1) / 2,
            (Math.min(((float) targetWidth), ((float) targetHeight)) / 2),
            Path.Direction.CCW);

    canvas.clipPath(path);
   
    Bitmap sourceBitmap = scaleBitmapImage;
   
    canvas.drawBitmap(sourceBitmap, new Rect(0, 0, sourceBitmap.getWidth(),
            sourceBitmap.getHeight()), new Rect(0, 0, targetWidth,
            targetHeight), null);
           
           
    Paint p = new Paint();                                             
    p.setAntiAlias(true);                  
    //    canvas.drawBitmap(sourceBitmap, 4, 4, p);                                     
    p.setXfermode(null);                                               
    p.setStyle(Paint.Style.STROKE);                                          
    p.setColor(borderColor);                                           
    p.setStrokeWidth(borderWidth);                                               
    canvas.drawCircle((targetWidth / 2) , (targetHeight / 2) , radius, p);                             

    return targetBitmap;


   
    import it.giuseppe.salvi.gridview.library.core.uil.*;

   
    public void _onResume() {
        if(ImageLoader.getInstance().isInited()){
            ImageLoader.getInstance().resume();
        }
    }
   
    public void _onPause() {
        if(ImageLoader.getInstance().isInited()){
            ImageLoader.getInstance().pause();
        }
    }
   
    public void _onDestroy() {
        if(ImageLoader.getInstance().isInited()){
            ImageLoader.getInstance().destroy();
        }
    }
   
    public void _onStop() {
        if(ImageLoader.getInstance().isInited()){
            ImageLoader.getInstance().stop();
        }
    }
   
    public void _onStart() {
        if(ImageLoader.getInstance().isInited()){
            ImageLoader.getInstance().resume();
        }
    }
#End If
 
Top