Example usage for android.view ViewGroup getContext

List of usage examples for android.view ViewGroup getContext

Introduction

In this page you can find the example usage for android.view ViewGroup 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.hannesdorfmann.home.filter.FilterAdapter.java

@Override
public FilterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    final FilterViewHolder holder = new FilterViewHolder(
            LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.filter_item, viewGroup, false));

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override/*  w  ww.j a  v a  2s.  c  o m*/
        public void onClick(View v) {
            final int position = holder.getAdapterPosition();
            if (position == RecyclerView.NO_POSITION)
                return;

            final SourceFilterPresentationModel filter = filters.get(position);
            holder.itemView.setHasTransientState(true);
            ObjectAnimator fade = ObjectAnimator.ofInt(holder.filterIcon, ViewUtils.IMAGE_ALPHA,
                    filter.getEnabled() ? FILTER_ICON_DISABLED_ALPHA : FILTER_ICON_ENABLED_ALPHA);
            fade.setDuration(300);
            fade.setInterpolator(AnimationUtils.loadInterpolator(holder.itemView.getContext(),
                    android.R.interpolator.fast_out_slow_in));
            fade.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    holder.itemView.setHasTransientState(false);
                    clickedListener.onSourceFilterClicked(filter);
                }
            });
            fade.start();
        }
    });
    return holder;
}

From source file:ca.appvelopers.mcgillmobile.ui.walkthrough.WalkthroughAdapter.java

@Override
public Object instantiateItem(ViewGroup collection, int position) {
    final Context context = collection.getContext();
    View view;//from   ww w .  ja v a 2  s  .c o  m
    switch (position) {
    //Welcome
    case 0:
        view = View.inflate(context, R.layout.item_walkthrough_0, null);
        break;
    //Access Essentials
    case 1:
        view = View.inflate(context, R.layout.item_walkthrough_1, null);
        break;
    //Main Menu Explanation
    case 2:
        view = View.inflate(context, R.layout.item_walkthrough_2, null);
        break;
    //            //Horizontal Schedule
    //            case 3:
    //                view = View.inflate(context, R.layout.item_walkthrough_3, null);
    //                break;
    //Info
    case 3:
        view = View.inflate(context, R.layout.item_walkthrough_4, null);
        break;
    //Default HomepageManager / Faculty (first open only)
    case 4:
        view = View.inflate(context, R.layout.item_walkthrough_5, null);

        FormGenerator fg = FormGenerator.bind(context, (LinearLayout) view);

        //HomepageManager Prompt
        fg.text(R.string.walkthrough_homepage).gravity(Gravity.CENTER)
                .padding(context.getResources().getDimensionPixelOffset(R.dimen.padding_small)).build();

        //HomepageManager
        fg.text(homepagePref.getTitleString()).leftIcon(R.drawable.ic_phone_android)
                .rightIcon(R.drawable.ic_chevron_right, Color.GRAY)
                .onClick(new TextViewFormItem.OnClickListener() {
                    @Override
                    public void onClick(final TextViewFormItem item) {
                        DialogUtils.list(context, R.string.settings_homepage_title,
                                new HomepageListAdapter(context) {
                                    @Override
                                    public void onHomepageSelected(@HomepageManager.Homepage int choice) {
                                        //Update it
                                        homepageManager.set(choice);

                                        item.view().setText(homepageManager.getTitleString());

                                        analytics.sendEvent("Walkthrough", "HomepageManager",
                                                homepageManager.getString());
                                    }
                                });
                    }
                }).build();

        //Faculty Prompt
        fg.text(R.string.walkthrough_faculty).gravity(Gravity.CENTER)
                .padding(context.getResources().getDimensionPixelOffset(R.dimen.padding_small)).build();

        //Faculty
        fg.text(R.string.faculty_none).leftIcon(R.drawable.ic_mycourses)
                .rightIcon(R.drawable.ic_chevron_right, Color.GRAY)
                .onClick(new TextViewFormItem.OnClickListener() {
                    @Override
                    public void onClick(final TextViewFormItem item) {
                        DialogUtils.list(context, R.string.faculty_title,
                                new FacultyListAdapter(context, item.view().getText().toString()) {
                                    @Override
                                    public void onFacultySelected(String faculty) {
                                        //Update the view
                                        item.view().setText(faculty);

                                        //If the faculty is not empty, send the GA
                                        analytics.sendEvent("Walkthrough", "Faculty", faculty);
                                    }
                                });
                    }
                }).build();

        break;
    default:
        throw new IllegalStateException("Unknown position " + position + " in walkthrough");
    }

    collection.addView(view);
    return view;
}

From source file:com.aashreys.walls.application.adapters.CollectionsAdapter.java

@Override
public CollectionViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    return new CollectionViewHolder((CollectionView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.item_collection, parent, false));
}

From source file:com.simplechatclient.android.TabsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.tabs_fragment, container, false);
    context = container.getContext();

    myStart();//from w  w  w  . jav a2s .c o m

    return view;
}

From source file:com.justwayward.reader.view.recyclerview.adapter.BaseViewHolder.java

