Skip to content

Instantly share code, notes, and snippets.

🎮
Playing games

TakWolf TakWolf

🎮
Playing games
View GitHub Profile
@TakWolf
TakWolf / Some.java
Last active Jul 18, 2016
修复RefreshLayout和ViewPager手势冲突
View Some.java
viewPager.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
refreshLayout.setEnabled(false);
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
@TakWolf
TakWolf / ini.lua
Last active Apr 28, 2019
Lua读取ini文件
View ini.lua
--===================--
-- INI格式读取工具类
--===================--
ini = {}
--[[
载入一个INI文件
--]]
function ini.load(filename)
local data = {}
View gist:3700db3c403fe2498d40
$ git filter-branch --tree-filter 'rm -f LICENSE' --prune-empty HEAD
// 删除git历史中的“LICENSE”文件, rm -f 表示强制删除,“--prune-empty”表示修改之后commit为空则删除这个commit
View android-ripple.xml
<?xml version="1.0" encoding="utf-8"?>
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="#908967">
<item>
<selector>
<item android:state_enabled="false" android:drawable="@drawable/button_pressed" />
<item android:state_focused="true" android:drawable="@drawable/button_pressed" />
<item android:drawable="@drawable/button_normal" />
</selector>
</item>
View GetAndroidCacheDir.java
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) {
String dir = "SD:" + getExternalCacheDir().getPath();
} else {
String dir = "package:" + getCacheDir().getPath();
}
View MailActivity.java
//先跳转到邮件
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:takwolf@foxmail.com"));
//判断能否跳转
if (intent.resolveActivity(getPackageManager()) != null) { //可以接收
intent.putExtra(Intent.EXTRA_SUBJECT, "邮件标题");
intent.putExtra(Intent.EXTRA_TEXT, "邮件正文啦啦啦~");
startActivity(intent);
} else { //不能跳转
@TakWolf
TakWolf / AndroidGetVideoThumbnail
Last active Aug 29, 2015
Android获取视频缩略图,需要API > 8
View AndroidGetVideoThumbnail
//......
String path = Environment.getExternalStorageDirectory() + "/video.m4v";
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path, Images.Thumbnails.MINI_KIND);
//......
@TakWolf
TakWolf / DisplayUtil.java
Created Jan 4, 2015
Android px, sp, dp convert util
View DisplayUtil.java
package com.takwolf.android.util;
import android.content.Context;
public class DisplayUtil {
/**
* 将px值转换为dip或dp值,保证尺寸大小不变
*/
public static int px2dip(Context context, float pxValue) {
@TakWolf
TakWolf / ShopActivity.java
Last active Aug 29, 2015
Android跳转到应用市场的详细信息页面,可以用于实现应用评分或者推荐
View ShopActivity.java
...
//参考链接:
//http://stackoverflow.com/questions/4702204/android-market-detailsid-not-working-for-app
...
//这里开始执行一个应用市场跳转逻辑,默认this为Context上下文对象
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + getPackageName())); //跳转到应用市场,非Google Play市场一般情况也实现了这个接口
//存在手机里没安装应用市场的情况,跳转会包异常,做一个接收判断
if (intent.resolveActivity(getPackageManager()) != null) { //可以接收
@TakWolf
TakWolf / TimeUtil.java
Last active Aug 29, 2015
根据时间返回“几分钟”、“几小时”、“几天”的时间String
View TimeUtil.java
package com.takwolf.util;
import java.util.Date;
public class TimeUtil {
private final static long minute = 60 * 1000;// 分钟
private final static long hour = 60 * minute;// 小时
private final static long day = 24 * hour;//
private final static long week = 7 * day; //
You can’t perform that action at this time.