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