List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.liyu.huahui.ui.widgets.MorphDialogToFab.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) @Override/*from w w w . j av a 2 s. c om*/ public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setInterpolator( AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); transition.setDuration(300); return transition; }
From source file:com.wolski_msk.collector.sample.transition.MorphDialogToFab.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/*from w ww. j a v a2 s . c om*/ public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setInterpolator( AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); transition.setDuration(300); return transition; }
From source file:com.sakisds.icymonitor.fragments.disk.DiskFSFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); ViewGroup viewGroup = (ViewGroup) view; mEmptyView = view.findViewById(R.id.emptyhidden); mEmptyView.setOnClickListener(this); mProgressBar = view.findViewById(R.id.progressBar_list); mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext()); ActionBarPullToRefresh.from(getActivity()).insertLayoutInto(viewGroup) .theseChildrenArePullable(android.R.id.list, android.R.id.empty).listener(this) .setup(mPullToRefreshLayout); // Refresh fragment data refreshData();/*from ww w . j av a 2 s . c om*/ }
From source file:com.lloydtorres.stately.region.MessageBoardRecyclerAdapter.java
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); View postCard = inflater.inflate(R.layout.card_post, parent, false); RecyclerView.ViewHolder viewHolder = new PostCard(context, postCard); return viewHolder; }
From source file:com.layer.atlas.cells.GeoCell.java
@Override public View onBind(final ViewGroup cellContainer) { ViewGroup cellRoot = (ViewGroup) Tools.findChildById(cellContainer, R.id.atlas_view_messages_cell_geo); if (cellRoot == null) { cellRoot = (ViewGroup) LayoutInflater.from(cellContainer.getContext()) .inflate(R.layout.atlas_view_messages_cell_geo, cellContainer, false); if (debug) Log.w(TAG, "geo.onBind() inflated geo cell"); }//from ww w .j a va 2 s. c o m ImageView geoImageMy = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_my); ImageView geoImageTheir = (ImageView) cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_image_their); View containerMy = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_my); View containerTheir = cellRoot.findViewById(R.id.atlas_view_messages_cell_geo_container_their); boolean myMessage = messagesList.getLayerClient().getAuthenticatedUserId() .equals(messagePart.getMessage().getSender().getUserId()); if (myMessage) { containerMy.setVisibility(View.VISIBLE); containerTheir.setVisibility(View.GONE); } else { containerMy.setVisibility(View.GONE); containerTheir.setVisibility(View.VISIBLE); } ImageView geoImage = myMessage ? geoImageMy : geoImageTheir; ShapedFrameLayout cellCustom = (ShapedFrameLayout) (myMessage ? containerMy : containerTheir); Object imageId = messagePart.getId(); Bitmap bmp = (Bitmap) Atlas.imageLoader.getImageFromCache(imageId); if (bmp != null) { if (debug) Log.d(TAG, "geo.onBind() bitmap: " + bmp.getWidth() + "x" + bmp.getHeight()); geoImage.setImageBitmap(bmp); } else { if (debug) Log.d(TAG, "geo.onBind() spec: " + spec); geoImage.setImageDrawable(Tools.EMPTY_DRAWABLE); // schedule image File tileFile = getTileFile(cellContainer.getContext()); if (tileFile.exists()) { if (debug) Log.d(TAG, "geo.onBind() decodeImage: " + tileFile); // request decoding spec = Atlas.imageLoader.requestImage(imageId, new Atlas.FileStreamProvider(tileFile), (int) Tools.getPxFromDp(150, cellContainer.getContext()), (int) Tools.getPxFromDp(150, cellContainer.getContext()), false, this); } else { int width = 300; int height = 300; int zoom = 16; final String url = new StringBuilder().append("https://maps.googleapis.com/maps/api/staticmap?") .append("format=png32&").append("center=").append(lat).append(",").append(lon).append("&") .append("zoom=").append(zoom).append("&").append("size=").append(width).append("x") .append(height).append("&").append("maptype=roadmap&").append("markers=color:red%7C") .append(lat).append(",").append(lon).toString(); Atlas.downloadQueue.schedule(url, tileFile, this); if (debug) Log.d(TAG, "geo.onBind() show stub and download image: " + tileFile); } } // clustering cellCustom.setCornerRadiusDp(16, 16, 16, 16); if (AtlasMessagesList.CLUSTERED_BUBBLES) { if (myMessage) { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 2, 16); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(16, 2, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 2, 2, 16); } } else { if (this.clusterHeadItemId == this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(16, 16, 16, 2); } else if (this.clusterTail && this.clusterHeadItemId != this.clusterItemId) { cellCustom.setCornerRadiusDp(2, 16, 16, 16); } else if (this.clusterHeadItemId != this.clusterItemId && !this.clusterTail) { cellCustom.setCornerRadiusDp(2, 16, 16, 2); } } } return cellRoot; }
From source file:com.tomeokin.lspush.biz.home.CollectionListAdapter.java
private void setExplorers(ViewGroup container, @Nullable List<User> explorers) { final Context context = container.getContext(); // // TODO: 2016/10/8 performance improve //container.removeAllViews(); //for (User explorer : explorers) { // final ImageView avatar = // (ImageView) LayoutInflater.from(context).inflate(R.layout.layout_item_explorer, container, false); // ImageLoader.loadAvatar(context, avatar, explorer.getImage()); // container.addView(avatar); //}/*from w w w . j a va2 s .c o m*/ final int count = container.getChildCount(); int targetCount = explorers == null ? 0 : explorers.size(); targetCount = targetCount >= 5 ? 5 : targetCount; final LayoutInflater inflater = LayoutInflater.from(context); if (count > targetCount) { container.removeViews(targetCount, count - targetCount); } ImageView avatar; for (int i = 0; i < targetCount; i++) { if (i > count - 1) { // no cache avatar = (ImageView) inflater.inflate(R.layout.layout_item_explorer, container, false); } else { avatar = (ImageView) container.getChildAt(i); } ImageLoader.loadAvatar(context, avatar, explorers.get(i).getImage()); if (avatar.getParent() == null) { container.addView(avatar); } avatar.setTag(R.id.avatar_tag_uid, explorers.get(i).getUid()); avatar.setOnClickListener(mExplorerListener); } }
From source file:com.amitupadhyay.aboutexample.ui.transitions.MorphDialogToFab.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {/* www. j a va 2 s .c o m*/ Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(getFastOutLinearInInterpolator(vg.getContext())).start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator(getFastOutSlowInInterpolator(sceneRoot.getContext())); return transition; }
From source file:com.caij.codehub.ui.transitions.MorphDialogToFab.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override/* w w w. j a va 2s . co m*/ public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator(AnimUtils.getMaterialInterpolator(sceneRoot.getContext())); return transition; }
From source file:com.fa.mastodon.adapter.NotificationsAdapter.java
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { switch (viewType) { default://from w w w.ja v a 2 s .c om case VIEW_TYPE_MENTION: { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_status, parent, false); return new StatusViewHolder(view); } case VIEW_TYPE_FOOTER: { View view; switch (footerState) { default: case LOADING: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer, parent, false); break; case END: { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_end, parent, false); break; } case EMPTY: { view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_empty, parent, false); break; } } return new FooterViewHolder(view); } case VIEW_TYPE_STATUS_NOTIFICATION: { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_status_notification, parent, false); return new StatusNotificationViewHolder(view); } case VIEW_TYPE_FOLLOW: { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_follow, parent, false); return new FollowViewHolder(view); } } }
From source file:com.josecalles.porridge.transitions.MorphDialogToFab.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {/* www . j a va2 s .c o m*/ Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues); if (startValues == null || endValues == null || changeBounds == null) { return null; } Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR); Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS); Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR); Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS); if (startColor == null || startCornerRadius == null || endColor == null || endCornerRadius == null) { return null; } MorphDrawable background = new MorphDrawable(startColor, startCornerRadius); endValues.view.setBackground(background); Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor); Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS, endCornerRadius); // hide child views (offset down & fade out) if (endValues.view instanceof ViewGroup) { ViewGroup vg = (ViewGroup) endValues.view; for (int i = 0; i < vg.getChildCount(); i++) { View v = vg.getChildAt(i); v.animate().alpha(0f).translationY(v.getHeight() / 3).setStartDelay(0L).setDuration(50L) .setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in)) .start(); } } AnimatorSet transition = new AnimatorSet(); transition.playTogether(changeBounds, corners, color); transition.setDuration(300); transition.setInterpolator( AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in)); return transition; }