android.support.v7.widget.CardView Java Examples

The following examples show how to use android.support.v7.widget.CardView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PlanActivity.java    From Dictionary with Apache License 2.0 6 votes vote down vote up
@Override
public View getView(int position, View v, ViewGroup parent) {
    ViewHolder vh = null;

    if (v == null) {
        v = View.inflate(PlanActivity.this, R.layout.item_plan, null);
        vh = new ViewHolder();
        vh.cv = (CardView) v.findViewById(R.id.item_plan_cv);
        vh.name = (TextView) v.findViewById(R.id.item_plan_name);
        vh.des = (TextView) v.findViewById(R.id.item_plan_des);
        v.setTag(vh);
    } else {
        vh = (ViewHolder) v.getTag();
    }

    int ranColor = 0xff000000 | random.nextInt(0x00ffffff);
    vh.cv.setCardBackgroundColor(ranColor);
    vh.name.setText(plans.get(position));
    vh.des.setText("共" + counts.get(position).getTotal() + "个,已完成" + counts.get(position).getDone() + "个");
    return v;
}
 
Example #2
Source File: PortfolioActivity.java    From EasyPortfolio with Apache License 2.0 6 votes vote down vote up
private void init() {

        if (getSupportActionBar() != null)
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(linearLayoutManager);

        githubContainer = (FrameLayout) findViewById(R.id.githubContainer);
        playStoreContainer = (FrameLayout) findViewById(R.id.playStoreContainer);
        linkedInContainer = (FrameLayout) findViewById(R.id.linkedInContainer);
        socialContainer = (CardView) findViewById(R.id.socialContainer);

        githubContainer.setOnClickListener(this);
        playStoreContainer.setOnClickListener(this);
        linkedInContainer.setOnClickListener(this);

    }
 
Example #3
Source File: LoginRegistrationActivity.java    From Password-Storage with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Fabric.with(this, new Crashlytics());
    setContentView(R.layout.activity_login_registration);
    login = (Button) findViewById(R.id.btn_login);
    register = (Button) findViewById(R.id.btn_register);
    cardView=(CardView)findViewById(R.id.layout2);
    splashActivity=new SplashActivity();

    login.setOnClickListener(this);
    register.setOnClickListener(this);
    b=splashActivity.containsPass("password");

    if(b==true)
    {
        register.setVisibility(View.INVISIBLE);
        cardView.setVisibility(View.INVISIBLE);
    }
}
 
Example #4
Source File: SwipeableCard.java    From SwipeableCard with Apache License 2.0 6 votes vote down vote up
/**
 * Animation Card for down animation, please do not modify this.
 * @param card card view instance
 * @param toolbar toolbar instance
 */
@Override
public void animationCardDown(@NotNull final CardView card, @NotNull final Toolbar toolbar, final long duration){
    new CountDownTimer(1, 1) {
        public void onTick(long millisUntilFinished) {
        }

        public void onFinish() {
            card.animate()
                    .translationY(height - ((int)(toolbar.getHeight() * 1.7)))
                    .setDuration(duration).start();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                fab.animate()
                        .translationY((height - ((int) (toolbar.getHeight() * 1.7))) + card.getHeight() - (fab.getHeight() - fab.getHeight()/4))
                        .setDuration(duration).start();
            }else{
                fab.animate()
                        .translationY((height - ((int) (toolbar.getHeight() * 1.7))) + card.getHeight() - (fab.getHeight() - fab.getHeight()/3))
                        .setDuration(duration).start();
            }
        }
    }.start();
}
 
Example #5
Source File: VideoAdapter.java    From JianDan_OkHttp with Apache License 2.0 6 votes vote down vote up
public VideoViewHolder(View contentView) {
    super(contentView);

    img = (ImageView) contentView.findViewById(R.id.img);
    tv_title = (TextView) contentView.findViewById(R.id.tv_title);
    tv_like = (TextView) contentView.findViewById(R.id.tv_like);
    tv_unlike = (TextView) contentView.findViewById(R.id.tv_unlike);

    tv_comment_count = (TextView) contentView.findViewById(R.id.tv_comment_count);
    tv_un_support_des = (TextView) contentView.findViewById(R.id.tv_unsupport_des);
    tv_support_des = (TextView) contentView.findViewById(R.id.tv_support_des);

    img_share = (ImageView) contentView.findViewById(R.id.img_share);
    ll_comment = (LinearLayout) contentView.findViewById(R.id.ll_comment);
    card = (CardView) contentView.findViewById(R.id.card);
}
 
