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.rukiasoft.androidapps.cocinaconroll.ui.RecipeListRecyclerViewAdapter.java

@Override
public RecipeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recipe_recycler_item, parent, false);
    RecipeViewHolder recipeViewHolder = new RecipeViewHolder(v);
    recipeViewHolder.cardView.setOnClickListener(this);
    recipeViewHolder.cardView.setOnLongClickListener(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (recipeViewHolder.backCardView != null) {
            recipeViewHolder.backCardView.setRotationY(180);
        }/*from   w  w  w  .j a  va 2 s.  co m*/
    }
    /*recipeViewHolder.favoriteButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if (onBackFavoriteClickListener != null) {
            final RecipeItem recipe = getRecipeFromParent(v);
            if (v instanceof ImageView) {
                ((ImageView) v).setImageDrawable(
                        (!recipe.getFavourite()) ? ContextCompat.getDrawable(mContext, R.drawable.ic_favorite_white_48dp) :
                                ContextCompat.getDrawable(mContext, R.drawable.ic_favorite_outline_white_48dp)
                );
            }
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    onBackFavoriteClickListener.onBackFavoriteClick(recipe);
                }
            }, 200);
        }
    }
    });*/

    return recipeViewHolder;
    /*v.setOnClickListener(this);
    return new RecipeViewHolder(v);*/
}

From source file:de.kodejak.hashr.fragmentHashFromText.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragmenthashfromtext_layout, container, false);
    this.mContext = container.getContext();

    this.fragJob = getArguments().getInt("job");

    switch (this.fragJob) {
    case 1://from  w  w  w  .j av  a2 s.  co  m
        fragTitle = "MD5 from text";
        fragJobStr = "MD5";
        break;
    case 2:
        fragTitle = "SHA-1 from text";
        fragJobStr = "SHA-1";
        break;
    case 3:
        fragTitle = "SHA-256 from text";
        fragJobStr = "SHA-256";
        break;

    }

    SharedPreferences mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    uppercaseHash = mySharedPreferences.getBoolean("uppercase_hash", false);
    trimHash = mySharedPreferences.getBoolean("trim_hash", false);

    TextView tvHead = (TextView) rootView.findViewById(R.id.tvHeader);
    tvHead.setText(fragTitle);
    Button btnGen = (Button) rootView.findViewById(R.id.btnGenerate);
    btnGen.setText("Generate " + fragJobStr + " hash");
    Button btnComp = (Button) rootView.findViewById(R.id.btnCompare);
    btnComp.setText("Compare " + fragJobStr + " hashes");

    sdk = android.os.Build.VERSION.SDK_INT;

    tvMatch = (TextView) rootView.findViewById(R.id.tvCompare);
    inputEdit = (EditText) rootView.findViewById(R.id.edInput);
    inputEdit.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            tvMatch.setText("");
            tvMatch.setVisibility(View.GONE);
        }
    });
    compareEdit = (EditText) rootView.findViewById(R.id.edCompare);
    compareEdit.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            tvMatch.setText("");
            tvMatch.setVisibility(View.GONE);
        }
    });

    return rootView;
}

From source file:de.msal.shoutemo.adapters.ChatAdapter.java

@Override
public ChatAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LayoutInflater inflater = LayoutInflater.from(parent.getContext());
    View itemView;//  w ww  .  jav a  2s  .  c  o m

    if (viewType == Message.Type.SHOUT.ordinal()) {
        itemView = inflater.inflate(R.layout.listrow_shout, parent, false);
        return new ViewHolder(itemView, Message.Type.SHOUT);
    } else {
        itemView = inflater.inflate(R.layout.listrow_event, parent, false);
        return new ViewHolder(itemView, Message.Type.GLOBAL);
    }
}

From source file:com.fastbootmobile.encore.app.tv.CardPresenter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent) {
    sDefaultBackgroundColor = parent.getResources().getColor(R.color.primary_dark);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.primary);

    mContext = parent.getContext();
    mDefaultCardImage = mContext.getResources().getDrawable(R.drawable.album_placeholder);

    ImageCardView cardView = new ImageCardView(mContext) {
        @Override//  w ww .j a  v a 2 s. c  o  m
        public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
        }
    };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);

    return new ViewHolder(cardView);
}

