use of it.gmariotti.cardslib.library.internal.ViewToClickToExpand in project cardslib by gabrielemariotti.
the class CardViewNative method setupExpandCollapseActionListener.
//--------------------------------------------------------------------------
// Expandable Actions and Listeners
//--------------------------------------------------------------------------
/**
* Add ClickListener to expand and collapse hidden view
*/
protected void setupExpandCollapseActionListener() {
if (mInternalExpandLayout != null) {
mInternalExpandLayout.setVisibility(View.GONE);
boolean internal_blockForLongClickOnImageButtonExpand = false;
ViewToClickToExpand viewToClickToExpand = null;
//ButtonExpandVisible has a priority to viewClickToExpand
if (mCardHeader != null && mCardHeader.isButtonExpandVisible()) {
viewToClickToExpand = ViewToClickToExpand.builder().setupView(mInternalHeaderLayout.getImageButtonExpand()).highlightView(true);
internal_blockForLongClickOnImageButtonExpand = true;
} else if (mCard.getViewToClickToExpand() != null) {
viewToClickToExpand = mCard.getViewToClickToExpand();
}
if (viewToClickToExpand != null) {
TitleViewOnClickListener titleViewOnClickListener = new TitleViewOnClickListener(mInternalExpandLayout, mCard, viewToClickToExpand.isViewToSelect());
/*if (mCardHeader!=null && mCardHeader.isButtonExpandVisible() && mInternalHeaderLayout != null) {
mInternalHeaderLayout.setOnClickExpandCollapseActionListener(titleViewOnClickListener);
}*/
View viewToClick = viewToClickToExpand.getViewToClick();
if (viewToClick != null) {
if (internal_blockForLongClickOnImageButtonExpand) {
//The long click on Header button is now allowed
viewToClick.setOnClickListener(titleViewOnClickListener);
} else {
if (viewToClickToExpand.isUseLongClick()) {
viewToClick.setOnLongClickListener(new TitleViewOnLongClickListener(titleViewOnClickListener));
} else {
viewToClick.setOnClickListener(titleViewOnClickListener);
}
}
} else {
ViewToClickToExpand.CardElementUI cardElementUI = viewToClickToExpand.getCardElementUIToClick();
if (cardElementUI != null) {
switch(cardElementUI) {
case CARD:
viewToClick = this;
break;
case HEADER:
viewToClick = getInternalHeaderLayout();
break;
case THUMBNAIL:
viewToClick = getInternalThumbnailLayout();
break;
case MAIN_CONTENT:
viewToClick = getInternalContentLayout();
break;
}
if (viewToClick != null) {
if (viewToClickToExpand.isUseLongClick()) {
viewToClick.setOnLongClickListener(new TitleViewOnLongClickListener(titleViewOnClickListener));
} else {
viewToClick.setOnClickListener(titleViewOnClickListener);
}
}
}
}
if (isExpanded()) {
//Make layout visible and button selected
mInternalExpandLayout.setVisibility(View.VISIBLE);
if (viewToClick != null) {
if (viewToClickToExpand.isViewToSelect())
viewToClick.setSelected(true);
}
} else {
//Make layout hidden and button not selected
mInternalExpandLayout.setVisibility(View.GONE);
if (viewToClick != null) {
if (viewToClickToExpand.isViewToSelect())
viewToClick.setSelected(false);
}
}
}
}
}
use of it.gmariotti.cardslib.library.internal.ViewToClickToExpand in project cardslib by gabrielemariotti.
the class NativeExpandPicassoFragment method initCard.
/**
* This method builds a simple cards list
*/
private void initCard() {
//Only for test scope, use images on assets folder
String[] fileName = { "file:///android_asset/images/sea.jpg", "file:///android_asset/images/snow.jpg", "file:///android_asset/images/water.jpg", "file:///android_asset/images/img2.jpg", "file:///android_asset/images/rose.jpg" };
//Only for test scope, use 5 different header titles
int[] resTitleId = { R.string.carddemo_extras_header_expand_area_inside_sea, R.string.carddemo_extras_header_expand_area_inside_snow, R.string.carddemo_extras_header_expand_area_inside_water, R.string.carddemo_extras_header_expand_area_inside_img2, R.string.carddemo_extras_header_expand_area_inside_rose };
//Remove debugging from Picasso
Picasso.with(getActivity()).setDebugging(false);
//Init an array of Cards
ArrayList<Card> cards = new ArrayList<Card>();
for (int j = 1; j < 30; j++) {
for (int i = 0; i < 10; i++) {
//Card
CardInside card = new CardInside(this.getActivity());
//Create a CardHeader
CardHeader header = new CardHeader(getActivity(), R.layout.carddemo_extras_expandinside_inner_base_header);
if (i % 2 == 0) {
//Set the header title
header.setTitle(getString(resTitleId[(int) (i / 2) % 5]));
//Add Header to card
card.addCardHeader(header);
//Add an expand area
CardExpandInside expand = new CardExpandInside(getActivity(), fileName[(int) (i / 2) % 5]);
card.addCardExpand(expand);
} else {
//Set the header title
header.setTitle(getString(R.string.carddemo_extras_header_expand_area_inside));
//Add Header to card
card.addCardHeader(header);
//Only for test scope, use a random number
int randomNumber = (int) (Math.random() * 6);
//Add an expand area
CardExpandInsideSquare expand = new CardExpandInsideSquare(getActivity(), randomNumber);
card.addCardExpand(expand);
}
//Add a viewToClickExpand to enable click on whole card
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().highlightView(false).setupCardElement(ViewToClickToExpand.CardElementUI.CARD);
card.setViewToClickToExpand(viewToClickToExpand);
cards.add(card);
}
}
//Set the arrayAdapter
CardArrayAdapter mCardArrayAdapter = new CardArrayAdapter(getActivity(), cards);
CardListView listView = (CardListView) getActivity().findViewById(R.id.carddemo_extra_list_mixinside);
//Add an animator
AnimationAdapter animCardArrayAdapter = new AlphaInAnimationAdapter(mCardArrayAdapter);
animCardArrayAdapter.setAbsListView(listView);
//animCardArrayAdapter.setInitialDelayMillis(500);
if (listView != null) {
listView.setExternalAdapter(animCardArrayAdapter, mCardArrayAdapter);
}
}
use of it.gmariotti.cardslib.library.internal.ViewToClickToExpand in project cardslib by gabrielemariotti.
the class CardExpandFragment method init_custom_card_expand_programmatic.
/**
* This method builds a card with a collpse/expand action in programmatic way
*/
private void init_custom_card_expand_programmatic() {
//Create a Card
final Card card = new Card(getActivity());
//This provides a simple (and useless) expand area
CardExpand expand = new CardExpand(getActivity());
//Set inner title in Expand Area
expand.setTitle(getString(R.string.demo_expand_customtitle3));
card.addCardExpand(expand);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().enableForExpandAction();
card.setViewToClickToExpand(viewToClickToExpand);
TextView tx = (TextView) getActivity().findViewById(R.id.carddemo_example_card_expand6_text);
tx.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
card.doToogleExpand();
}
});
//Set card in the cardView
CardView cardView = (CardView) getActivity().findViewById(R.id.carddemo_example_card_expand6);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.ViewToClickToExpand in project cardslib by gabrielemariotti.
the class NativeCardExpandFragment method init_custom_card_expand.
/**
* This method builds a custom card with expand/collapse action clickable in all card view
*/
private void init_custom_card_expand() {
//Create a Card
CustomCard card = new CustomCard(getActivity());
//This provides a simple (and useless) expand area
CardExpand expand = new CardExpand(getActivity());
//Set inner title in Expand Area
expand.setTitle(getString(R.string.demo_expand_customtitle3));
card.addCardExpand(expand);
//Set card in the cardView
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand2);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().setupView(cardView);
card.setViewToClickToExpand(viewToClickToExpand);
cardView.setCard(card);
}
use of it.gmariotti.cardslib.library.internal.ViewToClickToExpand in project cardslib by gabrielemariotti.
the class NativeCardExpandFragment method init_custom_card_expand_inside.
/**
* This method builds a card with a collpse/expand section inside
*/
private void init_custom_card_expand_inside() {
//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_expand_area_inside));
//Add Header to card
card.addCardHeader(header);
//This provides a simple (and useless) expand area
CardExpandInside expand = new CardExpandInside(getActivity());
card.addCardExpand(expand);
//Set card in the cardView
CardViewNative cardView = (CardViewNative) getActivity().findViewById(R.id.carddemo_example_card_expand5);
ViewToClickToExpand viewToClickToExpand = ViewToClickToExpand.builder().highlightView(false).setupView(cardView);
card.setViewToClickToExpand(viewToClickToExpand);
card.setOnExpandAnimatorEndListener(new Card.OnExpandAnimatorEndListener() {
@Override
public void onExpandEnd(Card card) {
/*
if (mScrollView!=null){
mScrollView.post(new Runnable() {
public void run() {
mScrollView.scrollTo(0, mScrollView.getBottom());
}
});
}*/
}
});
cardView.setCard(card);
}
Aggregations