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);
}
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);
}
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;
}
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);
}
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));
}
Aggregations