Java Code Examples for androidx.recyclerview.widget.LinearLayoutManager

The following examples show how to use androidx.recyclerview.widget.LinearLayoutManager. These examples are extracted from open source projects. 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
protected void setUpRecyclerView(RecyclerView recyclerView) {
  adapter = new SelectableCardsAdapter();
  adapter.setItems(generateItems());
  recyclerView.setAdapter(adapter);

  selectionTracker =
      new SelectionTracker.Builder<>(
              "card_selection",
              recyclerView,
              new SelectableCardsAdapter.KeyProvider(adapter),
              new SelectableCardsAdapter.DetailsLookup(recyclerView),
              StorageStrategy.createLongStorage())
          .withSelectionPredicate(SelectionPredicates.createSelectAnything())
          .build();

  adapter.setSelectionTracker(selectionTracker);
  selectionTracker.addObserver(
      new SelectionTracker.SelectionObserver<Long>() {
        @Override
        public void onSelectionChanged() {
          if (selectionTracker.getSelection().size() > 0) {
            if (actionMode == null) {
              actionMode = startSupportActionMode(CardSelectionModeActivity.this);
            }
            actionMode.setTitle(String.valueOf(selectionTracker.getSelection().size()));
          } else if (actionMode != null) {
            actionMode.finish();
          }
        }
      });
  recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
 
Example 2
Source Project: MHViewer   Source File: GalleryInfoScene.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_info, container, false);

    Context context = getContext2();
    AssertUtils.assertNotNull(context);

    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    InfoAdapter adapter = new InfoAdapter();
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(
            LinearDividerItemDecoration.VERTICAL,
            AttrResources.getAttrColor(context, R.attr.dividerColor),
            LayoutUtils.dp2pix(context, 1));
    decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    return view;
}
 
Example 3
Source Project: Word-By-Word-Quran-Android   Source File: AyahWordFragment.java    License: MIT License 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {

  super.onViewCreated(view, savedInstanceState);

  mRecyclerView.setAdapter(ayahWordAdapter);
  mRecyclerView.setHasFixedSize(true);
  mLayoutManager = new LinearLayoutManager(getActivity());
  mRecyclerView.setLayoutManager(mLayoutManager);

  mRecyclerView.setVerticalScrollBarEnabled(true);

  // set headerview
  RecyclerViewHeader recyclerViewHeader = view.findViewById(R.id.header);
  TextView headerTextView = recyclerViewHeader.findViewById(R.id.headerTextView);
  headerTextView.setText(getString(R.string.bismillah));
  recyclerViewHeader.attachTo(mRecyclerView, true);
}
 
Example 4
private void initViews() {
  nameView            = findViewById(R.id.contact_details_name);
  numberView          = findViewById(R.id.contact_details_number);
  avatarView          = findViewById(R.id.contact_details_avatar);
  addButtonView       = findViewById(R.id.contact_details_add_button);
  inviteButtonView    = findViewById(R.id.contact_details_invite_button);
  engageContainerView = findViewById(R.id.contact_details_engage_container);
  messageButtonView   = findViewById(R.id.contact_details_message_button);
  callButtonView      = findViewById(R.id.contact_details_call_button);

  contactFieldAdapter = new ContactFieldAdapter(dynamicLanguage.getCurrentLocale(), glideRequests, false);

  RecyclerView list = findViewById(R.id.contact_details_fields);
  list.setLayoutManager(new LinearLayoutManager(this));
  list.setAdapter(contactFieldAdapter);

  glideRequests = GlideApp.with(this);
}
 
Example 5
Source Project: RecyclerViewAdapter   Source File: RefreshActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_refresh);
    mPresenter = new DataPresenter(this);

    mRefreshLayout = findViewById(R.id.refresh_layout);
    mRecyclerView = findViewById(R.id.rcv_simple);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(RefreshActivity.this, LinearLayoutManager.VERTICAL, false));
    mRecyclerView.addItemDecoration(RcvLinearDecoration.createDefaultVertical(this));
    mAdapter = new Adapter(this, null);
    mAdapter.setEmptyView(R.layout.layout_emptyview02);
    RcvDefLoadMoreView loadMoreView = new RcvDefLoadMoreView.Builder()
            .setBgColor(Color.GREEN)
            .setTextColor(Color.RED)
            .build(this);
    mAdapter.setLoadMoreLayout(loadMoreView);
    mRecyclerView.setAdapter(mAdapter);

    mRefreshLayout.setOnRefreshListener(this);

    //初始化数据
    mRefreshLayout.setRefreshing(true);
    this.onRefresh();
}
 
