Java Code Examples for androidx.recyclerview.widget.LinearLayoutManager#setOrientation()

The following examples show how to use androidx.recyclerview.widget.LinearLayoutManager#setOrientation() . 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 File: AddToFoldersActivity.java    From android-notepad with MIT License 6 votes vote down vote up
@Override protected void onCreate(@Nullable Bundle savedInstanceState){
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_list_of_folders);
	AddToFoldersActivityIntentBuilder.inject(getIntent(), this);
	ButterKnife.bind(this);
	setSupportActionBar(mToolbar);
	mToolbar.setTitle("Add to folders");
	mToolbar.setNavigationIcon(R.drawable.ic_close_white_24dp);
	mToolbar.setNavigationOnClickListener(new View.OnClickListener(){
		@Override public void onClick(View v){
			onBackPressed();
		}
	});
	LinearLayoutManager llm = new LinearLayoutManager(this);
	llm.setOrientation(RecyclerView.VERTICAL);
	mRecyclerView.setLayoutManager(llm);
	adapter = new Adapter(noteId);
	mRecyclerView.setAdapter(adapter);
	adapter.loadFromDatabase();
}
 
Example 2
Source File: FilmDetailActivity.java    From CloudReader with Apache License 2.0 6 votes vote down vote up
/**
 * 剧照
 */
private void setImageAdapter(List<FilmDetailBean.ImageListBean> listBeans) {
    bindingContentView.xrvImages.setVisibility(View.VISIBLE);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(FilmDetailActivity.this);
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    bindingContentView.xrvImages.setLayoutManager(mLayoutManager);
    // 需加,不然滑动不流畅
    bindingContentView.xrvImages.setNestedScrollingEnabled(false);
    bindingContentView.xrvImages.setHasFixedSize(false);

    FilmDetailImageAdapter mAdapter = new FilmDetailImageAdapter(this, listBeans);
    mAdapter.addAll(listBeans);
    bindingContentView.xrvImages.setAdapter(mAdapter);
    bindingContentView.xrvImages.setFocusable(false);
    bindingContentView.xrvImages.setFocusableInTouchMode(false);
    initRxBus();
}
 
Example 3
Source File: FavFragment.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.fragment_fav, container, false);

    // find view
    mSwipeRefreshLayout = rootView.findViewById(R.id.swipe_refresh_layout);

    // init values
    timecount = 0;

    // view setting
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView = rootView.findViewById(R.id.novel_item_list);
    mRecyclerView.setHasFixedSize(false); // set variable size
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(mLayoutManager);

    mSwipeRefreshLayout.setColorSchemeColors(getResources().getColor(R.color.myAccentColor));
    mSwipeRefreshLayout.setOnRefreshListener(() -> new AsyncLoadAllCloud().execute(1));

    return rootView;
}
 
Example 4
Source File: ReorderListFragment.java    From RecyclerExt with Apache License 2.0 6 votes vote down vote up
private void setupRecyclerExt() {
    //Setup the standard Layout and Adapter
    listAdapter = new ListAdapter(getActivity());

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(orientation);

    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(listAdapter);


    //Create the ReorderDecoration, set the drag handle, and register for notifications of reorder events
    ReorderDecoration reorderDecoration = new ReorderDecoration(recyclerView);
    reorderDecoration.setDragHandleId(R.id.simple_drag_item_handle);
    reorderDecoration.setOrientation(orientation == LinearLayoutManager.VERTICAL ? ReorderDecoration.LayoutOrientation.VERTICAL : ReorderDecoration.LayoutOrientation.HORIZONTAL);
    reorderDecoration.setReorderListener(this);


    //Register the decoration and the item touch listener to monitor during the reordering
    recyclerView.addItemDecoration(reorderDecoration);
    recyclerView.addOnItemTouchListener(reorderDecoration);
}
 
Example 5
Source File: SongFragment.java    From Jockey with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_library_page, container, false);
    mRecyclerView = view.findViewById(R.id.library_page_list);
    mRecyclerView.addItemDecoration(new BackgroundDecoration());
    mRecyclerView.addItemDecoration(new DividerDecoration(getContext(), R.id.empty_layout));

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(layoutManager);

    if (mAdapter == null) {
        setupAdapter();
    } else {
        mRecyclerView.setAdapter(mAdapter);
    }

    int paddingH = (int) getActivity().getResources().getDimension(R.dimen.global_padding);
    view.setPadding(paddingH, 0, paddingH, 0);

    return view;
}
 
