Search in sources :

Example 6 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setLayoutManager(new LinearLayoutManager(this));
    adapter = new IconicAdapter();
    setAdapter(adapter);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 7 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setLayoutManager(new LinearLayoutManager(this));
    adapter = new IconicAdapter();
    setAdapter(adapter);
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 8 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class RowController method measureContentWidth.

// based on http://stackoverflow.com/a/26814964/115145
private int measureContentWidth(Context ctxt, ListAdapter listAdapter) {
    ViewGroup mMeasureParent = null;
    int maxWidth = 0;
    View itemView = null;
    int itemType = 0;
    final ListAdapter adapter = listAdapter;
    final int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    final int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    final int count = adapter.getCount();
    for (int i = 0; i < count; i++) {
        final int positionType = adapter.getItemViewType(i);
        if (positionType != itemType) {
            itemType = positionType;
            itemView = null;
        }
        if (mMeasureParent == null) {
            mMeasureParent = new FrameLayout(ctxt);
        }
        itemView = adapter.getView(i, itemView, mMeasureParent);
        itemView.measure(widthMeasureSpec, heightMeasureSpec);
        final int itemWidth = itemView.getMeasuredWidth();
        if (itemWidth > maxWidth) {
            maxWidth = itemWidth;
        }
    }
    return maxWidth;
}
Also used : ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter)

Example 9 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project cw-omnibus by commonsguy.

the class RowController method onTouch.

@Override
public boolean onTouch(View v, MotionEvent event) {
    if ((event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0 && event.getAction() == MotionEvent.ACTION_DOWN) {
        adapter.onChecked(position, true, true);
        String[] items = itemView.getContext().getResources().getStringArray(R.array.popup);
        ArrayAdapter<String> adapter = new ArrayAdapter<>(itemView.getContext(), android.R.layout.simple_list_item_1, items);
        final ListPopupWindow popup = new ListPopupWindow(itemView.getContext());
        popup.setAnchorView(itemView);
        popup.setHorizontalOffset((int) event.getX());
        popup.setVerticalOffset((int) event.getY() - itemView.getHeight());
        popup.setAdapter(adapter);
        popup.setWidth(measureContentWidth(itemView.getContext(), adapter));
        popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    ((MainActivity) itemView.getContext()).playVideo(videoUri);
                } else {
                    ((MainActivity) itemView.getContext()).showLargeThumbnail(videoUri);
                }
                popup.dismiss();
            }
        });
        popup.show();
        return (true);
    }
    return (false);
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 10 with Adapter

use of android.support.v7.widget.RecyclerView.Adapter in project materialistic by hidroh.

the class ListFragmentViewHolderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    TestApplication.applicationGraph.inject(this);
    reset(sessionManager);
    reset(favoriteManager);
    reset(itemManager);
    reset(userServices);
    item = new TestHnItem(1) {

        @Override
        public int getRank() {
            return 46;
        }

        @Override
        public String getBy() {
            return "author";
        }
    };
    controller = Robolectric.buildActivity(ListActivity.class).create().start().resume().visible();
    activity = controller.get();
    Bundle args = new Bundle();
    args.putString(ListFragment.EXTRA_ITEM_MANAGER, HackerNewsClient.class.getName());
    args.putString(ListFragment.EXTRA_FILTER, ItemManager.TOP_FETCH_MODE);
    activity.getSupportFragmentManager().beginTransaction().add(android.R.id.content, Fragment.instantiate(activity, ListFragment.class.getName(), args)).commit();
    verify(itemManager).getStories(any(), eq(ItemManager.MODE_DEFAULT), storiesListener.capture());
    storiesListener.getValue().onResponse(new Item[] { item });
    recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
    swipeCallback = (ItemTouchHelper.SimpleCallback) customShadowOf(recyclerView).getItemTouchHelperCallback();
    adapter = customShadowOf(recyclerView.getAdapter());
    item.populate(new PopulatedStory(1));
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) ShadowItemTouchHelper(io.github.hidroh.materialistic.test.shadow.ShadowItemTouchHelper) Bundle(android.os.Bundle) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) HackerNewsClient(io.github.hidroh.materialistic.data.HackerNewsClient) ListActivity(io.github.hidroh.materialistic.test.ListActivity) Before(org.junit.Before)

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