Java Code Examples for androidx.recyclerview.widget.DefaultItemAnimator

The following examples show how to use androidx.recyclerview.widget.DefaultItemAnimator. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: candybar   Source File: HomeFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mManager = new StaggeredGridLayoutManager(
            getActivity().getResources().getInteger(R.integer.home_column_count),
            StaggeredGridLayoutManager.VERTICAL);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(mManager);

    if (CandyBarApplication.getConfiguration().getHomeGrid() == CandyBarApplication.GridStyle.FLAT) {
        int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
        mRecyclerView.setPadding(padding, padding, 0, 0);
    }

    initHome();
}
 
Example 2
Source Project: weather   Source File: MainActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void initRecyclerView() {
  LinearLayoutManager layoutManager
      = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
  recyclerView.setLayoutManager(layoutManager);
  mItemAdapter = new ItemAdapter<>();
  mFastAdapter = FastAdapter.with(mItemAdapter);
  recyclerView.setItemAnimator(new DefaultItemAnimator());
  recyclerView.setAdapter(mFastAdapter);
  recyclerView.setFocusable(false);
  mFastAdapter.withOnClickListener(new OnClickListener<FiveDayWeather>() {
    @Override
    public boolean onClick(@Nullable View v, @NonNull IAdapter<FiveDayWeather> adapter, @NonNull FiveDayWeather item, int position) {
      Intent intent = new Intent(MainActivity.this, HourlyActivity.class);
      intent.putExtra(Constants.FIVE_DAY_WEATHER_ITEM, item);
      startActivity(intent);
      return true;
    }
  });
}
 
Example 3
Source Project: Instagram-Profile-Downloader   Source File: FeedFragment.java    License: MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_feed, container, false);
    recyclerView = view.findViewById(R.id.recycler_view);
    storiesRecyclerView = view.findViewById(R.id.storiesRecyclerView);
    noDataText = view.findViewById(R.id.noDataText);

    feedAdapter = new FeedAdapter(getActivity(),recyclerView);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getContext());
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(feedAdapter);
    if (edgeList != null && edgeList.size() > 0)
        feedAdapter.setEdges(edgeList);


    if (!TextUtils.isEmpty(username)) {
        showLoading();
        new RequestInstagramAPI(ApiUtils.getUsernameUrl(username)).execute();
    } else {
        noDataText.setVisibility(View.VISIBLE);
    }
    return view;
}
 
Example 4
Source Project: Twire   Source File: SettingsActivity.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_settings);
    ButterKnife.bind(this);

    setSupportActionBar(mToolbar);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }
    SettingsCategoryAdapter mAdapter = new SettingsCategoryAdapter();
    mAdapter.setItemCallback(this);
    mAdapter.addItems(constructSettingsCategories());

    mCategoryList.setAdapter(mAdapter);
    mCategoryList.setLayoutManager(new LinearLayoutManager(getBaseContext()));
    mCategoryList.setItemAnimator(new DefaultItemAnimator());
}
 
Example 5
Source Project: Hify   Source File: FriendRequests.java    License: MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mFirestore = FirebaseFirestore.getInstance();
    mAuth = FirebaseAuth.getInstance();

    mRequestView = view.findViewById(R.id.recyclerView);
    refreshLayout=view.findViewById(R.id.refreshLayout);

    requestList = new ArrayList<>();
    requestAdapter = new FriendRequestAdapter(requestList, view.getContext());

    mRequestView.setItemAnimator(new DefaultItemAnimator());
    mRequestView.setLayoutManager(new LinearLayoutManager(view.getContext(), VERTICAL, false));
    mRequestView.addItemDecoration(new DividerItemDecoration(view.getContext(),DividerItemDecoration.VERTICAL));
    mRequestView.setHasFixedSize(true);
    mRequestView.setAdapter(requestAdapter);

    refreshLayout.setOnRefreshListener(this::getUsers);

    getUsers();

}
 