Example #6
Source File: HivesAdapter.java    From go-bees with GNU General Public License v3.0 6 votes vote down vote up
HivesViewHolder(View itemView) {
    super(itemView);

    // Get views
    viewHolder = itemView;
    card = (CardView) itemView.findViewById(R.id.card);
    hiveName = (TextView) itemView.findViewById(R.id.hive_name);
    lastRevision = (TextView) itemView.findViewById(R.id.last_revision);
    moreIcon = (ImageView) itemView.findViewById(R.id.more_icon);

    // Set listeners
    viewHolder.setOnClickListener(this);
    viewHolder.setOnCreateContextMenuListener(this);
    moreIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Open Menu
            listener.onOpenMenuClick(viewHolder);
        }
    });

    background = card.getBackground();
}
 
Example #7
Source File: TimeCatActivity.java    From timecat with Apache License 2.0 6 votes vote down vote up
private void initContentView(boolean fullScreen) {
    alpha = SPHelper.getInt(Constants.TIMECAT_ALPHA, 100);
    lastPickedColor = SPHelper.getInt(Constants.TIMECAT_DIY_BG_COLOR, Color.parseColor("#03A9F4"));
    int value = (int) ((alpha / 100.0f) * 255);

    RegexUtil.refreshSymbolSelection();
    if (fullScreen) {
        setTheme(R.style.PreSettingTheme);
        setContentView(R.layout.activity_time_cat);
        getWindow().setBackgroundDrawable(getResources().getDrawable(R.drawable.timecat_activity_window_full));
        getWindow().getDecorView().setBackgroundColor(Color.argb(value, Color.red(lastPickedColor), Color.green(lastPickedColor), Color.blue(lastPickedColor)));
        showAppList4OneStep();
    } else {
        CardView cardView = new CardView(this);
        cardView.setRadius(ViewUtil.dp2px(10));
        cardView.setCardBackgroundColor(Color.argb(value, Color.red(lastPickedColor), Color.green(lastPickedColor), Color.blue(lastPickedColor)));
        View view = LayoutInflater.from(this).inflate(R.layout.activity_time_cat, null, false);
        cardView.addView(view);

        getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.trans));
        setContentView(cardView);
    }
}
 
Example #8
Source File: HistoryActivity.java    From timecat with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    CardView cardView = new CardView(this);
    cardView.setRadius(ViewUtil.dp2px(10));
    View view = LayoutInflater.from(this).inflate(R.layout.activity_history, null, false);
    cardView.addView(view);
    getWindow().getDecorView().setBackgroundColor(getResources().getColor(R.color.trans));
    setContentView(cardView);

    //<功能归类分区方法,必须调用>-----------------------------------------------------------------
    initView();
    initData();
    initEvent();
    //</功能归类分区方法,必须调用>----------------------------------------------------------------
}
 
Example #9
Source File: RecordingsAdapter.java    From go-bees with GNU General Public License v3.0 6 votes vote down vote up
RecordingViewHolder(View itemView) {
    super(itemView);

    // Get views
    viewHolder = itemView;
    card = (CardView) itemView.findViewById(R.id.card);
    recordingDate = (TextView) itemView.findViewById(R.id.recording_date);
    chart = (LineChart) itemView.findViewById(R.id.chart);
    moreIcon = (ImageView) itemView.findViewById(R.id.more_icon);

    // Set listeners
    viewHolder.setOnClickListener(this);
    viewHolder.setOnCreateContextMenuListener(this);
    moreIcon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // Open Menu
            listener.onOpenMenuClick(viewHolder);
        }
    });

    background = card.getBackground();
    formatter = new SimpleDateFormat(
            context.getString(R.string.hive_recordings_date_format), Locale.getDefault());
}
 
