use of com.amaze.filemanager.ui.fragments.preference_fragments.PreferencesConstants.PREFERENCE_SHOW_DIVIDERS in project AmazeFileManager by TeamAmaze.
the class MainFragment method onViewCreated.
@Override
@SuppressWarnings("PMD.NPathComplexity")
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mainFragmentViewModel = new ViewModelProvider(this).get(MainFragmentViewModel.class);
listView = rootView.findViewById(R.id.listView);
mToolbarContainer = getMainActivity().getAppbar().getAppbarLayout();
fastScroller = rootView.findViewById(R.id.fastscroll);
fastScroller.setPressedHandleColor(mainFragmentViewModel.getAccentColor());
View.OnTouchListener onTouchListener = (view1, motionEvent) -> {
if (adapter != null && mainFragmentViewModel.getStopAnims()) {
stopAnimation();
mainFragmentViewModel.setStopAnims(false);
}
return false;
};
listView.setOnTouchListener(onTouchListener);
// listView.setOnDragListener(new MainFragmentDragListener());
mToolbarContainer.setOnTouchListener(onTouchListener);
mSwipeRefreshLayout = rootView.findViewById(R.id.activity_main_swipe_refresh_layout);
mSwipeRefreshLayout.setOnRefreshListener(() -> loadlist((mainFragmentViewModel.getCurrentPath()), false, mainFragmentViewModel.getOpenMode()));
// String itemsstring = res.getString(R.string.items);// TODO: 23/5/2017 use or delete
mToolbarContainer.setBackgroundColor(MainActivity.currentTab == 1 ? mainFragmentViewModel.getPrimaryTwoColor() : mainFragmentViewModel.getPrimaryColor());
// listView.setPadding(listView.getPaddingLeft(), paddingTop, listView.getPaddingRight(),
// listView.getPaddingBottom());
setHasOptionsMenu(false);
initNoFileLayout();
HybridFile f = new HybridFile(OpenMode.UNKNOWN, mainFragmentViewModel.getCurrentPath());
f.generateMode(getActivity());
getMainActivity().getAppbar().getBottomBar().setClickListener();
if (utilsProvider.getAppTheme().equals(AppTheme.LIGHT) && !mainFragmentViewModel.isList()) {
listView.setBackgroundColor(Utils.getColor(getContext(), R.color.grid_background_light));
} else {
listView.setBackgroundDrawable(null);
}
listView.setHasFixedSize(true);
if (mainFragmentViewModel.isList()) {
mLayoutManager = new CustomScrollLinearLayoutManager(getContext());
listView.setLayoutManager(mLayoutManager);
} else {
if (mainFragmentViewModel.getColumns() == -1 || mainFragmentViewModel.getColumns() == 0)
mLayoutManagerGrid = new CustomScrollGridLayoutManager(getActivity(), 3);
else
mLayoutManagerGrid = new CustomScrollGridLayoutManager(getActivity(), mainFragmentViewModel.getColumns());
setGridLayoutSpanSizeLookup(mLayoutManagerGrid);
listView.setLayoutManager(mLayoutManagerGrid);
}
// use a linear layout manager
// View footerView = getActivity().getLayoutInflater().inflate(R.layout.divider, null);// TODO:
// 23/5/2017 use or delete
dividerItemDecoration = new DividerItemDecoration(getActivity(), false, getBoolean(PREFERENCE_SHOW_DIVIDERS));
listView.addItemDecoration(dividerItemDecoration);
mSwipeRefreshLayout.setColorSchemeColors(mainFragmentViewModel.getAccentColor());
DefaultItemAnimator animator = new DefaultItemAnimator();
listView.setItemAnimator(animator);
mToolbarContainer.getViewTreeObserver().addOnGlobalLayoutListener(this);
loadViews();
}
Aggregations