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


Java FastAdapter.withSelectable方法代码示例

本文整理汇总了Java中com.mikepenz.fastadapter.FastAdapter.withSelectable方法的典型用法代码示例。如果您正苦于以下问题:Java FastAdapter.withSelectable方法的具体用法?Java FastAdapter.withSelectable怎么用?Java FastAdapter.withSelectable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mikepenz.fastadapter.FastAdapter的用法示例。


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

示例1: onCreateView

import com.mikepenz.fastadapter.FastAdapter; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    context = super.getActivity();
    View ourView = inflater.inflate(R.layout.fragment_bookmarks, container, false);

    noBookmarksLayout = (LinearLayout) ourView.findViewById(R.id.no_bookmarks_layout);
    bookmarksList = (RecyclerView) ourView.findViewById(R.id.bookmarks_list);

    fastAdapter = new FastAdapter();
    itemFastAdapter = new ItemAdapter<>();
    fastAdapter.withSelectOnLongClick(false);
    fastAdapter.withSelectable(false);
    fastAdapter.withOnLongClickListener(this);


    bookmarksList.setLayoutManager(new LinearLayoutManager(context));
    bookmarksList.setAdapter(itemFastAdapter.wrap(fastAdapter));


    return ourView;
}
 
开发者ID:EladKeyshawn,项目名称:HackList,代码行数:23,代码来源:FragmentBookmarks.java

示例2: onCreate

import com.mikepenz.fastadapter.FastAdapter; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_generic_item);

    //style our ui
    new MaterializeBuilder().withActivity(this).build();


    //create our FastAdapter which will manage everything
    fastAdapter = new FastAdapter();
    fastAdapter.withSelectable(true);

    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

    //init our gridLayoutManager and configure RV
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);

    GenericItemAdapter<IconModel, GenericIconItem> itemAdapter = new GenericItemAdapter<>(new Function<IconModel, GenericIconItem>() {
        @Override
        public GenericIconItem apply(IconModel iconModel) {
            return new GenericIconItem(iconModel);
        }
    });

    final FastScrollIndicatorAdapter<GenericIconItem> fastScrollIndicatorAdapter = new FastScrollIndicatorAdapter<>();
    rv.setAdapter(fastScrollIndicatorAdapter.wrap(itemAdapter.wrap(fastAdapter)));

    DragScrollBar materialScrollBar = new DragScrollBar(this, rv, true);
    materialScrollBar.setHandleColour(ContextCompat.getColor(this, R.color.colorAccent));
    materialScrollBar.setHandleOffColour(ContextCompat.getColor(this, R.color.colorAccent));
    materialScrollBar.addIndicator(new CustomIndicator(this), true);

    rv.setLayoutManager(gridLayoutManager);
    rv.setItemAnimator(new SlideDownAlphaAnimator());

    //order fonts by their name
    List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
    Collections.sort(mFonts, new Comparator<ITypeface>() {
        @Override
        public int compare(final ITypeface object1, final ITypeface object2) {
            return object1.getFontName().compareTo(object2.getFontName());
        }
    });

    //add all icons of all registered Fonts to the list
    ArrayList<IconModel> models = new ArrayList<>();
    for (ITypeface font : mFonts) {
        for (String icon : font.getIcons()) {
            models.add(new IconModel(font.getIcon(icon)));
        }
    }

    //fill with some sample data
    itemAdapter.addModel(models);

    //restore selections (this has to be done after the items were added
    fastAdapter.withSavedInstanceState(savedInstanceState);

    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:71,代码来源:GenericItemActivity.java

示例3: onCreate

import com.mikepenz.fastadapter.FastAdapter; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_sticky_header);

    //style our ui
    new MaterializeBuilder().withActivity(this).build();

    //create our FastAdapter
    fastAdapter = new FastAdapter();
    fastAdapter.withSelectable(true);

    //create our adapters
    final StickyHeaderAdapter stickyHeaderAdapter = new StickyHeaderAdapter();
    final HeaderAdapter headerAdapter = new HeaderAdapter();
    final ItemAdapter itemAdapter = new ItemAdapter();

    //configure our fastAdapter
    //as we provide id's for the items we want the hasStableIds enabled to speed up things
    fastAdapter.setHasStableIds(true);

    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
    rv.setLayoutManager(new LinearLayoutManager(this));
    rv.setItemAnimator(new DefaultItemAnimator());
    rv.setAdapter(stickyHeaderAdapter.wrap(itemAdapter.wrap(headerAdapter.wrap(fastAdapter))));

    //this adds the Sticky Headers within our list
    final StickyRecyclerHeadersDecoration decoration = new StickyRecyclerHeadersDecoration(stickyHeaderAdapter);
    rv.addItemDecoration(decoration);

    //fill with some sample data
    headerAdapter.add(new SimpleItem().withName("Header").withIdentifier(1));
    List<IItem> items = new ArrayList<>();
    for (int i = 1; i <= 100; i++) {
        items.add(new SimpleItem().withName("Test " + i).withHeader(headers[i / 5]).withIdentifier(100 + i));
    }
    itemAdapter.add(items);

    //so the headers are aware of changes
    stickyHeaderAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
        @Override
        public void onChanged() {
            decoration.invalidateHeaders();
        }
    });

    //restore selections (this has to be done after the items were added
    fastAdapter.withSavedInstanceState(savedInstanceState);

    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:61,代码来源:StickyHeaderSampleActivity.java

示例4: onCreate

import com.mikepenz.fastadapter.FastAdapter; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);

    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setTitle(R.string.sample_multi_generic_item);

    //style our ui
    new MaterializeBuilder().withActivity(this).build();


    //create our FastAdapter which will manage everything
    fastAdapter = new FastAdapter();
    fastAdapter.withSelectable(true);

    //get our recyclerView and do basic setup
    RecyclerView rv = (RecyclerView) findViewById(R.id.rv);

    //init our gridLayoutManager and configure RV
    GridLayoutManager gridLayoutManager = new GridLayoutManager(this, 3);

    //if you need multiple items for different models you can also do this be defining a Function which get's the model object and returns the item (extends IItem)
    GenericItemAdapter<IconModel, GenericIconItem> itemAdapter = new GenericItemAdapter<>(new Function<IconModel, GenericIconItem>() {
        @Override
        public GenericIconItem apply(IconModel o) {
            if (o instanceof RightIconModel) {
                return new RightGenericIconItem(o);
            } else {
                return new GenericIconItem(o);
            }
        }
    });

    rv.setLayoutManager(gridLayoutManager);
    rv.setItemAnimator(new SlideDownAlphaAnimator());
    rv.setAdapter(itemAdapter.wrap(fastAdapter));

    //order fonts by their name
    List<ITypeface> mFonts = new ArrayList<>(Iconics.getRegisteredFonts(this));
    Collections.sort(mFonts, new Comparator<ITypeface>() {
        @Override
        public int compare(final ITypeface object1, final ITypeface object2) {
            return object1.getFontName().compareTo(object2.getFontName());
        }
    });

    //add all icons of all registered Fonts to the list
    ArrayList<IconModel> models = new ArrayList<>();
    int i = 0;
    for (ITypeface font : mFonts) {
        for (String icon : font.getIcons()) {
            if (i % 3 == 0) {
                models.add(new IconModel(font.getIcon(icon)));
            } else {
                models.add(new RightIconModel(font.getIcon(icon)));
            }
            i++;
        }
    }

    //fill with some sample data
    itemAdapter.addModel(models);

    //restore selections (this has to be done after the items were added
    fastAdapter.withSavedInstanceState(savedInstanceState);

    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:75,代码来源:MultiTypeGenericItemActivity.java


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