Example #10
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    fab.setSelected(false);
    removeFabMenuItems();

    if (menuListener != null) {
        if (v == this || v == touchGuard) {
            menuListener.onMenuClosed();
        } else if (v instanceof FloatingActionButton) {
            menuListener.onMenuItemSelected(fabMenuItemMap.get(v));
        } else if (v instanceof CardView) {
            menuListener.onMenuItemSelected(cardViewMenuItemMap.get(v));
        }
    } else {
        Log.d(TAG, "You haven't provided a MenuListener.");
    }
}
 
Example #11
Source File: PlaygroundNavigationCardRow.java    From MaterialDesignSupport with MIT License 6 votes vote down vote up
private ViewHolder createViewHolder(View contentView, int position) {
    ViewHolder viewHolder = new ViewHolder();
    if (contentView == null) {
        return viewHolder;
    }

    viewHolder.cardView = (CardView) contentView.findViewById(R.id.card_view);
    // viewHolder.cardView.setViewName("card:view:" + position);
    viewHolder.titleText = (TextView) contentView.findViewById(R.id.navigation_title_text);
    // viewHolder.titleText.setViewName("nav:title:" + position);
    viewHolder.infoText = (TextView) contentView.findViewById(R.id.navigation_info_text);
    // viewHolder.infoText.setViewName("nav:info:" + position);

    contentView.setTag(viewHolder);

    return viewHolder;
}
 
Example #12
Source File: ParticipantItemPresenter.java    From skype-android-app-sdk-samples with MIT License 6 votes vote down vote up
public ParticipantItemPresenter(CardView view, Conversation conversation) {
    super(view);
    this.cardView = view;
    this.conversation = conversation;
    this.propertyChangeListener = new ParticipantItemPropertyChangeListener();
    this.participant = null;

    this.participantDisplayNameTextView = (TextView)this.cardView.findViewById(
            R.id.participantDisplayId);

    this.participantOnHoldTextView = (TextView)this.cardView.findViewById(
            R.id.participantHoldId);

    this.participantMuteButton = (Button)this.cardView.findViewById(R.id.participantMuteId);
    this.participantMuteButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onParticipantMuteButtonClicked(v);
        }
    });


    this.conversation.getSelfParticipant().addOnPropertyChangedCallback(
            this.propertyChangeListener);
    this.setLocalParticipantLeader();
}
 
Example #13
Source File: CardPagerAdapter.java    From ViewPagerCards with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(container.getContext())
            .inflate(R.layout.adapter, container, false);
    container.addView(view);
    bind(mData.get(position), view);
    CardView cardView = (CardView) view.findViewById(R.id.cardView);

    if (mBaseElevation == 0) {
        mBaseElevation = cardView.getCardElevation();
    }

    cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
    mViews.set(position, cardView);
    return view;
}
 
Example #14
Source File: QueueActivity.java    From PainlessMusicPlayer with Apache License 2.0 6 votes vote down vote up
private void onEnterTransitionFinished() {
    if (fab.getScaleX() != 1f) {
        fab.animate().scaleX(1f).scaleY(1f).setDuration(mShortAnimTime).start();
    }
    if (albumArtDim.getAlpha() != 1f) {
        albumArtDim.animate().alpha(1f).setDuration(mShortAnimTime).start();
    }

    final CardView cardView = findViewById(R.id.cardView);
    if (cardView != null && cardView.getVisibility() != View.VISIBLE) {
        if (TransitionUtils.supportsActivityTransitions() && hasCoverTransition) {
            cardView.setTranslationY(SlideFromBottomHelper.getStartTranslation(cardView));
            cardView.setVisibility(View.VISIBLE);
            SlideFromBottomHelper.createAnimator(cardView).setDuration(mMediumAnimTime).start();
        } else {
            cardView.setVisibility(View.VISIBLE);
        }
    }
}
 
Example #15
Source File: CardPagerAdapter.java    From ViewPagerCards with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = LayoutInflater.from(container.getContext())
            .inflate(R.layout.adapter, container, false);
    container.addView(view);
    bind(mData.get(position), view);
    CardView cardView = (CardView) view.findViewById(R.id.cardView);

    if (mBaseElevation == 0) {
        mBaseElevation = cardView.getCardElevation();
    }

    cardView.setMaxCardElevation(mBaseElevation * MAX_ELEVATION_FACTOR);
    mViews.set(position, cardView);
    return view;
}
 
