Search in sources :

Example 11 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Timber by naman14.

the class AlbumDetailFragment method onCreateView.

@TargetApi(21)
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_album_detail, container, false);
    albumArt = (ImageView) rootView.findViewById(R.id.album_art);
    artistArt = (ImageView) rootView.findViewById(R.id.artist_art);
    albumTitle = (TextView) rootView.findViewById(R.id.album_title);
    albumDetails = (TextView) rootView.findViewById(R.id.album_details);
    toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
    fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    if (getArguments().getBoolean("transition")) {
        albumArt.setTransitionName(getArguments().getString("transition_name"));
    }
    recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    appBarLayout = (AppBarLayout) rootView.findViewById(R.id.app_bar);
    recyclerView.setEnabled(false);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    album = AlbumLoader.getAlbum(getActivity(), albumID);
    setAlbumart();
    setUpEverything();
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                @Override
                public void run() {
                    AlbumSongsAdapter adapter = (AlbumSongsAdapter) recyclerView.getAdapter();
                    MusicPlayer.playAll(getActivity(), adapter.getSongIds(), 0, albumID, TimberUtils.IdType.Album, true);
                    NavigationUtils.navigateToNowplaying(getActivity(), false);
                }
            }, 150);
        }
    });
    return rootView;
}
Also used : AlbumSongsAdapter(com.naman14.timber.adapters.AlbumSongsAdapter) Handler(android.os.Handler) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) TargetApi(android.annotation.TargetApi)

Example 12 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Timber by naman14.

the class Timber5 method setupSlidingQueue.

private void setupSlidingQueue() {
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
    adapter = new SlidingQueueAdapter((AppCompatActivity) getActivity(), QueueLoader.getQueueSongs(getActivity()));
    recyclerView.setAdapter(adapter);
    recyclerView.scrollToPosition(MusicPlayer.getQueuePosition() - 3);
}
Also used : SlidingQueueAdapter(com.naman14.timber.adapters.SlidingQueueAdapter) AppCompatActivity(androidx.appcompat.app.AppCompatActivity) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 13 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Timber by naman14.

the class ArtistMusicFragment method setUpSongs.

private void setUpSongs() {
    songsRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
    ArrayList<Song> songList;
    songList = ArtistSongLoader.getSongsForArtist(getActivity(), artistID);
    // adding one dummy song to top of arraylist
    // there will be albums header at this position in recyclerview
    songList.add(0, new Song(-1, -1, -1, "dummy", "dummy", "dummy", -1, -1));
    mSongAdapter = new ArtistSongAdapter(getActivity(), songList, artistID);
    songsRecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    songsRecyclerview.setAdapter(mSongAdapter);
}
Also used : Song(com.naman14.timber.models.Song) ArtistSongAdapter(com.naman14.timber.adapters.ArtistSongAdapter) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(com.naman14.timber.widgets.DividerItemDecoration)

Example 14 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Timber by naman14.

the class PlaylistDetailActivity method onCreate.

@TargetApi(21)
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playlist_detail);
    action = getIntent().getAction();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setTitle("");
    playlistsMap.put(Constants.NAVIGATE_PLAYLIST_LASTADDED, playlistLastAdded);
    playlistsMap.put(Constants.NAVIGATE_PLAYLIST_RECENT, playlistRecents);
    playlistsMap.put(Constants.NAVIGATE_PLAYLIST_TOPTRACKS, playlistToptracks);
    playlistsMap.put(Constants.NAVIGATE_PLAYLIST_USERCREATED, playlistUsercreated);
    recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
    blurFrame = (ImageView) findViewById(R.id.blurFrame);
    playlistname = (TextView) findViewById(R.id.name);
    foreground = findViewById(R.id.foreground);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    setAlbumart();
    animate = getIntent().getBooleanExtra(Constants.ACTIVITY_TRANSITION, false);
    if (animate && TimberUtils.isLollipop()) {
        if (savedInstanceState != null && savedInstanceState.containsKey("ROTATION_RECREATION")) {
            setUpSongs();
        } else {
            getWindow().getEnterTransition().addListener(new EnterTransitionListener());
        }
    } else {
        setUpSongs();
    }
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) Toolbar(androidx.appcompat.widget.Toolbar) TargetApi(android.annotation.TargetApi)

Example 15 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Tusky by Vavassor.

