use of android.support.v7.widget.helper.ItemTouchHelper.START in project VideoPlayerManager by danylovolokh.
the class BaseVideoItem method createView.
public View createView(ViewGroup parent, int screenWidth) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.video_item, parent, false);
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.height = screenWidth;
final VideoViewHolder videoViewHolder = new VideoViewHolder(view);
view.setTag(videoViewHolder);
videoViewHolder.mPlayer.addMediaPlayerListener(new MediaPlayerWrapper.MainThreadMediaPlayerListener() {
@Override
public void onVideoSizeChangedMainThread(int width, int height) {
}
@Override
public void onVideoPreparedMainThread() {
// When video is prepared it's about to start playback. So we hide the cover
videoViewHolder.mCover.setVisibility(View.INVISIBLE);
}
@Override
public void onVideoCompletionMainThread() {
}
@Override
public void onErrorMainThread(int what, int extra) {
}
@Override
public void onBufferingUpdateMainThread(int percent) {
}
@Override
public void onVideoStoppedMainThread() {
// Show the cover when video stopped
videoViewHolder.mCover.setVisibility(View.VISIBLE);
}
});
return view;
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project UltimateAndroid by cymcsg.
the class ItemSelectionSupport method onAdapterDataChanged.
public void onAdapterDataChanged() {
final Adapter adapter = mRecyclerView.getAdapter();
if (mChoiceMode == ChoiceMode.NONE || adapter == null || !adapter.hasStableIds()) {
return;
}
final int itemCount = adapter.getItemCount();
// Clear out the positional check states, we'll rebuild it below from IDs.
mCheckedStates.clear();
for (int checkedIndex = 0; checkedIndex < mCheckedIdStates.size(); checkedIndex++) {
final long currentId = mCheckedIdStates.keyAt(checkedIndex);
final int currentPosition = mCheckedIdStates.valueAt(checkedIndex);
final long newPositionId = adapter.getItemId(currentPosition);
if (currentId != newPositionId) {
// Look around to see if the ID is nearby. If not, uncheck it.
final int start = Math.max(0, currentPosition - CHECK_POSITION_SEARCH_DISTANCE);
final int end = Math.min(currentPosition + CHECK_POSITION_SEARCH_DISTANCE, itemCount);
boolean found = false;
for (int searchPos = start; searchPos < end; searchPos++) {
final long searchId = adapter.getItemId(searchPos);
if (currentId == searchId) {
found = true;
mCheckedStates.put(searchPos, true);
mCheckedIdStates.setValueAt(checkedIndex, searchPos);
break;
}
}
if (!found) {
mCheckedIdStates.delete(currentId);
mCheckedCount--;
checkedIndex--;
}
} else {
mCheckedStates.put(currentPosition, true);
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project UltimateAndroid by cymcsg.
the class TwoWayLayoutManager method updateLayoutEdgesFromRemovedChild.
private void updateLayoutEdgesFromRemovedChild(View removedChild, Direction direction) {
final int childCount = getChildCount();
if (childCount == 0) {
resetLayoutEdges();
return;
}
final int removedChildStart = getChildStart(removedChild);
final int removedChildEnd = getChildEnd(removedChild);
if (removedChildStart > mLayoutStart && removedChildEnd < mLayoutEnd) {
return;
}
int index;
final int limit;
if (direction == Direction.END) {
// Scrolling towards the end of the layout, child view being
// removed from the start.
mLayoutStart = Integer.MAX_VALUE;
index = 0;
limit = removedChildEnd;
} else {
// Scrolling towards the start of the layout, child view being
// removed from the end.
mLayoutEnd = Integer.MIN_VALUE;
index = childCount - 1;
limit = removedChildStart;
}
while (index >= 0 && index <= childCount - 1) {
final View child = getChildAt(index);
if (direction == Direction.END) {
final int childStart = getChildStart(child);
if (childStart < mLayoutStart) {
mLayoutStart = childStart;
}
// layout start edge, stop.
if (childStart >= limit) {
break;
}
index++;
} else {
final int childEnd = getChildEnd(child);
if (childEnd > mLayoutEnd) {
mLayoutEnd = childEnd;
}
// layout end edge, stop.
if (childEnd <= limit) {
break;
}
index--;
}
}
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project materialistic by hidroh.
the class ItemActivityTest method testScrollToTop.
@Config(shadows = ShadowRecyclerView.class)
@Test
public void testScrollToTop() {
Intent intent = new Intent();
intent.putExtra(ItemActivity.EXTRA_ITEM, new TestItem() {
@NonNull
@Override
public String getType() {
return STORY_TYPE;
}
@Override
public String getId() {
return "1";
}
@Override
public boolean isStoryType() {
return true;
}
@Override
public int getKidCount() {
return 10;
}
@Override
public String getUrl() {
return "http://example.com";
}
});
controller.withIntent(intent).create().start().resume();
// see https://github.com/robolectric/robolectric/issues/1326
ShadowLooper.pauseMainLooper();
controller.visible();
ShadowApplication.getInstance().getForegroundThreadScheduler().advanceToLastPostedRunnable();
RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recycler_view);
recyclerView.smoothScrollToPosition(1);
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(1);
TabLayout tabLayout = (TabLayout) activity.findViewById(R.id.tab_layout);
assertThat(tabLayout.getTabCount()).isEqualTo(2);
tabLayout.getTabAt(1).select();
tabLayout.getTabAt(0).select();
tabLayout.getTabAt(0).select();
assertThat(customShadowOf(recyclerView).getScrollPosition()).isEqualTo(0);
}
use of android.support.v7.widget.helper.ItemTouchHelper.START in project materialistic by hidroh.
the class FavoriteActivityTest method testSaveState.
@Test
public void testSaveState() {
Bundle outState = new Bundle();
controller.saveInstanceState(outState);
ActivityController<TestFavoriteActivity> controller = Robolectric.buildActivity(TestFavoriteActivity.class).create(outState).postCreate(outState).start().resume().visible();
assertEquals(2, ((RecyclerView) controller.get().findViewById(R.id.recycler_view)).getAdapter().getItemCount());
controller.pause().stop().destroy();
reset(keyDelegate);
}
Aggregations