Example 6
Source File: ArtistListFragment.java    From Jockey with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_library_page, container, false);
    mRecyclerView = view.findViewById(R.id.library_page_list);
    mRecyclerView.addItemDecoration(new BackgroundDecoration());
    mRecyclerView.addItemDecoration(new DividerDecoration(getContext(), R.id.empty_layout));

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(layoutManager);

    if (mAdapter == null) {
        setupAdapter();
    } else {
        mRecyclerView.setAdapter(mAdapter);
    }

    int paddingH = (int) getActivity().getResources().getDimension(R.dimen.global_padding);
    view.setPadding(paddingH, 0, paddingH, 0);

    return view;
}
 
Example 7
Source File: GenreListFragment.java    From Jockey with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {

    View view = inflater.inflate(R.layout.fragment_library_page, container, false);
    mRecyclerView = view.findViewById(R.id.library_page_list);
    mRecyclerView.addItemDecoration(new BackgroundDecoration());
    mRecyclerView.addItemDecoration(new DividerDecoration(getContext(), R.id.empty_layout));

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(layoutManager);

    if (mAdapter == null) {
        setupAdapter();
    } else {
        mRecyclerView.setAdapter(mAdapter);
    }

    int paddingH = (int) getActivity().getResources().getDimension(R.dimen.global_padding);
    view.setPadding(paddingH, 0, paddingH, 0);

    return view;
}
 
Example 8
Source File: OneMovieDetailActivity.java    From CloudReader with Apache License 2.0 5 votes vote down vote up
/**
 * 设置导演&演员adapter
 */
private void setAdapter(MovieDetailBean movieDetailBean) {
    bindingContentView.xrvCast.setVisibility(View.VISIBLE);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(OneMovieDetailActivity.this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    bindingContentView.xrvCast.setLayoutManager(mLayoutManager);
    // 需加,不然滑动不流畅
    bindingContentView.xrvCast.setNestedScrollingEnabled(false);
    bindingContentView.xrvCast.setHasFixedSize(false);

    MovieDetailAdapter mAdapter = new MovieDetailAdapter();
    mAdapter.addAll(movieDetailBean.getDirectors());
    mAdapter.addAll(movieDetailBean.getCasts());
    bindingContentView.xrvCast.setAdapter(mAdapter);
}
 
Example 9
Source File: CarouselDecorator.java    From Hentoid with Apache License 2.0 5 votes vote down vote up
public CarouselDecorator(Context context, @LayoutRes int itemLayout) {
    this.context = context;
    this.itemLayout = itemLayout;
    adapter = new CarouselAdapter();
    layoutManager = new LinearLayoutManager(context);
    layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
}
 
Example 10
Source File: GenerateAddressActivity.java    From guarda-android-wallets with GNU General Public License v3.0 5 votes vote down vote up
private void initRecycler() {
    adapter = new CryptoAdapter();

    adapter.setItemClickListener(new CryptoAdapter.OnItemClickListener() {
        @Override
        public void OnItemClick(int position, String name, String code) {

            String walletNum = String.valueOf(walletManager.getWalletFriendlyAddress());
            getAddress(walletNum, code);

        }
    });

    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    rvCryptoRecycler.setLayoutManager(layoutManager);
    rvCryptoRecycler.setAdapter(adapter);

    if (currentCrypto.getListOfCurrencies() == null
            || currentCrypto.getListOfCurrencies().isEmpty()) {
        loadCurrencies();
    } else {
        adapter.updateList(currentCrypto.getListOfCurrencies());
        initDropDownSpinner(getArrayOfCryptoCode(currentCrypto.getListOfCurrencies()));
    }

    initTokensFields();
}
 
Example 11
Source File: PictureMultiCuttingActivity.java    From Matisse-Kotlin with Apache License 2.0 5 votes vote down vote up
/**
 * 动态添加多图裁剪底部预览图片列表
 */
private void addPhotoRecyclerView() {
    mRecyclerView = new RecyclerView(this);
    mRecyclerView.setId(R.id.id_recycler);
    mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
    RelativeLayout.LayoutParams lp =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, dip2px(80));
    mRecyclerView.setLayoutParams(lp);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mRecyclerView.setLayoutManager(mLayoutManager);
    resetCutDataStatus();
    list.get(cutIndex).setCut(true);
    adapter = new PicturePhotoGalleryAdapter(this, list);
    mRecyclerView.setAdapter(adapter);
    adapter.setOnItemClickListener((position, view) -> {
        if (cutIndex == position) {
            return;
        }
        cutIndex = position;
        resetCutData();
    });

    uCropMultiplePhotoBox.addView(mRecyclerView);
    changeLayoutParams();
    FrameLayout uCropFrame = findViewById(R.id.ucrop_frame);
    ((RelativeLayout.LayoutParams) uCropFrame.getLayoutParams())
            .addRule(RelativeLayout.ABOVE, R.id.id_recycler);
}
 
