If you think the Android project android_app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* ******************************************************************************
* Copyright (c) 2013-2014 Gabriele Mariotti.
*/*www.java2s.com*/
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* *****************************************************************************
*/package it.gmariotti.cardslib.library.internal;
import android.view.View;
/**
* Use this class to enable the expand/collapse action anywhere in your card.
* <code>
* ViewToClickToExpand.builder()
* .setupView(myView) //view to click
* .highlightView(true); //highlight this view
*
* </code>
*
* @author Gabriele Mariotti (gabri.mariotti@gmail.com)
*/publicclass ViewToClickToExpand {
/**
* View to Click to enable the expand/collapse action.
* It has a higher priority than cardElementUIToClick.
*/protected View viewToClick;
/**
* Indicates if the view will be selected
*/protectedboolean viewToSelect=false;
/**
* Card element UI to click to enable the expand/collapse action
* It has a lower priority than cardElementUIToClick.
*/protected CardElementUI cardElementUIToClick;
/**
* Indicates the expand action will be used in programmatic way
*/protectedboolean enableForCode = false;
/**
* Use the longClick to enable expand/collapse action
*/protectedboolean useLongClick = false;
// -------------------------------------------------------------
// Constructors
// -------------------------------------------------------------
protected ViewToClickToExpand(){}
/**
* Builder
*
* @return
*/publicstatic ViewToClickToExpand builder(){
returnnew ViewToClickToExpand();
}
// -------------------------------------------------------------
// Enum
// -------------------------------------------------------------
publicenum CardElementUI{
CARD(0),
HEADER(1),
THUMBNAIL(2),
MAIN_CONTENT(3);
int mElement;
CardElementUI(int element){
mElement = element;
}
}
// -------------------------------------------------------------
// Setup
// -------------------------------------------------------------
/**
* Sets the view to click to enable the expand/collapse action
*
* @param viewToClick view to click
* @return
*/public ViewToClickToExpand setupView(View viewToClick){
this.viewToClick=viewToClick;
returnthis;
}
/**
* Indicates if the view clicked will be highlight as selected
*
* @param highlight
* @return
*/public ViewToClickToExpand highlightView(boolean highlight){
this.viewToSelect=highlight;
returnthis;
}
public ViewToClickToExpand setupCardElement(CardElementUI cardElementUIToClick){
this.cardElementUIToClick = cardElementUIToClick;
returnthis;
}
/**
* Indicates if the expand action will be enabled in a programmatic way
*
* @return
*/public ViewToClickToExpand enableForExpandAction() {
this.enableForCode = true;
returnthis;
}
/**
* Indicates if the expand action will be enabled with a long click
*
* @return
*/public ViewToClickToExpand useLongClick(boolean useLongClick) {
this.useLongClick = useLongClick;
returnthis;
}
// -------------------------------------------------------------
// Getters
// -------------------------------------------------------------
/**
* Returns the view to Click to enable the expand action
* @return
*/public View getViewToClick() {
return viewToClick;
}
/**
* Indicates if the view clicked will be highlight as selected
* @return
*/publicboolean isViewToSelect() {
return viewToSelect;
}
/**
* Returns the card element to click to enable the expand/collapse action
* @return
*/public CardElementUI getCardElementUIToClick() {
return cardElementUIToClick;
}
/**
* Indicates if the expand action will be enabled in a programmatic way
* @return
*/publicboolean isEnableForCode() {
return enableForCode;
}
/**
* Indicates if the expand action will be enabled with a long click
*/publicboolean isUseLongClick() {
return useLongClick;
}
}