Skip to content

Instantly share code, notes, and snippets.

@dzwillpower
dzwillpower / oppo_attrs.xml
Last active August 29, 2015 14:17
theme and style
<attr name="oppoPagerTabStripStyle" format="reference" />
<declare-styleable name="OppoPagerTabStrip">
<attr name="pagerTitle" format="reference" />
<attr name="pagerTitleSize" format="reference|dimension" />
<attr name="pagerTitleColor" format="reference|color" />
<attr name="pagerTitleColorHighlight" format="reference|color" />
<attr name="textPadding" format="reference|dimension" />
<attr name="bottomLine" format="reference|color" />
<attr name="focusLine" format="reference|color" />
@dzwillpower
dzwillpower / ProviderUtils.java
Last active August 29, 2015 14:14
SQLite 查询语句
public static List<Track> getLocalSongs(Context context, int pageIndex, int pageSize) {
long[] audioId;
Playlist playlist;
List<Track> trackList = new ArrayList<Track>();
String[] projection = new String[] { MediaStore.Audio.Media._ID, };
Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
.buildUpon()
.appendQueryParameter(QUERY_PARAMETER_LIMIT, String.valueOf(pageSize))
.appendQueryParameter(QUERY_PARAMETER_OFFSET,
String.valueOf((pageIndex - 1) * pageSize)).build();
@dzwillpower
dzwillpower / blurBitmap.java
Created January 4, 2015 02:07
图片高斯模糊
/**
* Blur a bitmap by specified radius
* @param context
* @param src
* @param radius
* @return
*/
public static Bitmap blurBitmap(Context context, Bitmap src, float radius)
throws RSIllegalArgumentException {
if (radius <= 0f) {
import android.graphics.*;
import com.squareup.picasso.Transformation;
/**
* Transforms an image into a circle representation. Such as a avatar.
*/
public class CircularTransformation implements Transformation
{
int radius = 10;
@dzwillpower
dzwillpower / VolleyLog.java
Created November 13, 2014 14:31
volley库 的log 类 可以打出调用的线程 方法名称
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dzwillpower
dzwillpower / DiskLruCache.java
Created September 19, 2014 02:42
DiskLruCache
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dzwillpower
dzwillpower / LruCache.java
Created September 19, 2014 02:40
Android使用 LruCache 缓存图片
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@dzwillpower
dzwillpower / DirectoryCreate.java
Created July 30, 2014 01:29
创建文件夹 和递归删除文件夹
package com.wits.dzwillpower;
import java.io.File;
public class DirectoryCreate {
public static void main(String[] args) {
deleteFile(new File("E:\\ProgrammeMaterial\\Android\\AndroidProgram\\3372\\1\\1"));
}
public static void deleteFile(File file) {
@dzwillpower
dzwillpower / OAuthActivity.java
Created May 1, 2014 13:05
新浪微博授权activity
package org.qii.weiciyuan.ui.login;
import org.qii.weiciyuan.R;
import org.qii.weiciyuan.bean.AccountBean;
import org.qii.weiciyuan.bean.UserBean;
import org.qii.weiciyuan.dao.URLHelper;
import org.qii.weiciyuan.dao.login.OAuthDao;
import org.qii.weiciyuan.support.database.AccountDBTask;
import org.qii.weiciyuan.support.debug.AppLogger;
import org.qii.weiciyuan.support.error.WeiboException;
@dzwillpower
dzwillpower / AssetfileToFile.java
Created April 29, 2014 08:59
将asset 里面的文件转换为file
AssetManager am = getAssets();
InputStream inputStream = am.open(file:///android_asset/myfoldername/myfilename);
File file = createFileFromInputStream(inputStream);
private File createFileFromInputStream(InputStream inputStream) {
try{
File f = new File(my_file_name);
OutputStream outputStream = new FileOutputStream(f);
byte buffer[] = new byte[1024];