Java 类android.support.v7.widget.SimpleItemAnimator 实例源码
项目:FriendBook
文件:BookcaseFragment.java
@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)
);
}
项目:RecyclerviewExpand
文件:MainActivity.java
@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);
}
项目:CSI-KJSCEOfficial
文件:NotificationActivity.java
@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);
}
项目:CosmoCalendar
文件:CalendarView.java
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);
}
项目:FinalProject
文件:MessagesList.java
/**
* 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);
}
项目:BizareChat
文件:PrivateDialogsFragment.java
@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;
}
项目:BizareChat
文件:PublicDialogsFragment.java
@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;
}
项目:Derpibooru
文件:ImageListFragment.java
/**
* 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;
}
项目:apkupdater
文件:InstalledAppFragment.java
@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() + ")"));
}
项目:apkupdater
文件:SearchFragment.java
@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);
}
项目:apkupdater
文件:UpdaterFragment.java
@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();
}
项目:aurora-imui
文件:MessageList.java
/**
* 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);
}
项目:CalendarSelector
文件:AppleCalendarActivity.java
@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
}
});
}
项目:ureport-android
文件:PollsResultsContributionsDialog.java
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);
}
项目:weekdays-buttons-bar
文件:WeekdaysDataSource.java
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);
}
项目:DominionPicker
文件:FragmentPicker.java
/** 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;
}
项目:GitHub
文件:Activity6.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_6);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRv = (RecyclerView) findViewById(R.id.rv);
mRv.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
mAdapter = new QuickAdapter<Integer>(initData()) {
@Override
public int getLayoutId(int viewType) {
return R.layout.item_6;
}
@Override
public void convert(VH holder, Integer data, int position) {
ImageView imageView = holder.getView(R.id.image);
Picasso.with(Activity6.this).load(data).into(imageView);
//holder.itemView.setOnClickListener(); 此处添加点击事件
}
@Override
public int getItemViewType(int position) {
return super.getItemViewType(position);
}
};
mAdapter.setHasStableIds(true);
((SimpleItemAnimator)mRv.getItemAnimator()).setSupportsChangeAnimations(false);
mRv.setAdapter(mAdapter);
}
项目:PlayStoreParallelDownload
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
LinearLayoutManager llm = new LinearLayoutManager(this);
recyclerView.setLayoutManager(llm);
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
String jsonObject = loadJSONFromAsset();
parseJson(jsonObject);
}
项目:TMP-Music_player
文件:MainActivity.java
private void removeItem(int position) {
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(true);
// jcAudios.remove(position);
player.removeAudio(player.getMyPlaylist().get(position));
audioAdapter.notifyItemRemoved(position);
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
}
项目:revolution-irc
文件:ColorListPickerDialog.java
private View buildDialogView() {
View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker, null);
RecyclerView recyclerView = view.findViewById(R.id.items);
recyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
recyclerView.setAdapter(new ColorListAdapter(this));
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
return view;
}
项目:FinalProject
文件:DialogsList.java
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
LinearLayoutManager layout = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
SimpleItemAnimator animator = new DefaultItemAnimator();
setLayoutManager(layout);
setItemAnimator(animator);
}
项目:FinalProject
文件:DialogsList.java
/**
* Set adapter for DialogsList
*
* @param adapter Adapter. Must extend DialogsListAdapter
* @param <DIALOG> Dialog model class
*/
public <DIALOG extends IDialog> void setAdapter(DialogsListAdapter<DIALOG> adapter) {
SimpleItemAnimator itemAnimator = new DefaultItemAnimator();
itemAnimator.setSupportsChangeAnimations(false);
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(),
LinearLayoutManager.VERTICAL, true);
setItemAnimator(itemAnimator);
setLayoutManager(layoutManager);
adapter.setStyle(dialogStyle);
super.setAdapter(adapter);
}
项目:decoy
文件:RecyclerViewUtil.java
public static void changeItemAnimation(RecyclerView recyclerView, boolean isOpen) {
// 关闭viewholder动画效果。解决viewholder闪烁问题
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(isOpen);
}
}
项目:Camera-Roll-Android-App
文件:AlbumAdapter.java
public AlbumAdapter(SelectorModeManager.Callback callback, final RecyclerView recyclerView,
final Album album, boolean pick_photos) {
super(pick_photos);
setData(album);
setSelectorModeManager(new SelectorModeManager());
if (callback != null) {
getSelectorManager().addCallback(callback);
}
if (pick_photos) {
getSelectorManager().setSelectorMode(true);
if (callback != null) {
callback.onSelectorModeEnter();
}
}
//disable default change animation
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
if (callback != null && dragSelectEnabled()) {
dragSelectTouchListener = new DragSelectTouchListener()
.withSelectListener(new DragSelectTouchListener.OnDragSelectListener() {
@Override
public void onSelectChange(int start, int end, boolean isSelected) {
for (int i = start; i <= end; i++) {
getSelectorManager().onItemSelect(getData()
.getAlbumItems().get(i).getPath());
//update ViewHolder
notifyItemChanged(i);
}
}
});
recyclerView.addOnItemTouchListener(dragSelectTouchListener);
}
}
项目:science-journal
文件:ManageDevicesRecyclerFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_manage_devices, container, false);
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler);
HeaderAdapter myHeader = new HeaderAdapter(R.layout.device_header, R.string.my_devices);
HeaderAdapter availableHeader = new HeaderAdapter(R.layout.device_header,
R.string.available_devices);
if (savedInstanceState != null) {
mMyDevices.onRestoreInstanceState(savedInstanceState.getBundle(KEY_MY_DEVICES));
mAvailableDevices.onRestoreInstanceState(
savedInstanceState.getBundle(KEY_AVAILABLE_DEVICES));
}
CompositeRecyclerAdapter adapter = new CompositeRecyclerAdapter(myHeader, mMyDevices,
availableHeader, mAvailableDevices);
adapter.setHasStableIds(true);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
// Don't animate on change: https://code.google.com/p/android/issues/detail?id=204277.
SimpleItemAnimator animator = new DefaultItemAnimator();
animator.setSupportsChangeAnimations(false);
recyclerView.setItemAnimator(animator);
return view;
}
项目:OneTapVideoDownload
文件:DownloadsFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View rootView = inflater.inflate(R.layout.fragment_downloads, container, false);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.downloadRecyclerView);
((SimpleItemAnimator) mRecyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setHasFixedSize(true);
mDownloadAdapter = new DownloadAdapter(getActivity());
mRecyclerView.setAdapter(mDownloadAdapter);
mEmptyView = rootView.findViewById(R.id.empty_view);
FloatingActionButton usageInstructionButton = (FloatingActionButton)rootView.findViewById(R.id.usage_instruction_button);
usageInstructionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent usageInstructionIntent = new Intent(getActivity(), UsageInstruction.class);
startActivity(usageInstructionIntent);
}
});
return rootView;
}
项目:beaconradar
文件:FragmentNearby.java
private void initRecycler(Bundle inState, final View rootView) {
//Setup recycler/adapter/layout manager
int fabBehavior = mPrefs.getInt(Prefs.KEY_FAB_BEHAVIOR, Defaults.FAB_BEHAVIOR);
boolean footer = (fabBehavior == FabBehavior.FAB_BEHAVIOR_FIXED);
mAdapter = new BeaconAdapter(this, getActivity(), footer);
mAdapter.setHasStableIds(true);
mManager = new LinearLayoutManager(getActivity());
((SimpleItemAnimator) mRecycler.getItemAnimator()).setSupportsChangeAnimations(false);
mRecycler.setLayoutManager(mManager);
mRecycler.setAdapter(mAdapter);
//Required to get reliably width of recyclerview for signal/distance bar animation
mRecycler.post(new Runnable() {
@Override
public void run() {
DisplayMetrics DM = getResources().getDisplayMetrics();
float padding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, DM); //TODO parametrize 28 (item_beacon_4)
mAdapter.setBarWidth(rootView.getWidth() - (int) padding);
}
});
//Restore state if possible
if(inState != null && inState.containsKey("FIRST_VISIBLE_POSITION")) {
int first = inState.getInt("FIRST_VISIBLE_POSITION");
int offset = inState.getInt("FIRST_VISIBLE_OFFSET");
//ID firstVisibleID = inState.getParcelable("FIRST_VISIBLE_BEACON_ID");
int size = mAdapter.getItemCount()-1;
if(first <= size) mManager.scrollToPositionWithOffset(first, offset);
else mManager.scrollToPosition(size);
}
}
项目:Aria2-Remote-for-Android
文件:DownloadListFragment.java
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout);
mSwipeRefreshLayout.setOnRefreshListener(this);
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
RecyclerView.ItemAnimator animator = mRecyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
}
FloatingActionButton mActionButton = (FloatingActionButton) view.findViewById(R.id.fab);
if (mActionButton != null) {
mActionButton.setOnClickListener(this);
}
String url = getArguments().getString(getString(R.string.KEY_URL));
String secret = getArguments().getString(getString(R.string.KEY_SECRET));
int typeIndex = getArguments().getInt(getString(R.string.KEY_LIST_TYPE_INDEX));
try {
mAria2 = Aria2Factory.getInstance(url, secret);
mType = Aria2.ListType.values()[typeIndex];
mAdapter = new DownloadAdapter(getContext(), mAria2, mAria2.getList(mType));
mRecyclerView.setAdapter(mAdapter);
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
项目:CalendarSelector
文件:CalendarSelectorActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
if(savedInstanceState != null)
selector = savedInstanceState.getParcelable("selector");
rvCalendar = (RecyclerView) findViewById(R.id.rvCalendar);
rvCalendar.setLayoutManager(new LinearLayoutManager(this));
((SimpleItemAnimator) rvCalendar.getItemAnimator()).setSupportsChangeAnimations(false);
data = getData();
segmentMode();
// intervalMode();
}
项目:CalendarSelector
文件:AnimCalendarSelectorActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
if(savedInstanceState != null)
selector = savedInstanceState.getParcelable("selector");
rvCalendar = (RecyclerView) findViewById(R.id.rvCalendar);
rvCalendar.setLayoutManager(new LinearLayoutManager(this));
((SimpleItemAnimator) rvCalendar.getItemAnimator()).setSupportsChangeAnimations(false);
data = getData();
segmentMode();
}
项目:android-mg-bootstrap
文件:MGRecyclerAdapter.java
/**
* Configures a recycler view and creates an instance of the adapter.
*/
public static <T extends MGRecyclerAdapter> T configure(@NonNull T adapter, RecyclerView.LayoutManager layoutManager, Integer animationDuration) {
RecyclerView recyclerView = adapter.getRecycler();
try {
if (layoutManager == null) {
layoutManager = new LinearLayoutManager(recyclerView.getContext());
}
// Configure recycler view with standard config.
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
if (recyclerView.getItemAnimator() instanceof SimpleItemAnimator) {
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
}
if (animationDuration != null) {
recyclerView.getItemAnimator().setAddDuration(animationDuration);
recyclerView.getItemAnimator().setRemoveDuration(animationDuration);
recyclerView.getItemAnimator().setChangeDuration(animationDuration);
recyclerView.getItemAnimator().setMoveDuration(animationDuration);
}
return adapter;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
项目:mobile-buy-sdk-android
文件:CartListView.java
@Override protected void onFinishInflate() {
super.onFinishInflate();
ButterKnife.bind(this);
listView.setHasFixedSize(true);
listView.setAdapter(listViewAdapter);
((SimpleItemAnimator) listView.getItemAnimator()).setSupportsChangeAnimations(false);
}
项目:NIM_Android_UIKit
文件:RecyclerViewUtil.java
public static void changeItemAnimation(RecyclerView recyclerView, boolean isOpen) {
// 关闭viewholder动画效果。解决viewholder闪烁问题
RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(isOpen);
}
}
项目:ProjectX
文件:ItemAnimatorControllableRecyclerView.java
/**
* 设置是否支持移除动画
*
* @param supportsChangeAnimations 是否支持
* @see Adapter#notifyItemChanged(int)
* @see Adapter#notifyItemRangeChanged(int, int)
*/
public void setSupportsChangeAnimations(boolean supportsChangeAnimations) {
ItemAnimator animator = getItemAnimator();
if (animator == null)
return;
if (supportsChangeAnimations) {
animator.setChangeDuration(mChangeDuration);
} else {
animator.setChangeDuration(0);
}
if (animator instanceof SimpleItemAnimator) {
((SimpleItemAnimator) animator).setSupportsChangeAnimations(supportsChangeAnimations);
}
}
项目:box-android-browse-sdk
文件:BoxBrowseFragment.java
protected void initRecyclerView(RecyclerView view){
view.addItemDecoration(new BoxItemDividerDecoration(getResources()));
view.addItemDecoration(new FooterDecoration(getResources()));
view.setLayoutManager(new LinearLayoutManager(getActivity()));
if (view.getItemAnimator() instanceof SimpleItemAnimator) {
((SimpleItemAnimator) view.getItemAnimator()).setSupportsChangeAnimations(false);
}
}
项目:box-android-browse-sdk
文件:BoxBrowseFolderGridFragment.java
protected void initRecyclerView(RecyclerView view){
int numColumns = (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) ? 5 : 3;
view.setLayoutManager(new GridLayoutManager(getActivity(),numColumns));
view.addItemDecoration(new SpacesItemDecoration(8));
if (view.getItemAnimator() instanceof SimpleItemAnimator) {
((SimpleItemAnimator) view.getItemAnimator()).setSupportsChangeAnimations(false);
}
}
项目:apps-android-wikipedia
文件:LocalCompilationsFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_local_compilations, container, false);
unbinder = ButterKnife.bind(this, view);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
recyclerView.addItemDecoration(new DrawableItemDecoration(getContext(), R.attr.list_separator_drawable));
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
errorView.setBackClickListener(v -> getActivity().finish());
emptyDescription.setMovementMethod(LinkMovementMethod.getInstance());
emptyDescription.setText(StringUtil.fromHtml(getString(R.string.offline_library_empty_description_sideload)));
RichTextUtil.removeUnderlinesFromLinks(emptyDescription);
packsHint.setMovementMethod(LinkMovementMethod.getInstance());
packsHint.setText(StringUtil.fromHtml(getString(R.string.offline_library_packs_hint)));
RichTextUtil.removeUnderlinesFromLinks(packsHint);
dataUsageHint.setMovementMethod(new LinkMovementMethodExt((url, titleString) -> {
if (url.equals(UriUtil.LOCAL_URL_SETTINGS)) {
startActivity(SettingsActivity.newIntent(getContext()));
}
}));
dataUsageHint.setText(StringUtil.fromHtml(getString(R.string.offline_library_data_usage_hint)));
RichTextUtil.removeUnderlinesFromLinks(dataUsageHint);
funnel = new OfflineLibraryFunnel(WikipediaApp.getInstance(), 0);
return view;
}
项目:AssistantBySDK
文件:ChatListFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.frag_chat_list, container, false);
//监听屏幕中的键盘是否打开,如果打开则限制话筒波纹效果的显示
SoftKeyboardStateHelper softKeyboardStateHelper = new SoftKeyboardStateHelper(rootView);
softKeyboardStateHelper.addSoftKeyboardStateListener(new SoftKeyboardStateHelper.SoftKeyboardStateListener() {
@Override
public void onSoftKeyboardOpened(int keyboardHeightInPx) {
//话筒波纹效果不展示
AppConfig.dPreferences.edit().putBoolean("wave_show", false).commit();
}
@Override
public void onSoftKeyboardClosed() {
//话筒波纹效果展示
if (getActivity() != null && ((MainActivity) getActivity()).voiceWaveable())
AppConfig.dPreferences.edit().putBoolean("wave_show", true).commit();
}
});
ButterKnife.bind(this, rootView);
chatListView.setHasFixedSize(true);
chatListView.setLayoutManager((linearLayoutManager = new LinearLayoutManager(getActivity())));
chatListView.setItemAnimator(new DefaultItemAnimator());
((SimpleItemAnimator)chatListView.getItemAnimator()).setSupportsChangeAnimations(false);
chatListView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
scrollable = false;
reset();
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
if (moveable) {
moveable = false; //必须放在移动方法的上面
moveToPosition(scrollPosition);
scrollPosition = -1;
}
}
}
});
/* chatListView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (bottom != oldBottom) {
scrollable = true;
resetChatLocation();
}
}
});*/
return rootView;
}
项目:Auto.js
文件:FileChooseListView.java
private void init() {
setDirectorySpanSize(2);
((SimpleItemAnimator) getScriptListView().getItemAnimator())
.setSupportsChangeAnimations(false);
}
项目:TagLayoutManager
文件:Demo1Activity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo_1);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle(R.string.title);
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mRvTag = (RecyclerView) findViewById(R.id.rv_tag);
mList = new ArrayList<>();
mAdapter = new TagAdapter(this, mList, new TagAdapter.OnTagClickListener() {
@Override
public void onRemoved(String removedTag) {
Log.i(TAG, "onRemoved: =============removed tag:" + removedTag);
}
@Override
public void onDataSetChange() {
mRvTag.smoothScrollToPosition(mAdapter.getItemCount() - 1);
}
});
mRvTag.setLayoutManager(new TagLayoutManager.Builder()
.setBorderLeft(Utils.dp2px(this, 12))
.setBorderTop(Utils.dp2px(this, 8))
.setBorderRight(Utils.dp2px(this, 12))
.setBorderBottom(Utils.dp2px(this, 8))
.setBorderHor(Utils.dp2px(this, 8))
.setBorderVer(Utils.dp2px(this, 4))
.setMaxHeight(Utils.dp2px(this, 100))
.create());
mRvTag.setAdapter(mAdapter);
// avoid adapter call notifyItemChanged then the other item flashing
((SimpleItemAnimator)mRvTag.getItemAnimator()).setSupportsChangeAnimations(false);
}