List of usage examples for android.view ViewGroup getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:org.lol.reddit.fragments.PostListingFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { super.onCreateView(inflater, container, savedInstanceState); final Context context = container.getContext(); sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); final LinearLayout outer = new LinearLayout(context) { @Override//w w w. java 2 s . c o m protected void onAttachedToWindow() { super.onAttachedToWindow(); getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; } }; outer.setOrientation(android.widget.LinearLayout.VERTICAL); fragmentHeader = createVerticalLinearLayout(context); // TODO output failed URL if (postListingURL == null) { fragmentHeader.addView(new ErrorView(getSupportActivity(), new RRError("Invalid post listing URL", "Could not navigate to that URL."))); return outer; } listHeader = createVerticalLinearLayout(context); listHeaderNotifications = createVerticalLinearLayout(context); listFooterNotifications = createVerticalLinearLayout(context); downloadPostCount = PrefsUtility.pref_behaviour_post_count(context, sharedPrefs); restackRefreshCount(); loadMoreView = (TextView) LayoutInflater.from(context).inflate(R.layout.load_more_posts, null); loadMoreView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { listFooterNotifications.removeView(loadMoreView); restackRefreshCount(); onLoadMoreItemsCheck(); } }); listHeader.addView(listHeaderNotifications); lv = (ListView) inflater.inflate(R.layout.reddit_post_list); lv.setOnScrollListener(this); lv.addHeaderView(listHeader); lv.addFooterView(listFooterNotifications, null, true); lv.setPersistentDrawingCache(ViewGroup.PERSISTENT_ALL_CACHES); lv.setAlwaysDrawnWithCacheEnabled(true); adapter = new PostListingAdapter(lv, this); lv.setAdapter(adapter); final ListOverlayView lov = new ListOverlayView(context, lv); outer.addView(fragmentHeader); outer.addView(lov); lv.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; request = new PostListingRequest(postListingURL.generateJsonUri(), RedditAccountManager.getInstance(context).getDefaultAccount(), session, downloadType, true); CacheManager.getInstance(context).makeRequest(request); switch (postListingURL.pathType()) { case UserPostListingURL: case SearchPostListingURL: setHeader(postListingURL.humanReadableName(getSupportActivity(), true), postListingURL.humanReadableUrl()); break; case SubredditPostListingURL: SubredditPostListURL subredditPostListURL = (SubredditPostListURL) postListingURL; switch (subredditPostListURL.type) { case FRONTPAGE: case ALL: case SUBREDDIT_COMBINATION: case ALL_SUBTRACTION: setHeader(postListingURL.humanReadableName(getSupportActivity(), true), postListingURL.humanReadableUrl()); break; case SUBREDDIT: { // Request the subreddit data final RequestResponseHandler<RedditSubreddit, SubredditRequestFailure> subredditHandler = new RequestResponseHandler<RedditSubreddit, SubredditRequestFailure>() { @Override public void onRequestFailed(SubredditRequestFailure failureReason) { // Ignore } @Override public void onRequestSuccess(RedditSubreddit result, long timeCached) { subreddit = result; onSubredditReceived(); } }; try { RedditSubredditManager .getInstance(getSupportActivity(), RedditAccountManager.getInstance(getSupportActivity()).getDefaultAccount()) .getSubreddit(RedditSubreddit.getCanonicalName(subredditPostListURL.subreddit), TimestampBound.NONE, subredditHandler, null); } catch (RedditSubreddit.InvalidSubredditNameException e) { throw new RuntimeException(e); } break; } } break; } return outer; }
From source file:com.jet.sweettips.snackbar.SweetSnackbar.java
private SweetSnackbar(ViewGroup parent) { mTargetParent = parent;/*from ww w . ja v a 2 s . c o m*/ mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); mView = (SnackbarLayout) inflater.inflate(com.jet.sweettips.R.layout.sweet_layout_snackbar, mTargetParent, false); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:android.support.designox.widget.Snackbar.java
private Snackbar(ViewGroup parent) { mTargetParent = parent;// w w w .j a va2 s .c o m mContext = parent.getContext(); try { ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); mView = (SnackbarLayout) inflater.inflate(R.layout.design_layout_snackbar, mTargetParent, false); // mView = (SnackbarLayout) inflater.inflate( // R.layout.mysnackbarlayout, mTargetParent, false); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); } catch (Throwable th) { Log.d("Snackbar class", th.getMessage()); } }
From source file:bulat.diet.helper_couch.adapter.ExpandableDraggableSwipeableExampleAdapter.java
@Override public DayTimeViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v = inflater.inflate(R.layout.list_group_item, parent, false); return new DayTimeViewHolder(v); }
From source file:bulat.diet.helper_couch.adapter.ExpandableDraggableSwipeableExampleAdapter.java
@Override public TodayDishItemViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v; if (viewType != 2) { v = inflater.inflate(R.layout.list_child_item, parent, false); } else {/* w w w.ja va 2 s.c om*/ v = inflater.inflate(R.layout.list_child_sport_item, parent, false); } return new TodayDishItemViewHolder(v); }
From source file:com.fastbootmobile.encore.app.adapters.SearchAdapter.java
/** * {@inheritDoc}//from w ww.j ava 2 s. c om */ @Override public View getGroupView(int i, boolean b, View view, ViewGroup parent) { final Context ctx = parent.getContext(); assert ctx != null; GroupViewHolder holder; if (view == null) { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.item_group_separator, parent, false); holder = new GroupViewHolder(); holder.tvSearchSeparator = (TextView) view.findViewById(R.id.tv_search_separator); view.setTag(holder); } else { holder = (GroupViewHolder) view.getTag(); } int title; switch (i) { case ARTIST: title = R.string.tab_artists; break; case ALBUM: title = R.string.albums; break; case SONG: title = R.string.songs; break; case PLAYLIST: title = R.string.tab_playlists; break; default: throw new RuntimeException("Unknown group index: " + i); } holder.tvSearchSeparator.setText(title); if (getChildrenCount(i) == 0) { view.setVisibility(View.GONE); } else { view.setVisibility(View.VISIBLE); } return view; }
From source file:com.lcl.designsnackbar.tsnackbar.TSnackbar.java
private TSnackbar(ViewGroup parent) { mTargetParent = parent;//from w ww . j a v a 2 s . c o m mContext = parent.getContext(); ThemeUtils.checkAppCompatTheme(mContext); LayoutInflater inflater = LayoutInflater.from(mContext); mView = (SnackbarLayout) inflater.inflate(com.lcl.designsnackbar.R.layout.design_layout_tsnackbar, mTargetParent, false); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); }
From source file:com.h6ah4i.android.example.advrecyclerview.demo_eds_vp_sec_long.MyExpandableDraggableSwipeableSectionAdapter.java
@Override public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) { final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); final View v; switch (viewType) { case GROUP_ITEM_VIEW_TYPE_SECTION_HEADER: v = inflater.inflate(R.layout.list_section_header, parent, false); break;/*from w w w .j a va 2 s . c o m*/ case GROUP_ITEM_VIEW_TYPE_SECTION_ITEM: v = inflater.inflate(R.layout.list_group_item_draggable, parent, false); break; default: throw new IllegalStateException("Unexpected viewType (= " + viewType + ")"); } return new MyGroupViewHolder(v); }
From source file:com.fastbootmobile.encore.app.adapters.SearchAdapter.java
/** * {@inheritDoc}//w ww. j av a 2s .c om */ @Override public View getChildView(int i, int i2, boolean b, View root, ViewGroup parent) { final Context ctx = parent.getContext(); assert ctx != null; if (root == null) { LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE); root = inflater.inflate(R.layout.item_search_element, parent, false); ViewHolder holder = new ViewHolder(); holder.albumArtImageView = (AlbumArtImageView) root.findViewById(R.id.ivCover); holder.tvTitle = (TextView) root.findViewById(R.id.tvTitle); holder.tvSubtitle = (TextView) root.findViewById(R.id.tvSubTitle); holder.divider = (TextView) root.findViewById(R.id.divider); holder.ivSource = (ImageView) root.findViewById(R.id.ivSource); holder.ivOverflow = (ImageView) root.findViewById(R.id.ivOverflow); holder.vRoot = root; holder.ivOverflow.setTag(holder); root.setTag(holder); } final ViewHolder tag = (ViewHolder) root.getTag(); if (i2 == getChildrenCount(i) - 1) { tag.albumArtImageView.setVisibility(View.INVISIBLE); tag.ivSource.setVisibility(View.GONE); if (getChildrenCount(i) == 1) { tag.tvTitle.setText(R.string.search_no_results); } else { tag.tvTitle.setText(R.string.more); } tag.tvSubtitle.setText(null); tag.ivOverflow.setVisibility(View.GONE); tag.content = null; } else { tag.albumArtImageView.setVisibility(View.VISIBLE); tag.ivSource.setVisibility(View.VISIBLE); tag.ivOverflow.setVisibility(View.VISIBLE); switch (i) { case ARTIST: updateArtistTag(i2, tag); break; case ALBUM: updateAlbumTag(i2, tag); break; case SONG: updateSongTag(i2, tag); break; case PLAYLIST: updatePlaylistTag(i2, tag); break; default: Log.e(TAG, "Unknown group " + i); break; } } return root; }
From source file:com.appolica.interactiveinfowindow.InfoWindowManager.java
private View createContainer(@NonNull final ViewGroup parent) { final DisallowInterceptLayout container = new DisallowInterceptLayout(parent.getContext()); container.setDisallowParentIntercept(true); container.setLayoutParams(generateDefaultLayoutParams()); container.setId(idProvider.getNewId()); container.setVisibility(View.INVISIBLE); return container; }