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.lloydtorres.stately.world.WorldRecyclerAdapter.java

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    RecyclerView.ViewHolder viewHolder = null;
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());

    switch (viewType) {
    case WORLD_COUNT:
        View statsCard = inflater.inflate(R.layout.card_wa_members, parent, false);
        viewHolder = new StatsCard(statsCard);
        break;//from w ww  .  j  a va2  s.c  om
    case WORLD_FEATURED_REGION:
        View featuredRegionCard = inflater.inflate(R.layout.card_world_featured_region, parent, false);
        viewHolder = new FeaturedRegionCard(featuredRegionCard);
        break;
    case WORLD_BREAKING_NEWS:
        View breakingNewsCard = inflater.inflate(R.layout.card_world_breaking_news, parent, false);
        viewHolder = new BreakingNewsCard(breakingNewsCard);
        break;
    case WORLD_FEATURED_CENSUS:
        View featuredCensusCard = inflater.inflate(R.layout.card_world_featured_census, parent, false);
        viewHolder = new FeaturedCensusCard(featuredCensusCard);
        break;
    case WORLD_CENSUS_DATA:
        View worldCensusCard = inflater.inflate(R.layout.card_census_delta, parent, false);
        viewHolder = new WorldCensusCard(worldCensusCard);
        break;
    }

    return viewHolder;
}

From source file:com.potato.appstore.store.ui.fragment.AppListFragment.java

@Nullable
@Override//from  w ww  . j av  a 2s.c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mSectionId = getArguments() == null ? 0 : getArguments().getLong(EXTRARS_SECTION_ID);
    mTitle = getArguments() == null ? "" : getArguments().getString(EXTRARS_TITLE);

    mBinding = DataBindingUtil.inflate(LayoutInflater.from(container.getContext()), R.layout.fragment_app_list,
            container, false);

    mParser = new ApkInfoListParser("");

    mAdapter = new AppListAdapter(mContext);

    mBinding.list.setAdapter(mAdapter);

    mBinding.swipeContainer.setFooterView(mContext, mBinding.list, R.layout.listview_footer);

    mBinding.swipeContainer.setColorSchemeResources(R.color.google_blue, R.color.google_green,
            R.color.google_red, R.color.google_yellow);

    mBinding.swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            sendRequest2RefreshList();
        }
    });
    mBinding.swipeContainer.setOnLoadListener(new ListSwipeLayout.OnLoadListener() {
        @Override
        public void onLoad() {
            sendRequest2LoadMoreList();
        }
    });

    mBinding.swipeContainer.setEmptyView(mBinding.emptyView);
    mBinding.emptyView.setOnClickListener(this);
    mBinding.swipeContainer.showProgress();
    sendRequest2RefreshList();

    return mBinding.getRoot();
}

From source file:com.andr.studio.proj.swipetab.slidingpanellayout.SlidingViewDragHelper.java

/**
 * Factory method to create a new ViewDragHelper.
 *
 * @param forParent Parent view to monitor
 * @param cb Callback to provide information and receive events
 * @return a new ViewDragHelper instance
 *//* w  w  w . j  av  a2  s. c om*/
public static SlidingViewDragHelper create(ViewGroup forParent, Callback cb) {
    return new SlidingViewDragHelper(forParent.getContext(), forParent, cb);
}

From source file:com.mercandalli.android.apps.files.file.audio.FileAudioRowAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == TYPE_HEADER) {
        return new HeaderViewHolder(LayoutInflater.from(parent.getContext())
                .inflate(R.layout.view_file_header_audio, parent, false), mOnHeaderClickListener);
    } else if (viewType == TYPE_ROW_CARDS_HEADER) {
        return new RowCardsViewHolder(
                LayoutInflater.from(parent.getContext()).inflate(R.layout.tab_file_row_cards, parent, false));
    }//from   www.  java 2s .co  m
    return new FileViewHolder(
            LayoutInflater.from(parent.getContext()).inflate(R.layout.tab_file_card_drag_drop, parent, false),
            mHasHeader, mItemClickListener, mItemLongClickListener);
}

