Search in sources :

Example 91 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project fresco by facebook.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRecyclerView = (RecyclerView) findViewById(R.id.image_grid);
    mRecyclerView.setLayoutManager(new GridLayoutManager(this, COLS_NUMBER));
    FLog.setMinimumLoggingLevel(FLog.WARN);
    Drawables.init(getResources());
    mPerfListener = new PerfListener();
    mAllowAnimations = true;
    mCurrentLoaderAdapterIndex = 0;
    mCurrentSourceAdapterIndex = 0;
    if (savedInstanceState != null) {
        mAllowAnimations = savedInstanceState.getBoolean(EXTRA_ALLOW_ANIMATIONS);
        mCurrentLoaderAdapterIndex = savedInstanceState.getInt(EXTRA_CURRENT_ADAPTER_INDEX);
        mCurrentSourceAdapterIndex = savedInstanceState.getInt(EXTRA_CURRENT_SOURCE_ADAPTER_INDEX);
    }
    mHandler = new Handler(Looper.getMainLooper());
    mStatsClockTickRunnable = new Runnable() {

        @Override
        public void run() {
            updateStats();
            scheduleNextStatsClockTick();
        }
    };
    mCurrentAdapter = null;
    mStatsDisplay = (TextView) findViewById(R.id.stats_display);
    mLoaderSelect = (Spinner) findViewById(R.id.loader_select);
    mLoaderSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setLoaderAdapter(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mLoaderSelect.setSelection(mCurrentLoaderAdapterIndex);
    mSourceSelect = (Spinner) findViewById(R.id.source_select);
    mSourceSelect.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            setSourceAdapter(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    mSourceSelect.setSelection(mCurrentSourceAdapterIndex);
    mHasStoragePermissions = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
}
Also used : PerfListener(com.facebook.samples.comparison.instrumentation.PerfListener) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) Handler(android.os.Handler) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) Point(android.graphics.Point)

Example 92 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project fresco by facebook.

the class MainFragment method initializeGridRecyclerView.

private void initializeGridRecyclerView(final View layout) {
    // Get RecyclerView
    mRecyclerView = UI.findViewById(layout, R.id.recycler_view);
    // Choose the LayoutManager
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), mConfig.gridSpanCount);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.scrollToPosition(0);
    mRecyclerView.setLayoutManager(layoutManager);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager)

Example 93 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project fresco by facebook.

the class VitoViewRecyclerFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    final RecyclerView recyclerView = view.findViewById(R.id.recycler_view);
    recyclerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {

        @Override
        public void onLayoutChange(View view, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
            final int imageSize = (right - left) / SPAN_COUNT;
            mResizeOptions = new ResizeOptions(imageSize, imageSize);
            mOptionsBuilder = mOptionsBuilder.resize(mResizeOptions);
        }
    });
    GridLayoutManager layoutManager = new GridLayoutManager(getContext(), SPAN_COUNT);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setHasFixedSize(true);
    final SimpleAdapter adapter = new SimpleAdapter(new ArrayList<Uri>());
    recyclerView.setAdapter(adapter);
    final Spinner imageSource = view.findViewById(R.id.spinner_image_source);
    ImageSourceSpinner.INSTANCE.setup(imageSource, sampleUris(), new Function1<List<Uri>, Unit>() {

        @Override
        public Unit invoke(List<Uri> uris) {
            adapter.setData(uris);
            return null;
        }
    });
}
Also used : ImageSourceSpinner(com.facebook.fresco.samples.showcase.misc.ImageSourceSpinner) Spinner(android.widget.Spinner) Unit(kotlin.Unit) VitoView(com.facebook.fresco.vito.view.VitoView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Uri(android.net.Uri) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) ResizeOptions(com.facebook.imagepipeline.common.ResizeOptions) RecyclerView(androidx.recyclerview.widget.RecyclerView) ArrayList(java.util.ArrayList) List(java.util.List)

Example 94 with GridLayoutManager

use of androidx.recyclerview.widget.GridLayoutManager in project MovieGuide by esoxjem.

the class MoviesListingFragment method initLayoutReferences.

private void initLayoutReferences() {
    moviesListing.setHasFixedSize(true);
    int columns;
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        columns = 2;
    } else {
        columns = getResources().getInteger(R.integer.no_of_columns);
    }
    LinearLayoutManager layoutManager = new GridLayoutManager(getActivity(), columns);
    moviesListing.setLayoutManager(layoutManager);
    adapter = new MoviesListingAdapter(movies, this);
    moviesListing.setAdapter(adapter);
    moviesListing.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(@NotNull RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            int visibleItemCount = layoutManager.getChildCount();
            int totalItemCount = layoutManager.getItemCount();
            int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
            if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount && firstVisibleItemPosition >= 0) {
                moviesPresenter.nextPage();
            }
        }
    });
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 95 with GridLayoutManager

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

the class AlbumFragment method setLayoutManager.

private void setLayoutManager() {
    if (isGrid) {
        layoutManager = new GridLayoutManager(getActivity(), 2);
        fastScroller.setVisibility(View.GONE);
    } else {
        layoutManager = new GridLayoutManager(getActivity(), 1);
        fastScroller.setVisibility(View.VISIBLE);
        fastScroller.setRecyclerView(recyclerView);
    }
    recyclerView.setLayoutManager(layoutManager);
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager)

Aggregations

GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)122 RecyclerView (androidx.recyclerview.widget.RecyclerView)63 View (android.view.View)45 TextView (android.widget.TextView)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)16 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)13 ImageView (android.widget.ImageView)12 Nullable (androidx.annotation.Nullable)11 Toolbar (androidx.appcompat.widget.Toolbar)10 ViewGroup (android.view.ViewGroup)7 SmoothScrollGridLayoutManager (eu.davidea.flexibleadapter.common.SmoothScrollGridLayoutManager)7 SuppressLint (android.annotation.SuppressLint)6 Context (android.content.Context)6 ArrayList (java.util.ArrayList)6 NonNull (androidx.annotation.NonNull)5 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)5 List (java.util.List)5 RefreshingListenerAdapter (me.dkzwm.widget.srl.RefreshingListenerAdapter)5 Drawable (android.graphics.drawable.Drawable)4 Handler (android.os.Handler)3