Search in sources :

Example 31 with CardViewNative

use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.

the class TopColoredCard method setupInnerViewElements.

@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
    //Use the title in super method
    super.setupInnerViewElements(parent, view);
    //Add a simple subtitle
    if (view != null) {
        ViewHolder holder = (ViewHolder) view.getTag();
        if (holder == null) {
            holder = new ViewHolder();
            holder.mLinearLayoutContainer = (LinearLayout) view.findViewById(R.id.card_main_inner_topcolored_layout);
            holder.mTitleView = (TextView) view.findViewById(R.id.card_main_inner_topcolored_title);
            holder.mSubTitleView = (TextView) view.findViewById(R.id.card_main_inner_topcolored_subtitle);
            View viewStub = ((View) getCardView()).findViewById(R.id.card_halfcolored_secondhalf);
            if (viewStub != null) {
                ((ViewStub) viewStub).setLayoutResource(mSecondHalfViewStubLayoutId);
                ((ViewStub) viewStub).inflate();
                holder.mSecondHalfView = ((View) getCardView()).findViewById(R.id.card_halfcolored_secondhalf_layout);
            }
            view.setTag(holder);
        }
        //Color the LinearLayout
        if (holder.mLinearLayoutContainer != null && mColorResourceId != 0) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
                holder.mLinearLayoutContainer.setBackgroundColor(mContext.getResources().getColor(mColorResourceId));
            else {
                ((CardViewNative) (getCardView())).setPreventCornerOverlap(false);
                GradientDrawable shapeDrawable = (GradientDrawable) (holder.mLinearLayoutContainer.getBackground());
                shapeDrawable.setColor(mContext.getResources().getColor(mColorResourceId));
            }
        }
        //Set the text elements
        buildTitleOverColor(holder);
        buildSubTitleOverColor(holder);
        //Set the second half area
        if (holder.mSecondHalfView != null && mSecondHalfViewStubLayoutId != 0) {
            setupInnerViewElementsSecondHalf(holder.mSecondHalfView);
        }
    }
}
Also used : ViewStub(android.view.ViewStub) TextView(android.widget.TextView) View(android.view.View) GradientDrawable(android.graphics.drawable.GradientDrawable) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 32 with CardViewNative

use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.

the class NativeMaterialCardFragment method init_largeimage_text.

/**
     * Builds a Material Card with Large Image and Text
     */
private void init_largeimage_text() {
    ArrayList<BaseSupplementalAction> actions = new ArrayList<BaseSupplementalAction>();
    // Set supplemental actions
    TextSupplementalAction t1 = new TextSupplementalAction(getActivity(), R.id.text1);
    t1.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {

        @Override
        public void onClick(Card card, View view) {
            Toast.makeText(getActivity(), " Click on Text SHARE ", Toast.LENGTH_SHORT).show();
        }
    });
    actions.add(t1);
    TextSupplementalAction t2 = new TextSupplementalAction(getActivity(), R.id.text2);
    t2.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {

        @Override
        public void onClick(Card card, View view) {
            Toast.makeText(getActivity(), " Click on Text LEARN ", Toast.LENGTH_SHORT).show();
        }
    });
    actions.add(t2);
    //Create a Card, set the title over the image and set the thumbnail
    MaterialLargeImageCard card = MaterialLargeImageCard.with(getActivity()).setTextOverImage("Italian Beaches").setTitle("This is my favorite local beach").setSubTitle("A wonderful place").useDrawableId(R.drawable.sea).setupSupplementalActions(R.layout.carddemo_native_material_supplemental_actions_large, actions).build();
    card.setOnClickListener(new Card.OnCardClickListener() {

        @Override
        public void onClick(Card card, View view) {
            Toast.makeText(getActivity(), " Click on ActionArea ", Toast.LENGTH_SHORT).show();
        }
    });
    //Set card in the CardViewNative
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_largeimage_text);
    cardView.setCard(card);
}
Also used : TextSupplementalAction(it.gmariotti.cardslib.library.cards.actions.TextSupplementalAction) ArrayList(java.util.ArrayList) BaseSupplementalAction(it.gmariotti.cardslib.library.cards.actions.BaseSupplementalAction) MaterialLargeImageCard(it.gmariotti.cardslib.library.cards.material.MaterialLargeImageCard) View(android.view.View) MaterialLargeImageCard(it.gmariotti.cardslib.library.cards.material.MaterialLargeImageCard) ProgressCard(it.gmariotti.cardslib.library.cards.ProgressCard) Card(it.gmariotti.cardslib.library.internal.Card) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 33 with CardViewNative

use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.

the class NativeMaterialCardFragment method init_largeimage.

/**
     * Builds a Material Card with Large and small icons as supplemental actions
     */