Example #16
Source File: RecyclerAdapter.java    From AndroidOperationQueue with MIT License 5 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);

    image = (ImageView)itemView.findViewById(R.id.image);
    line  = itemView.findViewById(R.id.line);
    cardView = (CardView)itemView.findViewById(R.id.cardView);
    progressBar = (ProgressBar)itemView.findViewById(R.id.progressBar);
}
 
Example #17
Source File: CellViewHolder.java    From MaterialLeanBack with Apache License 2.0 5 votes vote down vote up
public CellViewHolder(View itemView, int row, MaterialLeanBack.Adapter adapter, MaterialLeanBackSettings settings) {
    super(itemView);
    this.row = row;
    this.adapter = adapter;
    this.settings = settings;

    cardView = (CardView) itemView.findViewById(R.id.cardView);
    this.viewHolder = adapter.onCreateViewHolder(cardView, row);
    this.viewHolder.row = row;
    cardView.addView(viewHolder.itemView);
}
 
Example #18
Source File: TripFrame.java    From kute with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    //Connect basic views
    excuse_text_layout=(RelativeLayout) v.findViewById(R.id.excuseTextLayout);
    excuse_text=(TextView)v.findViewById(R.id.excuseText);
    main_card=(CardView)v.findViewById(R.id.mainCard);
    main_card.setOnClickListener(this);
}
 
Example #19
Source File: LauncherAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
ViewHolder(View itemView, int viewType) {
    super(itemView);
    if (viewType == TYPE_HEADER) {
        name = itemView.findViewById(R.id.name);
        holderId = TYPE_HEADER;
    } else if (viewType == TYPE_CONTENT) {
        icon = itemView.findViewById(R.id.icon);
        name = itemView.findViewById(R.id.name);
        container = itemView.findViewById(R.id.container);

        CardView card = itemView.findViewById(R.id.card);
        if (CandyBarApplication.getConfiguration().getApplyGrid() == CandyBarApplication.GridStyle.FLAT) {
            if (card.getLayoutParams() instanceof GridLayoutManager.LayoutParams) {
                card.setRadius(0f);
                card.setUseCompatPadding(false);
                int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
                GridLayoutManager.LayoutParams params = (GridLayoutManager.LayoutParams) card.getLayoutParams();
                params.setMargins(0, 0, margin, margin);

                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                    params.setMarginEnd(margin);
                }
            }
        }
        if (!Preferences.get(mContext).isCardShadowEnabled()) {
            if (card != null) card.setCardElevation(0);
        }

        holderId = TYPE_CONTENT;

        container.setOnClickListener(this);
    }
}
 
Example #20
Source File: NiboPlacesAutoCompleteSearchView.java    From Nibo with MIT License 5 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    final int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    int totalHeight = 0;
    int searchCardWidth;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; ++i) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            if (i == 0 && child instanceof CardView) {
                CardView searchCard = (CardView) child;
                int horizontalPadding = (int) Math.ceil(calculateHorizontalPadding(searchCard));
                int verticalPadding = (int) Math.ceil(calculateVerticalPadding(searchCard));
                // searchCardWidth = widthSize - 2 * mCardVisiblePadding + horizontalPadding * 2;
                int searchCardLeft = mCardHorizontalPadding - horizontalPadding;
                // searchCardTop = mCardVisiblePadding - verticalPadding;
                searchCardWidth = widthSize - searchCardLeft * 2;
                int cardWidthSpec = MeasureSpec.makeMeasureSpec(searchCardWidth, MeasureSpec.EXACTLY);
                // int cardHeightSpec = MeasureSpec.makeMeasureSpec(searchCardHeight, MeasureSpec.EXACTLY);
                measureChild(child, cardWidthSpec, heightMeasureSpec);
                int childMeasuredHeight = child.getMeasuredHeight();
                int childMeasuredWidth = child.getMeasuredWidth();
                int childHeight = childMeasuredHeight - verticalPadding * 2;
                totalHeight = totalHeight + childHeight + mCardVerticalPadding * 2;
            }
        }
    }
    if (totalHeight < mCustomToolbarHeight)
        totalHeight = mCustomToolbarHeight;
    setMeasuredDimension(widthSize, totalHeight);
}
 
