Search in sources :

Example 66 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Tusky by Vavassor.

the class ReportActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_report);
    Intent intent = getIntent();
    accountId = intent.getStringExtra("account_id");
    String accountUsername = intent.getStringExtra("account_username");
    String statusId = intent.getStringExtra("status_id");
    String statusContent = intent.getStringExtra("status_content");
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar bar = getSupportActionBar();
    if (bar != null) {
        String title = String.format(getString(R.string.report_username_format), accountUsername);
        bar.setTitle(title);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setDisplayShowHomeEnabled(true);
    }
    anyView = toolbar;
    final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.report_recycler_view);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(layoutManager);
    adapter = new ReportAdapter();
    recyclerView.setAdapter(adapter);
    DividerItemDecoration divider = new DividerItemDecoration(this, layoutManager.getOrientation());
    Drawable drawable = ThemeUtils.getDrawable(this, R.attr.report_status_divider_drawable, R.drawable.report_status_divider_dark);
    divider.setDrawable(drawable);
    recyclerView.addItemDecoration(divider);
    ReportAdapter.ReportStatus reportStatus = new ReportAdapter.ReportStatus(statusId, HtmlUtils.fromHtml(statusContent), true);
    adapter.addItem(reportStatus);
    comment = (EditText) findViewById(R.id.report_comment);
    reportAlreadyInFlight = false;
    fetchRecentStatuses(accountId);
}
Also used : ReportAdapter(com.keylesspalace.tusky.adapter.ReportAdapter) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 67 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Robot-Scouter by SUPERCILEX.

the class StopwatchViewHolder method bind.

@Override
protected void bind() {
    super.bind();
    mToggleStopwatch.setOnClickListener(this);
    setText(R.string.start_stopwatch);
    Tasks.whenAll(getOnViewReadyTask(getName()), getOnViewReadyTask(mToggleStopwatch)).addOnSuccessListener(this);
    LinearLayoutManager manager = new LinearLayoutManager(itemView.getContext(), LinearLayoutManager.HORIZONTAL, false);
    manager.setInitialPrefetchItemCount(5);
    mCycles.setLayoutManager(manager);
    mCycles.setAdapter(new Adapter());
    Timer timer = TIMERS.get(getMetric());
    if (timer != null) {
        timer.setHolder(this);
        mTimer = timer;
        mTimer.updateButtonTime();
    }
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 68 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Rocket.Chat.Android by RocketChat.

the class SidebarMainFragment method onSetupView.

@SuppressLint("RxLeakedSubscription")
@Override
protected void onSetupView() {
    setupUserActionToggle();
    setupUserStatusButtons();
    setupLogoutButton();
    setupVersionInfo();
    adapter = new RoomListAdapter();
    adapter.setOnItemClickListener(new RoomListAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(Room room) {
            searchView.clearFocus();
            presenter.onRoomSelected(room);
        }

        @Override
        public void onItemClick(SpotlightRoom spotlightRoom) {
            searchView.setQuery(null, false);
            searchView.clearFocus();
            methodCallHelper.joinRoom(spotlightRoom.getId()).onSuccessTask(task -> {
                presenter.onSpotlightRoomSelected(spotlightRoom);
                return null;
            });
        }
    });
    RecyclerView recyclerView = (RecyclerView) rootView.findViewById(R.id.room_list_container);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
    recyclerView.setAdapter(adapter);
    searchView = (SearchView) rootView.findViewById(R.id.search);
    RxSearchView.queryTextChanges(searchView).compose(bindToLifecycle()).debounce(300, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).switchMap(it -> {
        if (it.length() == 0) {
            adapter.setMode(RoomListAdapter.MODE_ROOM);
            return Observable.just(Collections.<SpotlightRoom>emptyList());
        }
        adapter.setMode(RoomListAdapter.MODE_SPOTLIGHT_ROOM);
        final String queryString = it.toString();
        methodCallHelper.searchSpotlightRooms(queryString);
        return realmSpotlightRoomRepository.getSuggestionsFor(queryString, SortDirection.DESC, 10).toObservable();
    }).subscribe(this::showSearchSuggestions, Logger::report);
}
Also used : Bundle(android.os.Bundle) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) DialogFragment(android.support.v4.app.DialogFragment) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) RealmSpotlightRoomRepository(chat.rocket.persistence.realm.repositories.RealmSpotlightRoomRepository) RocketChatAvatar(chat.rocket.android.widget.RocketChatAvatar) MethodCallHelper(chat.rocket.android.api.MethodCallHelper) DirectMessageRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.DirectMessageRoomListHeader) View(android.view.View) TextUtils(chat.rocket.android.helper.TextUtils) AbsoluteUrlHelper(chat.rocket.android.helper.AbsoluteUrlHelper) User(chat.rocket.core.models.User) RocketChatAbsoluteUrl(chat.rocket.android.fragment.chatroom.RocketChatAbsoluteUrl) RealmServerInfoRepository(chat.rocket.persistence.realm.repositories.RealmServerInfoRepository) RoomListAdapter(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter) RxSearchView(com.jakewharton.rxbinding2.support.v7.widget.RxSearchView) UserRenderer(chat.rocket.android.renderer.UserRenderer) SessionInteractor(chat.rocket.core.interactors.SessionInteractor) List(java.util.List) TextView(android.widget.TextView) RealmSessionRepository(chat.rocket.persistence.realm.repositories.RealmSessionRepository) Room(chat.rocket.core.models.Room) BuildConfig(chat.rocket.android.BuildConfig) ChannelRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.ChannelRoomListHeader) Nullable(android.support.annotation.Nullable) RxCompoundButton(com.jakewharton.rxbinding2.widget.RxCompoundButton) AbstractFragment(chat.rocket.android.fragment.AbstractFragment) RocketChatCache(chat.rocket.android.RocketChatCache) NonNull(android.support.annotation.NonNull) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) Observable(io.reactivex.Observable) R(chat.rocket.android.R) RealmRoomRepository(chat.rocket.persistence.realm.repositories.RealmRoomRepository) AddDirectMessageDialogFragment(chat.rocket.android.fragment.sidebar.dialog.AddDirectMessageDialogFragment) AddChannelDialogFragment(chat.rocket.android.fragment.sidebar.dialog.AddChannelDialogFragment) FavoriteRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.FavoriteRoomListHeader) CompoundButton(android.widget.CompoundButton) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Logger(chat.rocket.android.helper.Logger) UnreadRoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.UnreadRoomListHeader) RoomInteractor(chat.rocket.core.interactors.RoomInteractor) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) RealmUserRepository(chat.rocket.persistence.realm.repositories.RealmUserRepository) RoomListHeader(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListHeader) SortDirection(chat.rocket.core.SortDirection) Collections(java.util.Collections) RoomListAdapter(chat.rocket.android.layouthelper.chatroom.roomlist.RoomListAdapter) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Logger(chat.rocket.android.helper.Logger) Room(chat.rocket.core.models.Room) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) SpotlightRoom(chat.rocket.core.models.SpotlightRoom) SuppressLint(android.annotation.SuppressLint)