From source file:ca.ualberta.cs.drivr.RequestsListAdapter.java

/**
 * Inflates the view.//www  . ja v  a 2  s  .  co m
 * @param parent
 * @param viewType
 * @return
 */
@Override
public RequestsListAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    Context context = parent.getContext();
    LayoutInflater inflater = LayoutInflater.from(context);

    // Inflate the custom layout
    View requestView = inflater.inflate(R.layout.item_request, parent, false);

    // Return a new holder instance
    ViewHolder viewHolder = new ViewHolder(requestView);
    return viewHolder;
}

From source file:com.keylesspalace.tusky.NotificationsAdapter.java

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    switch (viewType) {
    default:/*from   w  w  w  . ja v a 2s  .c  om*/
    case VIEW_TYPE_MENTION: {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_status, parent, false);
        return new StatusViewHolder(view);
    }
    case VIEW_TYPE_FOOTER: {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer, parent, false);
        return new FooterViewHolder(view);
    }
    case VIEW_TYPE_STATUS_NOTIFICATION: {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_status_notification, parent,
                false);
        return new StatusNotificationViewHolder(view);
    }
    case VIEW_TYPE_FOLLOW: {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_follow, parent, false);
        return new FollowViewHolder(view);
    }
    }
}

From source file:com.sakisds.icymonitor.fragments.NotificationsFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ViewGroup viewGroup = (ViewGroup) view;

    mPullToRefreshLayout = new PullToRefreshLayout(viewGroup.getContext());

    ActionBarPullToRefresh.from(getActivity()).insertLayoutInto(viewGroup)
            .theseChildrenArePullable(android.R.id.list, android.R.id.empty).listener(this)
            .setup(mPullToRefreshLayout);

    // Refresh fragment data
    refreshData();//from  www . java  2 s. c  o m

    // List view properties
    getListView().setLongClickable(true);
    getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
    getListView().setMultiChoiceModeListener(new MultipleChoiceListener());
}

From source file:com.zzisoo.toylibrary.adapter.ToyListAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    // Create a new view.
    View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.toy_item_view, viewGroup, false);

    //setItemSize(v);
    TextView tvLoading = (TextView) (v.findViewById(R.id.tvLoading));
    tvLoading.setTypeface(Typefaces.get(v.getContext(), "Satisfy-Regular.ttf"));

    return new ViewHolder(v);
}

From source file:android.support.v17.leanback.app.BrandedSupportFragment.java

/**
 * Called by {@link #installTitleView(LayoutInflater, ViewGroup, Bundle)} to inflate
 * title view.  Default implementation uses layout file lb_browse_title.
 * Subclass may override and use its own layout, the layout must have a descendant with id
 * browse_title_group that implements {@link TitleViewAdapter.Provider}. Subclass may return
 * null if no title is needed.//from  ww  w  .  j  a  va  2  s.c  o  m
 *
 * @param inflater           The LayoutInflater object that can be used to inflate
 *                           any views in the fragment,
 * @param parent             Parent of title view.
 * @param savedInstanceState If non-null, this fragment is being re-constructed
 *                           from a previous saved state as given here.
 * @return Title view which must have a descendant with id browse_title_group that implements
 *         {@link TitleViewAdapter.Provider}, or null for no title view.
 */
public View onInflateTitleView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
    TypedValue typedValue = new TypedValue();
    boolean found = parent.getContext().getTheme().resolveAttribute(R.attr.browseTitleViewLayout, typedValue,
            true);
    return inflater.inflate(found ? typedValue.resourceId : R.layout.lb_browse_title, parent, false);
}

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