the class NotificationsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_timeline_notifications, container, false);
    // from inflater to silence warning
    @NonNull Context context = inflater.getContext();
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
    boolean showNotificationsFilterSetting = preferences.getBoolean("showNotificationsFilter", true);
    // Clear notifications on filter visibility change to force refresh
    if (showNotificationsFilterSetting != showNotificationsFilter)
        notifications.clear();
    showNotificationsFilter = showNotificationsFilterSetting;
    // Setup the SwipeRefreshLayout.
    swipeRefreshLayout = rootView.findViewById(R.id.swipeRefreshLayout);
    recyclerView = rootView.findViewById(R.id.recyclerView);
    progressBar = rootView.findViewById(R.id.progressBar);
    statusView = rootView.findViewById(R.id.statusView);
    appBarOptions = rootView.findViewById(R.id.appBarOptions);
    swipeRefreshLayout.setOnRefreshListener(this);
    swipeRefreshLayout.setColorSchemeResources(R.color.tusky_blue);
    loadNotificationsFilter();
    // Setup the RecyclerView.
    recyclerView.setHasFixedSize(true);
    layoutManager = new LinearLayoutManager(context);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAccessibilityDelegateCompat(new ListStatusAccessibilityDelegate(recyclerView, this, (pos) -> {
        NotificationViewData notification = notifications.getPairedItemOrNull(pos);
        // We support replies only for now
        if (notification instanceof NotificationViewData.Concrete) {
            return ((NotificationViewData.Concrete) notification).getStatusViewData();
        } else {
            return null;
        }
    }));
    recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    StatusDisplayOptions statusDisplayOptions = new StatusDisplayOptions(preferences.getBoolean("animateGifAvatars", false), accountManager.getActiveAccount().getMediaPreviewEnabled(), preferences.getBoolean("absoluteTimeView", false), preferences.getBoolean("showBotOverlay", true), preferences.getBoolean("useBlurhash", true), CardViewMode.NONE, preferences.getBoolean("confirmReblogs", true), preferences.getBoolean("confirmFavourites", false), preferences.getBoolean(PrefKeys.WELLBEING_HIDE_STATS_POSTS, false), preferences.getBoolean(PrefKeys.ANIMATE_CUSTOM_EMOJIS, false));
    adapter = new NotificationsAdapter(accountManager.getActiveAccount().getAccountId(), dataSource, statusDisplayOptions, this, this, this);
    alwaysShowSensitiveMedia = accountManager.getActiveAccount().getAlwaysShowSensitiveMedia();
    alwaysOpenSpoiler = accountManager.getActiveAccount().getAlwaysOpenSpoiler();
    recyclerView.setAdapter(adapter);
    topLoading = false;
    bottomLoading = false;
    bottomId = null;
    updateAdapter();
    Button buttonClear = rootView.findViewById(R.id.buttonClear);
    buttonClear.setOnClickListener(v -> confirmClearNotifications());
    buttonFilter = rootView.findViewById(R.id.buttonFilter);
    buttonFilter.setOnClickListener(v -> showFilterMenu());
    if (notifications.isEmpty()) {
        swipeRefreshLayout.setEnabled(false);
        sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1);
    } else {
        progressBar.setVisibility(View.GONE);
    }
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    updateFilterVisibility();
    return rootView;
}
Also used : Context(android.content.Context) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) AsyncDifferConfig(androidx.recyclerview.widget.AsyncDifferConfig) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) Utils(at.connyduck.sparkbutton.helpers.Utils) AccountActionListener(com.keylesspalace.tusky.interfaces.AccountActionListener) NotificationTypeConverterKt(com.keylesspalace.tusky.util.NotificationTypeConverterKt) AppBarLayout(com.google.android.material.appbar.AppBarLayout) BackgroundMessageView(com.keylesspalace.tusky.view.BackgroundMessageView) Locale(java.util.Locale) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) ActionButtonActivity(com.keylesspalace.tusky.interfaces.ActionButtonActivity) View(android.view.View) Button(android.widget.Button) RecyclerView(androidx.recyclerview.widget.RecyclerView) Function(androidx.arch.core.util.Function) Log(android.util.Log) ViewDataUtils(com.keylesspalace.tusky.util.ViewDataUtils) StatusViewData(com.keylesspalace.tusky.viewdata.StatusViewData) CoordinatorLayout(androidx.coordinatorlayout.widget.CoordinatorLayout) ListUpdateCallback(androidx.recyclerview.widget.ListUpdateCallback) DiffUtil(androidx.recyclerview.widget.DiffUtil) PreferenceChangedEvent(com.keylesspalace.tusky.appstore.PreferenceChangedEvent) StatusActionListener(com.keylesspalace.tusky.interfaces.StatusActionListener) Set(java.util.Set) Function1(kotlin.jvm.functions.Function1) Relationship(com.keylesspalace.tusky.entity.Relationship) ViewGroup(android.view.ViewGroup) ReselectableFragment(com.keylesspalace.tusky.interfaces.ReselectableFragment) Objects(java.util.Objects) FavoriteEvent(com.keylesspalace.tusky.appstore.FavoriteEvent) StatusDisplayOptions(com.keylesspalace.tusky.util.StatusDisplayOptions) AndroidSchedulers(io.reactivex.rxjava3.android.schedulers.AndroidSchedulers) List(java.util.List) Unit(kotlin.Unit) AutoDispose.autoDisposable(autodispose2.AutoDispose.autoDisposable) Nullable(androidx.annotation.Nullable) Pair(androidx.core.util.Pair) Disposable(io.reactivex.rxjava3.disposables.Disposable) CollectionsKt(kotlin.collections.CollectionsKt) AsyncListDiffer(androidx.recyclerview.widget.AsyncListDiffer) ListView(android.widget.ListView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) StringUtils.isLessThan(com.keylesspalace.tusky.util.StringUtils.isLessThan) AccountEntity(com.keylesspalace.tusky.db.AccountEntity) Context(android.content.Context) BookmarkEvent(com.keylesspalace.tusky.appstore.BookmarkEvent) Notification(com.keylesspalace.tusky.entity.Notification) Single(io.reactivex.rxjava3.core.Single) AlertDialog(androidx.appcompat.app.AlertDialog) Status(com.keylesspalace.tusky.entity.Status) AndroidLifecycleScopeProvider.from(autodispose2.androidx.lifecycle.AndroidLifecycleScopeProvider.from) ReblogEvent(com.keylesspalace.tusky.appstore.ReblogEvent) Poll(com.keylesspalace.tusky.entity.Poll) NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData) PairedList(com.keylesspalace.tusky.util.PairedList) ArrayList(java.util.ArrayList) StatusBaseViewHolder(com.keylesspalace.tusky.adapter.StatusBaseViewHolder) PrefKeys(com.keylesspalace.tusky.settings.PrefKeys) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Lifecycle(androidx.lifecycle.Lifecycle) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) R(com.keylesspalace.tusky.R) CardViewMode(com.keylesspalace.tusky.util.CardViewMode) Observable(io.reactivex.rxjava3.core.Observable) AttachmentViewData(com.keylesspalace.tusky.viewdata.AttachmentViewData) DialogInterface(android.content.DialogInterface) ListStatusAccessibilityDelegate(com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate) EventHub(com.keylesspalace.tusky.appstore.EventHub) BlockEvent(com.keylesspalace.tusky.appstore.BlockEvent) Iterator(java.util.Iterator) LayoutInflater(android.view.LayoutInflater) SwipeRefreshLayout(androidx.swiperefreshlayout.widget.SwipeRefreshLayout) PopupWindow(android.widget.PopupWindow) HttpHeaderLink(com.keylesspalace.tusky.util.HttpHeaderLink) Either(com.keylesspalace.tusky.util.Either) IOException(java.io.IOException) TimeUnit(java.util.concurrent.TimeUnit) ArrayAdapter(android.widget.ArrayAdapter) SparseBooleanArray(android.util.SparseBooleanArray) PinEvent(com.keylesspalace.tusky.appstore.PinEvent) SharedPreferences(android.content.SharedPreferences) NotificationsAdapter(com.keylesspalace.tusky.adapter.NotificationsAdapter) PreferenceManager(androidx.preference.PreferenceManager) ListUtils(com.keylesspalace.tusky.util.ListUtils) AccountManager(com.keylesspalace.tusky.db.AccountManager) EndlessOnScrollListener(com.keylesspalace.tusky.view.EndlessOnScrollListener) Injectable(com.keylesspalace.tusky.di.Injectable) Activity(android.app.Activity) Collections(java.util.Collections) SimpleItemAnimator(androidx.recyclerview.widget.SimpleItemAnimator) SharedPreferences(android.content.SharedPreferences) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) BackgroundMessageView(com.keylesspalace.tusky.view.BackgroundMessageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ListView(android.widget.ListView) StatusDisplayOptions(com.keylesspalace.tusky.util.StatusDisplayOptions) NotificationsAdapter(com.keylesspalace.tusky.adapter.NotificationsAdapter) ListStatusAccessibilityDelegate(com.keylesspalace.tusky.util.ListStatusAccessibilityDelegate) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Button(android.widget.Button) NonNull(androidx.annotation.NonNull) NotificationViewData(com.keylesspalace.tusky.viewdata.NotificationViewData) Nullable(androidx.annotation.Nullable)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)470 RecyclerView (androidx.recyclerview.widget.RecyclerView)281 View (android.view.View)183 TextView (android.widget.TextView)65 ArrayList (java.util.ArrayList)37 Nullable (androidx.annotation.Nullable)33 Bundle (android.os.Bundle)32 Toolbar (androidx.appcompat.widget.Toolbar)32 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)27 List (java.util.List)24 Test (org.junit.Test)24 Context (android.content.Context)23 NonNull (androidx.annotation.NonNull)23 ViewGroup (android.view.ViewGroup)22 AlertDialog (androidx.appcompat.app.AlertDialog)21 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 LayoutInflater (android.view.LayoutInflater)18 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16