Search in sources :

Example 31 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project material-dialogs by afollestad.

the class MaterialDialog method invalidateList.

/**
   * Sets the dialog RecyclerView's adapter/layout manager, and it's item click listener.
   */
final void invalidateList() {
    if (recyclerView == null) {
        return;
    } else if ((builder.items == null || builder.items.size() == 0) && builder.adapter == null) {
        return;
    }
    if (builder.layoutManager == null) {
        builder.layoutManager = new LinearLayoutManager(getContext());
    }
    recyclerView.setLayoutManager(builder.layoutManager);
    recyclerView.setAdapter(builder.adapter);
    if (listType != null) {
        ((DefaultRvAdapter) builder.adapter).setCallback(this);
    }
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 32 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project lottie-android by airbnb.

the class ListFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_list, container, false);
    ButterKnife.bind(this, view);
    recyclerView.setAdapter(adapter);
    return view;
}
Also used : LottieAnimationView(com.airbnb.lottie.LottieAnimationView) BindView(butterknife.BindView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 33 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Carbon by ZieIony.

the class IconTextListItemActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listcomponent);
    Samples.initToolbar(this, getString(R.string.iconTextListItemActivity_title));
    RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
    recycler.setLayoutManager(new LinearLayoutManager(this));
    RowListAdapter adapter = new RowListAdapter<>(DefaultIconTextItem.class, IconTextRow::new);
    adapter.addFactory(DefaultIconSearchItem.class, parent -> new IconSearchRow(parent, new ArraySearchDataProvider(new String[] {}), filterResults -> {
    }));
    recycler.setAdapter(adapter);
    DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(new ColorDrawable(Carbon.getThemeColor(this, R.attr.carbon_dividerColor)), getResources().getDimensionPixelSize(R.dimen.carbon_1dip));
    dividerItemDecoration.setDrawRules(position -> position == 0);
    recycler.addItemDecoration(dividerItemDecoration);
    VectorDrawable drawable = new VectorDrawable(getResources(), R.raw.ic_face_24px);
    adapter.setItems(Arrays.asList(new DefaultIconSearchItem(this), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text"), new DefaultIconTextItem(drawable, "text")));
}
Also used : Arrays(java.util.Arrays) Bundle(android.os.Bundle) IconSearchRow(carbon.component.IconSearchRow) DividerItemDecoration(carbon.recycler.DividerItemDecoration) IconTextRow(carbon.component.IconTextRow) ColorDrawable(android.graphics.drawable.ColorDrawable) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultIconTextItem(carbon.component.DefaultIconTextItem) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) Carbon(carbon.Carbon) RecyclerView(carbon.widget.RecyclerView) SamplesActivity(tk.zielony.carbonsamples.SamplesActivity) VectorDrawable(carbon.drawable.VectorDrawable) R(tk.zielony.carbonsamples.R) RowListAdapter(carbon.recycler.RowListAdapter) Nullable(android.support.annotation.Nullable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider) Samples(tk.zielony.carbonsamples.Samples) DefaultIconSearchItem(carbon.component.DefaultIconSearchItem) ColorDrawable(android.graphics.drawable.ColorDrawable) IconTextRow(carbon.component.IconTextRow) RowListAdapter(carbon.recycler.RowListAdapter) RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(carbon.recycler.DividerItemDecoration) DefaultIconTextItem(carbon.component.DefaultIconTextItem) IconSearchRow(carbon.component.IconSearchRow) VectorDrawable(carbon.drawable.VectorDrawable) ArraySearchDataProvider(carbon.widget.ArraySearchDataProvider)

Example 34 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Carbon by ZieIony.

the class ImageTextSubtextDateListItemActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listcomponent);
    Samples.initToolbar(this, getString(R.string.imageTextSubtextDateListItemActivity_title));
    RecyclerView recycler = (RecyclerView) findViewById(R.id.recycler);
    recycler.setLayoutManager(new LinearLayoutManager(this));
    RowListAdapter adapter = new RowListAdapter<>(DefaultImageTextSubtextDateItem.class, ImageTextSubtextDateRow::new);
    adapter.addFactory(DefaultHeaderItem.class, PaddedHeaderRow.FACTORY);
    recycler.setAdapter(adapter);
    Drawable drawable = getResources().getDrawable(R.drawable.watermelon);
    String date = format.format(new Date().getTime());
    adapter.setItems(Arrays.asList(new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultHeaderItem("Header"), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date), new DefaultImageTextSubtextDateItem(drawable, "text", "subtext", date)));
}
Also used : DefaultHeaderItem(carbon.component.DefaultHeaderItem) ImageTextSubtextDateRow(carbon.component.ImageTextSubtextDateRow) Drawable(android.graphics.drawable.Drawable) RowListAdapter(carbon.recycler.RowListAdapter) RecyclerView(carbon.widget.RecyclerView) DefaultImageTextSubtextDateItem(carbon.component.DefaultImageTextSubtextDateItem) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Date(java.util.Date)

Example 35 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project Carbon by ZieIony.

the class DrawerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_drawer);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(R.string.app_name);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
    drawerMenu = (LinearLayout) findViewById(R.id.drawerMenu);
    RecyclerView drawerList = (RecyclerView) findViewById(R.id.drawerList);
    drawerList.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    FruitAdapter adapter = new FruitAdapter(fruits, null);
    drawerList.setAdapter(adapter);
    adapter.setOnItemClickedListener(position -> {
        setTitle(fruits.get(position));
        drawerLayout.closeDrawer(drawerMenu);
    });
}
Also used : RecyclerView(carbon.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

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