Search in sources :

Example 1 with FavoriteAnime

use of tr.bcxip.hummingbird.api.objects.FavoriteAnime in project Hummingbird-for-Android by xiprox.

the class FavoriteAnimeAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View rootView = inflater.inflate(R.layout.item_favorite_grid, null);
    FavoriteAnime fav = mItems.get(position);
    final ImageView mCover = (ImageView) rootView.findViewById(R.id.item_favorite_cover);
    final TextView mTitle = (TextView) rootView.findViewById(R.id.item_favorite_title);
    ViewFlipper mFlipper = (ViewFlipper) rootView.findViewById(R.id.item_favorite_flipper);
    Picasso.with(context).load(fav.getCoverImage()).into(mCover, new Callback() {

        @Override
        public void onSuccess() {
            int darkMutedColor;
            Bitmap bitmap = ((BitmapDrawable) mCover.getDrawable()).getBitmap();
            darkMutedColor = Palette.generate(bitmap).getDarkMutedSwatch().getRgb();
            mTitle.setBackgroundDrawable(new ColorDrawable(darkMutedColor));
        }

        @Override
        public void onError() {
        }
    });
    mTitle.setText(fav.getTitle());
    if (mFlipper.getDisplayedChild() == 0)
        mFlipper.showNext();
    return rootView;
}
Also used : ViewFlipper(android.widget.ViewFlipper) Bitmap(android.graphics.Bitmap) Callback(com.squareup.picasso.Callback) ColorDrawable(android.graphics.drawable.ColorDrawable) FavoriteAnime(tr.bcxip.hummingbird.api.objects.FavoriteAnime) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

Bitmap (android.graphics.Bitmap)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 ViewFlipper (android.widget.ViewFlipper)1 Callback (com.squareup.picasso.Callback)1 FavoriteAnime (tr.bcxip.hummingbird.api.objects.FavoriteAnime)1