Example usage for android.view View getContext

List of usage examples for android.view View getContext

Introduction

In this page you can find the example usage for android.view View getContext.

Prototype

@ViewDebug.CapturedViewProperty
public final Context getContext() 

Source Link

Document

Returns the context the view is running in, through which it can access the current theme, resources, etc.

Usage

From source file:com.bangqu.eshow.util.ESDialogUtil.java

/**
 * /*from   w  ww .  j  av  a 2s.  c  o  m*/
 * ???.
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param gravity ?
 * @return
 */
public static ESSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int gravity, int style) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    // Create and show the dialog.
    ESSampleDialogFragment newFragment = ESSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE,
            style, gravity);
    newFragment.setContentView(view);
    //
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    ft.setCustomAnimations(animEnter, animExit, animPopEnter, animPopExit);
    newFragment.show(ft, dialogTag);
    return newFragment;
}

From source file:Main.java

public static void animExpand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;/*w w w  . j av a 2  s  .  c o m*/
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:com.ab.util.AbDialogUtil.java

/**
 * /*from   w ww .j  a  v  a  2  s . c  o  m*/
 * ???().
 * @param view
 * @param gravity ?
 * @param onCancelListener?
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int gravity,
        DialogInterface.OnCancelListener onCancelListener) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    // Create and show the dialog.
    AbSampleDialogFragment newFragment = AbSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE,
            android.R.style.Theme_Holo_Light_Dialog, gravity);
    newFragment.setContentView(view);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    //   
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.setOnCancelListener(onCancelListener);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}

From source file:com.ab.util.AbDialogUtil.java

/**
 * ?()/*from www  . j  a  v  a 2s  .c o m*/
 * @param view
 * @param onCancelListener
 * @return
 */
public static AbSampleDialogFragment showPanel(View view, int gravity,
        DialogInterface.OnCancelListener onCancelListener) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    // Create and show the dialog.
    AbSampleDialogFragment newFragment = AbSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE,
            android.R.style.Theme_Light_Panel, gravity);
    newFragment.setContentView(view);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    //    
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    newFragment.setOnCancelListener(onCancelListener);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}

From source file:Main.java

public static void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;//w  ww. ja v a  2  s. c o m
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? LayoutParams.WRAP_CONTENT
                    : (int) (targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targtetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:com.ab.util.AbDialogUtil.java

/**
 * /* w  ww .ja va2s .com*/
 * ???().
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param gravity ?
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int gravity) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    // Create and show the dialog.
    AbSampleDialogFragment newFragment = AbSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE,
            android.R.style.Theme_Holo_Light_Dialog, gravity);
    newFragment.setContentView(view);
    //
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    ft.setCustomAnimations(animEnter, animExit, animPopEnter, animPopExit);
    newFragment.show(ft, mDialogTag);
    return newFragment;
}

From source file:Main.java

public static void expand(final View v) {
    v.measure(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;//from   w w w  .ja  v  a  2s  .  co  m
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? ViewGroup.LayoutParams.WRAP_CONTENT
                    : (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}

From source file:cn.org.eshow.framwork.util.AbDialogUtil.java

/**
 * //from  ww w  .  java2 s. c om
 * ???.
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param gravity
 * @param onCancelListener
 * @return
 */
public static AbSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int gravity, int style, DialogInterface.OnCancelListener onCancelListener) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    // Create and show the dialog.
    AbSampleDialogFragment newFragment = AbSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE,
            style, gravity);
    newFragment.setContentView(view);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    ft.setCustomAnimations(animEnter, animExit, animPopEnter, animPopExit);
    newFragment.setOnCancelListener(onCancelListener);
    newFragment.show(ft, dialogTag);
    return newFragment;
}

From source file:com.bangqu.eshow.util.ESDialogUtil.java

/**
 * //from w  ww.j av a 2  s .  com
 * ???.
 * @param view
 * @param animEnter
 * @param animExit
 * @param animPopEnter
 * @param animPopExit
 * @param gravity
 * @param onCancelListener
 * @return
 */
public static ESSampleDialogFragment showDialog(View view, int animEnter, int animExit, int animPopEnter,
        int animPopExit, int gravity, int style, DialogInterface.OnCancelListener onCancelListener) {
    FragmentActivity activity = (FragmentActivity) view.getContext();
    // Create and show the dialog.
    ESSampleDialogFragment newFragment = ESSampleDialogFragment.newInstance(DialogFragment.STYLE_NO_TITLE,
            style, gravity);
    newFragment.setContentView(view);
    FragmentTransaction ft = activity.getFragmentManager().beginTransaction();
    ft.setCustomAnimations(animEnter, animExit, animPopEnter, animPopExit);
    newFragment.setOnCancelListener(onCancelListener);
    newFragment.show(ft, dialogTag);
    return newFragment;
}

From source file:Main.java

public static void expandViews(final View v) {
    v.measure(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    final int targtetHeight = v.getMeasuredHeight();

    v.getLayoutParams().height = 0;//from  w ww.  j  a  va2s.c o m
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ? RelativeLayout.LayoutParams.WRAP_CONTENT
                    : (int) (targtetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targtetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}