Example usage for android.util Log e

List of usage examples for android.util Log e

Introduction

In this page you can find the example usage for android.util Log e.

Prototype

public static int e(String tag, String msg) 

Source Link

Document

Send an #ERROR log message.

Usage

From source file:Main.java

public static Bitmap fastblur(Bitmap sentBitmap, int radius) {
    Bitmap bitmap = sentBitmap.copy(sentBitmap.getConfig(), true);

    if (radius < 1) {
        return (null);
    }/*from  w w w .j a va  2s.  c o  m*/

    int w = bitmap.getWidth();
    int h = bitmap.getHeight();

    int[] pix = new int[w * h];
    Log.e("pix", w + " " + h + " " + pix.length);
    bitmap.getPixels(pix, 0, w, 0, 0, w, h);

    int wm = w - 1;
    int hm = h - 1;
    int wh = w * h;
    int div = radius + radius + 1;

    int r[] = new int[wh];
    int g[] = new int[wh];
    int b[] = new int[wh];
    int rsum, gsum, bsum, x, y, i, p, yp, yi, yw;
    int vmin[] = new int[Math.max(w, h)];

    int divsum = (div + 1) >> 1;
    divsum *= divsum;
    int dv[] = new int[256 * divsum];
    for (i = 0; i < 256 * divsum; i++) {
        dv[i] = (i / divsum);
    }

    yw = yi = 0;

    int[][] stack = new int[div][3];
    int stackpointer;
    int stackstart;
    int[] sir;
    int rbs;
    int r1 = radius + 1;
    int routsum, goutsum, boutsum;
    int rinsum, ginsum, binsum;

    for (y = 0; y < h; y++) {
        rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
        for (i = -radius; i <= radius; i++) {
            p = pix[yi + Math.min(wm, Math.max(i, 0))];
            sir = stack[i + radius];
            sir[0] = (p & 0xff0000) >> 16;
            sir[1] = (p & 0x00ff00) >> 8;
            sir[2] = (p & 0x0000ff);
            rbs = r1 - Math.abs(i);
            rsum += sir[0] * rbs;
            gsum += sir[1] * rbs;
            bsum += sir[2] * rbs;
            if (i > 0) {
                rinsum += sir[0];
                ginsum += sir[1];
                binsum += sir[2];
            } else {
                routsum += sir[0];
                goutsum += sir[1];
                boutsum += sir[2];
            }
        }
        stackpointer = radius;

        for (x = 0; x < w; x++) {

            r[yi] = dv[rsum];
            g[yi] = dv[gsum];
            b[yi] = dv[bsum];

            rsum -= routsum;
            gsum -= goutsum;
            bsum -= boutsum;

            stackstart = stackpointer - radius + div;
            sir = stack[stackstart % div];

            routsum -= sir[0];
            goutsum -= sir[1];
            boutsum -= sir[2];

            if (y == 0) {
                vmin[x] = Math.min(x + radius + 1, wm);
            }
            p = pix[yw + vmin[x]];

            sir[0] = (p & 0xff0000) >> 16;
            sir[1] = (p & 0x00ff00) >> 8;
            sir[2] = (p & 0x0000ff);

            rinsum += sir[0];
            ginsum += sir[1];
            binsum += sir[2];

            rsum += rinsum;
            gsum += ginsum;
            bsum += binsum;

            stackpointer = (stackpointer + 1) % div;
            sir = stack[(stackpointer) % div];

            routsum += sir[0];
            goutsum += sir[1];
            boutsum += sir[2];

            rinsum -= sir[0];
            ginsum -= sir[1];
            binsum -= sir[2];

            yi++;
        }
        yw += w;
    }
    for (x = 0; x < w; x++) {
        rinsum = ginsum = binsum = routsum = goutsum = boutsum = rsum = gsum = bsum = 0;
        yp = -radius * w;
        for (i = -radius; i <= radius; i++) {
            yi = Math.max(0, yp) + x;

            sir = stack[i + radius];

            sir[0] = r[yi];
            sir[1] = g[yi];
            sir[2] = b[yi];

            rbs = r1 - Math.abs(i);

            rsum += r[yi] * rbs;
            gsum += g[yi] * rbs;
            bsum += b[yi] * rbs;

            if (i > 0) {
                rinsum += sir[0];
                ginsum += sir[1];
                binsum += sir[2];
            } else {
                routsum += sir[0];
                goutsum += sir[1];
                boutsum += sir[2];
            }

            if (i < hm) {
                yp += w;
            }
        }
        yi = x;
        stackpointer = radius;
        for (y = 0; y < h; y++) {
            // Preserve alpha channel: ( 0xff000000 & pix[yi] )
            pix[yi] = (0xff000000 & pix[yi]) | (dv[rsum] << 16) | (dv[gsum] << 8) | dv[bsum];

            rsum -= routsum;
            gsum -= goutsum;
            bsum -= boutsum;

            stackstart = stackpointer - radius + div;
            sir = stack[stackstart % div];

            routsum -= sir[0];
            goutsum -= sir[1];
            boutsum -= sir[2];

            if (x == 0) {
                vmin[y] = Math.min(y + r1, hm) * w;
            }
            p = x + vmin[y];

            sir[0] = r[p];
            sir[1] = g[p];
            sir[2] = b[p];

            rinsum += sir[0];
            ginsum += sir[1];
            binsum += sir[2];

            rsum += rinsum;
            gsum += ginsum;
            bsum += binsum;

            stackpointer = (stackpointer + 1) % div;
            sir = stack[stackpointer];

            routsum += sir[0];
            goutsum += sir[1];
            boutsum += sir[2];

            rinsum -= sir[0];
            ginsum -= sir[1];
            binsum -= sir[2];

            yi += w;
        }
    }

    Log.e("pix", w + " " + h + " " + pix.length);
    bitmap.setPixels(pix, 0, w, 0, 0, w, h);

    return (bitmap);
}

