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
| private static void scaleImage(final Activity activity, final View view, int drawableResId) { | |
| // 获取屏幕的高宽 | |
| Point outSize = new Point(); | |
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { | |
| activity.getWindow().getWindowManager().getDefaultDisplay().getSize(outSize); | |
| } else { | |
| outSize.x = activity.getWindow().getWindowManager().getDefaultDisplay().getWidth(); | |
| outSize.y = activity.getWindow().getWindowManager().getDefaultDisplay().getHeight(); | |
| } |
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
| ActivityManager am = ((ActivityManager)mAppContext.getSystemService(Context.ACTIVITY_SERVICE)); | |
| List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses(); | |
| String mainProcessName = mAppContext.getPackageName(); | |
| int myPid = Process.myPid(); | |
| for (ActivityManager.RunningAppProcessInfo info : processInfos) { | |
| if (info.pid == myPid && mainProcessName.equals(info.processName)) { | |
| return true; | |
| } | |
| } | |
| return false; |
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 mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension("txt"); | |
| if (mime == null) { | |
| mime = "application/octet-stream"; | |
| } |
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
| // 二叉树 | |
| // 节点construct | |
| function Node(data, left, right) { | |
| this.data = data; | |
| this.left = left; | |
| this.right = right; | |
| this.show = show; | |
| } |
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
| public static StringBuilder printMotionEvent(MotionEvent event, StringBuilder stringBuilder) { | |
| if (stringBuilder == null) { | |
| stringBuilder = new StringBuilder(); | |
| } | |
| stringBuilder.append("[RawAction:0x").append(Integer.toHexString(event.getAction())) | |
| .append(""); | |
| switch (event.getAction()) { | |
| case MotionEvent.ACTION_DOWN: | |
| stringBuilder.append("(down)"); |
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
| public class RoundCornerImageView extends ImageView { | |
| private final RectF mTmpRectF = new RectF(); | |
| private int topLeftRadius; | |
| private int topRightRadius; | |
| private int bottomLeftRadius; | |
| private int bottomRightRadius; | |
| // todo canvas.clipPath(Round Rect)? |
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
| public class CenterBottomRoundImageView extends RoundCornerImageView { | |
| private Matrix mMatrix; | |
| public CenterBottomRoundImageView(Context context) { | |
| super(context); | |
| init(); | |
| } | |
| public CenterBottomRoundImageView(Context context, @Nullable AttributeSet attrs) { |
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
| private static class DividerDecoration extends RecyclerView.ItemDecoration { | |
| final int bottomOffset = DisplayUtil.dip2px(15); | |
| final int hOffset = DisplayUtil.dip2px(7); | |
| final ShadowHelper mShadowHelper; | |
| DividerDecoration(Context context) { | |
| mShadowHelper = new ShadowHelper(context); | |
| } |
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.wyon.util; | |
| import android.os.Build; | |
| import android.support.annotation.RequiresApi; | |
| import android.util.Log; | |
| import android.view.Choreographer; | |
| /** | |
| * 功能:分析丢帧情况和帧绘制耗时 | |
| * 描述:需要分析的代码前后加上 FrameAnalyze.start(), FrameAnalyze.stop() |
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
| public class BlockDetect { | |
| // BlockDetectByPrinter | |
| public static void start() { | |
| Looper.getMainLooper().setMessageLogging(new Printer() { | |
| private static final String START = ">>>>> Dispatching"; | |
| private static final String END = "<<<<< Finished"; | |
| @Override |
OlderNewer