Search in sources :

Example 96 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LegacySuggestionContextualCardRendererTest method bindView_shouldSetListener.

@Test
public void bindView_shouldSetListener() {
    final RecyclerView recyclerView = new RecyclerView(mActivity);
    recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
    final ContextualCard card = buildContextualCard();
    final View cardView = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
    final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(cardView, card.getViewType());
    when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.LEGACY_SUGGESTION)).thenReturn(mController);
    mRenderer.bindView(viewHolder, buildContextualCard());
    assertThat(cardView).isNotNull();
    assertThat(cardView.hasOnClickListeners()).isTrue();
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 97 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LegacySuggestionContextualCardRendererTest method bindView_closeButton_shouldSetListener.

@Test
public void bindView_closeButton_shouldSetListener() {
    final RecyclerView recyclerView = new RecyclerView(mActivity);
    recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
    final ContextualCard card = buildContextualCard();
    final View cardView = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
    final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(cardView, card.getViewType());
    final View closeButton = viewHolder.itemView.findViewById(R.id.close_button);
    when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.LEGACY_SUGGESTION)).thenReturn(mController);
    mRenderer.bindView(viewHolder, buildContextualCard());
    assertThat(closeButton).isNotNull();
    assertThat(closeButton.hasOnClickListeners()).isTrue();
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 98 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LegacySuggestionContextualCardRendererTest method viewClick_shouldInvokeControllerPrimaryClick.

@Test
public void viewClick_shouldInvokeControllerPrimaryClick() {
    final RecyclerView recyclerView = new RecyclerView(mActivity);
    recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
    final ContextualCard card = buildContextualCard();
    final View cardView = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
    final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(cardView, card.getViewType());
    when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.LEGACY_SUGGESTION)).thenReturn(mController);
    mRenderer.bindView(viewHolder, buildContextualCard());
    assertThat(cardView).isNotNull();
    cardView.performClick();
    verify(mController).onPrimaryClick(any(ContextualCard.class));
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 99 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LegacySuggestionContextualCardRendererTest method viewClick_closeButton_shouldInvokeControllerDismissClick.

@Test
public void viewClick_closeButton_shouldInvokeControllerDismissClick() {
    final RecyclerView recyclerView = new RecyclerView(mActivity);
    recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
    final ContextualCard card = buildContextualCard();
    final View cardView = LayoutInflater.from(mActivity).inflate(card.getViewType(), recyclerView, false);
    final RecyclerView.ViewHolder viewHolder = mRenderer.createViewHolder(cardView, card.getViewType());
    final View closeButton = viewHolder.itemView.findViewById(R.id.close_button);
    when(mControllerRendererPool.getController(mActivity, ContextualCard.CardType.LEGACY_SUGGESTION)).thenReturn(mController);
    mRenderer.bindView(viewHolder, buildContextualCard());
    assertThat(closeButton).isNotNull();
    closeButton.performClick();
    verify(mController).onDismissed(any(ContextualCard.class));
}
Also used : ContextualCard(com.android.settings.homepage.contextualcards.ContextualCard) RecyclerView(androidx.recyclerview.widget.RecyclerView) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Test(org.junit.Test)

Example 100 with LinearLayoutManager

use of androidx.recyclerview.widget.LinearLayoutManager in project BaseRecyclerViewAdapterHelper by CymChad.

the class HeaderAndFooterUseActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_universal_recycler);
    setBackBtn();
    setTitle("HeaderAndFooter Use");
    mRecyclerView = findViewById(R.id.rv);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    initAdapter();
    View headerView = getHeaderView(0, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            adapter.addHeaderView(getHeaderView(1, getRemoveHeaderListener()), 0);
        }
    });
    adapter.addHeaderView(headerView);
    View footerView = getFooterView(0, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            adapter.addFooterView(getFooterView(1, getRemoveFooterListener()), 0);
        }
    });
    adapter.addFooterView(footerView, 0);
    mRecyclerView.setAdapter(adapter);
}
Also used : LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)470 RecyclerView (androidx.recyclerview.widget.RecyclerView)281 View (android.view.View)183 TextView (android.widget.TextView)65 ArrayList (java.util.ArrayList)37 Nullable (androidx.annotation.Nullable)33 Bundle (android.os.Bundle)32 Toolbar (androidx.appcompat.widget.Toolbar)32 Intent (android.content.Intent)30 ImageView (android.widget.ImageView)27 List (java.util.List)24 Test (org.junit.Test)24 Context (android.content.Context)23 NonNull (androidx.annotation.NonNull)23 ViewGroup (android.view.ViewGroup)22 AlertDialog (androidx.appcompat.app.AlertDialog)21 ContextualCard (com.android.settings.homepage.contextualcards.ContextualCard)20 LayoutInflater (android.view.LayoutInflater)18 AppCompatActivity (androidx.appcompat.app.AppCompatActivity)16 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)16