From source file:Main.java

public static File getPhotoCacheDir(Context context, File file) {
    File cacheDir = context.getCacheDir();
    if (cacheDir != null) {
        File mCacheDir = new File(cacheDir, DEFAULT_DISK_CACHE_DIR);
        if (!mCacheDir.mkdirs() && (!mCacheDir.exists() || !mCacheDir.isDirectory())) {
            return file;
        } else {/*  w w w.j  a  va  2 s  .c  o  m*/
            return new File(mCacheDir, file.getName());
        }
    }
    if (Log.isLoggable(TAG, Log.ERROR)) {
        Log.e(TAG, "default disk cache dir is null");
    }
    return file;
}

From source file:Main.java

public static String formatException(Exception exception) {
    String formattedString = "Internal Error";
    Log.e("App Error", exception.toString());
    Log.getStackTraceString(exception);/*  w ww.j a v  a 2 s  .co m*/

    String temp = exception.getMessage();

    if (temp != null && temp.length() > 0) {
        formattedString = temp.split("\\(")[0];
        if (temp != null && temp.length() > 0) {
            return formattedString;
        }
    }

    return formattedString;
}

From source file:Main.java

public static JSONObject readJSONFile(String path) {
    String file = new String(), tmp;
    try {/*from   w w w .j ava 2s.c o  m*/
        // Read the file
        BufferedReader bf = new BufferedReader(new FileReader(new File(path)));
        while ((tmp = bf.readLine()) != null) {
            file += tmp;
        }
        bf.close();

        // Parse the JSON
        JSONObject jso = new JSONObject(file);
        return jso;
    } catch (JSONException e) {
        Log.e("JSO reading", "Error parsing the JSO file " + path + "\n" + e.getMessage());
    } catch (IOException e) {
        Log.e("JSO reading", "Error reading the file " + path + "\n" + e.getMessage());
    }

    return null;
}

From source file:Main.java

public static void GetSUAccess() {
    Thread su = new Thread(new Thread() {
        public void run() {
            try {
                Log.i("SU", "Trying to grant access to port...");
                Process suProcess = Runtime.getRuntime().exec("su");

                DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());

                if (null != os) {
                    os.writeBytes("chmod 666 /dev/ttymxc1 \n");
                    os.flush();//w  ww  .ja v a2s. co  m
                }
                Log.i("SU", "Granted Access to Port");
            } catch (IOException e) {
                Log.e("SU", "Grant SuperUser Access Failed");
            }
        }
    });
    su.start();
}

From source file:Main.java

public static void showLog(int info) {
    Log.e("TAG", String.valueOf(info));
}

From source file:Main.java

public static int[] splitToIntArray(String s) {
    int ai1[];/*www . ja v  a  2 s.com*/
    if (s == null) {
        ai1 = null;
    } else {
        String as[] = s.split(":");
        ArrayList arraylist = new ArrayList();
        int i = as.length;
        int j = 0;
        do {
            if (j >= i)
                break;
            String s1 = as[j];
            if (s1 != null && s1.length() > 0)
                try {
                    arraylist.add(Integer.valueOf(Integer.valueOf(s1).intValue()));
                } catch (Exception exception) {
                    exception.printStackTrace();
                    Log.e("MicroMsg.Util", "invalid port num, ignore");
                }
            j++;
        } while (true);
        int ai[] = new int[arraylist.size()];
        for (int k = 0; k < ai.length; k++)
            ai[k] = ((Integer) arraylist.get(k)).intValue();

        ai1 = ai;
    }
    return ai1;
}

From source file:Main.java

public static Boolean checkSOLoaded() {
    if (loadedSO == false) {
        Log.e("NDKHelper", "--------------------------------------------\n"
                + ".so has not been loaded. To use JUI helper, please initialize with \n"
                + "NDKHelper::Init( ANativeActivity* activity, const char* helper_class_name, const char* native_soname);\n"
                + "--------------------------------------------\n");
        return false;
    } else/*w ww . j av a  2s . c o m*/
        return true;
}

From source file:Main.java

public static boolean saveRes(Context gContext, int res, String dirjpg) {
    InputStream is = gContext.getApplicationContext().getResources().openRawResource(res);
    boolean rez = false;
    try {/*from  w ww  .  j  a  va2 s .  co m*/
        FileOutputStream rtFOS = new FileOutputStream(dirjpg + "/" + res + ".gif");
        byte[] buffer = new byte[4096];
        int n = -1;
        while ((n = is.read(buffer, 0, 4095)) != -1) {
            if (n > 0)
                rtFOS.write(buffer, 0, n);
            rez = true;
        }
        rtFOS.flush();
        rtFOS.close();
    } catch (Exception e) {
        Log.e("FullscreenActivity", e.toString());
    }
    return rez;
}

From source file:Main.java

public static void execCmd(String szCmd, boolean bCatchLog) {
    try {//from w w w  .ja  va  2  s  .  co m
        Log.d("PvTorrent_proc", "execCmd=" + szCmd);
        Runtime runtime = Runtime.getRuntime();
        Process process = runtime.exec(szCmd);

        if (bCatchLog) {
            InputStream is = process.getInputStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            while (null != (line = br.readLine())) {
                Log.e("PvTorrent_proc", line);
            }
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        Log.d("PvTorrent_proc", e.toString());
    }
}