Search in sources :

Example 46 with LinearLayoutManager

use of android.support.v7.widget.LinearLayoutManager in project material-dialogs by afollestad.

the class MaterialDialog method invalidateList.

/**
   * Sets the dialog RecyclerView's adapter/layout manager, and it's item click listener.
   */
final void invalidateList() {
    if (recyclerView == null) {
        return;
    } else if ((builder.items == null || builder.items.size() == 0) && builder.adapter == null) {
        return;
    }
    if (builder.layoutManager == null) {
        builder.layoutManager = new LinearLayoutManager(getContext());
    }
    recyclerView.setLayoutManager(builder.layoutManager);
    recyclerView.setAdapter(builder.adapter);
    if (listType != null) {
        ((DefaultRvAdapter) builder.adapter).setCallback(this);
    }
}
Also used : LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 47 with LinearLayoutManager

use of android.support.v7.widget.LinearLayoutManager in project GestureViews by alexvasilkov.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RecyclerView recyclerView = Views.find(this, R.id.main_list);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(new SampleAdapter(this, getActivitiesList()));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 48 with LinearLayoutManager

use of android.support.v7.widget.LinearLayoutManager in project StarWars.Android by Yalantis.

the class SideFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mTilesFrameLayout.setOnAnimationFinishedListener(this);
    mRecycler.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecycler.setAdapter(new ProfileAdapter(getContext(), getUser(), this));
    setUpToolbar(mToolbar);
    mHeader.setImageResource(getUser().getPhotoRes());
    if (getArguments() != null) {
        mAppBarLayout.setExpanded(getArguments().getBoolean(ARG_SHOULD_EXPAND), false);
    }
}
Also used : ProfileAdapter(com.yalantis.starwarsdemo.adapter.ProfileAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 49 with LinearLayoutManager

use of android.support.v7.widget.LinearLayoutManager in project Fragmentation by YoKeyword.

the class WechatFirstTabFragment method onLazyInitView.

@Override
public void onLazyInitView(@Nullable Bundle savedInstanceState) {
    super.onLazyInitView(savedInstanceState);
    mRefreshLayout.setOnRefreshListener(this);
    mRecy.setLayoutManager(new LinearLayoutManager(_mActivity));
    mRecy.setHasFixedSize(true);
    final int space = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0.5f, getResources().getDisplayMetrics());
    mRecy.addItemDecoration(new RecyclerView.ItemDecoration() {

        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            outRect.set(0, 0, 0, space);
        }
    });
    mAdapter = new ChatAdapter(_mActivity);
    mRecy.setAdapter(mAdapter);
    mRecy.addOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);
            mScrollTotal += dy;
            if (mScrollTotal <= 0) {
                mInAtTop = true;
            } else {
                mInAtTop = false;
            }
        }
    });
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position, View view, RecyclerView.ViewHolder vh) {
            // 因为启动的MsgFragment是MainFragment的兄弟Fragment,所以需要MainFragment.start()
            // 这里我使用EventBus通知父MainFragment处理跳转(接耦),
            EventBus.getDefault().post(new StartBrotherEvent(MsgFragment.newInstance(mAdapter.getMsg(position))));
        // 也可以像使用getParentFragment()的方式,拿到父Fragment的引用来操作 (不建议)
        //              ((MainFragment) getParentFragment()).startMsgBrother(MsgFragment.newInstance());
        }
    });
    List<Chat> chatList = initDatas();
    mAdapter.setDatas(chatList);
}
Also used : Rect(android.graphics.Rect) OnItemClickListener(me.yokeyword.sample.demo_wechat.listener.OnItemClickListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) StartBrotherEvent(me.yokeyword.sample.demo_wechat.event.StartBrotherEvent) Chat(me.yokeyword.sample.demo_wechat.entity.Chat) RecyclerView(android.support.v7.widget.RecyclerView) ChatAdapter(me.yokeyword.sample.demo_wechat.adapter.ChatAdapter)

Example 50 with LinearLayoutManager

use of android.support.v7.widget.LinearLayoutManager in project Fragmentation by YoKeyword.

the class MenuListFragment method onActivityCreated.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    LinearLayoutManager manager = new LinearLayoutManager(_mActivity);
    mRecy.setLayoutManager(manager);
    mAdapter = new MenuAdapter(_mActivity);
    mRecy.setAdapter(mAdapter);
    mAdapter.setDatas(mMenus);
    mAdapter.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(int position, View view) {
            showContent(position);
        }
    });
    if (savedInstanceState != null) {
        mCurrentPosition = savedInstanceState.getInt(SAVE_STATE_POSITION);
        mAdapter.setItemChecked(mCurrentPosition);
    } else {
        mCurrentPosition = 0;
        mAdapter.setItemChecked(0);
    }
}
Also used : OnItemClickListener(me.yokeyword.sample.demo_flow.listener.OnItemClickListener) MenuAdapter(me.yokeyword.sample.demo_flow.adapter.MenuAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1976 RecyclerView (android.support.v7.widget.RecyclerView)1085 View (android.view.View)822 TextView (android.widget.TextView)352 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)235 ArrayList (java.util.ArrayList)204 ImageView (android.widget.ImageView)186 Intent (android.content.Intent)150 Toolbar (android.support.v7.widget.Toolbar)134 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)131 GridLayoutManager (android.support.v7.widget.GridLayoutManager)125 BindView (butterknife.BindView)124 Bundle (android.os.Bundle)109 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)105 Nullable (android.support.annotation.Nullable)98 ViewGroup (android.view.ViewGroup)82 Context (android.content.Context)81 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)80 AdapterView (android.widget.AdapterView)70 List (java.util.List)69