From source file:com.fastbootmobile.encore.app.adapters.PlaylistListAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == VIEW_TYPE_REGULAR) {
        final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        final View root = inflater.inflate(R.layout.item_playlist_list, parent, false);
        ensureOrderer(parent.getContext());
        return new ViewHolder(root);
    } else if (viewType == VIEW_TYPE_HEADER) {
        final LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        final View root = inflater.inflate(R.layout.item_special_playlists, parent, false);
        ensureOrderer(parent.getContext());
        return new SpecialViewHolder(root);
    }//from  w w  w.  ja v a2  s .c o  m

    return null; // Should not happen
}

From source file:com.example.administrator.mouseapp.M5ViewDragHelper.java

/**
 * Factory method to create a new ViewDragHelper.
 *
 * @param forParent Parent view to monitor
 * @param cb Callback to provide information and receive events
 * @return a new ViewDragHelper instance
 */// w  ww.jav  a2  s.c om
public static M5ViewDragHelper create(ViewGroup forParent, Callback cb) {
    return new M5ViewDragHelper(forParent.getContext(), forParent, cb);
}

From source file:com.mercandalli.android.apps.files.file.FileModelCardAdapter.java

@Override
public FileModelCardAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (viewType == TYPE_HEADER_AUDIO) {
        return new HeaderViewHolder(LayoutInflater.from(parent.getContext())
                .inflate(R.layout.view_file_header_audio, parent, false), mHeaderIds, mOnHeaderClickListener);
    } else if (viewType == TYPE_HEADER_IMAGE) {
        return new HeaderViewHolder(LayoutInflater.from(parent.getContext())
                .inflate(R.layout.view_file_header_image, parent, false), mHeaderIds, mOnHeaderClickListener);
    } else if (viewType == TYPE_CARD_ITEM) {
        return new CardViewHolder(
                LayoutInflater.from(parent.getContext()).inflate(R.layout.card_file, parent, false),
                hasHeader(), mOnFileClickListener, mOnFileLongClickListener);
    }/*from  www. j  av a 2 s  .  co m*/
    throw new RuntimeException(
            "There is no type that matches the type " + viewType + " + make sure your using types correctly.");
}

From source file:android.support.app.SwipeRefreshListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    // Create the list fragment's content view by calling the super method
    final View listFragmentView = super.onCreateView(inflater, container, savedInstanceState);

    // Now create a SwipeRefreshLayout to wrap the fragment's content view
    mSwipeRefreshLayout = new ListFragmentSwipeRefreshLayout(container.getContext());

    // Add the list fragment's content view to the SwipeRefreshLayout, making sure that it fills
    // the SwipeRefreshLayout
    mSwipeRefreshLayout.addView(listFragmentView, ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);

    // Make sure that the SwipeRefreshLayout will fill the fragment
    mSwipeRefreshLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // Now return the SwipeRefreshLayout as this fragment's content view
    return mSwipeRefreshLayout;
}

From source file:android.support.v17.leanback.widget.AbstractMediaItemPresenter.java

@Override
protected RowPresenter.ViewHolder createRowViewHolder(ViewGroup parent) {
    Context context = parent.getContext();
    if (mThemeId != 0) {
        context = new ContextThemeWrapper(context, mThemeId);
    }/*w w  w .  j  a va 2  s  .  c o m*/
    View view = LayoutInflater.from(context).inflate(R.layout.lb_row_media_item, parent, false);
    final ViewHolder vh = new ViewHolder(view);
    vh.mRowPresenter = this;
    if (mBackgroundColorSet) {
        vh.mMediaRowView.setBackgroundColor(mBackgroundColor);
    }
    return vh;
}

From source file:com.nexa.cityseason.fragment.FacilityAndService.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // TODO Auto-generated method stub      
    if (getActivity() instanceof RootActivity) {
        activity = (RootActivity) getActivity();
    }/*from   www  .  ja  va 2 s . c  o  m*/

    super.onCreate(savedInstanceState);
    View rootView = inflater.inflate(R.layout.fragment_facility_list, container, false);

    mContext = container.getContext();

    mListView = (ListView) rootView.findViewById(R.id.listView);

    FaciltyListAdapter simpleAdpt = new FaciltyListAdapter(mContext, createListViewData());
    mListView.setAdapter(simpleAdpt);

    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {

            openFragment();
        }
    });

    return rootView;
}