com.bumptech.glide.load.engine.cache.LruResourceCache#com.socks.library.KLog源码实例Demo

下面列出了com.bumptech.glide.load.engine.cache.LruResourceCache#com.socks.library.KLog 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: star-zone-android   文件: FileUtil.java
/**
 * 复制单个文件
 *
 * @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;
}
 
源代码2 项目: star-zone-android   文件: FileUtil.java
/**
 * 写入文件
 *
 * @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);
    }
}
 
源代码3 项目: star-zone-android   文件: FileUtil.java
/**
 * 调用系统打开文件
 */
public static boolean openFile(File file, Context context) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    // 设置intent的Action属性
    intent.setAction(Intent.ACTION_VIEW);
    // 获取文件file的MIME类型
    String type = getMIMEType(file);
    // 设置intent的data和Type属性。
    intent.setDataAndType(Uri.fromFile(file), type);
    // 跳转
    try {
        ((Activity) context).startActivity(intent);
    } catch (ActivityNotFoundException e) {
        KLog.e(e);
        return false;
    }
    return true;
}
 
源代码4 项目: star-zone-android   文件: CircleBaseViewHolder.java
@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());
}
 
源代码5 项目: BitkyShop   文件: CartFragment.java
/**
 * 更新全选复选框的状态
 */
private void updateCheckedAll() {
  Boolean isCheckedAll = true;
  if (commodityLocals == null || commodityLocals.size() == 0) {
    isCheckedAll = false;
  } else {
    for (CommodityLocal commodityLocal : commodityLocals) {
      if (!commodityLocal.getCartIsChecked()) {
        isCheckedAll = false;
        break;
      }
    }
  }
  KLog.d("isCheckedAll+" + isCheckedAll);
  checkBoxAll.setChecked(isCheckedAll);
}
 
源代码6 项目: star-zone-android   文件: PhotoBrowseActivity.java
@Override
public void finish() {
    final GalleryPhotoView currentPhotoView = viewBuckets.get(photoViewpager.getCurrentItem());
    if (currentPhotoView == null) {
        KLog.e(TAG, "childView is null");
        super.finish();
        return;
    }
    final Rect endRect = photoBrowseInfo.getViewLocalRects().get(photoViewpager.getCurrentItem());
    currentPhotoView.playExitAnima(endRect, blackBackground, new GalleryPhotoView.OnExitAnimaEndListener() {
        @Override
        public void onExitAnimaEnd() {
            PhotoBrowseActivity.super.finish();
            overridePendingTransition(0, 0);
        }
    });
}
 
源代码7 项目: star-zone-android   文件: DefaultGlideModule.java
@Override
public void applyOptions(Context context, GlideBuilder builder) {
    //磁盘缓存
    builder.setDiskCache(new DiskLruCacheFactory(context.getCacheDir().getAbsolutePath(), 50 * 1024 * 1024));
    KLog.d("Glide", "glide cache file path  >>>  " + context.getCacheDir().getAbsolutePath());
    //内存缓存
    MemorySizeCalculator calculator = new MemorySizeCalculator.Builder(context).build();
    int defaultMemoryCacheSize = calculator.getMemoryCacheSize();
    int defaultBitmapPoolSize = calculator.getBitmapPoolSize();
    //设置比默认大小大1.5倍的缓存和图片池大小
    int customMemoryCacheSize = (int) (1.5 * defaultMemoryCacheSize);
    int customBitmapPoolSize = defaultBitmapPoolSize;

    builder.setMemoryCache(new LruResourceCache(customMemoryCacheSize));
    builder.setBitmapPool(new LruBitmapPool(customBitmapPoolSize));


    KLog.d("Glide", "bitmapPoolSize >>>>>   " +
            formatFileSize(context, customBitmapPoolSize) +
            " / memorySize>>>>>>>>   " +
            formatFileSize(context, customMemoryCacheSize));

    builder.setLogLevel(Log.ERROR);
}
 
public HeaderViewWrapperAdapter(RecyclerView recyclerView,
                                @NonNull RecyclerView.Adapter mWrappedAdapter,
                                ArrayList<FixedViewInfo> mHeaderViewInfos,
                                ArrayList<FixedViewInfo> mFooterViewInfos) {
    this.recyclerView = recyclerView;
    this.mWrappedAdapter = mWrappedAdapter;
    try {
        mWrappedAdapter.registerAdapterDataObserver(mDataObserver);
    }catch (IllegalStateException e){
        //maybe observer is added
        KLog.w(e);
    }
    if (mHeaderViewInfos == null) {
        this.mHeaderViewInfos = EMPTY_INFO_LIST;
    } else {
        this.mHeaderViewInfos = mHeaderViewInfos;
    }
    if (mFooterViewInfos == null) {
        this.mFooterViewInfos = EMPTY_INFO_LIST;
    } else {
        this.mFooterViewInfos = mFooterViewInfos;
    }
}
 