Example 12
Source File: MainFragment.java    From fresco with MIT License 5 votes vote down vote up
private void initializeRecyclerView(final View layout) {
  // Get RecyclerView
  mRecyclerView = UI.findViewById(layout, R.id.recycler_view);
  // Choose the LayoutManager
  LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  layoutManager.scrollToPosition(0);
  mRecyclerView.setLayoutManager(layoutManager);
}
 
Example 13
Source File: SettingActivity.java    From OneText_For_Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void initFeed() {
    feedList.clear();
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    feed_recyclerview.setLayoutManager(linearLayoutManager);
    feedAdapter = new FeedAdapter(feedList);
    feed_recyclerview.setAdapter(feedAdapter);
    int selectedInt = sharedPreferences.getInt("feed_code", 0);
    try {
        JSONArray jsonArray = new JSONArray(FileUtil.readTextFromFile(getFilesDir().getPath() + "/Feed/Feed.json"));
        for (int i = 0; i < jsonArray.length(); i++) {
            JSONObject jsonObject = new JSONObject(jsonArray.optString(i));
            String feedType = jsonObject.optString("feed_type");
            int feedTypeImageInt = 0;
            Boolean ifSelected;
            if (feedType.equals("remote")) {
                feedTypeImageInt = R.drawable.ic_cloud;
            } else if (feedType.equals("local")) {
                feedTypeImageInt = R.drawable.ic_file;
            } else if (feedType.equals("internet")) {
                feedTypeImageInt = R.drawable.ic_world;
            }
            if (selectedInt == i) {
                ifSelected = true;
            } else {
                ifSelected = false;
            }
            Feed feed = new Feed(this, feedTypeImageInt, jsonObject.optString("feed_name"), ifSelected);
            feedList.add(feed);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
 
Example 14
Source File: FriendsFragment.java    From toktok-android with GNU General Public License v3.0 5 votes vote down vote up
@NonNull
@Override
public LinearLayout onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedState) {
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.fragment_home_friends, container, false);
    AppCompatActivity activity = (AppCompatActivity) getActivity();

    //Recycler View

    RecyclerView friendsRecycler = view.findViewById(R.id.home_friends_recycler);

    LinearLayoutManager layoutManager = new LinearLayoutManager(activity.getBaseContext());
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    friendsRecycler.setLayoutManager(layoutManager);

    final List<Friend> friends = Arrays.asList(
            Friend.bart,
            Friend.lorem,
            Friend.jane,
            Friend.john
    );

    mFriendsRecyclerAdapter = new FriendsRecyclerHeaderAdapter(friends, this);

    friendsRecycler.setAdapter(mFriendsRecyclerAdapter);
    friendsRecycler.setHasFixedSize(true);
    friendsRecycler.addItemDecoration(new StickyRecyclerHeadersDecoration(mFriendsRecyclerAdapter));

    return view;
}
 
Example 15
Source File: EditFragment.java    From pandora with Apache License 2.0 4 votes vote down vote up
@Override
protected View getLayoutView() {
    View wrapper;
    editText = new EditText(getContext());
    int padding = ViewKnife.dip2px(16);
    editText.setPadding(padding, padding, padding, padding);
    editText.setBackgroundColor(Color.WHITE);
    editText.setGravity(Gravity.START | Gravity.TOP);
    editText.setTextColor(ViewKnife.getColor(R.color.pd_label_dark));
    editText.setLineSpacing(0, 1.2f);

    String[] options = getArguments().getStringArray(PARAM3);
    if (options != null && options.length > 0) {
        LinearLayout layout = new LinearLayout(getContext());
        layout.setOrientation(LinearLayout.VERTICAL);
        wrapper = layout;
        RecyclerView recyclerView = new RecyclerView(getContext());
        recyclerView.setBackgroundColor(Color.WHITE);
        LinearLayoutManager manager = new LinearLayoutManager(getContext());
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(manager);
        UniversalAdapter adapter = new UniversalAdapter();
        recyclerView.setAdapter(adapter);
        adapter.setListener(new UniversalAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, BaseItem item) {
                notifyResult(((OptionItem)item).data);
            }
        });
        List<BaseItem> items = new ArrayList<>(options.length);
        for (String option : options) {
            items.add(new OptionItem(option));
        }
        adapter.setItems(items);

        LinearLayout.LayoutParams recyclerParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewKnife.dip2px(50)
        );
        layout.addView(recyclerView, recyclerParam);
        LinearLayout.LayoutParams editParam = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT
        );
        layout.addView(editText, editParam);
    } else {
        wrapper = editText;
    }
    return wrapper;
}
 
