This file contains hidden or 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.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; // 周 |
This file contains hidden or 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
... | |
//参考链接: | |
//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) { //可以接收 |
This file contains hidden or 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.takwolf.android.util; | |
import android.content.Context; | |
public class DisplayUtil { | |
/** | |
* 将px值转换为dip或dp值,保证尺寸大小不变 | |
*/ | |
public static int px2dip(Context context, float pxValue) { |
This file contains hidden or 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
//...... | |
String path = Environment.getExternalStorageDirectory() + "/video.m4v"; | |
Bitmap thumb = ThumbnailUtils.createVideoThumbnail(path, Images.Thumbnails.MINI_KIND); | |
//...... | |
This file contains hidden or 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
//先跳转到邮件 | |
Intent intent = new Intent(Intent.ACTION_SENDTO); | |
intent.setData(Uri.parse("mailto:[email protected]")); | |
//判断能否跳转 | |
if (intent.resolveActivity(getPackageManager()) != null) { //可以接收 | |
intent.putExtra(Intent.EXTRA_SUBJECT, "邮件标题"); | |
intent.putExtra(Intent.EXTRA_TEXT, "邮件正文啦啦啦~"); | |
startActivity(intent); | |
} else { //不能跳转 |
This file contains hidden or 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
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) || !Environment.isExternalStorageRemovable()) { | |
String dir = "SD:" + getExternalCacheDir().getPath(); | |
} else { | |
String dir = "package:" + getCacheDir().getPath(); | |
} |
This file contains hidden or 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
<?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> |
This file contains hidden or 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
$ git filter-branch --tree-filter 'rm -f LICENSE' --prune-empty HEAD | |
// 删除git历史中的“LICENSE”文件, rm -f 表示强制删除,“--prune-empty”表示修改之后commit为空则删除这个commit |
This file contains hidden or 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
--===================-- | |
-- INI格式读取工具类 | |
--===================-- | |
ini = {} | |
--[[ | |
载入一个INI文件 | |
--]] | |
function ini.load(filename) | |
local data = {} |
This file contains hidden or 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
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: |