Java Code Examples for com.socks.library.KLog#e()

The following examples show how to use com.socks.library.KLog#e() . 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 File: FileUtil.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
/**
 * 复制单个文件
 *
 * @param oldPath String 原文件路径
 * @param newPath String 复制后路径
 * @return boolean
 */
public static boolean copyFile(String oldPath, String newPath) {
    try {
        int byteread = 0;
        File oldfile = new File(oldPath);
        if (oldfile.exists()) { // 文件存在时
            InputStream inStream = new FileInputStream(oldPath); // 读入原文件
            FileOutputStream fs = new FileOutputStream(newPath);
            byte[] buffer = new byte[IO_BUFFER_SIZE];

            while ((byteread = inStream.read(buffer)) != -1) {
                fs.write(buffer, 0, byteread);
            }
            inStream.close();
            fs.close();
        }
    } catch (Exception e) {
        KLog.e(e);
        return false;
    }
    return true;
}
 
Example 2
Source File: FileUtil.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
/**
 * 写入文件
 *
 * @param strFileName 文件名
 * @param ins         流
 */
public static void writeToFile(String strFileName, InputStream ins) {
    try {
        File file = new File(strFileName);

        FileOutputStream fouts = new FileOutputStream(file);
        int len;
        int maxSize = 1024 * 1024;
        byte buf[] = new byte[maxSize];
        while ((len = ins.read(buf, 0, maxSize)) != -1) {
            fouts.write(buf, 0, len);
            fouts.flush();
        }

        fouts.close();
    } catch (IOException e) {
        KLog.e(e);
    }
}
 
Example 3
Source File: DotIndicator.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
/**
 * 当前需要展示的dotview数量
 */
public void setDotViewNum(int num) {
    if (num > MAX_DOT_NUM || num <= 0) {
        KLog.e(TAG, "num必须在1~" + MAX_DOT_NUM + "之间哦");
        return;
    }
    if (num <= 1) {
        removeAllViews();
        setVisibility(GONE);
    }

    if (this.mDotsNum != num) {
        this.mDotsNum = num;
        removeAllViews();
        mDotViews.clear();
        mDotViews = null;
        buildDotView(getContext());
        setCurrentSelection(currentSelection);
    }
}
 
Example 4
Source File: DBManager.java    From ZZShow with Apache License 2.0 6 votes vote down vote up
/**
 *  获取 记录条数
 * @return 记录条数
 */
public long getCount(){
    db.beginTransaction();
    long count = 0;
    Cursor cursor = null;
    try {
        cursor = db.rawQuery("select count(news_channel_id) from " + DBHelper.TABLE_NEWS_CHANNEL,null);
        cursor.moveToFirst();
        count = cursor.getLong(0);
        db.setTransactionSuccessful();
    }catch (Exception e){
        KLog.e(e.getMessage());
    }finally {
        if(cursor != null) cursor.close();
        db.endTransaction();
    }
    return count;
}
 
Example 5
Source File: CircleBaseViewHolder.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
@Override
public void onBindData(MomentInfo data, int position) {
    if (data == null) {
        KLog.e("数据是空的!!!!");
        findView(userText, R.id.item_text_field);
        userText.setText("这个动态的数据是空的。。。。OMG");
        return;
    }
    this.momentInfo = data;
    this.itemPosition = position;
    //通用数据绑定
    onBindMutualDataToViews(data);
    //点击事件
    menuButton.setOnClickListener(onMenuButtonClickListener);
    menuButton.setTag(R.id.momentinfo_data_tag_id, data);
    deleteMoments.setOnClickListener(onDeleteMomentClickListener);
    //传递到子类
    onBindDataToView(data, position, getViewType());
}
 
Example 6
Source File: PhotoTextView.java    From ZZShow with Apache License 2.0 5 votes vote down vote up
/**
 *  解绑ImageGetterSubscription
 */
public void cancelImageGetterSubscription(){
    if(imgGetter != null){
        try {
            imgGetter.unSubscribe();
        }catch (Exception e){
            KLog.e("解绑 UrlImageGetter Subscription 异常");
        }
    }
}
 
Example 7
Source File: MainActivity.java    From KLog with Apache License 2.0 5 votes vote down vote up
public void logWithTag(View view) {
    KLog.v(TAG, LOG_MSG);
    KLog.d(TAG, LOG_MSG);
    KLog.i(TAG, LOG_MSG);
    KLog.w(TAG, LOG_MSG);
    KLog.e(TAG, LOG_MSG);
    KLog.a(TAG, LOG_MSG);
}
 
Example 8
Source File: TitleBar.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public void setRightIcon(int resid) {
    try {
        iv_right.setImageResource(resid);
        setShowRightIcon(resid != 0);
    } catch (Exception e) {
        KLog.e(e);
    }
}
 
Example 9
Source File: TitleBar.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public void setLeftIcon(int resid) {
    try {
        iv_left.setImageResource(resid);
        setShowLeftIcon(resid != 0);
    } catch (Exception e) {
        KLog.e(e);
    }
}
 
Example 10
Source File: UIHelper.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
/**
 * 隐藏软键盘
 */