Example 6
Source Project: FirefoxReality   Source File: BookmarksView.java    License: Mozilla Public License 2.0 6 votes vote down vote up
@Override
public void onMore(@NonNull View view, @NonNull Bookmark item) {
    mBinding.bookmarksList.requestFocusFromTouch();

    int rowPosition = mBookmarkAdapter.getItemPosition(item.getGuid());
    RecyclerView.ViewHolder row = mBinding.bookmarksList.findViewHolderForLayoutPosition(rowPosition);
    boolean isLastVisibleItem = false;
    if (mBinding.bookmarksList.getLayoutManager() instanceof LinearLayoutManager) {
        LinearLayoutManager layoutManager = (LinearLayoutManager) mBinding.bookmarksList.getLayoutManager();
        int lastItem = mBookmarkAdapter.getItemCount();
        if ((rowPosition == layoutManager.findLastVisibleItemPosition() || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition() ||
                rowPosition == layoutManager.findLastVisibleItemPosition()-1 || rowPosition == layoutManager.findLastCompletelyVisibleItemPosition()-1)
                && rowPosition != lastItem) {
            isLastVisibleItem = true;
        }
    }

    mBinding.getCallback().onShowContextMenu(
            row.itemView,
            item,
            isLastVisibleItem);
}
 
Example 7
Source Project: NineGridView   Source File: WechatActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wechat);

    mRecyclerView = findViewById(R.id.rcv_wechat);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.addItemDecoration(RcvLinearDecoration.createDefaultVertical(this));

    List<String> dataList = new LinkedList<>();
    for (int i = 0; i < 20; i++)
    {
        dataList.add("i=" + i);
    }

    mRecyclerView.setAdapter(new MyAdapter(this, dataList));
}
 
Example 8
Source Project: litho   Source File: ListSectionSpec.java    License: Apache License 2.0 6 votes vote down vote up
@OnCreateChildren
static Children onCreateChildren(final SectionContext c) {
  return Children.create()
      .child(
          SingleComponentSection.create(c)
              .component(
                  RecyclerCollectionComponent.create(c)
                      .disablePTR(true)
                      .recyclerConfiguration(
                          new ListRecyclerConfiguration(
                              LinearLayoutManager.HORIZONTAL, false, SNAP_TO_CENTER))
                      .section(
                          DataDiffSection.<Integer>create(c)
                              .data(generateData(32))
                              .renderEventHandler(ListSection.onRender(c))
                              .build())
                      .canMeasureRecycler(true))
              .build())
      .child(
          DataDiffSection.<Integer>create(c)
              .data(generateData(32))
              .renderEventHandler(ListSection.onRender(c)))
      .build();
}
 
Example 9
Source Project: realm-monarchy   Source File: PagedFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    pagedDogAdapter = new PagedDogAdapter();
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(pagedDogAdapter);
    realmDataSourceFactory = monarchy.createDataSourceFactory(
            realm -> realm.where(RealmDog.class));
    dataSourceFactory = realmDataSourceFactory.map(input -> Dog.create(input.getName()));
    dogs = monarchy.findAllPagedWithChanges(realmDataSourceFactory,
            new LivePagedListBuilder<>(dataSourceFactory, new PagedList.Config.Builder()
                    .setEnablePlaceholders(true)
                    .setPageSize(20)
                    .build())
    );
    dogs.observeForever(observer); // detach != destroy in fragments so this is manual
}
 
