@@ -35,19 +35,21 @@ Usage
3535
3636``` java
3737public class MainActivity extends Activity {
38- private final static int DEFAULT_DISPLAY_HEIGHT = 1280 ;
39- private final static int DEFAULT_DISPLAY_WIDTH = 768 ;
40- private final static float DEFAULT_SCALED_DENSITY = 3.0f ;
41- private final static float DEFAULT_DENSITY = 3.0f ;
38+ private final static int TESTED_DEVICE_DISPLAY_HEIGHT = 1280 ;
39+ private final static int TESTED_DEVICET_DISPLAY_WIDTH = 768 ;
40+
41+ private final static float TESTED_DEVICET_SCALED_DENSITY = 3.0f ;
42+ private final static float TESTED_DEVICET_DENSITY = 3.0f ;
4243
4344 @Override
4445 protected void onCreate (@Nullable Bundle savedInstanceState ) {
4546 super . onCreate(savedInstanceState);
4647 setContentView(getProperContentView());
4748
4849 // How to get density & scaledDensity for tested device
49- float density = getResources(). getDisplayMetrics(). density; // DEFAULT_DENSITY
50- float scaledDensity = getResources(). getDisplayMetrics(). scaledDensity; // DEFAULT_SCALED_DENSITY
50+ DisplayMetrics metrics = getResources(). getDisplayMetrics();
51+ float density = metrics. density; // DEFAULT_DENSITY
52+ float scaledDensity = metrics. scaledDensity; // DEFAULT_SCALED_DENSITY
5153 ...
5254 }
5355
@@ -56,22 +58,22 @@ public class MainActivity extends Activity {
5658 .layout(R . layout. activity_main)
5759 .excludeIds(R . id. divider, R . id. login_button) // Disable optimization for specific ids.
5860 .deviceType(ZOptimization . DeviceType . TABLET ) // Optimized for tablets only.
59- .defaultDisplaySize( DEFAULT_DISPLAY_WIDTH , DEFAULT_DISPLAY_HEIGHT ) // Tested device display width & height
60- .measureConfiguration( TypedValue . COMPLEX_UNIT_DIP , DEFAULT_DENSITY ) // Setup dp optimization.
61- .textConfiguration( TypedValue . COMPLEX_UNIT_SP , DEFAULT_SCALED_DENSITY ) // Setup sp optimization.
62- .determinateDisplaySize( )
61+ .testedDeviceDisplaySize( TESTED_DEVICE_DISPLAY_WIDTH , TESTED_DEVICE_DISPLAY_HEIGHT )
62+ .config( new ConfigBuilder ()
63+ .applyDp( TESTED_DEVICE_DENSITY )
64+ .applySp( TESTED_DEVICE_SCALED_DENSITY ) )
6365 .makeOptimization();
6466 }
6567}
6668```
67- #### Note: measureConfiguration and textConfiguration by default = TypedValue. COMPLEX_UNIT_PX.
69+ #### Note: If the config is not specified, then COMPLEX_UNIT_PX will be used by default
6870
6971Download
7072--------
7173
7274``` groovy
7375dependencies {
74- compile 'com.github.z-four:zoptimization:1.0.2 '
76+ compile 'com.github.z-four:zoptimization:1.0.3 '
7577}
7678```
7779
@@ -94,12 +96,10 @@ Methods
9496| layout(int)| Set layout id which need to optimize|
9597| layout(ViewGroup)| Set ViewGroup which need to optimize|
9698| deviceType(short)| Set device type (default: ALL_DEVICES)|
97- | defaultDisplaySize (int, int)| Set default display size (width, height)|
99+ | testedDeviceDisplaySize (int, int)| Set default display size (width, height)|
98100| currentDisplaySize(int, int)| Set current display size (width, height)|
99- | determinateDisplaySize()| Auto-determine current display size|
100101| excludeIds(int[ ] )| Disable optimization for specific ids|
101- | measureConfiguration(short, int[ ] )| Setup complexUnit & tested device density|
102- | textConfiguration(short, int[ ] )| Setup complexUnit & tested device scaledDensity|
102+ | config(ConfigBuilder)| Setup tested device density & scaledDensity|
103103| disableOptimization(short, int[ ] )| Setup optimization type (ZOptimization.Type) & specific ids for disable|
104104| marginEnable(boolean)| Enable or disable margin optimization (default: true)|
105105| paddingEnable(boolean)| Enable or disable padding optimization (default: true)|
@@ -109,7 +109,7 @@ Methods
109109License
110110-------
111111
112- Copyright 2013 Dmitriy Zhyzhko
112+ Copyright 2017 Dmitriy Zhyzhko
113113
114114 Licensed under the Apache License, Version 2.0 (the "License");
115115 you may not use this file except in compliance with the License.
0 commit comments