public static void hideInputMethod(View view) {
    try {
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
        }
    } catch (Exception e) {
        e.printStackTrace();
        KLog.e(e);
    }
}
 
Example 11
Source File: MainActivity.java    From KLog with Apache License 2.0 5 votes vote down vote up
public void logWithMsg(View view) {
    KLog.v(LOG_MSG);
    KLog.d(LOG_MSG);
    KLog.i(LOG_MSG);
    KLog.w(LOG_MSG);
    KLog.e(LOG_MSG);
    KLog.a(LOG_MSG);
}
 
Example 12
Source File: MainActivity.java    From KLog with Apache License 2.0 5 votes vote down vote up
public void logWithNull(View view) {
    KLog.v(null);
    KLog.d(null);
    KLog.i(null);
    KLog.w(null);
    KLog.e(null);
    KLog.a(null);
}
 
Example 13
Source File: CompressManager.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public void start(OnCompressListener listener) {
    BaseCompressTaskHelper helper;
    if (getContext() == null) {
        KLog.e("context为空");
        return;
    }
    if (ToolUtil.isListEmpty(mOptions)) {
        KLog.e("配置为空");
        return;
    }
    new CompressTaskQueue(getContext(), mOptions, listener).start();
}
 
Example 14
Source File: FileUtil.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
/**
 * @return 文件的大小,带单位(MB、KB等)
 */
public static String getFileLength(String filePath) {
    try {
        File file = new File(filePath);
        return fileLengthFormat(getFileSize(file));
    } catch (Exception e) {
        KLog.e(e);
        return "";
    }
}
 
Example 15
Source File: DBManager.java    From ZZShow with Apache License 2.0 5 votes vote down vote up
/**
 *  根据 index 查询频道
 * @param index  频道值
 * @return
 */
public NewsChannelTable findNewsChannelByIndex(int index) {
    NewsChannelTable newsChannel = null;
    db.beginTransaction();
    Cursor cursor = null;
    try{
        cursor = db.query(DBHelper.TABLE_NEWS_CHANNEL,null, "news_channel_index = ? " ,new String[]{index+""} ,null,null,null);
        if(cursor.moveToFirst()) {
            String channelName = cursor.getString(cursor.getColumnIndex("news_channel_name"));
            String channelId = cursor.getString(cursor.getColumnIndex("news_channel_id"));
            String channelType = cursor.getString(cursor.getColumnIndex("news_channel_type"));
            boolean channelSelect = cursor.getInt(cursor.getColumnIndex("news_channel_select")) == 1;
            int channelIndex = cursor.getInt(cursor.getColumnIndex("news_channel_index"));
            boolean channelFixed = cursor.getInt(cursor.getColumnIndex("news_channel_fixed")) == 1;
            newsChannel = new NewsChannelTable(channelName, channelId, channelType, channelSelect, channelIndex, channelFixed);
            KLog.d("FIND--", "findNewsChannelByIndex--" + newsChannel.toString());
        }
        db.setTransactionSuccessful();
    }catch (Exception e){
        KLog.e(e.getMessage());
    }finally {
        if(cursor != null){
            cursor.close();
        }
        db.endTransaction();
    }
    return newsChannel;
}
 
Example 16
Source File: Push4FreshCommentParser.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
/**
 * 包装无父评论的请求参数
 *
 * @return
 */
public static String getRequestURLNoParent(String post_id, String name, String email, String content) {
    //方法1 转义
    //content= MessageFormat.format("%40%3Ca+href%3D%27%23comment-{0}%27%3E{1}%3C%2Fa%3E%3A+{2}",parent_id,parent_name, content);
    //方法2 URLEncoder(更优)
    try {
        name = URLEncoder.encode(name, "utf-8");
        content = URLEncoder.encode(content, "utf-8");
    } catch (Exception ex) {
        KLog.e("URLEncoder error");
    }
    return MessageFormat.format("{0}&post_id={1}&content={2}&email={3}&name={4}",
            Comment4FreshNews.URL_PUSH_COMMENT, post_id, content, email, name);
}
 
Example 17
Source File: TimeUtil.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
/**
 * 时间戳转格式化日期
 *
 * @param timestamp 单位毫秒
 * @param format    日期格式
 * @return
 */
private static String transferLongToDate(long timestamp, String format) {
    try {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date date = new Date(timestamp);
        return sdf.format(date);
    } catch (Exception e) {
        KLog.e(e);
        return "null";
    }
}
 
Example 18
Source File: ThreadPoolManager.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public static void executeOnUploadPool(Runnable runnable) {
    try {
        uploadThreadPool.execute(runnable);
    } catch (Exception e) {
        e.printStackTrace();
        KLog.e(e.toString());
    }
}
 
Example 19
Source File: ThreadPoolManager.java    From star-zone-android with Apache License 2.0 5 votes vote down vote up
public static void execute(Runnable runnable) {
    try {
        threadPool.execute(runnable);
    } catch (Exception e) {
        e.printStackTrace();
        KLog.e(e.toString());
    }
}
 
Example 20
Source File: OkHttpUtil.java    From Pas with Apache License 2.0 3 votes vote down vote up
@Override
protected void onProgressUpdate(Long... values) {


    KLog.e(String.format("%d / %d", values[0], values[1]));

}