Example 16
Source File: SearchActivity.java    From light-novel-library_Wenku8_Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_search);

    // bind views
    toolbarSearchView = findViewById(R.id.search_view);
    View searchClearButton = findViewById(R.id.search_clear);

    // Clear search text when clear button is tapped
    searchClearButton.setOnClickListener(v -> toolbarSearchView.setText(""));

    // set indicator enable
    Toolbar mToolbar = findViewById(R.id.toolbar_actionbar);
    setSupportActionBar(mToolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setHomeButtonEnabled(true);
    }

    // change status bar color tint, and this require SDK16
    if (Build.VERSION.SDK_INT >= 16 ) { //&& Build.VERSION.SDK_INT <= 21) {
        // Android API 22 has more effects on status bar, so ignore

        // create our manager instance after the content view is set
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        // enable all tint
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setNavigationBarTintEnabled(true);
        tintManager.setTintAlpha(0.15f);
        tintManager.setNavigationBarAlpha(0.0f);
        // set all color
        tintManager.setTintColor(getResources().getColor(android.R.color.black));
        // set Navigation bar color
        if(Build.VERSION.SDK_INT >= 21)
            getWindow().setNavigationBarColor(getResources().getColor(R.color.myNavigationColorWhite));
    }

    // set search clear icon color
    ImageView searchClearIcon = findViewById(R.id.search_clear_icon);
    searchClearIcon.setColorFilter(getResources().getColor(R.color.mySearchToggleColor), PorterDuff.Mode.SRC_ATOP);

    // set history list
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);

    RecyclerView mRecyclerView = this.findViewById(R.id.search_history_list);
    mRecyclerView.setHasFixedSize(true); // set variable size
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.setLayoutManager(mLayoutManager);

    historyList = GlobalConfig.getSearchHistory();
    adapter = new SearchHistoryAdapter(historyList);
    adapter.setOnItemClickListener(this); // add item click listener
    adapter.setOnItemLongClickListener(this); // add item click listener
    mRecyclerView.setAdapter(adapter);

    // set search action
    toolbarSearchView.setOnEditorActionListener((v, actionId, event) -> {
        // purify
        String temp = toolbarSearchView.getText().toString().trim();
        if(temp.length()==0) return false;

        // real action
        //Toast.makeText(MyApp.getContext(), temp, Toast.LENGTH_SHORT).show();
        GlobalConfig.addSearchHistory(temp);
        refreshHistoryList();

        // jump to search
        Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
        intent.putExtra("key", temp);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // long-press will cause repetitions
        startActivity(intent);
        overridePendingTransition( R.anim.fade_in, R.anim.hold);

        return false;
    });
}
 
Example 17
Source File: FavoritesCardItemView.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
@NonNull
private RecyclerView.LayoutManager getLayoutManager() {
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    return linearLayoutManager;
}
 