public BaseViewHolder(ViewGroup parent, @LayoutRes int res) {
    super(LayoutInflater.from(parent.getContext()).inflate(res, parent, false));
    holder = this;
    mConvertView = itemView;/* ww w.jav a2 s . co m*/
    mLayoutId = res;
    mContext = mConvertView.getContext();
}

From source file:com.arlib.floatingsearchview.suggestions.SearchSuggestionsAdapter.java

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

    View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.search_suggestion_item, viewGroup,
            false);/*w  w w .j av a  2  s  . c o  m*/
    SearchSuggestionViewHolder viewHolder = new SearchSuggestionViewHolder(view,
            new SearchSuggestionViewHolder.Listener() {

                @Override
                public void onItemClicked(int adapterPosition) {

                    if (mListener != null) {
                        mListener.onItemSelected(mSearchSuggestions.get(adapterPosition));
                    }
                }

                @Override
                public void onMoveItemToSearchClicked(int adapterPosition) {

                    if (mListener != null) {
                        mListener.onMoveItemToSearchClicked(mSearchSuggestions.get(adapterPosition));
                    }
                }

            });

    viewHolder.rightIcon.setImageDrawable(mRightIconDrawable);
    viewHolder.body.setTextSize(TypedValue.COMPLEX_UNIT_PX, mBodyTextSizePx);

    return viewHolder;
}

From source file:com.fastbootmobile.encore.app.fragments.HistoryFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ListView rootView = (ListView) inflater.inflate(R.layout.fragment_history, container, false);
    mAdapter = new HistoryAdapter(container.getContext());
    rootView.setAdapter(mAdapter);//ww w  . ja  va 2 s .co  m
    rootView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ListenLogger.LogEntry entry = mAdapter.getItem(position);
            Song song = ProviderAggregator.getDefault().retrieveSong(entry.getReference(),
                    entry.getIdentifier());
            PlaybackProxy.playSong(song);
        }
    });
    return rootView;
}

From source file:com.tompee.funtablayout.BubbleTabAdapter.java

@Override
public BubbleTabAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    BubbleTabView itemView = new BubbleTabView(parent.getContext());
    itemView.setLayoutParams(createLayoutParamsForTabs(parent));
    ViewCompat.setPaddingRelative(itemView, mTabPaddingStart, mTabPaddingTop, mTabPaddingEnd,
            mTabPaddingBottom);/*from  w  w  w  .jav  a  2s .  com*/
    itemView.setBackgroundResource(mTabBackgroundResId);
    itemView.setIconDimension(mIconDimension);
    itemView.setTextAppearance(mTabTextAppearance);
    itemView.setMaxLines(MAX_TAB_TEXT_LINES);
    return new ViewHolder(itemView);
}

From source file:com.rascarlo.aurdroid.ui.SearchFragment.java

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    context = container.getContext();
    FragmentSearchBinding fragmentSearchBinding = FragmentSearchBinding.inflate(LayoutInflater.from(context),
            container, false);//from  www  .ja v a 2  s  . com
    TextInputEditText textInputEditText = fragmentSearchBinding.fragmentSearchKeywordsLayout.searchKeywordsTextInputEditText;
    textInputEditText.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    textInputEditText.setOnEditorActionListener((editTextView, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            if (editTextView.getEditableText() != null
                    && !TextUtils.isEmpty(editTextView.getEditableText().toString().trim())) {
                if (searchFragmentCallback != null) {
                    searchFragmentCallback.onSearchFragmentCallbackOnFabClicked(getSearchBy(), getSort(),
                            editTextView.getEditableText().toString().trim());
                }
            }
            InputMethodManager inputMethodManager = (InputMethodManager) editTextView.getContext()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            if (inputMethodManager != null)
                inputMethodManager.hideSoftInputFromWindow(editTextView.getWindowToken(), 0);
            return true;
        }
        return false;
    });
    // search by
    radioButtonSearchByNameOrDescription = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonNameOrDescription;
    radioButtonSearchByName = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonName;
    radioButtonSearchByMaintainer = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonMaintainer;
    radioButtonSearchByDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonDepends;
    radioButtonSearchByMakeDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonMakeDepends;
    radioButtonSearchByOptDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonOptDepends;
    radioButtonSearchByCheckDepends = fragmentSearchBinding.fragmentSearchByLayout.searchByRadioButtonCheckDepends;
    // sort
    radioButtonSortPackageName = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonPackageName;
    radioButtonSortVotes = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonVotes;
    radioButtonSortPopularity = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonPopularity;
    radioButtonSortLastUpdated = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonLastUpdated;
    radioButtonSortFirstSubmitted = fragmentSearchBinding.fragmentSearchSortLayout.searchRadioButtonFirstSubmitted;
    bindViews();
    return fragmentSearchBinding.getRoot();
}

From source file:com.kyleszombathy.sms_scheduler.RecyclerAdapter.java

@Override
public RecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v;//  w  ww  .ja  v  a 2s . com
    context = parent.getContext();
    v = LayoutInflater.from(context).inflate(R.layout.recycler_text_view, parent, false);
    return new ViewHolder(v);
}