Search in sources :

Example 41 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project epoxy by airbnb.

the class ModelClickListenerTest method mockCompoundButtonForClicking.

private CompoundButton mockCompoundButtonForClicking(EpoxyModel model) {
    CompoundButton mockedView = mock(CompoundButton.class);
    RecyclerView recyclerMock = mock(RecyclerView.class);
    EpoxyViewHolder holderMock = mock(EpoxyViewHolder.class);
    when(holderMock.getAdapterPosition()).thenReturn(1);
    doReturn(recyclerMock).when(mockedView).getParent();
    doReturn(holderMock).when(recyclerMock).findContainingViewHolder(mockedView);
    doReturn(model).when(holderMock).getModel();
    when(mockedView.getParent()).thenReturn(recyclerMock);
    when(recyclerMock.findContainingViewHolder(mockedView)).thenReturn(holderMock);
    when(holderMock.getAdapterPosition()).thenReturn(1);
    when(holderMock.getModel()).thenReturn(model);
    View parentView = mock(View.class);
    when(holderMock.objectToBind()).thenReturn(parentView);
    doReturn(parentView).when(holderMock).objectToBind();
    return mockedView;
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CompoundButton(android.widget.CompoundButton)

Example 42 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project epoxy by airbnb.

the class ListenersUtils method getEpoxyHolderForChildView.

@Nullable
static EpoxyViewHolder getEpoxyHolderForChildView(View v) {
    RecyclerView recyclerView = findParentRecyclerView(v);
    if (recyclerView == null) {
        return null;
    }
    ViewHolder viewHolder = recyclerView.findContainingViewHolder(v);
    if (viewHolder == null) {
        return null;
    }
    if (!(viewHolder instanceof EpoxyViewHolder)) {
        return null;
    }
    return (EpoxyViewHolder) viewHolder;
}
Also used : ViewHolder(androidx.recyclerview.widget.RecyclerView.ViewHolder) RecyclerView(androidx.recyclerview.widget.RecyclerView) Nullable(androidx.annotation.Nullable)

Example 43 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project Signal-Android by WhisperSystems.

the class ReviewCardDialogFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    try {
        initializeViewModel();
    } catch (BadGroupIdException e) {
        throw new IllegalStateException(e);
    }
    TextView description = view.findViewById(R.id.description);
    RecyclerView recycler = view.findViewById(R.id.recycler);
    ReviewCardAdapter adapter = new ReviewCardAdapter(getNoGroupsInCommonResId(), getGroupsInCommonResId(), new AdapterCallbacks());
    recycler.setAdapter(adapter);
    viewModel.getReviewCards().observe(getViewLifecycleOwner(), cards -> {
        adapter.submitList(cards);
        description.setText(getString(getDescriptionResId(), cards.size()));
    });
    viewModel.getReviewEvents().observe(getViewLifecycleOwner(), this::onReviewEvent);
}
Also used : TextView(android.widget.TextView) RecyclerView(androidx.recyclerview.widget.RecyclerView) BadGroupIdException(org.thoughtcrime.securesms.groups.BadGroupIdException)

Example 44 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project xabber-android by redsolution.

the class ServerInfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_server_info);
    final Intent intent = getIntent();
    AccountJid account = getAccount(intent);
    if (account == null) {
        finish();
        return;
    }
    accountItem = AccountManager.getInstance().getAccount(account);
    if (accountItem == null) {
        Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
        finish();
        return;
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    toolbar.setTitle(accountItem.getConnection().getXMPPServiceDomain());
    BarPainter barPainter = new BarPainter(this, toolbar);
    barPainter.updateWithAccountName(account);
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.server_info_recycler_view);
    serverInfoAdapter = new ServerInfoAdapter();
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(serverInfoAdapter);
    progressBar = findViewById(R.id.server_info_progress_bar);
    requestServerInfo();
}
Also used : ServerInfoAdapter(com.xabber.android.ui.adapter.ServerInfoAdapter) AccountJid(com.xabber.android.data.entity.AccountJid) Intent(android.content.Intent) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Toolbar(androidx.appcompat.widget.Toolbar) BarPainter(com.xabber.android.ui.color.BarPainter)

Example 45 with RecyclerView

use of androidx.recyclerview.widget.RecyclerView in project xabber-android by redsolution.

the class MessageVH method setupForwarded.

protected void setupForwarded(MessageItem messageItem, MessagesAdapter.MessageExtraData extraData) {
    String[] forwardedIDs = messageItem.getForwardedIdsAsArray();
    if (!Arrays.asList(forwardedIDs).contains(null)) {
        RealmResults<MessageItem> forwardedMessages = MessageDatabaseManager.getInstance().getRealmUiThread().where(MessageItem.class).in(MessageItem.Fields.UNIQUE_ID, forwardedIDs).findAllSorted(MessageItem.Fields.TIMESTAMP, Sort.ASCENDING);
        if (forwardedMessages.size() > 0) {
            RecyclerView recyclerView = forwardLayout.findViewById(R.id.recyclerView);
            ForwardedAdapter adapter = new ForwardedAdapter(forwardedMessages, extraData);
            recyclerView.setLayoutManager(new LinearLayoutManager(extraData.getContext()));
            recyclerView.setAdapter(adapter);
            forwardLayout.setBackgroundColor(ColorManager.getColorWithAlpha(R.color.forwarded_background_color, 0.2f));
            forwardLeftBorder.setBackgroundColor(extraData.getAccountMainColor());
            forwardLayout.setVisibility(View.VISIBLE);
        }
    }
}
Also used : MessageItem(com.xabber.android.data.database.messagerealm.MessageItem) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Aggregations

RecyclerView (androidx.recyclerview.widget.RecyclerView)352 View (android.view.View)232 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)156 TextView (android.widget.TextView)51 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)39 ImageView (android.widget.ImageView)29 Nullable (androidx.annotation.Nullable)29 Toolbar (androidx.appcompat.widget.Toolbar)25 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)20 Intent (android.content.Intent)19 NonNull (androidx.annotation.NonNull)19 StaggeredGridLayoutManager (androidx.recyclerview.widget.StaggeredGridLayoutManager)19 Bundle (android.os.Bundle)18 ViewGroup (android.view.ViewGroup)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16 Context (android.content.Context)15 Rect (android.graphics.Rect)15 SuppressLint (android.annotation.SuppressLint)12 LayoutInflater (android.view.LayoutInflater)11