Example 18
Source File: PictureMultiCuttingActivity.java    From PictureSelector with Apache License 2.0 4 votes vote down vote up
/**
 * 动态添加多图裁剪底部预览图片列表
 */
private void addPhotoRecyclerView() {
    boolean isMultipleSkipCrop = getIntent().getBooleanExtra(UCrop.Options.EXTRA_SKIP_MULTIPLE_CROP, true);
    mRecyclerView = new RecyclerView(this);
    mRecyclerView.setId(R.id.id_recycler);
    mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
    RelativeLayout.LayoutParams lp =
            new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
                    ScreenUtils.dip2px(this, 80));
    mRecyclerView.setLayoutParams(lp);
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    if (isAnimation) {
        LayoutAnimationController animation = AnimationUtils
                .loadLayoutAnimation(getApplicationContext(), R.anim.ucrop_layout_animation_fall_down);
        mRecyclerView.setLayoutAnimation(animation);
    }
    mRecyclerView.setLayoutManager(mLayoutManager);
    // 解决调用 notifyItemChanged 闪烁问题,取消默认动画
    ((SimpleItemAnimator) mRecyclerView.getItemAnimator())
            .setSupportsChangeAnimations(false);
    resetCutDataStatus();
    list.get(cutIndex).setCut(true);
    mAdapter = new PicturePhotoGalleryAdapter(this, list);
    mRecyclerView.setAdapter(mAdapter);
    if (isMultipleSkipCrop) {
        mAdapter.setOnItemClickListener(new PicturePhotoGalleryAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int position, View view) {
                CutInfo cutInfo = list.get(position);
                if (MimeType.isHasVideo(cutInfo.getMimeType())) {
                    return;
                }
                if (cutIndex == position) {
                    return;
                }
                resetLastCropStatus();
                cutIndex = position;
                oldCutIndex = cutIndex;
                resetCutData();
            }
        });
    }
    uCropPhotoBox.addView(mRecyclerView);
    changeLayoutParams(mShowBottomControls);

    // 裁剪框居于RecyclerView之上
    FrameLayout uCropFrame = findViewById(R.id.ucrop_frame);
    ((RelativeLayout.LayoutParams) uCropFrame.getLayoutParams())
            .addRule(RelativeLayout.ABOVE, R.id.id_recycler);

    // RecyclerView居于BottomControls之上
    ((RelativeLayout.LayoutParams) mRecyclerView.getLayoutParams())
            .addRule(RelativeLayout.ABOVE, R.id.controls_wrapper);
}
 
Example 19
Source File: ThemesHorizontalListCell.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public ThemesHorizontalListCell(Context context, int type, ArrayList<Theme.ThemeInfo> def, ArrayList<Theme.ThemeInfo> dark) {
    super(context);

    darkThemes = dark;
    defaultThemes = def;
    currentType = type;

    if (type == ThemeActivity.THEME_TYPE_OTHER) {
        setBackgroundColor(Theme.getColor(Theme.key_dialogBackground));
    } else {
        setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
    }
    setItemAnimator(null);
    setLayoutAnimation(null);
    horizontalLayoutManager = new LinearLayoutManager(context) {
        @Override
        public boolean supportsPredictiveItemAnimations() {
            return false;
        }
    };
    setPadding(0, 0, 0, 0);
    setClipToPadding(false);
    horizontalLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    setLayoutManager(horizontalLayoutManager);
    setAdapter(adapter = new ThemesListAdapter(context));
    setOnItemClickListener((view1, position) -> {
        selectTheme(((InnerThemeView) view1).themeInfo);
        int left = view1.getLeft();
        int right = view1.getRight();
        if (left < 0) {
            smoothScrollBy(left - AndroidUtilities.dp(8), 0);
        } else if (right > getMeasuredWidth()) {
            smoothScrollBy(right - getMeasuredWidth(), 0);
        }
    });
    setOnItemLongClickListener((view12, position) -> {
        InnerThemeView innerThemeView = (InnerThemeView) view12;
        showOptionsForTheme(innerThemeView.themeInfo);
        return true;
    });
}
 
Example 20
Source File: FullScreenActivityGraph.java    From arcusandroid with Apache License 2.0 4 votes vote down vote up
protected RecyclerView.LayoutManager getLayoutManager() {
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
    linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);

    return linearLayoutManager;
}