List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.ben.gank.adapter.SortTypeAdapter.java
@Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v; switch (viewType) { case ITEM_VIEW_TYPE_SECTION_HEADER: v = inflater.inflate(R.layout.list_section_header, parent, false); break;/*from ww w .ja va2 s . c om*/ case ITEM_VIEW_TYPE_SECTION_ITEM: v = inflater.inflate(R.layout.item_sort, parent, false); break; default: throw new IllegalStateException("Unexpected viewType (= " + viewType + ")"); } return new MyViewHolder(v); }
From source file:com.ideascontest.navi.uask.MainQuestionAnswerAdapter.java
/** * * This gets called when each new ViewHolder is created. This happens when the RecyclerView * is laid out. Enough ViewHolders will be created to fill the screen and allow for scrolling. * * @param viewGroup The ViewGroup that these ViewHolders are contained within. * @param viewType If your RecyclerView has more than one type of item (which ours doesn't) you * can use this viewType integer to provide a different layout. See * {@link android.support.v7.widget.RecyclerView.Adapter#getItemViewType(int)} * for more details.//from ww w . j ava 2s.c om * @return A new NumberViewHolder that holds the View for each list item */ @Override public QuestionTopAnswerHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { Context context = viewGroup.getContext(); LayoutInflater inflater = LayoutInflater.from(context); boolean shouldAttachToParentImmediately = false; int layoutIdForListItem; View view; QuestionTopAnswerHolder viewHolder; if (viewType == STATIC_CARD) { Log.d("onCreateAdapter", "static"); layoutIdForListItem = getStaticLayouts(_category); view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); viewHolder = new QuestionTopAnswerHolder(view, viewType); } else { Log.d("onCreateAdapter", "dynamic"); layoutIdForListItem = R.layout.question_list_item; view = inflater.inflate(layoutIdForListItem, viewGroup, shouldAttachToParentImmediately); viewHolder = new QuestionTopAnswerHolder(view, viewType); } return viewHolder; }
From source file:com.shizhefei.view.multitype.MultiTypeAdapter.java
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int providerType) { if (layoutInflater == null) { layoutInflater = LayoutInflater.from(parent.getContext()); }/*from w w w . ja v a 2 s . c o m*/ ItemViewProvider<?> provider = providerIndex.get(providerType); return provider.onCreateViewHolder(layoutInflater, parent, providerType); }
From source file:com.tomeokin.lspush.biz.home.CollectionListAdapter.java
@Override public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); if (viewType == VIEW_TYPE_NORMAL) { return createCollectionHolder(inflater, parent); } else if (viewType == VIEW_TYPE_LOADING) { return createLoadingViewHolder(inflater, parent); }//from w w w. j a v a 2s . co m return null; }
From source file:com.potato.sticker.main.ui.fragment.TopicListFragment.java
@Nullable @Override//from www . j a v a 2 s .c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.fragment_topic_list, container, false); // View view = inflater.inflate( // R.layout.recycleview, container, false); mSectionId = getArguments() == null ? "" : getArguments().getString(EXTRARS_SECTION_ID); mTitle = getArguments() == null ? "" : getArguments().getString(EXTRARS_TITLE); mAdapter = new TopicAdapter(mContext); binding.swipeContainer.setRecyclerView(binding.list, mAdapter); binding.swipeContainer.setLayoutManager(new LinearLayoutManager(mContext)); binding.swipeContainer.setFooterView(binding.list, R.layout.potato_listview_footer); binding.swipeContainer.setColorSchemeResources(R.color.google_blue, R.color.google_green, R.color.google_red, R.color.google_yellow); binding.swipeContainer.setScrollStateLisener(new PotatoRecyclerSwipeLayout.ScrollStateLisener() { @Override public void pause() { ImageLoader.getInstance().pause(); } @Override public void resume() { ImageLoader.getInstance().resume(); } }); binding.swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { sendRequest2RefreshList(); } }); binding.swipeContainer.setOnLoadListener(new PotatoRecyclerSwipeLayout.OnLoadListener() { @Override public void onLoad() { sendRequest2LoadMoreList(); } }); binding.swipeContainer.setEmptyView(binding.emptyView); binding.emptyView.setOnClickListener(this); binding.swipeContainer.showProgress(); sendRequest2RefreshList(); return binding.getRoot(); }
From source file:cn.edu.zucc.list.FabAnimation.MorphDialogToFab.java
@Override public Animator createAnimator(final ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {//from w ww .ja v a 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(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.gm.grecyclerview.SimpleAdapter.java
@Override public SimpleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { SimpleCell cell = cellTypeMap.get(viewType); View view = LayoutInflater.from(parent.getContext()).inflate(cell.getLayoutRes(), parent, false); final SimpleViewHolder viewHolder = cell.onCreateViewHolder(parent, view); if (dragAndDropHelper != null && dragAndDropHelper.getDragHandleId() != 0) { View dragHandle = viewHolder.itemView.findViewById(dragAndDropHelper.getDragHandleId()); dragHandle.setOnTouchListener(new View.OnTouchListener() { @Override//from www. j a v a 2s . c o m public boolean onTouch(View v, MotionEvent event) { if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_DOWN) { dragAndDropHelper.onStartDrag(viewHolder); } return false; } }); } return viewHolder; }
From source file:com.justplay1.shoppist.features.lists.items.ListItemAdapter.java
@Override public BaseHeaderHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) { View view;/*from w w w. j a va2 s . co m*/ switch (viewType) { case ItemType.HEADER_ITEM: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_header, parent, false); return new HeaderViewHolder(view); case ItemType.CART_HEADER: view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_list_header, parent, false); CartViewHolder holder = new CartViewHolder(view); holder.setColor(preferences.getColorPrimary()); return holder; } return null; }
From source file:com.simplechatclient.android.ProfileRegisterFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.profile_register_fragment, container, false); context = container.getContext(); myStart();/*from www . j av a 2 s . c o m*/ return view; }
From source file:com.stoneapp.ourvlemoodle2.adapters.CourseContentListAdapter.java
@Override public CourseContentViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { int layout = viewType == TYPE_HEADER ? R.layout.list_section_header : R.layout.list_module_item; View v = LayoutInflater.from(viewGroup.getContext()).inflate(layout, viewGroup, false); return new CourseContentViewHolder(v); }