Example 10
public GameLayout(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    View.inflate(context, R.layout.game_layout, this);

    starredCards = StarredCardsManager.get();

    blackCard = findViewById(R.id.gameLayout_blackCard);
    instructions = findViewById(R.id.gameLayout_instructions);
    time = findViewById(R.id.gameLayout_time);
    startGame = findViewById(R.id.gameLayout_startGame);

    whiteCardsList = findViewById(R.id.gameLayout_whiteCards);
    whiteCardsList.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));

    playersList = findViewById(R.id.gameLayout_players);
    playersList.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    playersList.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));

    startGame.setOnClickListener(v -> {
        if (listener != null) listener.startGame();
    });
}
 
Example 11
Source Project: prayer-times-android   Source File: SortFragment.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle bdl) {
    View v = inflater.inflate(R.layout.vakit_sort_main, container, false);
    RecyclerView recyclerMan = v.findViewById(R.id.list);
    mAdapter = new MyAdapter();
    recyclerMan.setAdapter(mAdapter);
    LinearLayoutManager linLayMan = new LinearLayoutManager(getContext());
    recyclerMan.setLayoutManager(linLayMan);
    recyclerMan.setHasFixedSize(true);

    ItemTouchHelper.Callback callback = new SimpleItemTouchHelperCallback();
    mItemTouchHelper = new ItemTouchHelper(callback);
    mItemTouchHelper.attachToRecyclerView(recyclerMan);
    setHasOptionsMenu(true);

    Times.getTimes().observe(this, mAdapter);
    mAdapter.onChanged(Times.getTimes());
    return v;
}
 
Example 12
Source Project: FirebaseUI-Android   Source File: ChooserActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (AuthUI.canHandleIntent(getIntent())) {
        Intent intent = new Intent(ChooserActivity.this, AuthUiActivity
                .class);
        intent.putExtra(ExtraConstants.EMAIL_LINK_SIGN_IN, getIntent().getData().toString());
        startActivity(intent);
        finish();
        return;
    }

    setContentView(R.layout.activity_chooser);
    ButterKnife.bind(this);

    mActivities.setLayoutManager(new LinearLayoutManager(this));
    mActivities.setAdapter(new ActivityChooserAdapter());
    mActivities.setHasFixedSize(true);
}
 
Example 13
/**
 * initialization of views and others
 *
 * @param @null
 */
private void initialization() {
    progress_circular_movie_article = (ProgressBar) findViewById(R.id.progress_circular_movie_article);
    my_recycler_view = (RecyclerView) findViewById(R.id.my_recycler_view);

    // use a linear layout manager
    layoutManager = new LinearLayoutManager(MainActivity.this);
    my_recycler_view.setLayoutManager(layoutManager);

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    my_recycler_view.setHasFixedSize(true);

    // adapter
    adapter = new MovieArticleAdapter(MainActivity.this, articleArrayList);
    my_recycler_view.setAdapter(adapter);

    // View Model
    articleViewModel = ViewModelProviders.of(this).get(ArticleViewModel.class);
}
 
Example 14
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversations_overview, container, false);
    this.binding.fab.setOnClickListener((view) -> StartConversationActivity.launch(getActivity()));
    this.conversationsAdapter = new ConversationAdapter(this.activity, this.conversations);
    this.conversationsAdapter.setConversationClickListener((view, conversation) -> {
        if (activity instanceof OnConversationSelected) {
            ((OnConversationSelected) activity).onConversationSelected(conversation);
        } else {
            Log.w(ConversationsOverviewFragment.class.getCanonicalName(), "Activity does not implement OnConversationSelected");
        }
    });

    this.binding.list.setAdapter(this.conversationsAdapter);
    this.binding.list.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
    return binding.getRoot();
}
 
Example 15
@Override
protected void onCreate(Bundle savedInstanceState) {
    AndroidInjection.inject(this);
    super.onCreate(savedInstanceState);
    layoutManager = new LinearLayoutManager(this);
    messagesList.setLayoutManager(layoutManager);
    messagesList.setAdapter(adapter);

    Intent intent = getIntent();
    if (intent != null){
        if (intent.hasExtra(ARG_CHAT)){
            String companionId = getIntent().getStringExtra(ARG_CHAT);
            presenter.onShowChatByCompanionId(companionId);
        }

        //if intent contains special action
        showByAddress(intent);
    }

    newMessageText.setOnFocusChangeListener( (view, isFocused) -> {
        if (!isFocused){
            AdamantApplication.hideKeyboard(this, newMessageText);
        }
    });
}
 
