Search in sources :

Example 16 with CardHeader

use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.

the class CardFragment method init_card_inner_layout.

/**
 * This method builds a simple card with a custom inner layout
 */
private void init_card_inner_layout() {
    // Create a Card
    Card card = new Card(getActivity(), R.layout.carddemo_example_inner_content);
    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());
    // Set the header title
    header.setTitle(getString(R.string.demo_header_basetitle));
    card.addCardHeader(header);
    // Set the card inner text
    card.setTitle(getString(R.string.demo_card_basetitle));
    // Set card in the cardView
    CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_card_inner);
    cardView.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardView(it.gmariotti.cardslib.library.view.CardView) Card(it.gmariotti.cardslib.library.internal.Card) CustomCard(it.gmariotti.cardslib.demo.cards.CustomCard)

Example 17 with CardHeader

use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.

the class GoogleNowWeatherCard method initCardHeader.

@Override
protected CardHeader initCardHeader() {
    // Add Header
    CardHeader header = new CardHeader(getContext(), R.layout.carddemo_googlenowweather_inner_header);
    // Add a popup menu. This method set OverFlow button to visible
    header.setPopupMenu(R.menu.popup_item, new CardHeader.OnClickCardHeaderPopupMenuListener() {

        @Override
        public void onMenuItemClick(BaseCard card, MenuItem item) {
            switch(item.getItemId()) {
                case R.id.action_add:
                    // Example: add an item
                    WeatherObject w1 = new WeatherObject(GoogleNowWeatherCard.this);
                    w1.city = "Madrid";
                    w1.temperature = 24;
                    w1.weatherIcon = R.drawable.ic_action_sun;
                    w1.setObjectId(w1.city);
                    mLinearListAdapter.add(w1);
                    break;
                case R.id.action_remove:
                    // Example: remove an item
                    mLinearListAdapter.remove(mLinearListAdapter.getItem(0));
                    break;
            }
        }
    });
    // should use R.string.
    header.setTitle("Weather");
    return header;
}
Also used : BaseCard(it.gmariotti.cardslib.library.internal.base.BaseCard) CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) MenuItem(android.view.MenuItem)

Example 18 with CardHeader

use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.

the class MayKnowCard method init.

private void init() {
    // Add Header
    CardHeader header = new MayKnowCardHeader(getContext(), R.layout.carddemo_mayknow_inner_header);
    header.setTitle(getContext().getString(R.string.may_know_card_title));
    addCardHeader(header);
    setShadow(false);
    // Add Thumbnail
    CardThumbnail thumbnail = new CardThumbnail(getContext());
    thumbnail.setUrlResource("https://lh5.googleusercontent.com/-squZd7FxR8Q/UyN5UrsfkqI/AAAAAAAAbAo/VoDHSYAhC_E/s72/new%2520profile%2520%25282%2529.jpg");
    thumbnail.setErrorResource(R.drawable.ic_error_loadingsmall);
    addCardThumbnail(thumbnail);
    OnCardClickListener clickListener = new OnCardClickListener() {

        @Override
        public void onClick(Card card, View view) {
        // Do something
        }
    };
    addPartialOnClickListener(Card.CLICK_LISTENER_CONTENT_VIEW, clickListener);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) CardThumbnailView(it.gmariotti.cardslib.library.view.component.CardThumbnailView) TextView(android.widget.TextView) View(android.view.View) CardThumbnail(it.gmariotti.cardslib.library.internal.CardThumbnail) Card(it.gmariotti.cardslib.library.internal.Card)

Example 19 with CardHeader

use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.

the class NativeShadowFragment method init_card_elevation_shadow.

/**
 * This method builds a card with a different elevation
 */
private void init_card_elevation_shadow() {
    // Create a Card
    Card card = new Card(getActivity());
    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());
    // Set the header title
    header.setTitle(getString(R.string.demo_header_basetitle));
    card.addCardHeader(header);
    // Card elevation
    card.setCardElevation(getResources().getDimension(R.dimen.carddemo_shadow_elevation));
    // Set card in the cardView
    CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_shadow_elevation);
    cardView.setCard(card);
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) Card(it.gmariotti.cardslib.library.internal.Card) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative)

Example 20 with CardHeader

use of it.gmariotti.cardslib.library.internal.CardHeader in project cardslib by gabrielemariotti.

the class NativeShadowFragment method init_card_animation_shadow.

/**
 * This method builds a card with an animation
 */
private void init_card_animation_shadow() {
    // Create a Card
    Card card = new Card(getActivity());
    // Create a CardHeader
    CardHeader header = new CardHeader(getActivity());
    // Set the header title
    header.setTitle(getString(R.string.demo_header_basetitle));
    card.addCardHeader(header);
    // Set card in the cardView
    final CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_shadow_animation);
    cardView.setCard(card);
    cardView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            switch(motionEvent.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    if (Build.VERSION.SDK_INT >= Constants.API_L) {
                        cardView.animate().setDuration(100).scaleX(1.1f).scaleY(1.1f).translationZ(10);
                    } else {
                        cardView.animate().setDuration(100).scaleX(1.1f).scaleY(1.1f);
                    }
                    return true;
                case MotionEvent.ACTION_CANCEL:
                case MotionEvent.ACTION_UP:
                    if (Build.VERSION.SDK_INT >= Constants.API_L) {
                        cardView.animate().setDuration(100).scaleX(1).scaleY(1).translationZ(0);
                    } else {
                        cardView.animate().setDuration(100).scaleX(1).scaleY(1);
                    }
                    return true;
            }
            return false;
        }
    });
}
Also used : CardHeader(it.gmariotti.cardslib.library.internal.CardHeader) ScrollView(android.widget.ScrollView) View(android.view.View) Card(it.gmariotti.cardslib.library.internal.Card) CardViewNative(it.gmariotti.cardslib.library.view.CardViewNative) MotionEvent(android.view.MotionEvent)

Aggregations

CardHeader (it.gmariotti.cardslib.library.internal.CardHeader)58 Card (it.gmariotti.cardslib.library.internal.Card)51 BaseCard (it.gmariotti.cardslib.library.internal.base.BaseCard)27 CustomExpandCard (it.gmariotti.cardslib.demo.cards.CustomExpandCard)20 CardView (it.gmariotti.cardslib.library.view.CardView)20 CardViewNative (it.gmariotti.cardslib.library.view.CardViewNative)20 View (android.view.View)19 CustomHeaderInnerCard (it.gmariotti.cardslib.demo.cards.CustomHeaderInnerCard)18 MenuItem (android.view.MenuItem)15 CustomCard (it.gmariotti.cardslib.demo.cards.CustomCard)12 ScrollView (android.widget.ScrollView)11 TextView (android.widget.TextView)8 CardExpand (it.gmariotti.cardslib.library.internal.CardExpand)8 CustomThumbCard (it.gmariotti.cardslib.demo.cards.CustomThumbCard)6 CardThumbnail (it.gmariotti.cardslib.library.internal.CardThumbnail)6 ArrayList (java.util.ArrayList)5 PopupMenu (android.widget.PopupMenu)4 ViewToClickToExpand (it.gmariotti.cardslib.library.internal.ViewToClickToExpand)4 CardListView (it.gmariotti.cardslib.library.view.CardListView)4 ViewGroup (android.view.ViewGroup)2