use of android.support.v7.widget.DefaultItemAnimator in project Android-Iconics by mikepenz.
the class IconsFragment method onViewCreated.
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// Init and Setup RecyclerView
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
//animator not yet working
recyclerView.setItemAnimator(new DefaultItemAnimator());
mAdapter = new FastItemAdapter<>();
configAdapter();
recyclerView.setAdapter(mAdapter);
if (getArguments() != null) {
String fontName = getArguments().getString(FONT_NAME);
for (ITypeface iTypeface : Iconics.getRegisteredFonts(getActivity())) {
if (iTypeface.getFontName().equalsIgnoreCase(fontName)) {
if (iTypeface.getIcons() != null) {
for (String icon : iTypeface.getIcons()) {
icons.add(new IconItem(icon));
}
mAdapter.set(icons);
break;
}
}
}
}
//filter if a search param was provided
onSearch(search);
}
use of android.support.v7.widget.DefaultItemAnimator in project AboutLibraries by mikepenz.
the class LibsFragmentCompat method onCreateView.
public View onCreateView(Context context, LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState, Bundle arguments) {
if (arguments != null) {
builder = (LibsBuilder) arguments.getSerializable("data");
} else {
Log.e("AboutLibraries", "The AboutLibraries fragment can't be build without the bundle containing the LibsBuilder");
}
View view = inflater.inflate(R.layout.fragment_opensource, container, false);
//allows to modify the view before creating
if (LibsConfiguration.getInstance().getUiListener() != null) {
view = LibsConfiguration.getInstance().getUiListener().preOnCreateView(view);
}
// init CardView
RecyclerView mRecyclerView;
if (view.getId() == R.id.cardListView) {
mRecyclerView = (RecyclerView) view;
} else {
mRecyclerView = (RecyclerView) view.findViewById(R.id.cardListView);
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
if (LibsConfiguration.getInstance().getItemAnimator() != null) {
mRecyclerView.setItemAnimator(LibsConfiguration.getInstance().getItemAnimator());
} else {
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
}
if (builder != null) {
mAdapter = new FastAdapter();
mItemAdapter = new ItemAdapter();
mRecyclerView.setAdapter(mItemAdapter.wrap(mAdapter));
mItemAdapter.add(new LoaderItem());
}
//allows to modify the view after creating
if (LibsConfiguration.getInstance().getUiListener() != null) {
view = LibsConfiguration.getInstance().getUiListener().postOnCreateView(view);
}
return view;
}
use of android.support.v7.widget.DefaultItemAnimator in project MaterialDrawer by mikepenz.
the class MiniDrawer method build.
/**
* build the MiniDrawer
*
* @param ctx
* @return
*/
public View build(Context ctx) {
mContainer = new LinearLayout(ctx);
if (mInnerShadow) {
if (!mInRTL) {
mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_left);
} else {
mContainer.setBackgroundResource(R.drawable.material_drawer_shadow_right);
}
}
//create and append recyclerView
mRecyclerView = new RecyclerView(ctx);
mContainer.addView(mRecyclerView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
//set the itemAnimator
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
//some style improvements on older devices
mRecyclerView.setFadingEdgeLength(0);
//set the drawing cache background to the same color as the slider to improve performance
//mRecyclerView.setDrawingCacheBackgroundColor(UIUtils.getThemeColorFromAttrOrRes(mActivity, R.attr.material_drawer_background, R.color.material_drawer_background));
mRecyclerView.setClipToPadding(false);
//additional stuff
mRecyclerView.setLayoutManager(new LinearLayoutManager(ctx));
//adapter
mAdapter = new FastAdapter<>();
mItemAdapter = new ItemAdapter<>();
mAdapter.withSelectable(true);
mAdapter.withAllowDeselection(false);
mAdapter.withPositionBasedStateManagement(mPositionBasedStateManagement);
mRecyclerView.setAdapter(mItemAdapter.wrap(mAdapter));
//if the activity with the drawer should be fullscreen add the padding for the statusbar
if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentStatusBar)) {
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), UIUtils.getStatusBarHeight(ctx), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom());
}
//if the activity with the drawer should be fullscreen add the padding for the navigationBar
if (mDrawer != null && mDrawer.mDrawerBuilder != null && (mDrawer.mDrawerBuilder.mFullscreen || mDrawer.mDrawerBuilder.mTranslucentNavigationBar) && ctx.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), UIUtils.getNavigationBarHeight(ctx));
}
//set the adapter with the items
createItems();
return mContainer;
}
use of android.support.v7.widget.DefaultItemAnimator in project Signal-Android by WhisperSystems.
the class GiphyFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle bundle) {
super.onActivityCreated(bundle);
this.giphyAdapter = new GiphyAdapter(getActivity(), new LinkedList<GiphyImage>());
this.giphyAdapter.setListener(this);
this.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
this.recyclerView.setItemAnimator(new DefaultItemAnimator());
this.recyclerView.setAdapter(giphyAdapter);
this.recyclerView.addOnScrollListener(new GiphyScrollListener());
getLoaderManager().initLoader(0, null, this);
}
use of android.support.v7.widget.DefaultItemAnimator in project FastDev4Android by jiangqqlmj.
the class RecyclerViewTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recyclerview_test_layout);
top_bar_linear_back = (LinearLayout) this.findViewById(R.id.top_bar_linear_back);
btn_add = (Button) this.findViewById(R.id.btn_add);
btn_delete = (Button) this.findViewById(R.id.btn_delete);
top_bar_linear_back.setOnClickListener(new CustomOnClickListener());
btn_add.setOnClickListener(new CustomOnClickListener());
btn_delete.setOnClickListener(new CustomOnClickListener());
top_bar_title = (TextView) this.findViewById(R.id.top_bar_title);
top_bar_title.setText("RecyclerView使用实例");
//开始设置RecyclerView
recyclerView_one = (RecyclerView) this.findViewById(R.id.recyclerView_one);
recyclerView_one.setHasFixedSize(true);
//1.LinearLayoutManager 线性布局类型
mLayoutManager = new LinearLayoutManager(this);
mLayoutManager.setOrientation(OrientationHelper.VERTICAL);
recyclerView_one.setLayoutManager(mLayoutManager);
//2.GridLayoutManager 表格布局类型
// GridLayoutManager girdLayoutManager=new GridLayoutManager(this,4);
// recyclerView_one.setLayoutManager(girdLayoutManager);
//3.采用StaggeredGridLayoutManager 流式布局类型
// StaggeredGridLayoutManager staggeredGridLayoutManager=new StaggeredGridLayoutManager(2,OrientationHelper.VERTICAL);
// recyclerView_one.setLayoutManager(staggeredGridLayoutManager);
//添加默认的动画效果
recyclerView_one.setItemAnimator(new DefaultItemAnimator());
//添加分隔线
recyclerView_one.addItemDecoration(new AdvanceDecoration(this, OrientationHelper.VERTICAL));
mAdapter = new TestRecyclerAdapter(this, new TestRecyclerAdapter.OnRecyclerItemClickListener() {
@Override
public void onItemClick(View view, int position) {
Toast.makeText(RecyclerViewTestActivity.this, "点击了第" + position + "项", Toast.LENGTH_SHORT).show();
}
});
recyclerView_one.setAdapter(mAdapter);
}
Aggregations