Java Code Examples for com.lidroid.xutils.util.LogUtils

The following examples show how to use com.lidroid.xutils.util.LogUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLoading(long total, long current, boolean isUploading) {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    downloadInfo.setFileLength(total);
    downloadInfo.setProgress(current);
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onLoading(total, current, isUploading);
    }
}
 
Example 2
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLoading(long total, long current, boolean isUploading) {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    downloadInfo.setFileLength(total);
    downloadInfo.setProgress(current);
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onLoading(total, current, isUploading);
    }
}
 
Example 3
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, BitmapSize maxSize, Bitmap.Config config) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        options.inPurgeable = true;
        options.inInputShareable = true;
        BitmapFactory.decodeResource(res, resId, options);
        options.inSampleSize = calculateInSampleSize(options, maxSize.getWidth(), maxSize.getHeight());
        options.inJustDecodeBounds = false;
        if (config != null) {
            options.inPreferredConfig = config;
        }
        try {
            return BitmapFactory.decodeResource(res, resId, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 4
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap decodeSampledBitmapFromFile(String filename, BitmapSize maxSize, Bitmap.Config config) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        options.inPurgeable = true;
        options.inInputShareable = true;
        BitmapFactory.decodeFile(filename, options);
        options.inSampleSize = calculateInSampleSize(options, maxSize.getWidth(), maxSize.getHeight());
        options.inJustDecodeBounds = false;
        if (config != null) {
            options.inPreferredConfig = config;
        }
        try {
            return BitmapFactory.decodeFile(filename, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 5
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap decodeSampledBitmapFromDescriptor(FileDescriptor fileDescriptor, BitmapSize maxSize, Bitmap.Config config) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true; // 只读头信息
        options.inPurgeable = true;
        options.inInputShareable = true;
        BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
        //这个就是图片压缩倍数的参数
        options.inSampleSize = calculateInSampleSize(options, maxSize.getWidth(), maxSize.getHeight());
        options.inJustDecodeBounds = false;
        if (config != null) {
            options.inPreferredConfig = config;
        }
        try {
            return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 6
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 6 votes vote down vote up
public static Bitmap decodeSampledBitmapFromByteArray(byte[] data, BitmapSize maxSize, Bitmap.Config config) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        options.inPurgeable = true;
        options.inInputShareable = true;
        BitmapFactory.decodeByteArray(data, 0, data.length, options);
        options.inSampleSize = calculateInSampleSize(options, maxSize.getWidth(), maxSize.getHeight());
        options.inJustDecodeBounds = false;
        if (config != null) {
            options.inPreferredConfig = config;
        }
        try {
            return BitmapFactory.decodeByteArray(data, 0, data.length, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 7
Source Project: android-open-project-demo   Source File: BitmapCache.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the disk cache.  Note that this includes disk access so this should not be
 * executed on the main/UI thread. By default an ImageCache does not initialize the disk
 * cache when it is created, instead you should call initDiskCache() to initialize it on a
 * background thread.
 */
public void initDiskCache() {
    // Set up disk cache
    synchronized (mDiskCacheLock) {
        if (globalConfig.isDiskCacheEnabled() && (mDiskLruCache == null || mDiskLruCache.isClosed())) {
            File diskCacheDir = new File(globalConfig.getDiskCachePath());
            if (diskCacheDir.exists() || diskCacheDir.mkdirs()) {
                long availableSpace = OtherUtils.getAvailableSpace(diskCacheDir);
                long diskCacheSize = globalConfig.getDiskCacheSize();
                diskCacheSize = availableSpace > diskCacheSize ? diskCacheSize : availableSpace;
                try {
                    mDiskLruCache = LruDiskCache.open(diskCacheDir, 1, 1, diskCacheSize);
                    mDiskLruCache.setFileNameGenerator(globalConfig.getFileNameGenerator());
                    LogUtils.d("create disk cache success");
                } catch (Throwable e) {
                    mDiskLruCache = null;
                    LogUtils.e("create disk cache error", e);
                }
            }
        }
    }
}
 
Example 8
Source Project: android-open-project-demo   Source File: ColumnUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static Method getColumnGetMethod(Class<?> entityType, Field field) {
    String fieldName = field.getName();
    Method getMethod = null;
    if (field.getType() == boolean.class) {
        getMethod = getBooleanColumnGetMethod(entityType, fieldName);
    }
    if (getMethod == null) {
        String methodName = "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
        try {
            getMethod = entityType.getDeclaredMethod(methodName);
        } catch (NoSuchMethodException e) {
            LogUtils.d(methodName + " not exist");
        }
    }

    if (getMethod == null && !Object.class.equals(entityType.getSuperclass())) {
        return getColumnGetMethod(entityType.getSuperclass(), field);
    }
    return getMethod;
}
 
Example 9
Source Project: android-open-project-demo   Source File: ColumnUtils.java    License: Apache License 2.0 6 votes vote down vote up
public static Method getColumnSetMethod(Class<?> entityType, Field field) {
    String fieldName = field.getName();
    Method setMethod = null;
    if (field.getType() == boolean.class) {
        setMethod = getBooleanColumnSetMethod(entityType, field);
    }
    if (setMethod == null) {
        String methodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1);
        try {
            setMethod = entityType.getDeclaredMethod(methodName, field.getType());
        } catch (NoSuchMethodException e) {
            LogUtils.d(methodName + " not exist");
        }
    }

    if (setMethod == null && !Object.class.equals(entityType.getSuperclass())) {
        return getColumnSetMethod(entityType.getSuperclass(), field);
    }
    return setMethod;
}
 
Example 10
Source Project: AndroidAppCodeFramework   Source File: DownloadService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    if (DOWNLOAD_MANAGER != null) {
        try {
            DOWNLOAD_MANAGER.stopAllDownload();
            DOWNLOAD_MANAGER.backupDownloadInfoList();
        } catch (DbException e) {
            LogUtils.e(e.getMessage(), e);
        }
    }
    super.onDestroy();
}
 
Example 11
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
DownloadManager(Context appContext) {
    ColumnConverterFactory.registerColumnConverter(HttpHandler.State.class, new HttpHandlerStateConverter());
    mContext = appContext;
    db = DbUtils.create(mContext);
    try {
        downloadInfoList = db.findAll(Selector.from(DownloadInfo.class));
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (downloadInfoList == null) {
        downloadInfoList = new ArrayList<DownloadInfo>();
    }
}
 
Example 12
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onStart();
    }
}
 
Example 13
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStopped() {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onStopped();
    }
}
 
Example 14
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(ResponseInfo<File> responseInfo) {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onSuccess(responseInfo);
    }
}
 
Example 15
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onFailure(HttpException error, String msg) {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onFailure(error, msg);
    }
}
 
Example 16
Source Project: AndroidAppCodeFramework   Source File: DownloadService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    if (DOWNLOAD_MANAGER != null) {
        try {
            DOWNLOAD_MANAGER.stopAllDownload();
            DOWNLOAD_MANAGER.backupDownloadInfoList();
        } catch (DbException e) {
            LogUtils.e(e.getMessage(), e);
        }
    }
    super.onDestroy();
}
 
