"Android Source design mode"--strategy mode

Source: Internet
Author: User

NO1:

definition : The policy pattern defines a series of algorithms, encapsulates each algorithm, and allows them to be replaced with each other. The policy pattern makes the algorithm independent of the customers who use it.

No2:

Usage Scenarios :

1) Multiple treatments for the same type of problem, only when the specific behavior is different

2) requires safe encapsulation of multiple operations of the same type

3) If you have multiple subclasses of the same abstract class and need to use If-else or switch-case to select a specific subclass

No3:

The function of the timeinterpolator time Interpolator is to calculate the percentage of the current attribute value change based on the percentage of time elapsed, and the system preset

1) Linear interpolator (Linearinterpolator): For constant speed animation

2) Accelerated deceleration interpolator (acceleratedecelerateinterpolator) for animation acceleration at start-up with animation deceleration at the end

3) deceleration interpolator (decelerateinterpolator): Used to animate more and more slowly over time, i.e. deceleration animation

No4:

Typeevaluator Type Estimator

The time Interpolator calculates the percentage of time elapsed at the current point in time, Typeevaluator calculates the value of the property at the current moment based on the percentage, the starting value of the attribute, and the target value, and the last value is set to view, and the process is repeated to form an animation.

System presets with shaping properties (intevaluator), floating-point properties (floatevaluator), and Color properties (argbevaluator)

NO5:

Valueanimator flowchart

NO6:

Objectanimator flowchart

No7:

cons : As the strategy grows, subclasses become more diverse

"Android Source design mode"--strategy mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.