androidx.recyclerview.widget.LinearLayoutManager Java Examples

The following examples show how to use androidx.recyclerview.widget.LinearLayoutManager. 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: CardSelectionModeActivity.java    From material-components-android with Apache License 2.0 7 votes vote down vote up
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 File: SortFragment.java    From prayer-times-android with 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 #3
Source File: ProfileSettingsFragment.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
@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 #4
Source File: AyahWordFragment.java    From Word-By-Word-Quran-Android with 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 #5
Source File: CertificateManagerActivity.java    From revolution-irc with GNU General Public License v3.0 6 votes vote down vote up
@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 #6
Source File: GalleryInfoScene.java    From MHViewer with 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 #7
Source File: SharedContactDetailsActivity.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
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 #8
Source File: Example9Fragment.java    From SectionedRecyclerViewAdapter with 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 #9
Source File: RecyclerViewListFragment.java    From android-app with GNU General Public License v3.0 6 votes vote down vote up
@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 #10
Source File: OpenChannelListFragment.java    From SendBird-Android with 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 #11
Source File: RefreshActivity.java    From RecyclerViewAdapter with 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 #12
Source File: BookmarksView.java    From FirefoxReality with 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 #13
Source File: MessagesScreen.java    From adamant-android with GNU General Public License v3.0 6 votes vote down vote up
@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 #14
Source File: ConversationsOverviewFragment.java    From Pix-Art-Messenger with GNU General Public License v3.0 6 votes vote down vote up
@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
Source File: WechatActivity.java    From NineGridView with 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 #16
Source File: ListSectionSpec.java    From litho with 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 #17
Source File: MainActivity.java    From android-architecture-components-mvvm-retrofit-java with MIT License 6 votes vote down vote up
/**
 * 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 #18
Source File: ChooserActivity.java    From FirebaseUI-Android with 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 #19
Source File: PagedFragment.java    From realm-monarchy with 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 #20
Source File: GameLayout.java    From PretendYoureXyzzyAndroid with GNU General Public License v3.0 6 votes vote down vote up
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 #21
Source File: HeaderAndFooterViewActivity.java    From RecyclerViewHelper with Apache License 2.0 5 votes vote down vote up
private void init() {
    Toolbar toolbar = findViewById(R.id.toolbar);
    mRecyclerView = findViewById(R.id.recycler_view);

    // Toolbar replace ActionBar
    setSupportActionBar(toolbar);

    // Simulate get data
    getData();
    CommonAdapter commonAdapter = new CommonAdapter(mDataList);
    mHeaderAndFooterWrapper = new HeaderAndFooterWrapper(commonAdapter);
    addHeaderAndFooterView();
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.setAdapter(mHeaderAndFooterWrapper);
}
 
Example #22
Source File: MaterialAboutActivity.java    From material-about-library with Apache License 2.0 5 votes vote down vote up
private void initViews() {
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    adapter = new MaterialAboutListAdapter(getViewTypeManager());
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(adapter);
    RecyclerView.ItemAnimator animator = recyclerView.getItemAnimator();
    if (animator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) animator).setSupportsChangeAnimations(false);
    }
}
 
Example #23
Source File: SelectUserFragment.java    From SendBird-Android with MIT License 5 votes vote down vote up
private void setUpRecyclerView() {
    mLayoutManager = new LinearLayoutManager(getActivity());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setAdapter(mListAdapter);
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (mLayoutManager.findLastVisibleItemPosition() == mListAdapter.getItemCount() - 1) {
                loadNextUserList(10);
            }
        }
    });
}
 
Example #24
Source File: DetailsViewHolder.java    From GeometricWeather with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onBindView(GeoActivity activity, @NonNull Location location, @NonNull ResourceProvider provider,
                       boolean listAnimationEnabled, boolean itemAnimationEnabled, boolean firstCard) {
    super.onBindView(activity, location, provider,
            listAnimationEnabled, itemAnimationEnabled, firstCard);

    if (location.getWeather() != null) {
        card.setCardBackgroundColor(themeManager.getRootColor(context));

        title.setTextColor(themeManager.getWeatherThemeColors()[0]);

        detailsRecyclerView.setLayoutManager(new LinearLayoutManager(context));
        detailsRecyclerView.setAdapter(new DetailsAdapter(context, location.getWeather()));
    }
}
 
Example #25
Source File: TestAdMobClassicActivity.java    From UltimateRecyclerView with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_loadmore);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
    ultimateRecyclerView.setHasFixedSize(false);

    /**
     * wokring example 1 implementation of Admob banner with static Adview
     */
    //  simpleRecyclerViewAdapter = new admobdfpadapter(createadmob(), 5, stringList);
    /**
     * working example 2 with multiple called Adviews
     */
    simpleRecyclerViewAdapter = new ZeroStickyAdvertistmentAdapter(createadmob(), SampleDataboxset.newListFromGen());
    linearLayoutManager = new LinearLayoutManager(this);
    ultimateRecyclerView.setLayoutManager(linearLayoutManager);
    ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
    ultimateRecyclerView.setItemViewCacheSize(3);
    ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#f5f5ff"));
    enableEmptyView();
    enableRefresh();
    enableLoadMore();
    enableClick();
    impleAddDrop();
}
 