Example 6
Source Project: memorize   Source File: OptionsFragment.java    License: MIT License 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_options, container, false);

    prgLoading = (TSProgressBar) rootView.findViewById(R.id.options_progress);
    titleId = getResources().getStringArray(R.array.title);
    subtitleId = getResources().getStringArray(R.array.subtitle);

    userText = rootView.findViewById(R.id.user_name);
    userAvatar = rootView.findViewById(R.id.user_avatar);

    final RecyclerView mRecyclerView = rootView.findViewById(R.id.options_rv);
    mRecyclerView.setHasFixedSize(true);
    RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(AppMain.getContext());
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(mLayoutManager);
    RecyclerView.Adapter mAdapter = new OptionsAdapter(titleId, subtitleId, imageId);
    mRecyclerView.setAdapter(mAdapter);

    ImageLoader imageLoader = new ImageLoader(AppMain.getContext());

    return rootView;
}
 
Example 7
Source Project: memorize   Source File: FavoriteFragment.java    License: MIT License 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View root = inflater.inflate(R.layout.fragment_favorite, container, false);
        mRecyclerView = root.findViewById(R.id.fav_recycler_view);
        mRecyclerView.setHasFixedSize(true);
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());
        mRecyclerView.setLayoutManager(new LinearLayoutManager(AppMain.getContext(), LinearLayoutManager.VERTICAL, false));
        SnapHelper snapHelper = new LinearSnapHelper();
        snapHelper.attachToRecyclerView(mRecyclerView);
        mRecyclerView.setAdapter(mAdapter);

        swipeRefreshLayout = (SwipeRefreshLayout) root.findViewById(R.id.fav_swiper);
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                presenter.loadWords(false);
            }
        });
//        animation = AnimationUtils.loadAnimation(AppMain.getContext(), R.anim.card_in);

        return root;
    }
 
Example 8
private void setupSelectNetKeyUi() {
    setContentView(R.layout.activity_keys);

    //Bind ui
    ButterKnife.bind(this);
    netKeysRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    netKeysRecyclerView.setItemAnimator(new DefaultItemAnimator());
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //noinspection ConstantConditions
    getSupportActionBar().setTitle(R.string.title_manage_net_keys);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle(R.string.title_select_net_key);
    fab.hide();
    mAdapter = new ManageNetKeyAdapter(this, mViewModel.getSelectedMeshNode(), mViewModel.getNetworkLiveData().getNetworkKeys());
    mAdapter.setOnItemClickListener(this);
    netKeysRecyclerView.setAdapter(mAdapter);
}
 
Example 9
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_settings);
	ButterKnife.bind(this);

	setSupportActionBar(mToolbar);
	if (getSupportActionBar() != null) {
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
	}
	SettingsCategoryAdapter mAdapter = new SettingsCategoryAdapter();
	mAdapter.setItemCallback(this);
	mAdapter.addItems(constructSettingsCategories());

	mCategoryList.setAdapter(mAdapter);
	mCategoryList.setLayoutManager(new LinearLayoutManager(getBaseContext()));
	mCategoryList.setItemAnimator(new DefaultItemAnimator());
}
 
Example 10
Source Project: brickkit-android   Source File: BrickFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@CallSuper
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view;
    if (orientation() == OrientationHelper.VERTICAL) {
        view = inflater.inflate(R.layout.vertical_fragment_brick, container, false);
    } else {
        view = inflater.inflate(R.layout.horizontal_fragment_brick, container, false);
    }

    RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    recyclerView.setBackgroundColor(recyclerViewBackground);
    ((DefaultItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    dataManager.setRecyclerView(getContext(), recyclerView, orientation(), reverse(), view);
    return view;
}
 
Example 11
Source Project: OmegaRecyclerView   Source File: OmegaExpandableRecyclerView.java    License: MIT License 6 votes vote down vote up
@Nullable
private ItemAnimator requestItemAnimator() {
    switch (mChildExpandAnimation) {
        case CHILD_ANIM_DEFAULT:
            return new DefaultItemAnimator();
        case CHILD_ANIM_DROPDOWN:
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                return new DropDownItemAnimator();
            } else {
                Log.e(TAG, "DropDownItemAnimator supported only since Lollipop");
                return new DefaultItemAnimator();
            }
        case CHILD_ANIM_FADE:
            return new FadeItemAnimator();
    }
    return null;
}
 