Example 17
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
DownloadManager(Context appContext) {
    ColumnConverterFactory.registerColumnConverter(HttpHandler.State.class, new HttpHandlerStateConverter());
    mContext = appContext;
    db = DbUtils.create(mContext);
    try {
        downloadInfoList = db.findAll(Selector.from(DownloadInfo.class));
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (downloadInfoList == null) {
        downloadInfoList = new ArrayList<DownloadInfo>();
    }
}
 
Example 18
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStart() {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onStart();
    }
}
 
Example 19
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStopped() {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onStopped();
    }
}
 
Example 20
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onSuccess(ResponseInfo<File> responseInfo) {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onSuccess(responseInfo);
    }
}
 
Example 21
Source Project: AndroidAppCodeFramework   Source File: DownloadManager.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onFailure(HttpException error, String msg) {
    HttpHandler<File> handler = downloadInfo.getHandler();
    if (handler != null) {
        downloadInfo.setState(handler.getState());
    }
    try {
        db.saveOrUpdate(downloadInfo);
    } catch (DbException e) {
        LogUtils.e(e.getMessage(), e);
    }
    if (baseCallBack != null) {
        baseCallBack.onFailure(error, msg);
    }
}
 
Example 22
Source Project: AndJie   Source File: BaseActivity.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	startIntent = new Intent();
	beforeCreate();
	LogUtils.customTagPrefix = "jwzhangjie";
	initView();
	initListener();
	initData();
}
 