Example #21
Source File: NotificationAdapter.java    From faveo-helpdesk-android-app with Open Software License 3.0 5 votes vote down vote up
CardViewHolder(View itemView) {
    super(itemView);
    card = (CardView) itemView.findViewById(R.id.notification_cardview);
    textSub = (TextView) itemView.findViewById(R.id.noti_subject);
    textNotificationtime = (RelativeTimeTextView) itemView.findViewById(R.id.noti_time);
    roundedImageViewProfilePic = (AvatarView) itemView.findViewById(R.id.dthumbnail);
}
 
Example #22
Source File: TopicListAdapter.java    From Readhub with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View convertView) {
    super(convertView);
    title = (TextView) convertView.findViewById(R.id.title);
    summary = (TextView) convertView.findViewById(R.id.summary);
    more = (TextView) convertView.findViewById(R.id.more);
    cardView = (CardView) convertView.findViewById(R.id.cardView);
    waitView = (ImageView) convertView.findViewById(R.id.iv_wait);
}
 
Example #23
Source File: MoviesAdapter.java    From FabulousFilter with Apache License 2.0 5 votes vote down vote up
public MovieViewHolder(View x) {
    super(x);
    iv_cover = (ImageView) x.findViewById(R.id.iv_cover);
    tv_title = (TextView) x.findViewById(R.id.tv_title);
    tv_genre = (TextView) x.findViewById(R.id.tv_genre);
    tv_rating = (TextView) x.findViewById(R.id.tv_rating);
    tv_year = (TextView) x.findViewById(R.id.tv_year);
    tv_quality = (TextView) x.findViewById(R.id.tv_quality);
    card_view = (CardView) x.findViewById(R.id.card_view);
}
 
Example #24
Source File: PersistentSearchView.java    From PersistentSearchView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
    final int heightSize = MeasureSpec.getSize(heightMeasureSpec);

    int totalHeight = 0;
    int searchCardWidth;
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; ++i) {
        final View child = getChildAt(i);
        if (child.getVisibility() != GONE) {
            if (i == 0 && child instanceof CardView) {
                CardView searchCard = (CardView) child;
                int horizontalPadding = (int) Math.ceil(calculateHorizontalPadding(searchCard));
                int verticalPadding = (int) Math.ceil(calculateVerticalPadding(searchCard));
                // searchCardWidth = widthSize - 2 * mCardVisiblePadding + horizontalPadding * 2;
                int searchCardLeft = mCardHorizontalPadding - horizontalPadding;
                // searchCardTop = mCardVisiblePadding - verticalPadding;
                searchCardWidth = widthSize - searchCardLeft * 2;
                int cardWidthSpec = MeasureSpec.makeMeasureSpec(searchCardWidth, MeasureSpec.EXACTLY);
                // int cardHeightSpec = MeasureSpec.makeMeasureSpec(searchCardHeight, MeasureSpec.EXACTLY);
                measureChild(child, cardWidthSpec, heightMeasureSpec);
                int childMeasuredHeight = child.getMeasuredHeight();
                int childMeasuredWidth = child.getMeasuredWidth();
                int childHeight = childMeasuredHeight - verticalPadding * 2;
                totalHeight = totalHeight + childHeight + mCardVerticalPadding * 2;
            }
        }
    }
    if(totalHeight < mCustomToolbarHeight)
        totalHeight = mCustomToolbarHeight;
    setMeasuredDimension(widthSize, totalHeight);
}
 
Example #25
Source File: NewsAdapter.java    From MyHearts with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);
    mNewsPic = (ImageView) itemView.findViewById(R.id.news_pic);
    mNewsTitle = (TextView) itemView.findViewById(R.id.news_title);
    mNewsViewCount = (TextView) itemView.findViewById(R.id.news_count_see);
    mNewsPublishTime = (TextView) itemView.findViewById(R.id.publish_time);
    mNewsSubTitle = (TextView) itemView.findViewById(R.id.news_sub_title);
    mCardView = (CardView) itemView.findViewById(R.id.card_view);
}
 