Example 12
Source Project: science-journal   Source File: GalleryNoteFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(
    LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
  View rootView = inflater.inflate(R.layout.gallery_note_fragment, null);

  RecyclerView gallery = rootView.findViewById(R.id.gallery);
  GridLayoutManager layoutManager =
      new GridLayoutManager(
          gallery.getContext(),
          gallery.getContext().getResources().getInteger(R.integer.gallery_column_count));
  gallery.setLayoutManager(layoutManager);
  gallery.setItemAnimator(new DefaultItemAnimator());
  gallery.setAdapter(galleryAdapter);
  addButton = rootView.findViewById(R.id.btn_add);

  requestPermission();
  attachAddButton(addButton);
  actionController.attachAddButton(addButton);
  actionController.attachProgressBar(rootView.findViewById(R.id.recording_progress_bar));
  setUpTitleBar(rootView, false, R.string.action_bar_gallery, R.drawable.ic_gallery);

  return rootView;
}
 
Example 13
Source Project: candybar   Source File: SettingsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    initSettings();
}
 
Example 14
Source Project: candybar   Source File: ApplyFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
            getActivity().getResources().getInteger(R.integer.apply_column_count)));

    if (CandyBarApplication.getConfiguration().getApplyGrid() == CandyBarApplication.GridStyle.FLAT) {
        int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
        mRecyclerView.setPadding(padding, padding, 0, 0);
    }

    mAsyncTask = new LaunchersLoader().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 15
Source Project: candybar   Source File: IconsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
            getActivity().getResources().getInteger(R.integer.icons_column_count)));
    setFastScrollColor(mFastScroll);
    mFastScroll.attachRecyclerView(mRecyclerView);

    IconsAdapter adapter = new IconsAdapter(getActivity(), mIcons, false, this);
    mRecyclerView.setAdapter(adapter);
}
 
Example 16
Source Project: candybar   Source File: IconsSearchFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(true);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
            getActivity().getResources().getInteger(R.integer.icons_column_count)));
    mFastScroll.attachRecyclerView(mRecyclerView);
    setFastScrollColor(mFastScroll);

    mAsyncTask = new IconsLoader().execute();
}
 
Example 17
Source Project: candybar   Source File: AboutFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    resetRecyclerViewPadding(getActivity().getResources().getConfiguration().orientation);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    int spanCount = getActivity().getResources().getInteger(R.integer.about_column_count);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(
            spanCount, StaggeredGridLayoutManager.VERTICAL));
    mRecyclerView.setAdapter(new AboutAdapter(getActivity(), spanCount));
}
 
Example 18
Source Project: candybar   Source File: FAQsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

    setFastScrollColor(mFastScroll);
    mFastScroll.attachRecyclerView(mRecyclerView);

    mAsyncTask = new FAQsLoader().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example 19
Source Project: candybar   Source File: WallpapersFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ViewCompat.setNestedScrollingEnabled(mRecyclerView, false);

    initPopupBubble();
    mProgress.getIndeterminateDrawable().setColorFilter(
            ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent),
            PorterDuff.Mode.SRC_IN);
    mSwipe.setColorSchemeColors(
            ContextCompat.getColor(getActivity(), R.color.swipeRefresh));

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setHasFixedSize(false);
    mRecyclerView.setLayoutManager(new GridLayoutManager(getActivity(),
            getActivity().getResources().getInteger(R.integer.wallpapers_column_count)));

    if (CandyBarApplication.getConfiguration().getWallpapersGrid() == CandyBarApplication.GridStyle.FLAT) {
        int padding = getActivity().getResources().getDimensionPixelSize(R.dimen.card_margin);
        mRecyclerView.setPadding(padding, padding, 0, 0);
    }

    setFastScrollColor(mFastScroll);
    mFastScroll.attachRecyclerView(mRecyclerView);

    mSwipe.setOnRefreshListener(() -> {
        if (mProgress.getVisibility() == View.GONE)
            mAsyncTask = new WallpapersLoader(true).execute();
        else mSwipe.setRefreshing(false);
    });

    mAsyncTask = new WallpapersLoader(false).execute();
}
 