源代码9 项目: OkHttpPlus   文件: MainActivity.java
public void downloadFile(View view) {

        String desFileDir = Environment.getExternalStorageDirectory().getAbsolutePath();
        OkHttpProxy.download(URL_DOWMLOAD, new DownloadListener(desFileDir, "json.jar") {

            @Override
            public void onUIProgress(Progress progress) {
                //当下载资源长度不可知时,progress.getTotalBytes()为-1,此时不能显示下载进度
                int pro = (int) (progress.getCurrentBytes() / progress.getTotalBytes() * 100);
                if (pro > 0) {
                    pb.setProgress(pro);
                }
                KLog.d("pro = " + pro + " getCurrentBytes = " + progress.getCurrentBytes() + " getTotalBytes = " + progress.getTotalBytes());
            }

            @Override
            public void onSuccess(File file) {
                tv_response.setText(file.getAbsolutePath());
            }

            @Override
            public void onFailure(Exception e) {
                tv_response.setText(e.getMessage());
            }
        });
    }
 
源代码10 项目: BitkyShop   文件: SearchActivity.java
private void searchCommodity() {
  ((InputMethodManager) context.getSystemService(
      Context.INPUT_METHOD_SERVICE)).hideSoftInputFromWindow(searchEdittext.getWindowToken(),
      InputMethodManager.HIDE_NOT_ALWAYS);
  String msg = searchEdittext.getText().toString().trim();
  if (msg.equals("")) {
    toastUtil.show("请输入要搜索的商品");
    return;
  }
  BmobQuery<Commodity> bmobQuery = new BmobQuery<>();
  bmobQuery.addWhereEqualTo("categorySub", msg);
  KLog.d(msg);
  bmobQuery.findObjects(new FindListener<Commodity>() {
    @Override public void done(List<Commodity> list, BmobException e) {
      if (e != null) {
        KLog.d(e.getMessage());
      }
      if (list != null) {
        KLog.d(list.size());
      }
    }
  });
}
 
源代码11 项目: ZZShow   文件: NewsFragment.java
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments() != null) {
        mParam1 = getArguments().getString(ARG_PARAM1);
        mParam2 = getArguments().getString(ARG_PARAM2);
    }
    mSubscription = RxBus.getInstance().toObservable(ChannelChangeEvent.class)
            .subscribe(new Action1<ChannelChangeEvent>() {
                @Override
                public void call(ChannelChangeEvent channelChangeEvent) {
                    KLog.d("NewsChannelPresenterImpl","GET ---------------");
                    if(channelChangeEvent.isChannelChanged()) {
                        mPresenter.loadNewsChannels();
                        if(channelChangeEvent.getChannelName() != null) {
                            mCurrentViewPagerName = channelChangeEvent.getChannelName();
                        }
                    }else{
                        if(channelChangeEvent.getChannelName() != null) {
                            mCurrentViewPagerName = channelChangeEvent.getChannelName();
                            mViewPager.setCurrentItem(getCurrentViewPagerPosition());
                        }
                    }
                }
            });
}
 
源代码12 项目: ZZShow   文件: SplashActivity.java
private void startLogoOuterAndAppName() {
    final ValueAnimator valueAnimator = ValueAnimator.ofFloat(0, 1);
    valueAnimator.setDuration(1000);
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            float fraction = animation.getAnimatedFraction();
            KLog.d("fraction: " + fraction);
            if (fraction >= 0.8 && !isShowingRubberEffect) {
                isShowingRubberEffect = true;
                startLogoOuter();
                startShowAppName();
                finishActivity();
            } else if (fraction >= 0.95) {
                valueAnimator.cancel();
                startLogoInner2();
            }

        }
    });
    valueAnimator.start();
}
 
源代码13 项目: ZZShow   文件: DBManager.java
/**
 * 修改
 * @param channelTable 对象
 */
public int update (NewsChannelTable channelTable){
    db.beginTransaction();
    int index = -1;
    try {
        ContentValues values = new ContentValues();
        values.put("news_channel_name", channelTable.getNewsChannelName());
        values.put("news_channel_id", channelTable.getNewsChannelId());
        values.put("news_channel_type", channelTable.getNewsChannelType());
        values.put("news_channel_select", channelTable.isNewsChannelSelect() ? 1:0);
        values.put("news_channel_index", channelTable.getNewsChannelIndex());
        values.put("news_channel_fixed", channelTable.isNewsChannelFixed()? 1:0);
        index = db.update(DBHelper.TABLE_NEWS_CHANNEL,values,"news_channel_id = ?",new String[]{channelTable.getNewsChannelId()});
        db.setTransactionSuccessful();
    }catch (Exception e){
        KLog.e(e.getMessage());
    }finally {
        db.endTransaction();
    }
    return index;
}
 
