Example usage for android.widget FrameLayout getContext

List of usage examples for android.widget FrameLayout getContext

Introduction

In this page you can find the example usage for android.widget FrameLayout 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.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Create a color change animation over a foreground property of a {@link FrameLayout}.
 *
 * @param target The target view.//  www.j  a  v  a  2 s  .co m
 * @param startColorRes The color to start from.
 * @param targetColorRes The color this animation will end with.
 * @param interpolator The interpolator to use.
 * @return The color change animation.
 */
@NonNull
public static ObjectAnimator createColorChange(@NonNull FrameLayout target, @ColorRes int startColorRes,
        @ColorRes int targetColorRes, @NonNull Interpolator interpolator) {
    Context context = target.getContext();
    final int startColor = ContextCompat.getColor(context, startColorRes);
    final int targetColor = ContextCompat.getColor(context, targetColorRes);
    ObjectAnimator colorChange = ObjectAnimator.ofInt(target, ViewUtils.FOREGROUND_COLOR, startColor,
            targetColor);
    colorChange.setEvaluator(new ArgbEvaluator());
    colorChange.setInterpolator(interpolator);
    colorChange.setDuration(context.getResources().getInteger(android.R.integer.config_longAnimTime));
    return colorChange;
}

From source file:org.zywx.wbpalmstar.engine.EBrowserWidgetPool.java

public EBrowserWidgetPool(EBrowser inBrw, FrameLayout window, EBrowserAround inShelter) {
    mBrw = inBrw;// ww w . j  av  a 2s .com
    mNativeWindow = window;
    mBrowserAround = inShelter;
    mSpaceWidgetResu = new EWgtResultInfo(null, null);
    mWgtStack = new EWidgetStack();
    mContext = (EBrowserActivity) window.getContext();
    mWidPoolLoop = new PoolHandler(Looper.getMainLooper());
}

From source file:com.h6ah4i.android.example.advrecyclerview.demo_eds_vp_sec_long.MyExpandableDraggableSwipeableSectionAdapter.java

private void onBindItemGroupViewHolder(MyGroupViewHolder holder, int groupPosition) {
    // group item
    final AbstractExpandableDataProvider.GroupData item = mProvider.getGroupItem(groupPosition);

    // set listeners
    holder.itemView.setOnClickListener(mItemViewOnClickListener);

    // set text//  w  ww  . jav a  2  s  . c om
    holder.mTextView.setText(item.getText());

    // set background resource (target view ID: container)
    final int dragState = holder.getDragStateFlags();
    final int expandState = holder.getExpandStateFlags();
    final int swipeState = holder.getSwipeStateFlags();

    if (((dragState & Draggable.STATE_FLAG_IS_UPDATED) != 0)
            || ((expandState & Expandable.STATE_FLAG_IS_UPDATED) != 0)
            || ((swipeState & Swipeable.STATE_FLAG_IS_UPDATED) != 0)) {
        int bgResId;
        boolean isExpanded;
        boolean animateIndicator = ((expandState & Expandable.STATE_FLAG_HAS_EXPANDED_STATE_CHANGED) != 0);

        if ((dragState & Draggable.STATE_FLAG_IS_ACTIVE) != 0) {
            bgResId = R.drawable.bg_group_item_dragging_active_state;

            // need to clear drawable state here to get correct appearance of the dragging item.
            DrawableUtils.clearState(holder.mContainer.getForeground());
        } else if ((dragState & Draggable.STATE_FLAG_DRAGGING) != 0) {
            bgResId = R.drawable.bg_group_item_dragging_state;
        } else if ((swipeState & Swipeable.STATE_FLAG_IS_ACTIVE) != 0) { //The One being swipe
            bgResId = R.drawable.bg_group_item_swiping_active_state;
        } else if ((swipeState & Swipeable.STATE_FLAG_SWIPING) != 0) { //The others...
            bgResId = R.drawable.bg_group_item_swiping_state;
        } else if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
            bgResId = R.drawable.bg_group_item_expanded_state;
        } else {
            bgResId = R.drawable.bg_group_item_normal_state;
        }

        if ((expandState & Expandable.STATE_FLAG_IS_EXPANDED) != 0) {
            isExpanded = true;
        } else {
            isExpanded = false;
        }

        holder.mContainer.setBackgroundResource(bgResId);

        /* Testing Layout change while expanding */
        FrameLayout parent = ((FrameLayout) holder.mContainer.getParent());
        ViewGroup.LayoutParams lp = parent.getLayoutParams();
        lp.height = parent.getContext().getResources().getDimensionPixelSize(R.dimen.list_group_item_height);
        if (isExpanded)
            lp.height += 20;
        parent.setLayoutParams(lp);

        holder.mIndicator.setExpandedState(isExpanded, animateIndicator);
    }

    // set swiping properties
    holder.setSwipeItemHorizontalSlideAmount(item.isPinned() ? Swipeable.OUTSIDE_OF_THE_WINDOW_LEFT : 0);
}

From source file:com.ndn.menurandom.ImageDownloader.java

private void makeFrameLayout(ImageView imageView) {
    boolean isExist = false;
    ViewGroup vg = (ViewGroup) imageView.getParent();
    if (vg instanceof FrameLayout) {
        FrameLayout frameLayout = (FrameLayout) vg;
        String tag = (String) frameLayout.getTag();
        if (tag != null && tag.equals("fl_imagedownloader")) {
            isExist = true;//from w w  w  .j a v  a  2  s.  c om
        }
    }

    if (!isExist) {
        int childCount = vg.getChildCount();
        int index = 0;
        while (index < childCount) {
            if (imageView == vg.getChildAt(index)) {
                break;
            }
            index++;
        }
        vg.removeViewAt(index);

        FrameLayout frameLayout = new FrameLayout(vg.getContext().getApplicationContext());
        frameLayout.setTag("fl_imagedownloader");
        ViewGroup.LayoutParams lpImageView = (ViewGroup.LayoutParams) imageView.getLayoutParams();
        frameLayout.setLayoutParams(lpImageView);
        imageView.setLayoutParams(new LayoutParams(lpImageView.width, lpImageView.height));
        frameLayout.setPadding(imageView.getPaddingLeft(), imageView.getPaddingTop(),
                imageView.getPaddingRight(), imageView.getPaddingBottom());
        imageView.setPadding(0, 0, 0, 0);
        frameLayout.addView(imageView);
        vg.addView(frameLayout, index);

        ProgressBar progressBar = new ProgressBar(frameLayout.getContext());
        progressBar.setTag("pb_imagedownloader");
        int leftRightPadding = (imageView.getLayoutParams().width - 50) / 2;
        int topBottomPadding = (imageView.getLayoutParams().height - 50) / 2;
        progressBar.setPadding(leftRightPadding, topBottomPadding, leftRightPadding, topBottomPadding);
        frameLayout.addView(progressBar);

    }
}