本文整理汇总了Java中android.support.v7.widget.SimpleItemAnimator类的典型用法代码示例。如果您正苦于以下问题:Java SimpleItemAnimator类的具体用法?Java SimpleItemAnimator怎么用?Java SimpleItemAnimator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleItemAnimator类属于android.support.v7.widget包,在下文中一共展示了SimpleItemAnimator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRecyclerView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@Override
public void setRecyclerView(RecyclerView recyclerView) {
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 3));
recyclerView.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
int i = getResources().getDisplayMetrics().widthPixels;
int y = DensityUtil.dp2px(getContext(), 90);
int p = DensityUtil.dp2px(getContext(), 15);
int padding = (3 * y + 2 * 3 * p + 2 * p - i) / (2 * 3);
recyclerView.setPadding(
padding,
DensityUtil.dp2px(getContext(), 8),
padding,
DensityUtil.dp2px(getContext(), 8)
);
}
示例2: onCreate
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 实例化控件
final RecyclerView rv = (RecyclerView) findViewById(R.id.rv);
// 设置启动列表的修改动画效果(默认为关闭状态) 23.0.1以后使用方法,23.0.1之前用setSupportsChangeAnimations方法
RecyclerView.ItemAnimator animator = rv.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
// 设置动画时长
rv.getItemAnimator().setChangeDuration(300);
rv.getItemAnimator().setMoveDuration(300);
// 实现RecyclerView实现竖向列表展示模式
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
rv.setLayoutManager(layoutManager);
// 实例化数据适配器并绑定在控件上
final MainAdapter adapter = new MainAdapter();
rv.setAdapter(adapter);
}
示例3: onCreate
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notification);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = findViewById(R.id.notification_recycler_view);
notifications = new LinkedList<>();
LinearLayoutManager llm = new LinearLayoutManager(this);
recyclerView.setLayoutManager(llm);
//To prevent onBindViewHolder to be called twice on onClick
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
notifAdapter = new NotificationAdapter(this, notifications);
recyclerView.setAdapter(notifAdapter);
}
示例4: createRecyclerView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
private void createRecyclerView() {
rvMonths = new SlowdownRecyclerView(getContext());
rvMonths.setId(View.generateViewId());
rvMonths.setHasFixedSize(true);
rvMonths.setNestedScrollingEnabled(false);
((SimpleItemAnimator) rvMonths.getItemAnimator()).setSupportsChangeAnimations(false);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.addRule(RelativeLayout.BELOW, llDaysOfWeekTitles.getId());
rvMonths.setLayoutParams(params);
rvMonths.setLayoutManager(new GridLayoutManager(getContext(), 1, settingsManager.getCalendarOrientation(), false));
monthAdapter = createAdapter();
changeSnapHelper();
rvMonths.setAdapter(monthAdapter);
rvMonths.scrollToPosition(SettingsManager.DEFAULT_MONTH_COUNT / 2);
rvMonths.addOnScrollListener(pagingScrollListener);
rvMonths.getRecycledViewPool().setMaxRecycledViews(ItemViewType.MONTH, 10);
addView(rvMonths);
}
示例5: setAdapter
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
/**
* Sets adapter for MessagesList
*
* @param adapter Adapter. Must extend MessagesListAdapter
* @param reverseLayout weather to use reverse layout for layout manager.
* @param <MESSAGE> Message model class
*/
public <MESSAGE extends IMessage>
void setAdapter(MessagesListAdapter<MESSAGE> adapter, boolean reverseLayout) {
SimpleItemAnimator itemAnimator = new DefaultItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.VERTICAL, reverseLayout);
setItemAnimator(itemAnimator);
setLayoutManager(layoutManager);
adapter.setLayoutManager(layoutManager);
adapter.setStyle(messagesListStyle);
addOnScrollListener(new RecyclerScrollMoreListener(layoutManager, adapter));
super.setAdapter(adapter);
}
示例6: onCreateView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_dialogs, container, false);
mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView = (RecyclerView) view.findViewById(R.id.dialogs_recycler);
recyclerView.setLayoutManager(mLayoutManager);
((SimpleItemAnimator)recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.dialogs_swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);
setHasOptionsMenu(true);
return view;
}
示例7: onCreateView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
/**
* Returns an inflated image list view.
* <br>
* Call {@link #initializeList(ImageListProvider)} to initialize the list view and display the first page of a list.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) throws IllegalStateException {
View v = inflater.inflate(R.layout.fragment_image_list, container, false);
ButterKnife.bind(this, v);
/* disable item change animations for image interactions */
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
mSavedInstanceState = savedInstanceState;
mImageListPresenter = new PaginatedListPresenter<DerpibooruImageThumb>(refreshLayout, recyclerView) {
@Override
public RecyclerViewPaginationAdapter<DerpibooruImageThumb, ?> getNewInstanceOfListAdapter(List<DerpibooruImageThumb> initialItems) {
return getNewInstanceOfImageListAdapter(initialItems);
}
};
return v;
}
示例8: setListAdapter
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@UiThread(propagation = UiThread.Propagation.REUSE)
protected void setListAdapter(
List<InstalledApp> items
) {
if (mRecyclerView == null || mBus == null) {
return;
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
if (new UpdaterOptions(getContext()).disableAnimations()) {
mRecyclerView.setItemAnimator(null);
} else {
((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
}
mRecyclerView.setAdapter(new InstalledAppAdapter(getContext(), mRecyclerView, items));
mBus.post(new InstalledAppTitleChange(getString(R.string.tab_installed) + " (" + items.size() + ")"));
}
示例9: setListAdapter
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@UiThread(propagation = UiThread.Propagation.REUSE)
protected void setListAdapter(
@NonNull List<InstalledApp> items
) {
if (mRecyclerView == null || mBus == null || mProgressBar == null) {
return;
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
if (new UpdaterOptions(getContext()).disableAnimations()) {
mRecyclerView.setItemAnimator(null);
} else {
((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
}
mAdapter.init(getActivity(), mRecyclerView, items);
mRecyclerView.setAdapter(mAdapter);
mBus.post(new SearchTitleChange(getString(R.string.tab_search) + " (" + items.size() + ")"));
mProgressBar.setVisibility(View.GONE);
}
示例10: init
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@AfterViews
void init(
) {
mAdapter.init(mRecyclerView, new ArrayList<Update>());
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
if (new UpdaterOptions(getContext()).disableAnimations()) {
mRecyclerView.setItemAnimator(null);
} else {
((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
}
mRecyclerView.setAdapter(mAdapter);
// Load data
loadData();
initProgressBar();
}
示例11: setAdapter
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
/**
* Set adapter for MessageList.
*
* @param adapter Adapter, extends MsgListAdapter.
* @param <MESSAGE> Message model extends IMessage.
*/
public <MESSAGE extends IMessage> void setAdapter(MsgListAdapter<MESSAGE> adapter) {
mAdapter = adapter;
SimpleItemAnimator itemAnimator = new DefaultItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);
setItemAnimator(itemAnimator);
LinearLayoutManager layoutManager = new LinearLayoutManager(
getContext(), LinearLayoutManager.VERTICAL, true);
layoutManager.setStackFromEnd(true);
setLayoutManager(layoutManager);
adapter.setLayoutManager(layoutManager);
adapter.setStyle(mContext, mMsgListStyle);
mScrollMoreListener = new ScrollMoreListener(layoutManager, adapter);
addOnScrollListener(mScrollMoreListener);
super.setAdapter(adapter);
}
示例12: onCreate
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apple_calendar);
setTitle("2016");
rvCalendar = (RecyclerView) findViewById(R.id.rvCalendar);
rvCalendar.setLayoutManager(new LinearLayoutManager(this));
((SimpleItemAnimator) rvCalendar.getItemAnimator()).setSupportsChangeAnimations(false);
List<SCMonth> months = SCDateUtils.generateMonths(2016, 2016);
rvCalendar.setAdapter(new CalendarAdpater(months));
selector = new CalendarSelector(months, SingleMonthSelector.SEGMENT);
selector.setSegmentSelectListener(new SegmentSelectListener() {
@Override
public void onSegmentSelect(FullDay startDay, FullDay endDay) {
// TODO
}
});
}
示例13: setupView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
private void setupView(View view) {
ImageButton addContribution = (ImageButton) view.findViewById(R.id.addContribution);
addContribution.setOnClickListener((buttonView) -> this.onAddNewContribution());
contribution = (EditText) view.findViewById(R.id.contribution);
contribution.setHint(R.string.poll_comment);
contribution.setOnEditorActionListener(onDescriptionEditorActionListener);
RecyclerView contributionList = (RecyclerView) view.findViewById(R.id.contributionList);
((SimpleItemAnimator) contributionList.getItemAnimator()).setSupportsChangeAnimations(false);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext()
, LinearLayoutManager.VERTICAL, false);
linearLayoutManager.setAutoMeasureEnabled(true);
linearLayoutManager.setStackFromEnd(true);
contributionList.setLayoutManager(linearLayoutManager);
contributionAdapter = new ContributionAdapter();
contributionAdapter.setOnContributionRemoveListener(this);
contributionList.setAdapter(contributionAdapter);
contribute = (TextView) view.findViewById(R.id.contribute);
contribute.setText(R.string.title_comment_poll);
}
示例14: initRecyclerView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
private void initRecyclerView(Context context) {
if (mRecyclerView == null) return;
mRecyclerView.setBackgroundColor(mBackgroundColor);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(createAdapter());
mRecyclerView.setNestedScrollingEnabled(isNestedScrollEnable());
// mRecyclerView.getItemAnimator().setSupportsChangeAnimations(true);
RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
onRecyclerViewInit(mRecyclerView);
}
示例15: onCreateView
import android.support.v7.widget.SimpleItemAnimator; //导入依赖的package包/类
/** Called to create this fragment's view for the first time. */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_picker, container, false);
ButterKnife.bind(this, view);
card_list.setLayoutManager(new LinearLayoutManager(getContext()));
card_list.addItemDecoration(new ListDivider(getContext()));
// Disable flicker animation when an item changes
// (otherwise items will flicker when selection state changes)
ItemAnimator animator = card_list.getItemAnimator();
if (animator instanceof SimpleItemAnimator)
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
final SharedPreferences pref = Pref.get(getContext());
adapter = new AdapterCardsFilter(card_list, pref.getString(Pref.FILT_CARD, ""),
pref.getString(Pref.REQ_CARDS, ""));
card_list.setAdapter(adapter);
updateView();
return view;
}