源代码14 项目: KLog   文件: XmlLog.java
public static void printXml(String tag, String xml, String headString) {

        if (xml != null) {
            xml = XmlLog.formatXML(xml);
            xml = headString + "\n" + xml;
        } else {
            xml = headString + KLog.NULL_TIPS;
        }

        KLogUtil.printLine(tag, true);
        String[] lines = xml.split(KLog.LINE_SEPARATOR);
        for (String line : lines) {
            if (!KLogUtil.isEmpty(line)) {
                Log.d(tag, "║ " + line);
            }
        }
        KLogUtil.printLine(tag, false);
    }
 
源代码15 项目: ZZShow   文件: DBManager.java
/**
 * 根据条件查询记录条数
 *
 * @param selection    条件
 * @param selectionArgs  值
 * @return
 */
public long getCountByWhere(String selection,String[] selectionArgs){
    db.beginTransaction();
    long count = 0;
    Cursor cursor = null;
    try {
        cursor = db.rawQuery("select count(news_channel_id) from " + DBHelper.TABLE_NEWS_CHANNEL + " where " + selection,selectionArgs);
        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;
}
 
源代码16 项目: KLog   文件: JsonLog.java
public static void printJson(String tag, String msg, String headString) {

        String message;

        try {
            if (msg.startsWith("{")) {
                JSONObject jsonObject = new JSONObject(msg);
                message = jsonObject.toString(KLog.JSON_INDENT);
            } else if (msg.startsWith("[")) {
                JSONArray jsonArray = new JSONArray(msg);
                message = jsonArray.toString(KLog.JSON_INDENT);
            } else {
                message = msg;
            }
        } catch (JSONException e) {
            message = msg;
        }

        KLogUtil.printLine(tag, true);
        message = headString + KLog.LINE_SEPARATOR + message;
        String[] lines = message.split(KLog.LINE_SEPARATOR);
        for (String line : lines) {
            Log.d(tag, "║ " + line);
        }
        KLogUtil.printLine(tag, false);
    }
 
源代码17 项目: star-zone-android   文件: BaseActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    KLog.i("当前打开 :  " + this.getClass().getSimpleName());
    if (mPermissionHelper == null) {
        mPermissionHelper = new PermissionHelper(this);
    }
    ARouter.getInstance().inject(this);
    onHandleIntent(getIntent());
}
 
源代码18 项目: star-zone-android   文件: PermissionHelper.java
private void log(String desc, List<String> data) {
    String logText = null;
    if (!ToolUtil.isListEmpty(data)) {
        for (String datum : data) {
            logText = datum + "\n";
        }
    }
    KLog.i(TAG, desc + logText);
}
 
源代码19 项目: star-zone-android   文件: CompressManager.java
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();
}
 
源代码20 项目: star-zone-android   文件: CompressTaskHelper.java
@Override
public void start() {
    if (data == null) {
        callError("配置为空");
        return;
    }
    CompressOption option = data;
    int[] imageSize = BitmapUtil.getImageSize(option.originalImagePath);
    if (imageSize[0] <= -1 || imageSize[1] <= -1) {
        callError(">>>>>无法获取图片大小<<<<<");
        return;
    }
    File imageFile = new File(option.originalImagePath);
    if (!imageFile.exists()) {
        callError("图片不存在。。。退出");
        return;
    }
    long fileSize = 0;
    try {
        fileSize = FileUtil.getFileSize(new File(option.originalImagePath));
        KLog.i(TAG, "文件路径  >>>  " + option.originalImagePath + "\n文件大小  >>>  " + FileUtil.fileLengthFormat(fileSize));
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (fileSize <= 0 && option.compressType != CompressManager.SCALE) {
        callError("获取图片文件大小失败。。。。");
        return;
    }

    startTask(imageSize, fileSize, option);
}
 
源代码21 项目: star-zone-android   文件: CompressTaskHelper.java
private void startInternal(int[] imageSize, long fileSize, CompressOption option) throws Exception {
    String targetImagePath = null;
    switch (option.compressType) {
        case CompressManager.SCALE:
            targetImagePath = compressOnScale(option.originalImagePath, imageSize, option);
            break;
        case CompressManager.SIZE:
            targetImagePath = compressOnSize(option.originalImagePath, fileSize, option);
            break;
        case CompressManager.BOTH:
            String savePath = option.saveCompressImagePath;
            option.setSaveCompressImagePath(AppFileHelper.getAppTempPath().concat(EncryUtil.MD5(savePath) + option.suffix));
            String scaleTargetPath = compressOnScale(option.originalImagePath, imageSize, option);
            if (StringUtil.noEmpty(scaleTargetPath)) {
                option.setSaveCompressImagePath(savePath);
                targetImagePath = compressOnSize(scaleTargetPath, fileSize, option);
            }
            break;
    }
    if (StringUtil.noEmpty(targetImagePath)) {
        KLog.i(TAG, "压缩成功,图片地址  >>  " + targetImagePath);
        callCompress(1, 1);
        result.add(targetImagePath);
        callSuccess(result);
    } else {
        callError("压缩失败");
    }
}
 
源代码22 项目: JianDanRxJava   文件: JokeAdapter.java
private void getCommentCounts(final ArrayList<Joke> jokes) {

        StringBuilder sb = new StringBuilder();
        for (Joke joke : jokes) {
            sb.append("comment-" + joke.getComment_ID() + ",");
        }

        String url = sb.toString();
        if (url.endsWith(",")) {
            url = url.substring(0, url.length() - 1);
        }

        JDApi.getCommentNumber(url)
                .observeOn(Schedulers.io())
                .doOnNext(commentNumbers -> {
                    if (page == 1) {
                        mJokes.clear();
                        JokeCache.getInstance(mActivity).clearAllCache();
                    }
                    JokeCache.getInstance(mActivity).addResultCache(GsonHelper.toString(jokes), page);
                })
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(commentNumbers -> {
                    for (int i = 0; i < jokes.size(); i++) {
                        jokes.get(i).setComment_counts(commentNumbers.get(i).comments + "");
                    }
                    mJokes.addAll(jokes);
                    notifyDataSetChanged();
                    mLoadFinisCallBack.loadFinish(null);
                    mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                }, e -> {
                    mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET);
                    mLoadFinisCallBack.loadFinish(null);
                    KLog.e(e);
                });
    }
 
