自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 用位运算实现四则运算之加减乘除

原文  用位运算实现四则运算之加减乘除//递归版本 int _add(int num1,int num2){ int sum,carry; if(num2==0) return num1;//没有进位的时候完成运算 sum=num1^num2;//完成第一步没有进位的加法运算 carry=(num1&num2)<<1;//完成第二步进位并且左移运算

2015-08-30 11:06:12 549

原创 嵌套类,内部类,匿名内部类再学习

内部类在一个类内声明的类称为内部类。内部类“隐式”地持有外部类的引用,所以可以访问外部类对象的成员,方法。看下Oracle给的一个例子。public class DataStructure { // Create an array private final static int SIZE = 15; private int[] arrayOfInts =

2015-08-20 18:19:22 515

原创 Java,Android内存泄漏代码片段

public class MemoryLeakDemo extends Activity implements NewworkCallBack{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /**

2015-08-19 18:17:05 597

原创 Android性能优化-内存

内存方面遇到的问题常有OOM,内存泄漏。实际上JVM的GC对性能的影响也很大。GC时正在运行的线程会暂停,如果此时正在执行动画,那就有可能导致跳帧,对用户来说,看到的就是动画卡顿。应该避免使JVM频繁地GC。参考文章  Android性能优化之内存篇 。内存泄漏是指仍然引用不再使用的对象,从而导致GC无法回收,导致可用内存减少,导致频繁GC,导致性能问题。3种内存测量的

2015-08-18 09:08:20 582

原创 Python Web 实战 - 搭建Django环境和初步使用

Django环境搭建

2015-08-16 22:37:57 1115

原创 再次开始学习python-Python Web实战 第一课

之前,至少一年前吧,在微信公众号“Crossin的编程教室”的指引下开始学习python,大概学了4,5课的样子就无疾而终了,后来课程落了好多,就没再捡起来继续学。到现在python还是不会。做程序员也3年了,还是只会Java一门语言,丢人啊。最近关注了公众号“程序员在囧途”,维护这个号的哥们曾经在CSDN上出过一本小说,名字想不起来了,12年我开始学编程那会在紧张的学习之余,那本小说曾带给我

2015-08-16 20:35:33 614

原创 一道有关数据类型的笔试题

题目There are 4 variables:        short v1 = 18;        Long v2 = new Long("18");        Long v3 = new Long(18);        Short v4 = new Short(v1);Which of the following statements are true:

2015-08-14 14:29:52 768

原创 一道String拼接的考题

When doing string concatenation for many times in a loop, which is the fastest way in terms of executing time:A) The concat() method of StringB) The + operator of StringC) The append() method of

2015-08-14 12:09:40 1016

原创 android Service 总结

概述Service是一种没有UI界面,在后台执行长期任务的系统控件。Service可以用于IPC。android:exported  false,Service只供自己应用使用;true 可以被其他应用使用android:process 指定服务所在的进程,默认当前应用所在进程Foreground Service前台Service意味着用户知道Service

2015-08-11 15:53:38 513

原创 android消息处理机制

Android消息处理涉及到的类有Looper,MessageQueue,Handler,Thread。下面看下它们之间的关系。Looper默认Thread是没有message loop的,要创建一个,在Thread的run()中执行Looper.prepare(),使它跑起来处理消息,调用Looper.loop(),直到loop quit。下面是示例代码 class Loope

2015-08-10 17:17:50 415

原创 ThreadLocal源码解析

挖坑

2015-08-10 15:15:39 364

原创 HandlerThread源码解析

HandlerThread是带Looper的Thread,looper可用于创建Handler,这样就拥有一个在后台long-running的worker-thread,通过Handler给其发送消息,worker-thread收到消息后再回调Handler的handleMessage(),开启HandlerThread,仍需要start(),除非调用HandlerThread的quit(),或者

2015-08-10 11:36:33 404

原创 IntentServie源码解析

IntentService是Service的子类,默认Service运行在应用所在进程的主线程中,如果要在后台执行耗时任务,需要创建子线程,IntentService即可以满足这样的需求,它封装了一个work-thread,处理接收到的Intent,它可以处理多个请求,但一次只能处理一个。下面看下它的源码。 /** * Creates an IntentServic

2015-08-10 11:10:49 533

原创 Android动画总结

最近一周系统看了Android动画方面的知识点,总结成一篇文章,供网友参考,也供日后自己复习使用。Android系统提供了两类动画,View动画和Property动画。View动画从API level 1就有,Property动画从API level 11引入的。理解View动画Tween 动画View动画包括Tween 动画和 Frame动画。Tween 动画是指

2015-08-01 10:01:20 417

原创 Property Animation 源码学习

ValueAnimator.java /** * This method is called with the elapsed fraction of the animation during every * animation frame. This function turns the elapsed fraction into an interpolated f

2015-07-29 15:14:34 400

转载 java注解再学习

http://www.trinea.cn/android/java-annotation-android-open-source-analysis/不少开源库都用到了注解的方式来简化代码提高开发效率本文简单介绍下 Annotation 示例、概念及作用、分类、自定义、解析,并对几个 Android 开源库 Annotation 原理进行简析。一、Annotation 示例

2015-07-22 18:11:56 474

原创 Executor

public interface Executor { /** * Executes the given command at some time in the future. The command * may execute in a new thread, in a pooled thread, or in the calling * thread,

2015-07-16 17:22:59 374

原创 AsyncTask源码分析

AsyncTasks should ideally be used for short operations (a few seconds at the most.) If you need to keep threads running for long periods of time, it is highly recommended you use the various APIs pr

2015-07-16 16:08:25 473

原创 快速查找长度未知的单链表的中间结点

在小甲鱼的《数据结构与算法》上,看到的一道企鹅的面试题。我想到的方法比普通的方法要快,但不是最快的。普通方法:先遍历单链表,获取长度后,再找到中间结点。假设长度是L,则所需时间为O(L)+O(L/2) = O(3/2L)我想到的方法:因为想到要获取中间结点,那必须知道长度啊,因此遍历单链表是必需的,在遍历时,将每个结点的值放在数组中,遍历结束知道长度后,从数组中取中间长

2015-07-12 20:31:39 688

转载 java并发1

Java Synchronized Blocks同一对象上的synchronized代码块,同一时刻只允许一个线程进入,其他想进入的线程只能等待,直到之前的线程退出代码块。有4中synchronized代码块Instance methodsStatic methodsCode blocks inside instance methodsCode blocks inside

2015-07-06 18:07:29 527

转载 Java 并发0

http://tutorials.jenkov.com/java-concurrency/concurrency-models.html单核-单任务-多任务“并发”并不仅仅指多线程,还可以是多任务,分布式系统。多线程的好处:更好的系统资源利用;相近的设计;更好地响应速度。多线程的代价:复杂的设计;上下文切换开销;线程自身的资源消费。并

2015-07-03 18:49:24 323

转载 为PopupWindow设置动画效果

原文: http://blog.csdn.net/starrexstar/article/details/7896835首先定义显示效果的动画文件:[html] view plaincopyxml version="1.0" encoding="utf-8"?>  set xmlns:android="http://schemas

2015-07-02 10:57:41 441

原创 AtomicInteger 使用

使用Android Relativelayout动态添加child view时,设置id时,sdk 17提供了一个生成id的方法 private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1); /** * Generate a value suitable for use in {@

2015-06-30 11:03:27 486

转载 Android中Activity四种启动模式和taskAffinity属性详解

原文: http://www.xuebuyuan.com/1624447.html#title-5在android应用开发中,打造良好的用户体验是非常重要的。而在用户体验中,界面的引导和跳转是值得深入研究的重要内容。在开发中,与界面跳转联系比较紧密的概念是Task(任务)和Back Stack(回退栈)。activity的启动模式会影响Task和Back Stack的状态,进而

2015-06-22 22:10:47 1130

转载 android listview 异步加载图片并防止错位

网上看到的一个例子,使用LruCache,DiskLruCache进行内存,文件二级缓存图片,使用Tag防止ListView图片错位。我之前在pad项目上也使用过使用Lru进行两级缓存,我把getBitmapFromDisk部分的逻辑写在了AysncTask的doInBackground里,因为读取文件也是耗时操作,为防止ANR,故为之。原文:http://www.cnblogs.

2015-06-17 14:50:01 558

转载 Android中传递对象的三种方法

转自: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0104/2256.htmlAndroid中,Activity和Fragment之间传递对象,可以通过将对象序列化并存入Bundle或者Intent中进行传递,也可以将对象转化为JSON字符串,进行传递。序列化对象可以使用Java的Serializabl

2015-06-17 11:30:44 665

原创 @Override与方法的重写

@Override注解可以帮助检查父类中是否有该方法,但不加@Override,子类也可以复写父类的方法,且可以使用父类的引用调用该方法。class A { public void sayInA(int p ){ System.out.println("In A:"+p); } public void sayInAA(int p ){

2015-06-15 10:34:38 595

转载 Matrix0

原文  http://chroya.iteye.com/blog/712078Matrix ,中文里叫矩阵,高等数学里有介绍,在图像处理方面,主要是用于平面的缩放、平移、旋转等操作。        首先介绍一下矩阵运算。加法和减法就不用说了,太简单了,对应位相加就好。图像处理,主要用到的是乘法 。下面是一个乘法的公式:        在 Android 

2015-06-01 18:38:49 374

转载 Generic 泛型

参考 http://tutorials.jenkov.com/java-generics/methods.html定义使用泛型的类public class GenericFactory { Class theClass = null; public GenericFactory(Class aClass){ this.theClass = aCla

2015-06-01 15:12:08 380

转载 Java Reflection - Dynamic Class Loading and Reloading

http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.htmlIt is possible to load and reload classes at runtime in Java, though it is not as straightforward as one might

2015-05-31 11:55:46 741

转载 Java Reflection - Arrays

http://tutorials.jenkov.com/java-reflection/arrays.htmlWorking with arrays in Java Reflection can be a bit tricky at times. Especially if you need to obtain the Class object for a certain ty

2015-05-31 11:55:43 315

转载 Java Reflection - Generics

http://tutorials.jenkov.com/java-reflection/generics.htmlI have often read in articles and forums that all Java Generics information is erased at compile time so that you cannot access any o

2015-05-31 11:55:11 383

转载 Java Reflection - Dynamic Proxies

http://tutorials.jenkov.com/java-reflection/dynamic-proxies.htmlUsing Java Reflection you create dynamic implementations of interfaces at runtime. You do so using the classjava.lang.reflect.

2015-05-31 11:54:55 424

转载 Java Reflection - Annotations

http://tutorials.jenkov.com/java-reflection/annotations.htmlUsing Java Reflection you can access the annotations attached to Java classes at runtime.What are Java Annotations?Annotatio

2015-05-31 11:54:33 406

转载 Java Reflection - Getters and Setters

http://tutorials.jenkov.com/java-reflection/getters-setters.htmlUsing Java Reflection you can inspect the methods of classes and invoke them at runtime. This can be used to detect what gette

2015-05-31 11:52:53 436

转载 Java Reflection - Private Fields and Methods

http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.htmlDespite the common belief it is actually possible to access private fields and methods of other classes via Java Re

2015-05-31 11:51:58 396

转载 Java Reflection - Fields

http://tutorials.jenkov.com/java-reflection/fields.htmlUsing Java Reflection you can inspect the fields (member variables) of classes and get / set them at runtime. This is done via the Java

2015-05-31 11:51:29 330

转载 Java Reflection - Methods

http://tutorials.jenkov.com/java-reflection/methods.htmlUsing Java Reflection you can inspect the methods of classes and invoke them at runtime. This is done via the Java class java.lang.ref

2015-05-31 11:50:53 671

转载 Java Reflection - Classes

http://tutorials.jenkov.com/java-reflection/classes.htmlThe Class ObjectClass NameModifiersPackage InfoSuperclassImplemented InterfacesConstructorsMethodsFieldsAnnotationsUsi

2015-05-31 11:49:16 346

转载 Java Reflection - Constructors

http://tutorials.jenkov.com/java-reflection/constructors.htmlUsing Java Reflection you can inspect the constructors of classes and instantiate objects at runtime. This is done via the Java c

2015-05-31 11:48:50 459

PopupWindow 使用实例

PopupWindow 使用实例

2014-03-28

空空如也

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

TA关注的人

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