自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(45)
  • 资源 (1)
  • 收藏
  • 关注

原创 AsynclayoutInflater源码分析

简介AsyncLayoutInflater特点layout的parent ViewGroup的generateLayoutParams是线程安全的;inflater中的所有view内部不能创建Handler或者调用Looper.myLooper;异步inflate失败的layout最终都会在UI线程进行inflate;inflate出来的view不会被添加到parent;不支持设置L...

2019-09-05 00:12:42 365

原创 gradle问题集锦

resolved versions for compilation (26.0.2) and packaging (25.3.1) differandroid { compileSdkVersion 26 buildToolsVersion "26.0.2"} dependencies { providedCompile('group:artifact:ver...

2018-09-28 20:11:20 277

原创 Git简单操作

Git常用操作git修改远程仓库地址git remote rm origingit remote add origin [url]git生成patch和合并patch.当前分支的未提交修改生成patch: git diff > diff.patch当前分支的已提交修改(相对于主干master分支)生成patch: git format-patch maste...

2018-03-14 00:15:09 300

原创 Mac下配置Android NDK

ndk

2016-01-18 17:07:42 567

原创 获取status bar的高度

private int getStatusBarheight() { try { Class clazz = Class.forName("com.android.internal.R$dimen"); Object obj = clazz.newInstance(); Field field = clazz.

2015-12-29 17:13:53 668

原创 使用清华镜像下载Android源码

1. 创建bin路径 macbookpro-2d30:~ xxx$ mkdir bin PATH=~/bin:$PATH2. 从清华镜像下载repo文件 macbookpro-2d30:bin xxx$ git clone git://aosp.tuna.tsinghua.edu.cn/android/git-repo.git 从git-repo文件下降re

2015-12-26 20:07:04 4647

原创 [Binary Search]Search Insert Position

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.

2015-12-16 16:32:45 440

原创 ContentProvider启动时机问题简记

今天代码中用到了自定义的ContentProvider,除了在AndroidManifest.xml中的声明外:,应用侧的代码并没有显示启动MyProvider的逻辑。1. 那么ContentProvider是什么时候启动起来的?MyProvider的onCreate方法的执行调用栈可知:MyContentProvider.onCreate() line: 47MyConten

2015-12-15 00:30:10 7611

原创 [DP] Minimum Path Sum

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at

2015-12-14 14:56:34 539

原创 Android之meta-data理解

android:resource="resource specification"           android:value="string" />是提供给父组件使用的任意数据类型的补充数据。可以嵌入在如下几种Component组件中:    在每种AndroidManifest的某个组件中申明时,其数量没有限制,最终都是保存在Bundle类型

2015-12-11 16:19:40 674

原创 byte[]和short[]

1. short[]  to  byte[]ByteBuffer buffer = ByteBuffer.allocate(shortArray.length * 2);buffer.order(ByteOrder.LITTLE_ENDIAN);buffer.asShortBuffer().put(shortArray);byte[] bytes = buffer.array();

2015-12-10 19:13:50 836

原创 [DP] Unique Paths

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the

2015-12-10 14:51:20 913

原创 Android 连续点击back button退出当前Activity的两种实现方法

设定连续两次点击的时间差在2s内为有效。1. 通过辅助标志位和用sendEmptyMessageDelayed方法来进行更新的方式:private static boolean exited = false; mBackButton.setOnClickListener(new View.OnClickListener() { @Override

2015-12-09 19:03:55 3535

原创 Pow(x, n)

Implement pow(x, n).public class Solution { double myPow(double x, int n) { if(n==0) return 1; if(n<0){ n = -n; x = 1/x; } return n%2==0

2015-12-07 15:02:16 396

原创 [DP] Unique Binary Search Trees

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2015-12-07 14:24:43 627

原创 长度为0的数组和 null

长度为0的数组 int[] arr = new int[0],也称为空数组,虽然arr长度为0,但是依然是一个对象null数组,int[] arr = null;arr是一个数组类型的空引用。1. 编写api方法,进行参数校验时,不要漏掉空数组的情况比如下面这个计算递增子序列最大长度的方法,要考虑空数组的情况。public class Solution { public i

2015-12-03 12:59:36 13240

原创 [Leetcode] Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fi

2015-11-30 14:45:34 399

原创 Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?Floyd判圈算法的典型应用场景①使用Floyd判圈算法直接求解/** * Definition for singly-linked list.

2015-11-25 11:11:27 998

原创 Floyd判圈算法理解

关于该算法,wiki上有详细说明。https://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_harehttps://zh.wikipedia.org/wiki/Floyd%E5%88%A4%E5%9C%88%E7%AE%97%E6%B3%95Floyd判圈算法(Floyd Cycle Detection Algorit

2015-11-24 18:16:24 6080 4

原创 Find Peak Element

A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, i

2015-11-23 19:19:08 475

原创 ALPHA_8 RGB_565 ARGB_4444 ARGB_8888

Bitmap中定义了一个枚举结构:包含ALPHA_8,RGB_565,ARGB_4444,ARGB_8888,可用于一个Bitmap对象的不同配置。Bitmap.Config.ARGB_4444每个像素占4位,A=4,R=4,G=4,B=4,那么一个像素点占4+4+4+4=16位Bitmap.Config.ARGB_8888每个像素占8位,A=8,R=8,G=8,B=8,那么一

2015-11-23 17:17:23 2066 1

原创 adb命令

1. 写settings.secure表adb shell settings put secure adb_install_need_confirm 02. 读配置项adb shell getprop ro.config.ringtone3. 抓取实时logadb logcat -s tag:*4. 工厂级恢复出厂设置adb reboot resetfactory5. 用户级恢复出厂设置adb re

2015-11-17 23:13:28 4355

原创 内部类作用

1. 可以将只在一起使用的类从逻辑进行组合。如果一个类仅仅对另外一个类有用,那么就可以将这个类嵌入另外一个类中而使他们组合在一起。通过这种方式,可以使得自己的包更精简。2. 提高封装性。两个top level类A和B(B只需访问A中的私有成员),B放入A中,实现B访问A的私有成员,同时实现B和外界隔离。3. 变相多继承。在内部类定义多个继承其他类的内部类,并在外部类中定义各内部类对象,就变

2015-11-17 22:51:27 581

原创 Executors的工厂方法提供的5种不同的线程池

1、newFixedThreadPool() : 作用:该方法返回一个固定线程数量的线程池,该线程池中的线程数量始终不变,即不会再创建新的线程,也不会销毁已经创建好的线程,自始自终都是那几个固定的线程在工作,所以该线程池可以控制线程的最大并发数。 栗子:假如有一个新任务提交时,线程池中如果有空闲的线程则立即使用空闲线程来处理任务,如果没有,则会把这个新任务存在一个任务队列中,一旦有线程空闲

2015-11-17 18:51:00 3286 2

原创 [Leetcode] Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O

2015-11-11 16:40:19 373

原创 设置Theme为Theme.Dialog形式的Activity的宽和高

mDisplay = getWindowManager().getDefaultDisplay();DisplayMetrics outMetrics = new DisplayMetrics();mDisplay.getMetrics(outMetrics);LayoutParams layoutParams = getWindow().getAttributes();layoutPar

2015-11-10 15:19:49 1441

原创 [Leetcode] Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.方法一:假设链表长度为N,倒数第k处节点,对应正数第N+1

2015-11-03 15:50:14 980

原创 Insertion Sort List

Sort a linked list using insertion sort.分析:插入排序处理链表。借助一个helper 头节点,来避免比较过程中位置在头节点处的情况。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next;

2015-10-26 17:19:18 424

原创 [leetcode] Palindrome Linked List

Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?分析:palindrome:回文字,左后看都是一样。O(1)常数运行空间,说明不能通过建立数组等其他数据结构的方式来处理。从左右看,都是一样,考

2015-10-23 18:12:38 335

原创 [Leetcode] Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2015-10-23 11:56:24 353

原创 [Merge Sort] Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.一、比较排序/** * Definition for singly-linked list. *

2015-10-22 11:04:32 453

原创 [Leetcode] Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?题意:台阶总数为n,每次爬1阶或者2阶层,求爬完台阶

2015-10-21 18:49:10 1008

原创 [Leetcode] Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may a

2015-10-21 17:46:03 420

原创 [Leetcode] Word Search

Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically

2015-10-21 16:11:28 1018

原创 [Leetcode]Word Pattern

Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.

2015-10-19 16:32:26 1143

原创 [Leetcode]Container With Most Water

Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin

2015-10-16 17:33:42 349

原创 [Leetcode]Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5Credits:Special than

2015-10-12 14:46:23 1927

原创 [Leetcode]Move Zeroes

Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling you

2015-10-10 12:51:18 3380

原创 ViewServer源码分析

ViewServer源码分析

2015-10-09 16:31:25 2457 3

原创 apk在launcher配置多个icon启动入口

apk在launcher配置多个icon启动入口

2015-09-18 19:21:51 1025

html5与手机游戏的未来

大致简述html5和手机游戏开发的ppt

2012-04-05

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除