/**
 * {@inheritDoc}/*from w ww  .j  av  a2 s .  c  o  m*/
 */
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    final Context ctx = parent.getContext();
    assert ctx != null;
    final ProviderAggregator aggregator = ProviderAggregator.getDefault();

    View root = convertView;
    if (convertView == null) {
        // Recycle the existing view
        LayoutInflater inflater = LayoutInflater.from(ctx);
        root = inflater.inflate(R.layout.item_playlist_view, parent, false);
        assert root != null;

        ViewHolder holder = new ViewHolder();
        holder.tvTitle = (TextView) root.findViewById(R.id.tvTitle);
        holder.tvArtist = (TextView) root.findViewById(R.id.tvArtist);
        holder.tvDuration = (TextView) root.findViewById(R.id.tvDuration);
        holder.ivOverflow = (ImageView) root.findViewById(R.id.ivOverflow);
        holder.ivAlbumArt = (AlbumArtImageView) root.findViewById(R.id.ivAlbumArt);
        holder.ivOffline = (ImageView) root.findViewById(R.id.ivOffline);
        holder.vCurrentIndicator = root.findViewById(R.id.currentSongIndicator);
        holder.vRoot = (ViewGroup) root;

        holder.vRoot.setLayerType(View.LAYER_TYPE_HARDWARE, null);

        if (mShowAlbumArt) {
            // Fixup some style stuff
            holder.ivAlbumArt.setVisibility(View.VISIBLE);
        } else {
            holder.ivAlbumArt.setVisibility(View.GONE);
        }

        holder.ivOverflow.setOnClickListener(mOverflowClickListener);
        holder.ivOverflow.setTag(holder);
        root.setTag(holder);
    }
    final Song song = getItem(position);
    final ViewHolder tag = (ViewHolder) root.getTag();

    // Update tag
    tag.position = position;
    tag.song = song;
    root.setTag(tag);

    // Fill fields
    if (song != null && song.isLoaded()) {
        tag.tvTitle.setText(song.getTitle());
        tag.tvDuration.setText(Utils.formatTrackLength(song.getDuration()));

        if (mShowAlbumArt) {
            tag.ivAlbumArt.loadArtForSong(song);
        }

        if (song.getArtist() == null) {
            tag.tvArtist.setText(null);
        } else {
            Artist artist = aggregator.retrieveArtist(song.getArtist(), song.getProvider());
            if (artist != null) {
                tag.tvArtist.setText(artist.getName());
            } else {
                tag.tvArtist.setText("...");
            }
        }
    } else {
        tag.tvTitle.setText("...");
        tag.tvDuration.setText("...");
        tag.tvArtist.setText("...");

        if (mShowAlbumArt) {
            tag.ivAlbumArt.setDefaultArt();
        }
    }

    // Set current song indicator
    tag.vCurrentIndicator.setVisibility(View.INVISIBLE);

    Song currentSong = PlaybackProxy.getCurrentTrack();
    if (currentSong != null && currentSong.equals(tag.song)) {
        tag.vCurrentIndicator.setVisibility(View.VISIBLE);
    }

    if (song != null) {
        // Set alpha based on offline availability and mode
        if ((aggregator.isOfflineMode() && song.getOfflineStatus() != BoundEntity.OFFLINE_STATUS_READY)
                || !song.isAvailable()) {
            Utils.setChildrenAlpha(tag.vRoot,
                    Float.parseFloat(ctx.getResources().getString(R.string.unavailable_track_alpha)));
        } else {
            Utils.setChildrenAlpha(tag.vRoot, 1.0f);
        }

        // Show offline indicator in any case
        tag.ivOffline.setVisibility(View.VISIBLE);
        tag.ivOffline.clearAnimation();
        if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_READY) {
            tag.ivOffline.setImageResource(R.drawable.ic_track_downloaded);
        } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_DOWNLOADING) {
            tag.ivOffline.setImageResource(R.drawable.ic_sync_in_progress);

            if (mSyncRotateAnimation == null && tag.ivOffline.getMeasuredWidth() != 0) {
                mSyncRotateAnimation = new RotateAnimation(0, -360, tag.ivOffline.getMeasuredWidth() / 2.0f,
                        tag.ivOffline.getMeasuredHeight() / 2.0f);
                mSyncRotateAnimation.setRepeatMode(Animation.INFINITE);
                mSyncRotateAnimation.setRepeatCount(Animation.INFINITE);
                mSyncRotateAnimation.setDuration(1000);
                mSyncRotateAnimation.setInterpolator(new LinearInterpolator());
            }

            if (mSyncRotateAnimation != null) {
                tag.ivOffline.startAnimation(mSyncRotateAnimation);
            }
        } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_ERROR) {
            tag.ivOffline.setImageResource(R.drawable.ic_sync_problem);
        } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_PENDING) {
            tag.ivOffline.setImageResource(R.drawable.ic_track_download_pending);
        } else {
            tag.ivOffline.setVisibility(View.GONE);
        }
    }

    return root;
}