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);
}
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;
}
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);
}
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);
}
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;
}
});
}
Aggregations