Example #26
Source File: MovieLibraryFragment.java    From Mizuu with Apache License 2.0 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup container) {
    final MediumMovie movie = getItem(position);

    CoverItem holder;
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.grid_cover, container, false);
        holder = new CoverItem();

        holder.cardview = (CardView) convertView.findViewById(R.id.card);
        holder.cover = (ImageView) convertView.findViewById(R.id.cover);
        holder.text = (TextView) convertView.findViewById(R.id.text);
        holder.text.setTypeface(mTypeface);

        convertView.setTag(holder);
    } else {
        holder = (CoverItem) convertView.getTag();
    }

    if (!mShowTitles) {
        holder.text.setVisibility(View.GONE);
    } else {
        holder.text.setVisibility(View.VISIBLE);
        holder.text.setText(mMovieLoader.getType() == MovieLibraryType.COLLECTIONS ?
                movie.getCollection() : movie.getTitle());
    }

    holder.cover.setImageResource(R.color.card_background_dark);

    mPicasso.load(mMovieLoader.getType() == MovieLibraryType.COLLECTIONS ?
            movie.getCollectionPoster() : movie.getThumbnail()).placeholder(R.drawable.bg).config(mConfig).into(holder);

    if (mChecked.contains(position)) {
        holder.cardview.setForeground(getResources().getDrawable(R.drawable.checked_foreground_drawable));
    } else {
        holder.cardview.setForeground(null);
    }

    return convertView;
}
 
Example #27
Source File: VideoAdapter.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
@Override
public VideoAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
                                                  int viewType) {
    // create a new view
    CardView v = (CardView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.video_card, parent, false);
    // set the view's size, margins, paddings and layout parameters
    return new ViewHolder(v);
}
 
Example #28
Source File: StationListAdapter.java    From monkeyboard-radio-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public StationCard onCreateViewHolder(ViewGroup parent, int viewType) {
    // create a new view
    CardView stationCardView = (CardView) LayoutInflater.from(parent.getContext())
            .inflate(R.layout.station_card_layout, parent, false);
    return new StationCard(stationCardView);
}
 
Example #29
Source File: HomeAdapter.java    From candybar-library with Apache License 2.0 5 votes vote down vote up
IconRequestViewHolder(View itemView) {
    super(itemView);
    title = itemView.findViewById(R.id.title);
    installedApps = itemView.findViewById(R.id.installed_apps);
    missedApps = itemView.findViewById(R.id.missed_apps);
    themedApps = itemView.findViewById(R.id.themed_apps);
    progress = itemView.findViewById(R.id.progress);
    container = itemView.findViewById(R.id.container);

    CardView card = itemView.findViewById(R.id.card);
    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        if (card.getLayoutParams() instanceof StaggeredGridLayoutManager.LayoutParams) {
            card.setRadius(0f);
            card.setUseCompatPadding(false);
            int margin = mContext.getResources().getDimensionPixelSize(R.dimen.card_margin);
            StaggeredGridLayoutManager.LayoutParams params = (StaggeredGridLayoutManager.LayoutParams) card.getLayoutParams();
            params.setMargins(0, 0, margin, margin);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                params.setMarginEnd(margin);
            }
        }
    }

    if (!Preferences.get(mContext).isCardShadowEnabled()) {
        card.setCardElevation(0);
    }

    int color = ColorHelper.getAttributeColor(mContext, android.R.attr.textColorPrimary);
    title.setCompoundDrawablesWithIntrinsicBounds(DrawableHelper.getTintedDrawable(
            mContext, R.drawable.ic_toolbar_icon_request, color), null, null, null);

    int accent = ColorHelper.getAttributeColor(mContext, R.attr.colorAccent);
    progress.getProgressDrawable().setColorFilter(accent, PorterDuff.Mode.SRC_IN);

    container.setOnClickListener(this);
}
 
Example #30
Source File: NiboPlacesAutoCompleteSearchView.java    From Nibo with MIT License 5 votes vote down vote up
static float calculateVerticalPadding(CardView cardView) {
    float maxShadowSize = cardView.getMaxCardElevation();
    float cornerRadius = cardView.getRadius();
    boolean addPaddingForCorners = cardView.getPreventCornerOverlap();

    if (addPaddingForCorners) {
        return (float) (maxShadowSize * 1.5f + (1 - COS_45) * cornerRadius);
    } else {
        return maxShadowSize * 1.5f;
    }
}