Example #26
Source File: ReplaceRuleActivity.java    From a with GNU General Public License v3.0 5 votes vote down vote up
private void initRecyclerView() {
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.addItemDecoration(new DividerItemDecoration(this, LinearLayout.VERTICAL));
    adapter = new ReplaceRuleAdapter(this);
    recyclerView.setAdapter(adapter);
    ItemTouchCallback itemTouchCallback = new ItemTouchCallback();
    itemTouchCallback.setOnItemTouchCallbackListener(adapter.getItemTouchCallbackListener());
    itemTouchCallback.setDragEnable(true);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(itemTouchCallback);
    itemTouchHelper.attachToRecyclerView(recyclerView);
}
 
Example #27
Source File: RecyclerViewScrollHelperTest.java    From materialistic with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    layoutManager = mock(LinearLayoutManager.class);
    adapter = mock(RecyclerView.Adapter.class);
    recyclerView = mock(RecyclerView.class);
    when(recyclerView.getLayoutManager()).thenReturn(layoutManager);
    when(recyclerView.getAdapter()).thenReturn(adapter);
}
 
Example #28
Source File: ActivityEML.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getSupportActionBar().setSubtitle("EML");
    setContentView(R.layout.activity_eml);

    tvFrom = findViewById(R.id.tvFrom);
    tvTo = findViewById(R.id.tvTo);
    tvReplyTo = findViewById(R.id.tvReplyTo);
    tvCc = findViewById(R.id.tvCc);
    tvBcc = findViewById(R.id.tvBcc);
    tvSent = findViewById(R.id.tvSent);
    tvReceived = findViewById(R.id.tvReceived);
    tvSubject = findViewById(R.id.tvSubject);
    vSeparatorAttachments = findViewById(R.id.vSeparatorAttachments);
    rvAttachment = findViewById(R.id.rvAttachment);
    tvBody = findViewById(R.id.tvBody);
    pbWait = findViewById(R.id.pbWait);
    grpReady = findViewById(R.id.grpReady);

    rvAttachment.setHasFixedSize(false);
    LinearLayoutManager llm = new LinearLayoutManager(this);
    rvAttachment.setLayoutManager(llm);

    tvBody.setMovementMethod(LinkMovementMethod.getInstance());

    vSeparatorAttachments.setVisibility(View.GONE);
    grpReady.setVisibility(View.GONE);

    load();
}
 
Example #29
Source File: FilesActivity.java    From dropbox-sdk-java with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String path = getIntent().getStringExtra(EXTRA_PATH);
    mPath = path == null ? "" : path;

    setContentView(R.layout.activity_files);

    Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton)findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            performWithPermissions(FileAction.UPLOAD);
        }
    });
    //init picaso client
    PicassoClient.init(this,DropboxClientFactory.getClient());
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.files_list);
    mFilesAdapter = new FilesAdapter(PicassoClient.getPicasso(), new FilesAdapter.Callback() {
        @Override
        public void onFolderClicked(FolderMetadata folder) {
            startActivity(FilesActivity.getIntent(FilesActivity.this, folder.getPathLower()));
        }

        @Override
        public void onFileClicked(final FileMetadata file) {
            mSelectedFile = file;
            performWithPermissions(FileAction.DOWNLOAD);
        }
    });
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(mFilesAdapter);

    mSelectedFile = null;
}
 
Example #30
Source File: PositionFragment.java    From shinny-futures-android with GNU General Public License v3.0 5 votes vote down vote up
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);
}