Search in sources :

Example 1 with START

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;
}
Also used : ViewGroup(android.view.ViewGroup) MediaPlayerWrapper(com.volokh.danylo.video_player_manager.ui.MediaPlayerWrapper) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) VideoViewHolder(com.volokh.danylo.videolist.video_list_demo.adapter.holders.VideoViewHolder)

Example 2 with START

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);
        }
    }
}
Also used : Adapter(android.support.v7.widget.RecyclerView.Adapter)

Example 3 with START

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--;
        }
    }
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 4 with START

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);
}
Also used : TabLayout(android.support.design.widget.TabLayout) NonNull(android.support.annotation.NonNull) Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) ShadowRecyclerView(io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView) TestItem(io.github.hidroh.materialistic.test.TestItem) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 5 with START

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);
}
Also used : Bundle(android.os.Bundle) TestFavoriteActivity(io.github.hidroh.materialistic.test.TestFavoriteActivity) RecyclerView(android.support.v7.widget.RecyclerView) ShadowRecyclerView(io.github.hidroh.materialistic.test.shadow.ShadowRecyclerView) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest) Test(org.junit.Test)

Aggregations

View (android.view.View)367 RecyclerView (android.support.v7.widget.RecyclerView)271 TextView (android.widget.TextView)175 Intent (android.content.Intent)109 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)84 Toolbar (android.support.v7.widget.Toolbar)77 TextWatcher (android.text.TextWatcher)77 Editable (android.text.Editable)76 ImageView (android.widget.ImageView)76 ArrayList (java.util.ArrayList)68 Bundle (android.os.Bundle)48 DialogInterface (android.content.DialogInterface)47 AlertDialog (android.support.v7.app.AlertDialog)47 AdapterView (android.widget.AdapterView)46 EditText (android.widget.EditText)42 SuppressLint (android.annotation.SuppressLint)39 Button (android.widget.Button)39 ActionBar (android.support.v7.app.ActionBar)34 List (java.util.List)34 ViewPropertyAnimatorCompat (android.support.v4.view.ViewPropertyAnimatorCompat)33