This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* 解析 视频信息 类 | |
* | |
* 支持 优酷, 土豆 酷6 56 新浪 qq播客 乐视 乐视 | |
**/ | |
class class_video{ | |
// 超时时间 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewHolder { | |
// I added a generic return type to reduce the casting noise in client code | |
@SuppressWarnings("unchecked") | |
public static <T extends View> T get(View view, int id) { | |
SparseArray<View> viewHolder = (SparseArray<View>) view.getTag(); | |
if (viewHolder == null) { | |
viewHolder = new SparseArray<View>(); | |
view.setTag(viewHolder); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
task nativeLibsToJar(type: Zip, description: "create a jar archive of the native libs") { | |
destinationDir file("$buildDir/native-libs") | |
baseName "native-libs" | |
extension "jar" | |
from fileTree(dir: "libs", include: "**/*.so") | |
into "lib/" | |
} | |
tasks.withType(JavaCompile) { | |
compileTask -> compileTask.dependsOn(nativeLibsToJar) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Messenger mService; | |
final Messenger mMessenger = new Messenger(new Handler() { | |
@Override | |
public void dispatchMessage(Message msg) { | |
switch (msg.what) { | |
case SERV_RES_HAHA: | |
String s = msg.getData().getString("msg"); | |
Bundle data = new Bundle(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
在使用 AsyncTask 停止常常被人忽略的問題以下兩種。 | |
1. 呼叫了 cancel() 但是沒有馬上停止而造成其他 crash。 | |
2. Activity 已經被 onDestory 但是 AsyncTask 沒有被 cancel 造成 crash。 | |
*/ | |
public class MainActivity extends Activity { | |
private final static String TAG = "MainActivity"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ParseResourceID { | |
public static int getIdByName(Context context, String className, String name) { | |
String packageName = context.getPackageName(); | |
Class r = null; | |
int id = 0; | |
try { | |
r = Class.forName(packageName + ".R"); | |
Class[] classes = r.getClasses(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class ThreadTask<Params, Progress, Result> { | |
private HandlerThread mHandlerThread; | |
private TaskHandler mHandler; | |
private TaskHandler mUiHandler; | |
private Params[] mParams; | |
public ThreadTask() { | |
mHandlerThread = new HandlerThread("ThreadTask", android.os.Process.THREAD_PRIORITY_BACKGROUND); | |
mHandlerThread.start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OKStack implements HttpStack { | |
OkHttpClient client = new OkHttpClient(); | |
public static final String HEADER_CONTENT_TYPE = "Content-Type"; | |
@Override | |
public HttpResponse performRequest(Request<?> request, Map<String, String> additionalHeaders) throws IOException, | |
AuthFailureError { | |
URL url = new URL(request.getUrl()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
android { | |
compileSdkVersion rootProject.ext.compileSdkVersion | |
buildToolsVersion rootProject.ext.buildToolsVersion | |
defaultConfig { | |
minSdkVersion 14 | |
targetSdkVersion 19 | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.resultrecevie; | |
import android.os.Bundle; | |
import android.os.Handler; | |
import android.os.ResultReceiver; | |
public class APIResultReceive extends ResultReceiver { | |
private final static String TAG = "APIResultReceive"; | |
public final static int API_START = 1; |