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


Java DetailField.DIRECTION_DESCENDING屬性代碼示例

本文整理匯總了Java中org.commcare.suite.model.DetailField.DIRECTION_DESCENDING屬性的典型用法代碼示例。如果您正苦於以下問題:Java DetailField.DIRECTION_DESCENDING屬性的具體用法?Java DetailField.DIRECTION_DESCENDING怎麽用?Java DetailField.DIRECTION_DESCENDING使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.commcare.suite.model.DetailField的用法示例。


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

示例1: compare

@Override
public int compare(Entity<TreeReference> object1, Entity<TreeReference> object2) {
    for (int fieldIndex : fieldIndicesToSortBy) {
        boolean reverse = (detailFields[fieldIndex].getSortDirection() == DetailField.DIRECTION_DESCENDING) ^ reverseSort;
        int cmp = getCmp(object1, object2, fieldIndex, reverse);
        if (cmp != 0) {
            return cmp;
        }
    }
    return 0;
}
 
開發者ID:dimagi,項目名稱:commcare-core,代碼行數:11,代碼來源:EntitySorter.java

示例2: getSortOptionsList

private DialogChoiceItem[] getSortOptionsList() {
    DetailField[] fields = session.getDetail(selectDatum.getShortDetail()).getFields();
    List<String> namesList = new ArrayList<>();

    final int[] keyArray = new int[fields.length];
    int[] sorts = adapter.getCurrentSort();
    int currentSort = sorts.length == 1 ? sorts[0] : -1;
    boolean reversed = adapter.isCurrentSortReversed();

    int added = 0;
    for (int i = 0; i < fields.length; ++i) {
        String result = fields[i].getHeader().evaluate();
        if (!"".equals(result)) {
            String prepend = "";
            if (currentSort == -1) {
                for (int j = 0; j < sorts.length; ++j) {
                    if (sorts[j] == i) {
                        prepend = (j + 1) + " " + (fields[i].getSortDirection() == DetailField.DIRECTION_DESCENDING ? "(v) " : "(^) ");
                    }
                }
            } else if (currentSort == i) {
                prepend = reversed ^ fields[i].getSortDirection() == DetailField.DIRECTION_DESCENDING ? "(v) " : "(^) ";
            }
            namesList.add(prepend + result);
            keyArray[added] = i;
            added++;
        }
    }

    DialogChoiceItem[] choiceItems = new DialogChoiceItem[namesList.size()];
    for (int i = 0; i < namesList.size(); i++) {
        final int index = i;
        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                adapter.sortEntities(new int[]{keyArray[index]});
                adapter.filterByString(entitySelectSearchUI.getSearchText().toString());
                dismissAlertDialog();
            }
        };
        DialogChoiceItem item = new DialogChoiceItem(namesList.get(i), -1, listener);
        choiceItems[i] = item;
    }
    return choiceItems;
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:45,代碼來源:EntitySelectActivity.java

示例3: isSortAscending

/**
 * Returns the orientation that the specified field should be sorted in
 *
 * @param fieldKey The key to be sorted
 * @return true if the field should be sorted in ascending order. False otherwise
 */
public boolean isSortAscending(int index) {
    return !(shortDetail.getFields()[index].getSortDirection() == DetailField.DIRECTION_DESCENDING);
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:9,代碼來源:CommCareEntity.java


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