Android Open Source - Kite Param Map






From Project

Back to project page Kite.

License

The source code is released under:

Apache License

If you think the Android project Kite listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * /*w ww . ja v  a  2s  . c  om*/
 */
package com.efurture.kite.param;

import java.util.HashMap;
import java.util.Map;

import android.util.DisplayMetrics;
import android.view.View;

/**
 * @author gubaojian   email: gubaojian@163.com
 *  */
public class ParamMap {
  
  

  /**
   * parameters  for eval layout expression
   * */
  public static Map<String, Object>  from(View v){
    if (commonParamsMap == null) {
      commonParamsMap = new HashMap<String, Object>();
      DisplayMetrics  metrics = v.getContext().getResources().getDisplayMetrics();
      commonParamsMap.put(Params.DENSITY, metrics.density);
      commonParamsMap.put(Params.SCREEN_WIDTH, metrics.widthPixels);
      commonParamsMap.put(Params.SCREEN_HEIGHT, metrics.heightPixels);
    }
    Map<String, Object> paramsMap = new HashMap<String, Object>();
    paramsMap.putAll(commonParamsMap);
    paramsMap.put(Params.HEIGHT,  v.getHeight());
      paramsMap.put(Params.WIDTH,   v.getWidth());
      if (v.getParent() instanceof View) {
       View parent = (View) v.getParent();
       paramsMap.put(Params.PARENT_HEIGHT,  parent.getHeight());
       paramsMap.put(Params.PARENT_WIDTH,   parent.getWidth());
    }
    return paramsMap;
  }
  
  //???????
  private static  Map<String, Object> commonParamsMap;
}




Java Source Code List

com.efurture.kite.Kite.java
com.efurture.kite.OnFinishLayoutListener.java
com.efurture.kite.example.KiteItemActivity.java
com.efurture.kite.example.MainActivity.java
com.efurture.kite.expression.EvaluatorException.java
com.efurture.kite.expression.EvaluatorManager.java
com.efurture.kite.expression.Evaluator.java
com.efurture.kite.expression.Exp4jEvaluator.java
com.efurture.kite.expression.MVEL2Evaluator.java
com.efurture.kite.layout.LayoutExtension.java
com.efurture.kite.param.ParamMap.java
com.efurture.kite.param.Params.java