当前位置: 首页>>代码示例>>Java>>正文


Java PlaidItem类代码示例

本文整理汇总了Java中io.plaidapp.data.PlaidItem的典型用法代码示例。如果您正苦于以下问题:Java PlaidItem类的具体用法?Java PlaidItem怎么用?Java PlaidItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlaidItem类属于io.plaidapp.data包,在下文中一共展示了PlaidItem类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deduplicateAndAdd

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
/**
 * De-dupe as the same item can be returned by multiple feeds
 */
private void deduplicateAndAdd(List<? extends PlaidItem> newItems) {
    final int count = getDataItemCount();
    for (PlaidItem newItem : newItems) {
        boolean add = true;
        for (int i = 0; i < count; i++) {
            PlaidItem existingItem = getItem(i);
            if (existingItem.equals(newItem)) {
                add = false;
                break;
            }
        }
        if (add) {
            add(newItem);
        }
    }
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:20,代码来源:FeedAdapter.java

示例2: getItemViewType

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
@Override
public int getItemViewType(int position) {
    if (position < getDataItemCount()
            && getDataItemCount() > 0) {
        PlaidItem item = getItem(position);
        if (item instanceof Story) {
            return TYPE_DESIGNER_NEWS_STORY;
        } else if (item instanceof Shot) {
            return TYPE_DRIBBBLE_SHOT;
        } else if (item instanceof Post) {
            return TYPE_PRODUCT_HUNT_POST;
        }
    }
    return TYPE_LOADING_MORE;
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:16,代码来源:FeedAdapter.java

示例3: addAndResort

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
/**
 * Main entry point for adding items to this adapter. Takes care of de-duplicating items and
 * sorting them (depending on the data source). Will also expand some items to span multiple
 * grid columns.
 */
public void addAndResort(List<? extends PlaidItem> newItems) {
    weighItems(newItems);
    deduplicateAndAdd(newItems);
    sort();
    expandPopularItems();
    notifyDataSetChanged();
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:13,代码来源:FeedAdapter.java

示例4: expandPopularItems

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
private void expandPopularItems() {
    // for now just expand the first dribbble image per page which should be
    // the most popular according to our weighing & sorting
    List<Integer> expandedPositions = new ArrayList<>();
    int page = -1;
    final int count = items.size();
    for (int i = 0; i < count; i++) {
        PlaidItem item = getItem(i);
        if (item instanceof Shot && item.page > page) {
            item.colspan = columns;
            page = item.page;
            expandedPositions.add(i);
        } else {
            item.colspan = 1;
        }
    }

    // make sure that any expanded items are at the start of a row
    // so that we don't leave any gaps in the grid
    for (int expandedPos = 0; expandedPos < expandedPositions.size(); expandedPos++) {
        int pos = expandedPositions.get(expandedPos);
        int extraSpannedSpaces = expandedPos * (columns - 1);
        int rowPosition = (pos + extraSpannedSpaces) % columns;
        if (rowPosition != 0) {
            int swapWith = pos + (columns - rowPosition);
            if (swapWith < items.size()) {
                Collections.swap(items, pos, swapWith);
            }
        }
    }
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:32,代码来源:FeedAdapter.java

示例5: removeDataSource

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
public void removeDataSource(String dataSource) {
    for (int i = items.size() - 1; i >= 0; i--) {
        PlaidItem item = items.get(i);
        if (dataSource.equals(item.dataSource)) {
            items.remove(i);
        }
    }
    sort();
    expandPopularItems();
    notifyDataSetChanged();
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:12,代码来源:FeedAdapter.java

示例6: addAndResort

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
/**
 * Main entry point for adding items to this adapter. Takes care of de-duplicating items and
 * sorting them (depending on the data source). Will also expand some items to span multiple
 * grid columns.
 */
void addAndResort(List<? extends PlaidItem> newItems) {
    weighItems(newItems);
    deduplicateAndAdd(newItems);
    sort();
    expandPopularItems();
    notifyDataSetChanged();
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:13,代码来源:FeedAdapter.java

示例7: removeDataSource

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
void removeDataSource(String dataSource) {
    for (int i = items.size() - 1; i >= 0; i--) {
        PlaidItem item = items.get(i);
        if (dataSource.equals(item.dataSource)) {
            items.remove(i);
        }
    }
    sort();
    expandPopularItems();
    notifyDataSetChanged();
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:12,代码来源:FeedAdapter.java

示例8: getPreloadItems

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
@NonNull
@Override
public List<Shot> getPreloadItems(int position) {
    PlaidItem item = getItem(position);
    if (item instanceof Shot) {
        return Collections.singletonList((Shot) item);
    }
    return Collections.emptyList();
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:10,代码来源:FeedAdapter.java

示例9: getItem

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
private PlaidItem getItem(int position) {
    return items.get(position);
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:4,代码来源:FeedAdapter.java

示例10: add

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
private void add(PlaidItem item) {
    items.add(item);
}
 
开发者ID:liulinbo,项目名称:Amumu,代码行数:4,代码来源:FeedAdapter.java

示例11: onCreate

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    ButterKnife.bind(this);
    setupSearchView();

    dataManager = new SearchDataManager(this) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> data) {
            if (data != null && data.size() > 0) {
                if (results.getVisibility() != View.VISIBLE) {
                    TransitionManager.beginDelayedTransition(container,
                            getTransition(R.transition.search_show_results));
                    progress.setVisibility(View.GONE);
                    results.setVisibility(View.VISIBLE);
                    fab.setVisibility(View.VISIBLE);
                }
                adapter.addAndResort(data);
            } else {
                TransitionManager.beginDelayedTransition(
                        container, getTransition(R.transition.auto));
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            }
        }
    };
    adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this));
    setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
    results.setAdapter(adapter);
    results.setItemAnimator(new SlideInItemAnimator());
    GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    results.setLayoutManager(layoutManager);
    results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
        @Override
        public void onLoadMore() {
            dataManager.loadMore();
        }
    });
    results.setHasFixedSize(true);

    setupTransitions();
    onNewIntent(getIntent());
    ShortcutHelper.reportSearchUsed(this);
}
 
开发者ID:yongjhih,项目名称:android-proguards,代码行数:52,代码来源:SearchActivity.java

示例12: getItem

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
private PlaidItem getItem(int position) {
    if (position < 0 || position >= items.size()) return null;
    return items.get(position);
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:5,代码来源:FeedAdapter.java

示例13: onCreate

import io.plaidapp.data.PlaidItem; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    ButterKnife.bind(this);
    setupSearchView();

    dataManager = new SearchDataManager(this) {
        @Override
        public void onDataLoaded(List<? extends PlaidItem> data) {
            if (data != null && data.size() > 0) {
                if (results.getVisibility() != View.VISIBLE) {
                    TransitionManager.beginDelayedTransition(container,
                            getTransition(R.transition.search_show_results));
                    progress.setVisibility(View.GONE);
                    results.setVisibility(View.VISIBLE);
                    fab.setVisibility(View.VISIBLE);
                }
                adapter.addAndResort(data);
            } else {
                TransitionManager.beginDelayedTransition(
                        container, getTransition(R.transition.auto));
                progress.setVisibility(View.GONE);
                setNoResultsVisibility(View.VISIBLE);
            }
        }
    };
    ViewPreloadSizeProvider<Shot> shotPreloadSizeProvider = new ViewPreloadSizeProvider<>();
    adapter = new FeedAdapter(this, dataManager, columns, PocketUtils.isPocketInstalled(this),
            shotPreloadSizeProvider);
    setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
    results.setAdapter(adapter);
    results.setItemAnimator(new SlideInItemAnimator());
    GridLayoutManager layoutManager = new GridLayoutManager(this, columns);
    layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            return adapter.getItemColumnSpan(position);
        }
    });
    results.setLayoutManager(layoutManager);
    results.addOnScrollListener(new InfiniteScrollListener(layoutManager, dataManager) {
        @Override
        public void onLoadMore() {
            dataManager.loadMore();
        }
    });
    results.setHasFixedSize(true);
    RecyclerViewPreloader<Shot> shotPreloader =
            new RecyclerViewPreloader<>(this, adapter, shotPreloadSizeProvider, 4);
    results.addOnScrollListener(shotPreloader);

    setupTransitions();
    onNewIntent(getIntent());
    ShortcutHelper.reportSearchUsed(this);
}
 
开发者ID:nickbutcher,项目名称:plaid,代码行数:57,代码来源:SearchActivity.java


注:本文中的io.plaidapp.data.PlaidItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。