Example 16
Source Project: SendBird-Android   Source File: OpenChannelListFragment.java    License: MIT License 6 votes vote down vote up
void setUpRecyclerView() {
    mLayoutManager = new LinearLayoutManager(getContext());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mChannelListAdapter);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));

    // If user scrolls to bottom of the list, loads more channels.
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (mLayoutManager.findLastVisibleItemPosition() == mChannelListAdapter.getItemCount() - 1) {
                loadNextChannelList();
            }
        }
    });
}
 
Example 17
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View view = inflater.inflate(getLayoutResID(), container, false);

    recyclerView = view.findViewById(getRecyclerViewResID());

    recyclerViewLayoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(recyclerViewLayoutManager);

    scrollListener = new EndlessRecyclerViewScrollListener(recyclerViewLayoutManager) {
        @Override
        public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
            loadMore(page, totalItemsCount);
        }
    };

    recyclerView.addOnScrollListener(scrollListener);
    recyclerView.setAdapter(listAdapter);

    refreshLayout = view.findViewById(getSwipeContainerResID());
    refreshLayout.setOnRefreshListener(this::onSwipeRefresh);

    return view;
}
 
Example 18
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_certificate_manager);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    String serverUUID = getIntent().getStringExtra(ARG_SERVER_UUID);
    mHelper = ServerCertificateManager.get(this, UUID.fromString(serverUUID));
    mAliases = mHelper.getCertificateAliases();

    if (mAliases == null || mAliases.size() == 0) {
        findViewById(R.id.empty).setVisibility(View.VISIBLE);
        return;
    }

    RecyclerView recyclerView = findViewById(R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    // recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    mAdapter = new CertificateListAdapter();
    recyclerView.setAdapter(mAdapter);
}
 
Example 19
Source Project: SectionedRecyclerViewAdapter   Source File: Example9Fragment.java    License: MIT License 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_ex9, container, false);

    sectionedAdapter = new SectionedRecyclerViewAdapter();
    portfolioSection = new PortfolioSection(getPortfolio(), this);
    watchListSection = new WatchListSection(getWatchList(), this);

    sectionedAdapter.addSection(portfolioSection);
    sectionedAdapter.addSection(watchListSection);

    final RecyclerView recyclerView = view.findViewById(R.id.recyclerview);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(sectionedAdapter);

    handler.post(portfolioUpdatesRunnable);
    handler.post(watchListUpdatesRunnable);

    return view;
}
 
Example 20
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.profile_settings_fragment, container, false);
  adapter = new ProfileSettingsAdapter(getContext(), GlideApp.with(this), locale,this);

  list  = ViewUtil.findById(view, R.id.recycler_view);
  list.setAdapter(adapter);
  list.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
  listDecoration = new StickyHeaderDecoration(adapter, false, true);
  list.addItemDecoration(listDecoration);

  update();

  dcContext.eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
  dcContext.eventCenter.addObserver(DcContext.DC_EVENT_CONTACTS_CHANGED, this);
  dcContext.eventCenter.addObserver(DcContext.DC_EVENT_MSGS_CHANGED, this);
  dcContext.eventCenter.addObserver(DcContext.DC_EVENT_INCOMING_MSG, this);
  return view;
}
 
Example 21
protected void initData() {
    mIsUpdate = true;
    mBinding.rv.setLayoutManager(
            new LinearLayoutManager(getActivity(), RecyclerView.VERTICAL, false));
    mBinding.rv.addItemDecoration(
            new DividerItemDecorationUtils(getActivity(), DividerItemDecorationUtils.VERTICAL_LIST));
    mAdapter = new PositionAdapter(getActivity(), mOldData);
    mAdapter.setHighlightIns(mInstrumentId);
    mBinding.rv.setAdapter(mAdapter);
    if (!mIsInAccountFragment) EventBus.getDefault().register(this);
}
 