Example 23
Source Project: ALLGO   Source File: test.java    License: Apache License 2.0 5 votes vote down vote up
public void test3(){

        RequestParams params = new RequestParams();
        params.addQueryStringParameter("uname", "中文");
        //params.addHeader("appkey" , "0000001");
        HttpUtils http = new HttpUtils();
        try {
            ResponseStream responseStream = http.sendSync(HttpRequest.HttpMethod.POST,
            		"http://10.0.2.2:8080/ALLGO_SERVER/login", params);
            Log.i("Http" , responseStream.readString() ) ;
        } catch (Exception e) {
            LogUtils.e(e.getMessage(), e);
        }
    
	}
 
Example 24
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 5 votes vote down vote up
public static Bitmap decodeResource(Resources res, int resId) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inInputShareable = true;
        try {
            return BitmapFactory.decodeResource(res, resId, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 25
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 5 votes vote down vote up
public static Bitmap decodeFile(String filename) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inInputShareable = true;
        try {
            return BitmapFactory.decodeFile(filename, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 26
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 5 votes vote down vote up
public static Bitmap decodeFileDescriptor(FileDescriptor fileDescriptor) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inInputShareable = true;
        try {
            return BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 27
Source Project: android-open-project-demo   Source File: BitmapDecoder.java    License: Apache License 2.0 5 votes vote down vote up
public static Bitmap decodeByteArray(byte[] data) {
    synchronized (lock) {
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPurgeable = true;
        options.inInputShareable = true;
        try {
            return BitmapFactory.decodeByteArray(data, 0, data.length, options);
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
            return null;
        }
    }
}
 
Example 28
Source Project: android-open-project-demo   Source File: BitmapCache.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the bitmap from disk cache.
 *
 * @param uri
 * @param config
 * @return
 */
public Bitmap getBitmapFromDiskCache(String uri, BitmapDisplayConfig config) {
    if (uri == null || !globalConfig.isDiskCacheEnabled()) return null;
    if (mDiskLruCache == null) {
        initDiskCache();
    }
    if (mDiskLruCache != null) {
        LruDiskCache.Snapshot snapshot = null;
        try {
            snapshot = mDiskLruCache.get(uri);
            if (snapshot != null) {
                Bitmap bitmap = null;
                if (config == null || config.isShowOriginal()) {
                    bitmap = BitmapDecoder.decodeFileDescriptor(
                            snapshot.getInputStream(DISK_CACHE_INDEX).getFD());
                } else {
                    bitmap = BitmapDecoder.decodeSampledBitmapFromDescriptor(
                            snapshot.getInputStream(DISK_CACHE_INDEX).getFD(),
                            config.getBitmapMaxSize(),
                            config.getBitmapConfig());
                }

                bitmap = rotateBitmapIfNeeded(uri, config, bitmap);
                bitmap = addBitmapToMemoryCache(uri, config, bitmap, mDiskLruCache.getExpiryTimestamp(uri));
                return bitmap;
            }
        } catch (Throwable e) {
            LogUtils.e(e.getMessage(), e);
        } finally {
            IOUtils.closeQuietly(snapshot);
        }
    }
    return null;
}
 
Example 29
Source Project: android-open-project-demo   Source File: BitmapCache.java    License: Apache License 2.0 5 votes vote down vote up
public void clearDiskCache() {
    synchronized (mDiskCacheLock) {
        if (mDiskLruCache != null && !mDiskLruCache.isClosed()) {
            try {
                mDiskLruCache.delete();
                mDiskLruCache.close();
            } catch (Throwable e) {
                LogUtils.e(e.getMessage(), e);
            }
            mDiskLruCache = null;
        }
    }
    initDiskCache();
}
 
Example 30
Source Project: android-open-project-demo   Source File: BitmapCache.java    License: Apache License 2.0 5 votes vote down vote up
public void clearDiskCache(String uri) {
    synchronized (mDiskCacheLock) {
        if (mDiskLruCache != null && !mDiskLruCache.isClosed()) {
            try {
                mDiskLruCache.remove(uri);
            } catch (Throwable e) {
                LogUtils.e(e.getMessage(), e);
            }
        }
    }
}