Fork me on GitHub
卖欠账包的王大麻


  • Home

  • About

  • Categories

  • Archives

  • Commonweal 404

  • Search

原型模式与保护性拷贝

Posted on 2018-01-09 | In 设计模式
Words count in article: 720 字 | Reading time ≈ 3 分钟
原型模式可以理解为直接从已存在的对象中拷贝出一个新对象,在重新创建一个对象消耗较大,但又需要用到两个相互不影响的对象的时候才用到,这是它与单例模式的区别所在 原型模式中拷贝的方法有浅拷贝和深拷贝 ...
Read more »

组合模式

Posted on 2018-01-08 | In 设计模式
Words count in article: 500 字 | Reading time ≈ 3 分钟
组合模式也称为部分整体模式,它的作用是将一组相似的对象看作一个对象处理,然后提供同一的方法去访问相应对象,这样可以很容易地得到一个树形结构,操作系统中的文件就可以抽象成一个经典的组合模式,如下: ...
Read more »

单例模式的使用

Posted on 2018-01-06 | In 设计模式
Words count in article: 555 字 | Reading time ≈ 2 分钟
单例模式适用于重新构造消耗大,又时常需要用到的类,一般又懒汉模式、饿汉模式、DCL模式和静态内部类模式这几种 懒汉模式123456789101112public class Example & ...
Read more »

策略模式:再见if-else

Posted on 2018-01-05 | In 设计模式
Words count in article: 1,338 字 | Reading time ≈ 7 分钟
在软件开发中,我们时常用到if-else来对进行条件判断,然后再进行相应的操作,但这样做会使得项目再日后的维护中出现困难,所以,当遇到比较复杂的if-else结构的时候,使用策略模式是很好的选择 ...
Read more »

设计模式中的车轮战-责任链模式

Posted on 2018-01-03 | In 设计模式
Words count in article: 395 字 | Reading time ≈ 2 分钟
责任链模式在Android中的应用莫过于事件分发了,ViewGroup对事件分别给子View,从ViewTree的顶部至上而下地进行处理,直到事件被消化为止,这种方法在Android广播中也能看到 ...
Read more »

OpeningStartAnimation - Android开屏动画view

Posted on 2017-12-26 | In Android
Words count in article: 346 字 | Reading time ≈ 2 分钟
项目地址https://github.com/JoshuaRogue/FancyView 使用后效果如下: 使用方法: 在项目中添加依赖 1compile 'site.gemus:o ...
Read more »

MVP模式中的小技巧:软引用与弱引用

Posted on 2017-11-06 | In 设计模式
Words count in article: 400 字 | Reading time ≈ 2 分钟
在MVP当中,过多的类导致了内存控制十分困难,而强引用又很容易导致OOM(GC时不会回收被强引用持有的对象),在这个时候就轮到其他的两中对象引用的方式:软引用与弱引用登场了(虚引用几乎不会被用到) ...
Read more »

使用委托模式在Activity中操作RecyclerView中的item

Posted on 2017-11-02 | In 设计模式
Words count in article: 379 字 | Reading time ≈ 2 分钟
RecyclerView与ListView不同,无法直接通过setItemClicklistener来获得单个item的点击时间,这个时候,我们可以通过在adapter中定义接口,并在Activi ...
Read more »

Dagger2实现MVP模式

Posted on 2017-10-22 | In 设计模式
Words count in article: 817 字 | Reading time ≈ 3 分钟
MVP模式是为了实现View与Model完全解耦而生的模式,而配上Dagger2就能如虎添翼了 MVP模式的图解如下(网上盗的图) 而我们平常在实现MVP模式的时候,应该让View集成接口实现,这 ...
Read more »

android图片状态栏实现沉浸式状态栏

Posted on 2017-10-18 | In Android
Words count in article: 832 字 | Reading time ≈ 4 分钟
沉浸式状态栏实现起来的文章网上有很多了,不过再MD中有一个图片和toolbar一起使用,还会产生过度效果的沉浸式状态栏,像下面这样标题栏XML代码如下12345678910111213141516 ...
Read more »
1…567
Wong Zhenyu

Wong Zhenyu

科班出身的野生程序猿

61 posts
11 categories
GitHub 微博 E-Mail LinkedIn
© 2017 — 2020 Wong Zhenyu
Powered by Hexo
|
Theme — NexT.Mist v5.1.4