Example 22
Source Project: Android-skin-support   Source File: TFragment.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_t, null);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity().getApplication()));
    mRecyclerView.addItemDecoration(new CustomDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL));
    mRecyclerView.setAdapter(new TAdapter());
    return view;
}
 
Example 23
Source Project: ShadowsocksRR   Source File: TaskerActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_tasker);

    profilesAdapter = new ProfilesAdapter();

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    toolbar.setNavigationIcon(R.drawable.ic_navigation_close);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });

    taskerOption = TaskerSettings.fromIntent(getIntent());
    mSwitch = (Switch) findViewById(R.id.serviceSwitch);
    mSwitch.setChecked(taskerOption.switchOn);
    RecyclerView profilesList = (RecyclerView) findViewById(R.id.profilesList);
    LinearLayoutManager lm = new LinearLayoutManager(this);
    profilesList.setLayoutManager(lm);
    profilesList.setItemAnimator(new DefaultItemAnimator());
    profilesList.setAdapter(profilesAdapter);

    if (taskerOption.profileId >= 0) {
        int position = 0;
        List<Profile> profiles = profilesAdapter.profiles;
        for (int i = 0; i < profiles.size(); i++) {
            Profile profile = profiles.get(i);
            if (profile.id == taskerOption.profileId) {
                position = i + 1;
                break;
            }
        }
        lm.scrollToPosition(position);
    }
}
 
Example 24
Source Project: Gander   Source File: TransactionListActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gander_act_transaction_list);
    Toolbar toolbar = findViewById(R.id.gander_toolbar);
    setSupportActionBar(toolbar);
    toolbar.setSubtitle(getApplicationName());

    mRecyclerView = findViewById(R.id.gander_transaction_list);
    final AppBarLayout appBarLayout = findViewById(R.id.gander_appbar);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        appBarLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
            @Override
            public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                appBarLayout.setPadding(0, insets.getSystemWindowInsetTop(), 0, 0);
                return insets;
            }
        });
    }

    mListDiffUtil = new ListDiffUtil();
    mTransactionAdapter = new TransactionAdapter(this, mListDiffUtil).setListener(this);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));

    mRecyclerView.setAdapter(mTransactionAdapter);

    mViewModel = ViewModelProviders.of(this).get(TransactionListViewModel.class);

    loadResults(null, mViewModel.getTransactions(null));
}
 
Example 25
@Override
public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
    RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
    if (!(layoutManager instanceof LinearLayoutManager)) {
        return;
    }
    LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
    int mOrientation = linearLayoutManager.getOrientation();
    if (mOrientation == LinearLayoutManager.VERTICAL) {
        drawVertical(c, parent);
    } else {
        drawHorizontal(c, parent);
    }
}
 
Example 26
@Override
protected void initData() {
    mBinding = (ActivityBankTransferBinding) mViewDataBinding;
    mIsUpdate = true;
    mOldData = new ArrayList<>();
    mNewData = new ArrayList<>();
    mBinding.rv.setLayoutManager(new LinearLayoutManager(this));
    mBinding.rv.addItemDecoration(
            new DividerItemDecorationUtils(this, DividerItemDecorationUtils.VERTICAL_LIST));
    mBinding.rv.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new BankTransferAdapter(this, mOldData);
    mBinding.rv.setAdapter(mAdapter);

    mBankId = new HashMap<>();
    List<String> bankList = new ArrayList<>();
    List<String> currencyList = new ArrayList<>();

    mBankSpinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_display_style, R.id.tv_Spinner, bankList);
    mBankSpinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_style);
    mBinding.spinnerBank.setAdapter(mBankSpinnerAdapter);

    mCurrencySpinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_display_style, R.id.tv_Spinner, currencyList);
    mCurrencySpinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_style);
    mBinding.spinnerCurrency.setAdapter(mCurrencySpinnerAdapter);

    if (TRANSFER_IN.equals(mTitle)) mBinding.futureBank.setVisibility(View.GONE);

    if (TRANSFER_OUT.equals(mTitle)) mBinding.bankFuture.setVisibility(View.GONE);
}
 
