JAVA design patterns: Agent Model - static agent

Proxy mode: for other objects provide a proxy to control access to this object. In some cases, an object is not suitable or can not directly refer to another object, and the proxy object can play an intermediary role between the client and the target object. Of static agent agents and proxied object before the agent is determined, achieve the same interface or objects of the same inheritance. Proxy mode generally involves three kinds of roles: abstract object role, agent role and real role. Agent role played an intermediary role. Abstract: through the role / interface or abstract class is really sound...
read(164) comment(0)

Android study notes: Custom HorizontalScrollView sliding menu

Recent projects is busy, don't have much time to watch video learning, yesterday night pumping time watching the video, learning the how to customize the realization of imitation QQ sideslip menu effects. On the Internet literally cut two pictures, the study of things to make a note. Custom HorizontalScrollView: Class SideSlipMenu extends HorizontalScrollView public { In the outer layer of LinearLayout / / SideSlipMenu Private...
read(151) comment(0)

Android study notes: custom implementation flow layout

A few days ago in project development, there is a demand is displaying the history of the search for enlightenment, style show is (number of each row show the control according to the contents of the control different and not the same, when displayed full wrap display) did in like a waterfall flow. Is the beginning of a custom LinearLayout, by judging the location and size of the view to wrap. Effect is achieved, but in the use of the time to meet bug. The day before yesterday to learn the time, just to see the teacher talk about the custom ViewGroup to achieve the flow layout style, so I determined to learn. Write a note to facilitate the next use, thank you...
read(180) comment(0)

JAVA design patterns: the chain of responsibility model

Chain of responsibility pattern: multiple objects by the object corresponding to the homes of references are connected into a chain, the request on the chain transfer, chain until a receiving object to process this request. Because the client's request did not know chain eventually is who to handle the request, allows the system to be in do not affect the client dynamically re organization and allocation of responsibilities, thus avoiding the coupling between the request sender and requests are processed. Involves three kinds of roles in the chain of responsibility: 1 Abstract role 2 specific roles 3, request the sender Small example: suppose to buy...
read(199) comment(0)

Load page error handling in WebView

In the Android project, we usually use WebView to load the web page. Use, the display effect is good, and can be updated dynamically, using WebView to load web content of course, we develop the APP home page. However, there is also a time when people are a bit embarrassed. When we do not have a mobile phone network, or when the server is not careful paralysis, WebView show the effect of a little inhuman oh. As graph: This picture is still quite good, this is the case I have no network in the mobile browser to open the way Baidu. If it is our application on the load page...
read(130) comment(0)

Android study notes: WebView common skills

WebView is a control that we often use in the development of. Mainly used to load the web page or Html format content. In fact, in our Android system Web browser. In our Android program, using the WebView what advantage? In addition to the convenience of the web site after loading, there are mainly the following two aspects of the benefits oh. Before use, remember to add network permissions 1 update: app has a lot of H5 pages are used as part of the application, use WebView to load the H5 page...
read(54) comment(0)

Two ways to download the file using WebView

In applications, usually used to download the file function, generally we are writing a download tool class, in the asynchronous task to perform the download function. Today we look at how to use the WebView file download function! Method 1, custom download operation One First to layout" Http:// "xmlns:tools=" Xmlns:l...
read(142) comment(0)

JAVA design model: factory model (under) - abstract factory pattern

Abstract factory pattern is one of the most abstract and most common forms of factory pattern of all forms. Abstract factory pattern is a factory model used when there are many abstract roles. The abstract factory pattern can provide an interface to the client, so that the client can create a product object in a number of product families without having to specify a specific product. According to the principle of measuring the magnitude of the scale, any acceptance of the type of the parent, should be able to accept the sub type. So, in fact, what the system needs is just some examples of the same type of abstract product roles, rather than an instance of the abstract product. In other words, that's all...
read(130) comment(0)

JAVA design pattern: factory mode (on) - factory method model

Factory mode is our most commonly used to model the object is to use the factory method instead of new operation of a model. There are two types of factory models: - list content - factory method model - and the abstract factory model (an extension of the factory method model) Usually in what circumstances the use of the factory method model? - 1, there are multiple similar (functional similarity) object instances that need to be created (New). - 2, in the process of writing code can not be known in advance to create what type, how many instances of the number of instances. - 3...
read(127) comment(0)

Simple access to Android mobile phone pictures

Class MainActivity extends Activity public { @Override Void onCreate protected (savedInstanceState Bundle) { Super.onCreate (savedInstanceState); SetContentView (R.layout.activity_main); GetPicsFr...
read(32) comment(0)

JAVA design patterns: Strategic Model

Strategic mode refers to the method of separating the variable part of the program into a series of algorithms, and each algorithm is encapsulated, and so that they can be replaced by each other. The policy model allows the algorithm to vary independently from its customers. The strategy mode is generally composed of three parts: 1 Abstract policy role: a policy class, usually implemented by an interface or an abstract class. 2 specific strategic roles: packaging related algorithms and behaviors. 3 environmental roles: holding a reference to a policy class, client call. Strategy pattern design principle:...
read(137) comment(0)

JAVA design patterns: adapter mode

Adapter model is a class of interface adapter into the user's expectations, so that the original interface is not compatible with some of the classes can not work together to work together to achieve the desired functionality of the user. Adapter mode advantage: through the adapter, the client can call a unified interface, easy to operate, and the code logic is compact, easy to use. Code reuse, the adapter pattern is solved because the environment requirements are not the same, by adapting to achieve code reuse. Decoupling the target class and the adapter class, by creating an adapter class to reuse the current class, without repeating the original code,...
read(182) comment(0)

JAVA design pattern: Template Method Pattern

We are in life, a lot of things that are specific to some of the steps. As to the bank, usually step order is: take a number - > > fill - > - wait for the call for business. Some of these steps, some of the same, such as taking the number, each person has to take, but some are going to change, for example, fill in a single, but according to different business, fill in the different documents. Also, for example, we go out to dinner, the general steps are: ordering - > > wait - > to eat - > pay, but also to find the same law. Such a thing beyond count. Project development, it is also possible to encounter such a situation, more...
read(192) comment(0)

JAVA design patterns: one case model

In our project, some objects we have and only need one can be, such as the project configuration file, the operation of the database, operating documents, such as tools, thread pool, cache file operations, etc.. At this point, we can apply the singleton pattern to achieve these requirements. The singleton pattern is divided into two kinds, one is known as a hungry man, is we called lazy mode. First we look at implementation of lazy mode: / * * The idle mode * single mode: * @description: * / Class LazierPa public...
read(193) comment(0)

Android lottery scratch card (on)

Custom View scratch card interface: Android.annotation.SuppressLint import; Android.content.Context import; import; import; import; Impo...
read(96) comment(0)
21 data a total of 2 pagesOne Two Next page Shadowe
    personal data
    • visit51372 times
    • Integral:Two thousand three hundred and twenty-six
    • Grade
    • Rank:9595th name
    • original187
    • Reproduced:37
    • Translation:1
    • Comments:13
    Classification of articles
    Latest comments