Search in sources :

Example 76 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project EffectiveAndroid by rallat.

the class TopArticleListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    layoutManager.scrollToPosition(0);
    recyclerView.setLayoutManager(layoutManager);
    // allows for optimizations if all items are of the same size:
    recyclerView.setHasFixedSize(true);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnItemTouchListener(this);
    gestureDetector = new GestureDetectorCompat(this, new RecyclerViewDemoOnGestureListener());
    presenter = createPresenter();
    presenter.create();
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 77 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project EffectiveAndroid by rallat.

the class TopImagesListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnItemTouchListener(this);
    gestureDetector = new GestureDetectorCompat(this, new RecyclerViewDemoOnGestureListener());
    presenter = createPresenter();
    presenter.create();
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) GestureDetectorCompat(android.support.v4.view.GestureDetectorCompat) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 78 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project storio by pushtorefresh.

the class TweetsFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(tweetsAdapter);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setHasFixedSize(true);
    recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
    uiStateController = new UiStateController.Builder().withLoadingUi(view.findViewById(R.id.tweets_loading_ui)).withErrorUi(view.findViewById(R.id.tweets_error_ui)).withEmptyUi(view.findViewById(R.id.tweets_empty_ui)).withContentUi(recyclerView).build();
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(com.pushtorefresh.storio.sample.ui.DividerItemDecoration) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator)

Example 79 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project material by rey5137.

the class TabIndicatorView method init.

protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    setHorizontalScrollBarEnabled(false);
    mTabPadding = -1;
    mTabSingleLine = true;
    mCenterCurrentTab = false;
    mIndicatorHeight = -1;
    mIndicatorAtTop = false;
    mScrolling = false;
    mIsRtl = false;
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setColor(ThemeUtil.colorAccent(context, 0xFFFFFFFF));
    mAdapter = new Adapter();
    setAdapter(mAdapter);
    mLayoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, mIsRtl);
    setLayoutManager(mLayoutManager);
    setItemAnimator(new DefaultItemAnimator());
    addOnScrollListener(new OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                updateIndicator(mLayoutManager.findViewByPosition(mSelectedPosition));
            }
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            updateIndicator(mLayoutManager.findViewByPosition(mSelectedPosition));
        }
    });
    applyStyle(context, attrs, defStyleAttr, defStyleRes);
    if (!isInEditMode())
        mStyleId = ThemeManager.getStyleId(context, attrs, defStyleAttr, defStyleRes);
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) Paint(android.graphics.Paint) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Paint(android.graphics.Paint)

Example 80 with DefaultItemAnimator

use of android.support.v7.widget.DefaultItemAnimator in project FastAdapter by mikepenz.

the class RadioButtonSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sample);
    // Handle Toolbar
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    //style our ui
    new MaterializeBuilder().withActivity(this).build();
    //create our FastAdapter which will manage everything
    fastItemAdapter = new FastItemAdapter<>();
    fastItemAdapter.withSelectable(true);
    //configure our fastAdapter
    fastItemAdapter.withOnClickListener(new FastAdapter.OnClickListener<RadioButtonSampleItem>() {

        @Override
        public boolean onClick(View v, IAdapter<RadioButtonSampleItem> adapter, RadioButtonSampleItem item, int position) {
            Toast.makeText(v.getContext(), (item).name.getText(v.getContext()), Toast.LENGTH_LONG).show();
            return false;
        }
    });
    //init the ClickListenerHelper which simplifies custom click listeners on views of the Adapter
    mClickListenerHelper = new ClickListenerHelper<>(fastItemAdapter);
    fastItemAdapter.withOnPreClickListener(new FastAdapter.OnClickListener<RadioButtonSampleItem>() {

        @Override
        public boolean onClick(View v, IAdapter<RadioButtonSampleItem> adapter, RadioButtonSampleItem item, int position) {
            // consume otherwise radio/checkbox will be deselected
            return true;
        }
    });
    fastItemAdapter.withItemEvent(new RadioButtonSampleItem.RadioButtonClickEvent());
    //get our recyclerView and do basic setup
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rv);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(fastItemAdapter);
    //fill with some sample data
    int x = 0;
    List<RadioButtonSampleItem> items = new ArrayList<>();
    for (String s : ALPHABET) {
        int count = new Random().nextInt(20);
        for (int i = 1; i <= count; i++) {
            items.add(new RadioButtonSampleItem().withName(s + " Test " + x).withIdentifier(100 + x));
            x++;
        }
    }
    fastItemAdapter.add(items);
    //restore selections (this has to be done after the items were added
    fastItemAdapter.withSavedInstanceState(savedInstanceState);
    //set the back arrow in the toolbar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(false);
}
Also used : ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) MaterializeBuilder(com.mikepenz.materialize.MaterializeBuilder) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Random(java.util.Random) RadioButtonSampleItem(com.mikepenz.fastadapter.app.items.RadioButtonSampleItem) RecyclerView(android.support.v7.widget.RecyclerView) FastAdapter(com.mikepenz.fastadapter.FastAdapter) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)103 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)72 RecyclerView (android.support.v7.widget.RecyclerView)63 View (android.view.View)55 TextView (android.widget.TextView)30 ImageView (android.widget.ImageView)25 ArrayList (java.util.ArrayList)16 ClickItemTouchListener (com.sdsmdg.harjot.MusicDNA.clickitemtouchlistener.ClickItemTouchListener)14 GridLayoutManager (android.support.v7.widget.GridLayoutManager)13 Toolbar (android.support.v7.widget.Toolbar)13 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)10 FastAdapter (com.mikepenz.fastadapter.FastAdapter)10 UnifiedTrack (com.sdsmdg.harjot.MusicDNA.models.UnifiedTrack)10 MaterializeBuilder (com.mikepenz.materialize.MaterializeBuilder)9 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)8 LocalTrack (com.sdsmdg.harjot.MusicDNA.models.LocalTrack)8 DividerItemDecoration (de.madcyph3r.example.DividerItemDecoration)8 Button (android.widget.Button)7 Random (java.util.Random)6 Intent (android.content.Intent)5