Example 20
Source Project: candybar   Source File: RequestFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setHasOptionsMenu(false);
    resetRecyclerViewPadding(getResources().getConfiguration().orientation);

    mProgress.getIndeterminateDrawable().setColorFilter(
            ColorHelper.getAttributeColor(getActivity(), R.attr.colorAccent),
            PorterDuff.Mode.SRC_IN);

    int color = ColorHelper.getTitleTextColor(ColorHelper
            .getAttributeColor(getActivity(), R.attr.colorAccent));
    mFab.setImageDrawable(DrawableHelper.getTintedDrawable(
            getActivity(), R.drawable.ic_fab_send, color));
    mFab.setOnClickListener(this);

    if (!Preferences.get(getActivity()).isFabShadowEnabled()) {
        mFab.setCompatElevation(0f);
    }

    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.getItemAnimator().setChangeDuration(0);
    mManager = new StaggeredGridLayoutManager(
            getActivity().getResources().getInteger(R.integer.request_column_count),
            StaggeredGridLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(mManager);

    setFastScrollColor(mFastScroll);
    mFastScroll.attachRecyclerView(mRecyclerView);

    mAsyncTask = new MissingAppsLoader().execute();
}
 
Example 21
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.contact_selection_list_fragment, container, false);

  emptyText                = view.findViewById(android.R.id.empty);
  recyclerView             = view.findViewById(R.id.recycler_view);
  swipeRefresh             = view.findViewById(R.id.swipe_refresh);
  fastScroller             = view.findViewById(R.id.fast_scroller);
  showContactsLayout       = view.findViewById(R.id.show_contacts_container);
  showContactsButton       = view.findViewById(R.id.show_contacts_button);
  showContactsDescription  = view.findViewById(R.id.show_contacts_description);
  showContactsProgress     = view.findViewById(R.id.progress);
  chipGroup                = view.findViewById(R.id.chipGroup);
  chipGroupScrollContainer = view.findViewById(R.id.chipGroupScrollContainer);
  groupLimit               = view.findViewById(R.id.group_limit);
  constraintLayout         = view.findViewById(R.id.container);

  recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
  recyclerView.setItemAnimator(new DefaultItemAnimator() {
    @Override
    public boolean canReuseUpdatedViewHolder(@NonNull RecyclerView.ViewHolder viewHolder) {
      return true;
    }
  });

  swipeRefresh.setEnabled(requireActivity().getIntent().getBooleanExtra(REFRESHABLE, true));

  selectionLimit   = requireActivity().getIntent().getIntExtra(TOTAL_CAPACITY, NO_LIMIT);
  currentSelection = getCurrentSelection();

  updateGroupLimit(getChipCount());

  return view;
}
 
Example 22
@Override
public void onActivityCreated(Bundle bundle) {
  super.onActivityCreated(bundle);

  this.giphyAdapter = new GiphyAdapter(getActivity(), GlideApp.with(this), new LinkedList<>());
  this.giphyAdapter.setListener(this);

  setLayoutManager(TextSecurePreferences.isGifSearchInGridLayout(getContext()));
  this.recyclerView.setItemAnimator(new DefaultItemAnimator());
  this.recyclerView.setAdapter(giphyAdapter);
  this.recyclerView.addOnScrollListener(new GiphyScrollListener());

  getLoaderManager().initLoader(0, null, this);
}
 