Example 69 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Rocket.Chat.Android by RocketChat.

the class RoomFragment method onDestroyView.

@Override
public void onDestroyView() {
    RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    if (listView != null) {
        RecyclerView.Adapter adapter = listView.getAdapter();
        if (adapter != null) {
            adapter.unregisterAdapterDataObserver(autoScrollManager);
        }
    }
    compositeDisposable.clear();
    if (autocompleteManager != null) {
        autocompleteManager.dispose();
        autocompleteManager = null;
    }
    super.onDestroyView();
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView)

Example 70 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Rocket.Chat.Android by RocketChat.

the class RoomFragment method updateHistoryState.

@Override
public void updateHistoryState(boolean hasNext, boolean isLoaded) {
    RecyclerView listView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
    if (listView == null || !(listView.getAdapter() instanceof MessageListAdapter)) {
        return;
    }
    MessageListAdapter adapter = (MessageListAdapter) listView.getAdapter();
    if (isLoaded) {
        scrollListener.setLoadingDone();
    }
    adapter.updateFooter(hasNext, isLoaded);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) MessageListAdapter(chat.rocket.android.layouthelper.chatroom.MessageListAdapter)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)688 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)612 View (android.view.View)593 TextView (android.widget.TextView)245 ArrayList (java.util.ArrayList)179 Intent (android.content.Intent)148 ImageView (android.widget.ImageView)132 Toolbar (android.support.v7.widget.Toolbar)118 GridLayoutManager (android.support.v7.widget.GridLayoutManager)111 AdapterView (android.widget.AdapterView)109 ViewGroup (android.view.ViewGroup)97 AlertDialog (android.support.v7.app.AlertDialog)91 Bundle (android.os.Bundle)85 ListView (android.widget.ListView)85 BindView (butterknife.BindView)85 Nullable (android.support.annotation.Nullable)78 DialogInterface (android.content.DialogInterface)71 Context (android.content.Context)65 ArrayAdapter (android.widget.ArrayAdapter)65 LayoutInflater (android.view.LayoutInflater)64