private void init_largeimage() {
    // Set supplemental actions as icon
    ArrayList<BaseSupplementalAction> actions = new ArrayList<BaseSupplementalAction>();
    IconSupplementalAction t1 = new IconSupplementalAction(getActivity(), R.id.ic1);
    t1.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {

        @Override
        public void onClick(Card card, View view) {
            Toast.makeText(getActivity(), " Click on Text SHARE ", Toast.LENGTH_SHORT).show();
        }
    });
    actions.add(t1);
    IconSupplementalAction t2 = new IconSupplementalAction(getActivity(), R.id.ic2);
    t2.setOnActionClickListener(new BaseSupplementalAction.OnActionClickListener() {

        @Override
        public void onClick(Card card, View view) {
            Toast.makeText(getActivity(), " Click on Text LEARN ", Toast.LENGTH_SHORT).show();
        }
    });
    actions.add(t2);
    MaterialLargeImageCard card = MaterialLargeImageCard.with(getActivity()).setTextOverImage("Italian Beaches").useDrawableId(R.drawable.im_beach).setupSupplementalActions(R.layout.carddemo_native_material_supplemental_actions_large_icon, actions).build();
    card.setOnClickListener(new Card.OnCardClickListener() {

        @Override
        public void onClick(Card card, View view) {
            Toast.makeText(getActivity(), " Click on ActionArea ", Toast.LENGTH_SHORT).show();
        }
    });
    //Set card in the CardViewNative
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_largeimage);
    cardView.setCard(card);
}
Also used : IconSupplementalAction(it.gmariotti.cardslib.library.cards.actions.IconSupplementalAction) ArrayList(java.util.ArrayList) BaseSupplementalAction(it.gmariotti.cardslib.library.cards.actions.BaseSupplementalAction) MaterialLargeImageCard(it.gmariotti.cardslib.library.cards.material.MaterialLargeImageCard) View(android.view.View) MaterialLargeImageCard(it.gmariotti.cardslib.library.cards.material.MaterialLargeImageCard) ProgressCard(it.gmariotti.cardslib.library.cards.ProgressCard) Card(it.gmariotti.cardslib.library.internal.Card) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 34 with CardViewNative

use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.

the class NativeTopColoredCardFragment method init_BlackTopColoredCard.

/**
     * Builds a Material HalfColored Card
     */
private void init_BlackTopColoredCard() {
    TopColoredCard card = TopColoredCard.with(getActivity()).setColorResId(R.color.carddemo_blackcolored_color).setTitleOverColor(R.string.carddemo_match).setupSubLayoutId(R.layout.carddemo_native_blackcolored_simple_title).setupInnerElements(new TopColoredCard.OnSetupInnerElements() {

        @Override
        public void setupInnerViewElementsSecondHalf(View secondHalfView) {
            TextView mSimpleTitleView = (TextView) secondHalfView.findViewById(R.id.carddemo_blackcolored_simple_title);
            if (mSimpleTitleView != null) {
                mSimpleTitleView.setText("It is just an example!");
            }
        }
    }).build();
    //Set card in the CardViewNative
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_blackcolored);
    cardView.setCard(card);
}
Also used : TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) TopColoredCard(it.gmariotti.cardslib.library.cards.topcolored.TopColoredCard) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 35 with CardViewNative

use of it.gmariotti.cardslib.library.view.CardViewNative in project cardslib by gabrielemariotti.

the class NativeTopColoredCardFragment method init_HalfColoredCard.

/**
     * Builds a Material HalfColored Card
     */
private void init_HalfColoredCard() {
    TopColoredCard card = TopColoredCard.with(getActivity()).setColorResId(R.color.carddemo_halfcolored_color).setTitleOverColor("22 mins to Ancona").setSubTitleOverColor("Light traffic on SS16").setupSubLayoutId(R.layout.carddemo_native_halfcolored_simple_title).setupInnerElements(new TopColoredCard.OnSetupInnerElements() {

        @Override
        public void setupInnerViewElementsSecondHalf(View secondHalfView) {
            TextView mSimpleTitleView = (TextView) secondHalfView.findViewById(R.id.carddemo_halfcolored_simple_title);
            if (mSimpleTitleView != null) {
                mSimpleTitleView.setText("It is just an example!");
            }
        }
    }).build();
    //Set card in the CardViewNative
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_halfcolored);
    cardView.setCard(card);
}
Also used : TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) TopColoredCard(it.gmariotti.cardslib.library.cards.topcolored.TopColoredCard) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Aggregations

CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)42 Card (it.gmariotti.cardslib.library.internal.Card)31 CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)20 View (android.view.View)12 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)12 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)11 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)11 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)11 ScrollView (android.widget.ScrollView)7 TextView (android.widget.TextView)6 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)6 MenuItem (android.view.MenuItem)4 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)4 ViewToClickToExpand (it.gmariotti.cardslib.library.internal.ViewToClickToExpand)3 PopupMenu (android.widget.PopupMenu)2 GoogleNowBirthCard (it.gmariotti.cardslib.demo.cards.GoogleNowBirthCard)2 MayKnowCard (it.gmariotti.cardslib.demo.cards.MayKnowCard)2 SuggestedCard (it.gmariotti.cardslib.demo.cards.SuggestedCard)2 ProgressCard (it.gmariotti.cardslib.library.cards.ProgressCard)2 BaseSupplementalAction (it.gmariotti.cardslib.library.cards.actions.BaseSupplementalAction)2