Example 23
public ThreadPhotoRailView(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  inflate(context, R.layout.recipient_preference_photo_rail, this);

  this.recyclerView = ViewUtil.findById(this, R.id.photo_list);
  this.recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
  this.recyclerView.setItemAnimator(new DefaultItemAnimator());
  this.recyclerView.setNestedScrollingEnabled(false);
}
 
Example 24
public RecentPhotoViewRail(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);

  inflate(context, R.layout.recent_photo_view, this);

  this.recyclerView = ViewUtil.findById(this, R.id.photo_list);
  this.recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
  this.recyclerView.setItemAnimator(new DefaultItemAnimator());
}
 
Example 25
Source Project: weather   Source File: MultipleDaysFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void initRecyclerView() {
  LinearLayoutManager layoutManager
      = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
  recyclerView.setLayoutManager(layoutManager);
  mItemAdapter = new ItemAdapter<>();
  mFastAdapter = FastAdapter.with(mItemAdapter);
  recyclerView.setItemAnimator(new DefaultItemAnimator());
  recyclerView.setAdapter(mFastAdapter);
}
 
Example 26
Source Project: weather   Source File: HourlyActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void initRecyclerView() {
  LinearLayoutManager layoutManager
      = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
  recyclerView.setLayoutManager(layoutManager);
  mItemAdapter = new ItemAdapter<>();
  mFastAdapter = FastAdapter.with(mItemAdapter);
  recyclerView.setItemAnimator(new DefaultItemAnimator());
  recyclerView.setAdapter(mFastAdapter);
}
 
Example 27
Source Project: Instagram-Profile-Downloader   Source File: SearchActivity.java    License: MIT License 5 votes vote down vote up
private void initViews() {

        userObjectList = new ArrayList<>();
        userObjectListCopy = new ArrayList<>();
        storiesListAdapter = new StoriesListAdapter(this,false);
        RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(mLayoutManager);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.setAdapter(storiesListAdapter);
    }
 
Example 28
@Override
protected void bindView() {


    //设置为垂直的样式
    recycler_view_list.setLayoutManager(new LinearLayoutManager(this));
    //使用的是系统默认的分割线
    //recycler_view_list.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL));
    //设置适配器
    recycler_view_list.setAdapter(adapter=new SimpleBookListDetailAdapter(this));
    recycler_view_list.setNestedScrollingEnabled(false);
    //设置默认动画
    recycler_view_list.setItemAnimator(new DefaultItemAnimator());

    final Animation animation = AnimationUtils.loadAnimation(this, R.anim.alpha);
    adapter.setOnItemClickListener(new SimpleBookListDetailAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(View view, int position) {
            view.startAnimation(animation);
            // Toast.makeText(mContext, position + " click",
            //        Toast.LENGTH_SHORT).show();

            RecommendBookBean recommendBookBean = adapter.getDataList().get(position);
            Intent intent = new Intent(getContext(), MyMainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            String key = String.valueOf(System.currentTimeMillis());
            intent.putExtra("recommendBook", recommendBookBean.getTitle());

            startActivityByAnim(intent, android.R.anim.fade_in, android.R.anim.fade_out);

        }
    });
}
 
Example 29
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_quick_switch);
    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.quick_switch);

    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);
    if (app.profileId() >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == app.profileId()) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }

    if (Build.VERSION.SDK_INT >= 25) {
        ShortcutManager service = getSystemService(ShortcutManager.class);
        if (service != null) {
            service.reportShortcutUsed("switch");
        }
    }
}
 
Example 30
Source Project: ShadowsocksRR   Source File: TaskerActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_tasker);

    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    toolbar.setNavigationIcon(R.drawable.ic_navigation_close);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    taskerOption = TaskerSettings.fromIntent(getIntent());
    mSwitch = (Switch) findViewById(R.id.serviceSwitch);
    mSwitch.setChecked(taskerOption.switchOn);
    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);

    if (taskerOption.profileId >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == taskerOption.profileId) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }
}