當前位置: 首頁>>代碼示例>>Java>>正文


Java UndoCard類代碼示例

本文整理匯總了Java中it.gmariotti.cardslib.library.view.listener.UndoCard的典型用法代碼示例。如果您正苦於以下問題:Java UndoCard類的具體用法?Java UndoCard怎麽用?Java UndoCard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UndoCard類屬於it.gmariotti.cardslib.library.view.listener包,在下文中一共展示了UndoCard類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onDismiss

import it.gmariotti.cardslib.library.view.listener.UndoCard; //導入依賴的package包/類
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {

    int[] itemPositions=new int[reverseSortedPositions.length];
    String[] itemIds=new String[reverseSortedPositions.length];
    int i=0;

    //Remove cards and notifyDataSetChanged
    for (int position : reverseSortedPositions) {

        Card card = null;
        if (listView.getAdapter() != null && listView.getAdapter().getItem(position) instanceof Card)
            card = (Card) listView.getAdapter().getItem(position);
        //Card card = getItem(position);

        if (card != null) {
            itemPositions[i] = position;
            itemIds[i] = card.getId();
            i++;

            /*
            if (card.isExpanded()){
                if (card.getCardView()!=null && card.getCardView().getOnExpandListAnimatorListener()!=null){
                    //There is a List Animator.
                    card.getCardView().getOnExpandListAnimatorListener().onCollapseStart(card.getCardView(), card.getCardView().getInternalExpandLayout());
                }
            }*/
            remove(card);
            if (card.getOnSwipeListener() != null) {
                card.getOnSwipeListener().onSwipe(card);
            }
        }else{
            Log.e(TAG,"Error on swipe action. Impossible to retrieve the card from position");
        }
    }
    notifyDataSetChanged();

    //Check for a undo message to confirm
    if (isEnableUndo() && mUndoBarController!=null){

        //Show UndoBar
        UndoCard itemUndo=new UndoCard(itemPositions,itemIds);

        //MessageUndoBar
        String messageUndoBar=null;
        if (getUndoBarController().getUndoBarUIElements()!=null){
            messageUndoBar = getUndoBarController().getUndoBarUIElements().getMessageUndo(CardArrayAdapter.this,itemIds,itemPositions);
        }

        //Default message if null
        if (messageUndoBar == null) {
            if (getContext() != null) {
                Resources res = getContext().getResources();
                if (res != null) {
                    messageUndoBar = res.getQuantityString(R.plurals.list_card_undo_items, reverseSortedPositions.length, reverseSortedPositions.length);
                }
            }
        }

        mUndoBarController.showUndoBar(
                false,
                messageUndoBar,
                itemUndo);
    }
}
 
開發者ID:Daniele-Comi,項目名稱:System-Monitor,代碼行數:66,代碼來源:CardArrayAdapter.java

示例2: onDismiss

import it.gmariotti.cardslib.library.view.listener.UndoCard; //導入依賴的package包/類
@Override
public void onDismiss(ListView listView, int[] reverseSortedPositions) {

    int[] itemPositions=new int[reverseSortedPositions.length];
    String[] itemIds=new String[reverseSortedPositions.length];
    int i=0;

    //Remove cards and notifyDataSetChanged
    for (int position : reverseSortedPositions) {
        Card card = getItem(position);
        itemPositions[i]=position;
        itemIds[i]=card.getId();
        i++;

        /*
        if (card.isExpanded()){
            if (card.getCardView()!=null && card.getCardView().getOnExpandListAnimatorListener()!=null){
                //There is a List Animator.
                card.getCardView().getOnExpandListAnimatorListener().onCollapseStart(card.getCardView(), card.getCardView().getInternalExpandLayout());
            }
        }*/
        remove(card);
        if (card.getOnSwipeListener() != null){
                card.getOnSwipeListener().onSwipe(card);
        }
    }
    notifyDataSetChanged();

    //Check for a undo message to confirm
    if (isEnableUndo() && mUndoBarController!=null){

        //Show UndoBar
        UndoCard itemUndo=new UndoCard(itemPositions,itemIds);

        if (getContext()!=null){
            Resources res = getContext().getResources();
            if (res!=null){
                String messageUndoBar = res.getQuantityString(R.plurals.list_card_undo_items, reverseSortedPositions.length, reverseSortedPositions.length);

                mUndoBarController.showUndoBar(
                        false,
                        messageUndoBar,
                        itemUndo);
            }
        }

    }
}
 
開發者ID:tajchert,項目名稱:CEEHack,代碼行數:49,代碼來源:CardArrayAdapter.java


注:本文中的it.gmariotti.cardslib.library.view.listener.UndoCard類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。