源代码23 项目: star-zone-android   文件: ThreadPoolManager.java
public static void execute(Runnable runnable) {
    try {
        threadPool.execute(runnable);
    } catch (Exception e) {
        e.printStackTrace();
        KLog.e(e.toString());
    }
}
 
源代码24 项目: star-zone-android   文件: ThreadPoolManager.java
public static void executeOnUploadPool(Runnable runnable) {
    try {
        uploadThreadPool.execute(runnable);
    } catch (Exception e) {
        e.printStackTrace();
        KLog.e(e.toString());
    }
}
 
源代码25 项目: star-zone-android   文件: TimeUtil.java
/**
 * 时间戳转格式化日期
 *
 * @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";
    }
}
 
源代码26 项目: star-zone-android   文件: FileUtil.java
/**
 * 写入文件
 *
 * @param strFileName 文件名
 * @param bytes       bytes
 */
public static boolean writeToFile(String strFileName, byte[] bytes) {
    try {
        File file = new File(strFileName);

        FileOutputStream fouts = new FileOutputStream(file);
        fouts.write(bytes, 0, bytes.length);
        fouts.flush();
        fouts.close();
        return true;
    } catch (IOException e) {
        KLog.e(e);
    }
    return false;
}
 
源代码27 项目: star-zone-android   文件: FileUtil.java
public static String Read(String fileName) {
    String res = "";
    try {
        FileInputStream fin = new FileInputStream(fileName);
        int length = fin.available();
        byte[] buffer = new byte[length];
        fin.read(buffer);
        res = EncodingUtils.getString(buffer, "UTF-8");
        fin.close();
    } catch (Exception e) {
        KLog.e(e);
    }
    return res;
}
 
源代码28 项目: star-zone-android   文件: FileUtil.java
/**
 * 先改名,在删除(为了避免EBUSY (Device or resource busy)的错误)
 */
private static void safelyDelete(File file) {
    if (file == null || !file.exists()) return;
    try {
        final File to = new File(file.getAbsolutePath() + System.currentTimeMillis());
        file.renameTo(to);
        to.delete();
    } catch (Exception e) {
        KLog.e(e);
    }
}
 
源代码29 项目: star-zone-android   文件: MomentInfo.java
public int getMomentType() {
    if (content == null) {
        KLog.e("朋友圈是空的");
        return MomentsType.EMPTY_CONTENT;
    }
    return content.getMomentType();
}
 
源代码30 项目: BitkyShop   文件: CartRecyclerAdapter.java
/**
 * 初始化 RecyclerView 适配器
 *
 * @param mDatas 绑定的数据
 */
public CartRecyclerAdapter(List<CommodityLocal> mDatas) {
  super(mDatas, R.layout.recycler_cartfragment_show);
  listener = new KyRecyclerViewItemOnClickListener<CommodityLocal>() {
    @Override public void Onclick(View v, int adapterPosition, CommodityLocal data) {
      KLog.d("点击:" + data.getName() + "位置:" + adapterPosition);
    }
  };
}