Example 27
Source Project: CrazyDaily   Source File: ContactFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void handleSideBarSelect(String index) {
    if (mContactList == null) {
        return;
    }
    for (int i = 0, size = mContactList.size(); i < size; i++) {
        if (mContactList.get(i).getIndex().equals(index)) {
            //noinspection ConstantConditions
            ((LinearLayoutManager) mContacts.getLayoutManager()).scrollToPositionWithOffset(i, 0);
            return;
        }
    }
}
 
Example 28
private void bindView() {
    mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, privateMessage, mCustomThemeWrapper);
    mLinearLayoutManager = new LinearLayoutManager(this);
    mLinearLayoutManager.setReverseLayout(true);
    mLinearLayoutManager.setStackFromEnd(true);
    mRecyclerView.setLayoutManager(mLinearLayoutManager);
    mRecyclerView.setAdapter(mAdapter);
}
 
Example 29
Source Project: Bop   Source File: PlayingNowList.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.playerview_list);

    songListView = findViewById(R.id.tracks_nowplaying);

    mCoverView = findViewById(R.id.cover);
    mTitleView = findViewById(R.id.titleTrack);
    mTimeView = findViewById(R.id.time);
    mDurationView = findViewById(R.id.duration);
    seekArc = findViewById(R.id.progress);
    mFabView = findViewById(R.id.fab);
    mTitleViewq = findViewById(R.id.title);
    mCounterView = findViewById(R.id.counter);
    mPlaylistName = findViewById(R.id.name);

    songListView.setLayoutManager(new LinearLayoutManager(this));
    songListView.setAdapter(new CurrentPlayListSongsAdapter(Main.nowPlayingList));

    if (getIntent().getExtras() != null)
        if (getIntent().getExtras().containsKey("playlistname")) {
        mPlaylistName.setText(Objects.requireNonNull(getIntent().getExtras()).getString("playlistname", "Current Playlist"));
            if (Main.musicService.currentSong != Main.musicList.get(0))
                Main.musicService.playSong();
    }

    MainScreen.addNowPlayingItem();
}
 
Example 30
Source Project: CalendarView   Source File: SingleActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void initData() {
    int year = mCalendarView.getCurYear();
    int month = mCalendarView.getCurMonth();

    Map<String, Calendar> map = new HashMap<>();
    map.put(getSchemeCalendar(year, month, 3, 0xFF40db25, "假").toString(),
            getSchemeCalendar(year, month, 3, 0xFF40db25, "假"));
    map.put(getSchemeCalendar(year, month, 6, 0xFFe69138, "事").toString(),
            getSchemeCalendar(year, month, 6, 0xFFe69138, "事"));
    map.put(getSchemeCalendar(year, month, 9, 0xFFdf1356, "议").toString(),
            getSchemeCalendar(year, month, 9, 0xFFdf1356, "议"));
    map.put(getSchemeCalendar(year, month, 13, 0xFFedc56d, "记").toString(),
            getSchemeCalendar(year, month, 13, 0xFFedc56d, "记"));
    map.put(getSchemeCalendar(year, month, 14, 0xFFedc56d, "记").toString(),
            getSchemeCalendar(year, month, 14, 0xFFedc56d, "记"));
    map.put(getSchemeCalendar(year, month, 15, 0xFFaacc44, "假").toString(),
            getSchemeCalendar(year, month, 15, 0xFFaacc44, "假"));
    map.put(getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记").toString(),
            getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记"));
    map.put(getSchemeCalendar(year, month, 25, 0xFF13acf0, "假").toString(),
            getSchemeCalendar(year, month, 25, 0xFF13acf0, "假"));
    map.put(getSchemeCalendar(year, month, 27, 0xFF13acf0, "多").toString(),
            getSchemeCalendar(year, month, 27, 0xFF13acf0, "多"));
    //此方法在巨大的数据量上不影响遍历性能,推荐使用
    mCalendarView.setSchemeDate(map);


    mRecyclerView = findViewById(R.id.recyclerView);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.addItemDecoration(new GroupItemDecoration<String, Article>());
    mRecyclerView.setAdapter(new ArticleAdapter(this));
    mRecyclerView.notifyDataSetChanged();
}