List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:com.domowe.apki.lista2.MyDraggableWithSectionItemAdapter.java
@Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v = viewType == Constants.ITEM_VIEW_TYPE_SECTION_HEADER ? inflater.inflate(R.layout.list_section_header, parent, false) : inflater.inflate(getTileSize(), parent, false); return new MyViewHolder(v); }
From source file:com.rascarlo.aurdroid.ui.SearchResultFragment.java
@Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Context context = container.getContext(); FragmentSearchResultBinding fragmentSearchResultBinding = FragmentSearchResultBinding.inflate(inflater, container, false);//from ww w . ja v a2 s. c o m ProgressBar progressBar = fragmentSearchResultBinding.fragmentSearchResultProgressBar; progressBar.setVisibility(View.VISIBLE); SearchViewModelFactory searchViewModelFactory = new SearchViewModelFactory(bundleSearchBy, bundleQuery); SearchViewModel searchViewModel = ViewModelProviders.of(this, searchViewModelFactory) .get(SearchViewModel.class); resultAdapter = new SearchResultAdapter(searchResult -> { if (searchResultFragmentCallback != null) { if (searchResult != null && searchResult.getName() != null && !TextUtils.isEmpty(searchResult.getName())) { searchResultFragmentCallback .onSearchResultFragmentCallbackOnResultClicked(searchResult.getName()); } } }); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false); RecyclerView recyclerView = fragmentSearchResultBinding.fragmentSearchResultRecyclerView; recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL)); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(linearLayoutManager); searchViewModel.getSearchLiveData().observe(this, aurSearch -> { if (aurSearch != null) { this.searchResultList = aurSearch.getResults(); submitSearchResultList(false); } progressBar.setVisibility(View.GONE); }); searchViewModel.getMessageMutableLiveData().observe(this, s -> { if (s != null && !TextUtils.isEmpty(s)) { Toast.makeText(context, TextUtils.equals(AurdroidConstants.RETROFIT_FAILURE, s) ? getString(R.string.retrofit_something_went_wrong) : s, Toast.LENGTH_LONG).show(); } progressBar.setVisibility(View.GONE); }); recyclerView.setAdapter(resultAdapter); return fragmentSearchResultBinding.getRoot(); }
From source file:com.github.retrofit2.app.RxCardsFragment.java
@Nullable @Override//from w ww . j av a 2 s.c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_list_swipe, container, false); ButterKnife.inject(this, view); //viewSubject.onNext(view); listAdapter = ListRecyclerAdapter.create(); listAdapter.createViewHolder(new Func2<ViewGroup, Integer, CardViewHolder>() { @Override public CardViewHolder call(ViewGroup parent, Integer position) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_card, parent, false); /* TypedValue typedValue = new TypedValue(); parent.getContext().getTheme().resolveAttribute(R.attr.selectableItemBackground, typedValue, true); view.setBackgroundResource(typedValue.resourceId); */ return new CardViewHolder(view); } }); listView.setLayoutManager(new LinearLayoutManager(listView.getContext())); listView.setAdapter(listAdapter); refreshView.setOnRefreshListener(() -> { load(); }); return view; }
From source file:de.gebatzens.sia.fragment.RemoteDataFragment.java
public void createNoEntriesCard(ViewGroup parent, LayoutInflater inflater) { LinearLayout wrapper = new LinearLayout(parent.getContext()); wrapper.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); setOrientationPadding(wrapper);/*from w w w .jav a 2s .co m*/ CardView cv = (CardView) inflater.inflate(R.layout.basic_cardview, wrapper, false); createPrimaryTextView(getResources().getString(R.string.no_entries), 20, inflater, cv); wrapper.addView(cv); parent.addView(wrapper); }
From source file:ayushi.view.adapter.ShoppingListAdapter.java
@Override public ItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_product_list, parent, false); ItemViewHolder itemViewHolder = new ItemViewHolder(view); return itemViewHolder; }
From source file:com.umeng.comm.ui.imagepicker.adapters.ImagePagerAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { if (mPresenter == null) { mPresenter = new ImageBrowserPresenter(container.getContext()); }/* w w w . j a va 2 s .c om*/ View view = createView(container, mPaths.get(position)); container.addView(view, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return view; }
From source file:com.popdeem.sdk.uikit.adapter.PDUIFeedRecyclerViewAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { if (mSharedImageDimen == -1) { mSharedImageDimen = (int) parent.getContext().getResources() .getDimension(R.dimen.pd_feed_shared_image_dimen); }/*from w ww . j a va2 s . com*/ if (mProfileImageDimen == -1) { mProfileImageDimen = (int) parent.getContext().getResources() .getDimension(R.dimen.pd_feed_profile_image_dimen); } return new ViewHolder( LayoutInflater.from(parent.getContext()).inflate(R.layout.item_feed_v2, parent, false), parent.getContext()); }
From source file:com.google.android.apps.santatracker.dasherdancer.CharacterAdapter.java
@Override public Object instantiateItem(ViewGroup container, int position) { ImageView view = null;//w ww . j a v a2 s . co m if (position < mCharacters.length) { if (mViews.get(position) != null) { view = mViews.get(position); } else { view = new FrameAnimationView(container.getContext()); view.setScaleType(ImageView.ScaleType.CENTER_CROP); //Load the first idle frame. view.setBackgroundResource(mBackgrounds[position]); view.setTag(position); mViews.put(position, view); } LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); container.addView(view, lp); } return view; }
From source file:com.getchute.android.photopickerplus.ui.adapter.AssetAccountRecyclerAdapter.java
@Override public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { View itemView = null;//from www .j av a2s . com LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext()); if (displayType == DisplayType.LIST) { itemView = layoutInflater.inflate(R.layout.gc_adapter_assets_list, parent, false); } else { itemView = layoutInflater.inflate(R.layout.gc_adapter_assets_grid, parent, false); } return new ViewHolder(itemView); }
From source file:com.justplay1.shoppist.features.lists.items.ListItemAdapter.java
@Override public BaseSwipeableItemViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_shopping_list_item, parent, false);//from www.jav a2 s .co m ListItemViewHolder holder = new ListItemViewHolder(view); holder.setClickListener(itemClickListener); return holder; }