use of android.support.v7.widget.SimpleItemAnimator in project ChatExchange by HueToYou.
the class TutorialStuff method showChatSliderTutorial_MainActivity.
/*
* Main Activity
*/
public static void showChatSliderTutorial_MainActivity(final Activity activity) {
if (mSharedPreferences == null) {
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
}
if (mCategoryConfig == null) {
setCategoryConfig(activity);
}
if (mItemConfig == null) {
setItemConfig(activity);
}
final FloatingActionMenu chatFam = activity.findViewById(R.id.chat_slide_menu);
final FloatingActionButton home = activity.findViewById(R.id.home_fab);
final FloatingActionButton add = activity.findViewById(R.id.add_chat_fab);
final FloatingActionButton removeAll = activity.findViewById(R.id.remove_all_chats_fab);
final CustomRecyclerView dummyChats = activity.findViewById(R.id.dummy_chat_list);
final Drawable ico = activity.getResources().getDrawable(R.mipmap.ic_launcher);
final RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
final RecyclerAdapter recyclerAdapter = new RecyclerAdapter(activity, null, swipeManager);
recyclerAdapter.addItem(new ChatroomRecyclerObject(0, "Example 1", "U", ico, 0, 0, 0));
recyclerAdapter.addItem(new ChatroomRecyclerObject(1, "Example 2", "U", ico, 0, 0, 1));
recyclerAdapter.addItem(new ChatroomRecyclerObject(2, "Example 3", "U", ico, 0, 0, 2));
RecyclerView.Adapter adapter = swipeManager.createWrappedAdapter(recyclerAdapter);
dummyChats.setAdapter(adapter);
// disable change animations
((SimpleItemAnimator) dummyChats.getItemAnimator()).setSupportsChangeAnimations(false);
swipeManager.attachRecyclerView(dummyChats);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(dummyChats.getContext(), DividerItemDecoration.VERTICAL);
dummyChats.addItemDecoration(dividerItemDecoration);
final OnSwipeListener onSwipeListener = new OnSwipeListener() {
@Override
public void onSwipeRight(RecyclerView.ViewHolder viewHolder) {
swipeManager.performFakeSwipe(viewHolder, RecyclerViewSwipeManager.RESULT_SWIPED_RIGHT);
}
@Override
public void onSwipeLeft(RecyclerView.ViewHolder viewHolder) {
swipeManager.performFakeSwipe(viewHolder, RecyclerViewSwipeManager.RESULT_SWIPED_LEFT);
}
};
PreferencesManager manager = new PreferencesManager(activity);
if (!manager.isDisplayed(CHAT_ITEM)) {
activity.findViewById(R.id.chatroomsListView).setVisibility(View.GONE);
dummyChats.setVisibility(View.VISIBLE);
MainActivity.touchesBlocked = true;
}
SpotlightView chats = new SpotlightView.Builder(activity).target(dummyChats).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_chats_tutorial_text_title)).subHeadingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_chats_tutorial_text)).usageId(CHAT_ITEM).targetPadding(Util.dpToPx(activity, 50)).show();
final SpotlightView.Builder chatsSwipe = new SpotlightView.Builder(activity).setConfiguration(mCategoryConfig).headingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_chats_tutorial_text_swipe_delete)).subHeadingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_chats_tutorial_swipe_left_text)).usageId(CHAT_ITEM_SLIDE);
final SpotlightView.Builder chatFAM = new SpotlightView.Builder(activity).setConfiguration(mCategoryConfig).target(chatFam.getMenuButton()).headingTvText(activity.getResources().getString(R.string.tutorial_menu)).subHeadingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_FAM_tutorial_text)).usageId(CHAT_ITEM_FAM);
final SpotlightView.Builder chatHome = new SpotlightView.Builder(activity).setConfiguration(mItemConfig).target(home).headingTvText(activity.getResources().getString(R.string.tutorial_home)).subHeadingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_homeFAB_tutorial_text)).usageId(CHAT_ITEM_HOME);
final SpotlightView.Builder chatAdd = new SpotlightView.Builder(activity).setConfiguration(mItemConfig).target(add).headingTvText(activity.getResources().getString(R.string.tutorial_add)).subHeadingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_addChatFAB_tutorial_text)).usageId(CHAT_ITEM_ADD);
final SpotlightView.Builder chatRemAll = new SpotlightView.Builder(activity).setConfiguration(mItemConfig).target(removeAll).headingTvText(activity.getResources().getString(R.string.tutorial_remove_all)).subHeadingTvText(activity.getResources().getString(R.string.chatrooms_slidingMenu_removeALlChatsFAB_tutorial_text)).usageId(CHAT_ITEM_REMOVE_ALL);
SpotlightListener listener = new SpotlightListener() {
@Override
public void onUserClicked(String s) {
switch(s) {
case CHAT_ITEM:
chatsSwipe.target(recyclerAdapter.getViewHolderAt(0).getCloseChatButton()).show();
onSwipeListener.onSwipeRight(recyclerAdapter.getViewHolderAt(0));
MainActivity.touchesBlocked = true;
break;
case CHAT_ITEM_SLIDE:
onSwipeListener.onSwipeLeft(recyclerAdapter.getViewHolderAt(0));
MainActivity.touchesBlocked = true;
chatFAM.show();
break;
case CHAT_ITEM_FAM:
chatFam.open(true);
chatHome.show();
MainActivity.touchesBlocked = true;
break;
case CHAT_ITEM_HOME:
chatAdd.show();
MainActivity.touchesBlocked = true;
break;
case CHAT_ITEM_ADD:
chatRemAll.show();
MainActivity.touchesBlocked = true;
break;
case CHAT_ITEM_REMOVE_ALL:
chatFam.close(true);
activity.findViewById(R.id.chatroomsListView).setVisibility(View.VISIBLE);
dummyChats.setVisibility(View.GONE);
MainActivity.touchesBlocked = false;
break;
}
}
@Override
public void onFinishedDrawingSpotlight() {
MainActivity.touchesBlocked = false;
}
@Override
public void onStartedDrawingSpotlight() {
MainActivity.touchesBlocked = false;
}
};
chats.setListener(listener);
chatsSwipe.setListener(listener);
chatFAM.setListener(listener);
chatHome.setListener(listener);
chatAdd.setListener(listener);
chatRemAll.setListener(listener);
}
use of android.support.v7.widget.SimpleItemAnimator in project apps-android-wikipedia by wikimedia.
the class ReadingListFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_reading_list, container, false);
unbinder = ButterKnife.bind(this, view);
getAppCompatActivity().setSupportActionBar(toolbar);
getAppCompatActivity().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getAppCompatActivity().getSupportActionBar().setTitle("");
DeviceUtil.updateStatusBarTheme(requireActivity(), toolbar, true);
appBarLayout.addOnOffsetChangedListener(appBarListener);
toolBarLayout.setCollapsedTitleTextColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_toolbar_icon_color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
toolBarLayout.setStatusBarScrimColor(ResourceUtil.getThemedColor(requireContext(), R.attr.main_status_bar_color));
}
ItemTouchHelper.Callback touchCallback = new SwipeableItemTouchHelperCallback(requireContext());
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(touchCallback);
itemTouchHelper.attachToRecyclerView(recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
recyclerView.addItemDecoration(new DrawableItemDecoration(requireContext(), R.attr.list_separator_drawable, false));
recyclerView.addItemDecoration(new MarginItemDecoration(0, 0, 0, DimenUtil.roundedDpToPx(DimenUtil.getDimension(R.dimen.floating_queue_container_height))) {
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (parent.getChildAdapterPosition(view) == adapter.getItemCount() - 1 && floatingQueueView.getVisibility() == View.VISIBLE) {
super.getItemOffsets(outRect, view, parent, state);
}
}
});
headerView = new ReadingListItemView(getContext());
headerView.setCallback(headerCallback);
headerView.setClickable(false);
headerView.setThumbnailVisible(false);
headerView.setTitleTextAppearance(R.style.ReadingListTitleTextAppearance);
readingListId = getArguments().getLong(EXTRA_READING_LIST_ID);
disposables.add(WikipediaApp.getInstance().getBus().subscribe(new EventBusConsumer()));
floatingQueueView.setCallback(this);
swipeRefreshLayout.setColorSchemeResources(getThemedAttributeId(requireContext(), R.attr.colorAccent));
swipeRefreshLayout.setOnRefreshListener(() -> ReadingListsFragment.refreshSync(ReadingListFragment.this, swipeRefreshLayout));
if (ReadingListSyncAdapter.isDisabledByRemoteConfig()) {
swipeRefreshLayout.setEnabled(false);
}
appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> swipeRefreshLayout.setEnabled(verticalOffset == 0));
return view;
}
use of android.support.v7.widget.SimpleItemAnimator in project remusic by aa112901.
the class DownFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_down, container, false);
allStart = (LinearLayout) view.findViewById(R.id.down_start_all);
allStop = (LinearLayout) view.findViewById(R.id.down_pause_all);
clear = (LinearLayout) view.findViewById(R.id.down_clear_all);
setListener();
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
adapter = new DownLoadAdapter(null, null);
recyclerView.setAdapter(adapter);
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
reload();
return view;
}
use of android.support.v7.widget.SimpleItemAnimator in project Lightning-Browser by anthonycr.
the class TabsFragment method onCreateView.
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view;
final LayoutManager layoutManager;
if (mShowInNavigationDrawer) {
view = inflater.inflate(R.layout.tab_drawer, container, false);
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false);
setupFrameLayoutButton(view, R.id.tab_header_button, R.id.plusIcon);
setupFrameLayoutButton(view, R.id.new_tab_button, R.id.icon_plus);
setupFrameLayoutButton(view, R.id.action_back, R.id.icon_back);
setupFrameLayoutButton(view, R.id.action_forward, R.id.icon_forward);
setupFrameLayoutButton(view, R.id.action_home, R.id.icon_home);
} else {
view = inflater.inflate(R.layout.tab_strip, container, false);
layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
ImageView newTab = (ImageView) view.findViewById(R.id.new_tab_button);
newTab.setColorFilter(ThemeUtils.getIconDarkThemeColor(getActivity()));
newTab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mUiController.newTabButtonClicked();
}
});
}
mUnbinder = ButterKnife.bind(this, view);
SimpleItemAnimator animator;
if (mShowInNavigationDrawer) {
animator = new VerticalItemAnimator();
} else {
animator = new HorizontalItemAnimator();
}
animator.setSupportsChangeAnimations(false);
animator.setAddDuration(200);
animator.setChangeDuration(0);
animator.setRemoveDuration(200);
animator.setMoveDuration(200);
mRecyclerView.setLayerType(View.LAYER_TYPE_NONE, null);
mRecyclerView.setItemAnimator(animator);
mRecyclerView.setLayoutManager(layoutManager);
mTabsAdapter = new LightningViewAdapter(mShowInNavigationDrawer);
mRecyclerView.setAdapter(mTabsAdapter);
mRecyclerView.setHasFixedSize(true);
return view;
}
use of android.support.v7.widget.SimpleItemAnimator in project android-advancedrecyclerview by h6ah4i.
the class MinimalExpandableExampleActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_demo_minimal);
RecyclerView recyclerView = findViewById(R.id.recycler_view);
// Setup expandable feature and RecyclerView
RecyclerViewExpandableItemManager expMgr = new RecyclerViewExpandableItemManager(null);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(expMgr.createWrappedAdapter(new MyAdapter()));
// NOTE: need to disable change animations to ripple effect work properly
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
expMgr.attachRecyclerView(recyclerView);
}
Aggregations