Skip to content

Instantly share code, notes, and snippets.

@dzwillpower
dzwillpower / snippet.java
Last active June 22, 2018 06:22
代码片段
/** 注册外接设别插拔的广播*/
IntentFilter localIntentFilter = new IntentFilter();
localIntentFilter.addAction("android.intent.action.MEDIA_UNMOUNTED");
localIntentFilter.addAction("android.intent.action.MEDIA_MOUNTED");
localIntentFilter.addAction("android.intent.action.MEDIA_REMOVED");
localIntentFilter.addAction("android.intent.action.MEDIA_BAD_REMOVAL");
localIntentFilter.addDataScheme("file");
registerReceiver(this.mReceiver, localIntentFilter);
/** Stirng 中空格的写法 */
@dzwillpower
dzwillpower / selector.xml
Created March 4, 2014 01:30
各种selector的写法
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/detail_favorites_focus" android:state_focused="true"/>
<item android:drawable="@drawable/detail_favorites_unfocus" android:state_focused="false"/>
</selector>
@dzwillpower
dzwillpower / timeline.json
Last active August 29, 2015 13:56
新浪微博 主页时间线 http://open.weibo.com/wiki/2/statuses/home_timeline 字段说明 两条微博 带图片
{
"statuses": [
{
"created_at": "Thu May 15 13:51:34 +0800 2014",
"id": 3710489487555905,
"mid": "3710489487555905",
"idstr": "3710489487555905",
"text": "测试一张图片",
"source": "<a href=\"http://app.weibo.com/t/feed/6ghA0p\" rel=\"nofollow\">搜狗高速浏览器</a>",
"favorited": false,
@dzwillpower
dzwillpower / Channel.xml
Last active January 1, 2016 20:29
江西省网的数据结构 服务端返回的xml
<?xml version="1.0" encoding="GBK"?>
<Channels totalResults="4" restartAtToken="0" timeShiftURL="">
<Channel channelID="817447" channelCode="10001010-00000000000000000000345" channelName="CCTV-7" channelNumber="0"
logo="" isStartOver="1" isNPVR="0" isStandardChannel="1"
isTVAnyTime="1" npvrOrderFlag="0" tVAnyTimeOrderFlag="0" startOverOrderFlag="0">
@dzwillpower
dzwillpower / AlphaImageFetchTaskAlphaImageFetchTask.java
Created December 31, 2013 06:55
异步加载图片 动画渐变出来
public class AlphaImageFetchTask extends BaseImageFetchTask {
public AlphaImageFetchTask(String url, int targetWidth, int targetHeight) {
super(url, targetWidth, targetHeight);
}
public AlphaImageFetchTask(String url, int targetWidth, int targetHeight, String key) {
super(url, targetWidth, targetHeight, key);
}
@Override
public void setDrawable(View view, Drawable drawable) {
@dzwillpower
dzwillpower / content.xml
Created December 21, 2013 13:24
思华 内容详情 2013.12.21
<?xml version="1.0" encoding="UTF-8"?>
<message module="CATALOG_SERVICE" version="1.0">
<header action="RESPONSE" command="CONTENT_QUERY" sequence="" component-id="portal52" component-type="CATALOG_SERVER" />
<body>
<result code="1" description="ok" />
<contents>
<content>
<name><![CDATA[快乐大本营]]></name>
<code><![CDATA[jxgd-000000000000000000000000211]]></code>
<type><![CDATA[10]]></type>
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.NinePatch;
import android.graphics.Rect;
import android.graphics.drawable.NinePatchDrawable;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
/**
@dzwillpower
dzwillpower / scanMusic.java
Last active December 25, 2015 06:29
扫描外接设备
public HashMap<String, List<MusicInfo>> scanDirectory(File path, HashMap<String, List<MusicInfo>> musicHashMap) {
if (musicHashMap == null) {
musicHashMap = new HashMap<String, List<MusicInfo>>();
}
if (path.exists()) {
File[] files = path.listFiles();
if (files == null) {
return null;
}
for (int i = 0; i < files.length; i++) {
package com.example.app;
import java.io.File;
import android.media.MediaScannerConnection;
import android.media.MediaScannerConnection.MediaScannerConnectionClient;
import android.net.Uri;
import android.util.Log;
public class MyMediaScannerConnectionClient implements MediaScannerConnectionClient {
@dzwillpower
dzwillpower / autoscrolltextview.xml
Created September 2, 2013 04:55
auto-scroll-text-view textview 跑马灯效果
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:scrollHorizontally="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit ="marquee_forever"
android:focusable="true"
android:focusableInTouchMode="true"
android:text="Hello Android.. I am android developer and developing this auto scroll text view via XML." />