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;
}
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);
}
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;
}
});
}
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();
}
}
});
}
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);
}
Aggregations