Java 类android.support.v7.widget.LinearLayoutManager 实例源码
项目:mobile-app-dev-book
文件:JournalFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_journal_list, container, false);
// Set the adapter
if (view instanceof RecyclerView) {
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
DatabaseReference userRef = dbRef.getReference(user.getUid());
userRef.addChildEventListener (chEvListener);
userRef.addValueEventListener(valEvListener);
Context context = view.getContext();
RecyclerView recyclerView = (RecyclerView) view;
if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
} else {
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
}
adapter = new JournalAdapter(allTrips, mListener);
recyclerView.setAdapter(adapter);
}
return view;
}
项目:MeetMusic
文件:ThemeActivity.java
private void init(){
for (int i = 0 ;i < themeType.length;i++){
ThemeInfo info = new ThemeInfo();
info.setName(themeType[i]);
info.setColor(colors[i]);
info.setSelect((selectTheme == i) ? true : false);
if (i == themeType.length-1){
info.setBackground(R.color.nightBg);
}else {
info.setBackground(R.color.colorWhite);
}
themeInfoList.add(info);
}
recyclerView = (RecyclerView)findViewById(R.id.theme_rv);
adapter = new ThemeAdapter();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(adapter);
}
项目:GitHub
文件:MainFragment.java
@Override
protected void initData() {
List<ItemModel> items = new ArrayList<>();
fillData(items);
adapter = new MainAdapter(items);
adapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
adapter.isFirstOnly(false);
adapter.setOnLoadMoreListener(this);
refreshLayout.setColorSchemeColors(Color.RED, Color.BLUE, Color.GREEN);
refreshLayout.setOnRefreshListener(this);
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(context, LinearLayoutManager.VERTICAL));
recyclerView.setAdapter(adapter);
}
项目:adapters-android
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
RecyclerView rcViewList = (RecyclerView) findViewById(R.id.rc_item);
rcViewList.setAdapter(new ItemAdapter(generateFakeItems(), new OnItemClickListener() {
@Override
public void onItemClick(int position) {
startActivity(new Intent(MainActivity.this, FragmentPagerActivity.class));
}
}));
rcViewList.setLayoutManager(new LinearLayoutManager(this));
rcViewList.addItemDecoration(new DividerItemDecoration(this,
DividerItemDecoration.VERTICAL));
}
项目:Mix
文件:BackTopActivity.java
private void initView(List<String> list) {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setSmoothScrollbarEnabled(true);
recyclerView.setLayoutManager(linearLayoutManager);
ListRecyclerAdapter adapter = new ListRecyclerAdapter(list);
recyclerView.setAdapter(adapter);
FAB = (FloatingActionButton) findViewById(R.id.fab);
FAB.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
linearLayoutManager.scrollToPosition(0);
hideFAB();
}
});
}
项目:BilibiliClient
文件:VideoIntroductionFragment.java
private void setVideoRelated() {
List<VideoDetailsInfo.DataBean.RelatesBean> relates = mVideoDetailsInfo.getRelates();
if (relates == null) {
mVideoRelatedLayout.setVisibility(View.GONE);
return;
}
VideoRelatedAdapter mVideoRelatedAdapter = new VideoRelatedAdapter(mRecyclerView, relates);
mRecyclerView.setHasFixedSize(false);
mRecyclerView.setNestedScrollingEnabled(false);
mRecyclerView.setLayoutManager(
new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true));
mRecyclerView.setAdapter(mVideoRelatedAdapter);
mVideoRelatedAdapter.setOnItemClickListener(
(position, holder) -> VideoDetailsActivity.launch(getActivity(),
relates.get(position).getAid(), relates.get(position).getPic()));
}
项目:vlayout
文件:OnePlusNLayoutHelper.java
@Override
public int computeAlignOffset(int offset, boolean isLayoutEnd, boolean useAnchor,
LayoutManagerHelper helper) {
//Log.d(TAG,
// "range " + getRange() + " offset " + offset + " isLayoutEnd " + isLayoutEnd + " useAnchor " + useAnchor
// + " helper " + this.hashCode());
final boolean layoutInVertical = helper.getOrientation() == LinearLayoutManager.VERTICAL;
if (useAnchor) {
return 0;
}
if (isLayoutEnd) {
if (offset == getItemCount() - 1) {
return layoutInVertical ? mMarginBottom + mPaddingBottom : mMarginRight + mPaddingRight;
}
} else {
if (offset == 0) {
return layoutInVertical ? -mMarginTop - mPaddingTop : -mMarginLeft - mPaddingLeft;
}
}
return 0;
}
项目:RLibrary
文件:RecyclerViewPager.java
/**
* 计算每个Item的宽度
*/
public int getItemWidth() {
final LayoutManager layoutManager = getLayoutManager();
int itemWidth = 0;
if (layoutManager instanceof GridLayoutManager) {
final GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager;
final int spanCount = gridLayoutManager.getSpanCount();
if (gridLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
itemWidth = getRawWidth() / (mItemCount / spanCount);
} else {
itemWidth = getRawWidth() / spanCount;
}
} else if (layoutManager instanceof LinearLayoutManager) {
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager;
if (linearLayoutManager.getOrientation() == LinearLayoutManager.HORIZONTAL) {
itemWidth = getRawWidth() / mItemCount;
} else {
itemWidth = getRawWidth();
}
}
return itemWidth;
}
项目:SuperNatives
文件:HeroesListActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_heroes_list);
context = this;
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context,
LinearLayoutManager.VERTICAL, false);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context,
linearLayoutManager.getOrientation());
binding.rvHeroes.setLayoutManager(linearLayoutManager);
binding.rvHeroes.addItemDecoration(dividerItemDecoration);
binding.rvHeroes.setAdapter(heroesAdapter);
binding.fastScroll.setRecyclerView(binding.rvHeroes);
heroesAdapter.setOnClickListener(position -> presenter.onSuperHeroClicked(position));
binding.btnTryAgain.setOnClickListener(v -> presenter.getSuperHeroes());
binding.btnTryAgain.performClick();
}
项目:Remindy
文件:TaskDetailActivity.java
private void setUpRecyclerView() {
if(mTask.getAttachments().size() > 0) {
mAttachmentsSubtitle.setVisibility(View.VISIBLE);
mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
mAdapter = new AttachmentAdapter(this, mTask.getAttachments(), true);
mAdapter.setAttachmentDataUpdatedListener(new AttachmentAdapter.AttachmentDataUpdatedListener() {
@Override
public void onAttachmentDataUpdated() {
mTaskDataUpdated = true;
}
});
DividerItemDecoration itemDecoration = new DividerItemDecoration(this, mLayoutManager.getOrientation());
itemDecoration.setDrawable(ContextCompat.getDrawable(this, R.drawable.item_decoration_half_line));
mRecyclerView.addItemDecoration(itemDecoration);
mRecyclerView.setNestedScrollingEnabled(false);
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setAdapter(mAdapter);
}
}
项目:BounceView
文件:BounceMenu.java
private BounceMenu(View view, int resId, final MyAdapter myAdapter) {
parentVG = findParentVG(view);
rootView = LayoutInflater.from(view.getContext()).inflate(resId,null,false);
recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
bounceView = (BounceView) rootView.findViewById(R.id.bounceview);
recyclerView.setLayoutManager(new LinearLayoutManager(view.getContext()));
bounceView.setAnimatorListener(new BounceView.BounceAnimatorListener() {
@Override
public void showContent() {
recyclerView.setVisibility(View.VISIBLE);
recyclerView.setAdapter(myAdapter);
recyclerView.scheduleLayoutAnimation();
}
});
}
项目:Pilem
文件:MovieInfoFragment.java
private void setUpInfo(View view) {
RecyclerView rvInfo = (RecyclerView) view.findViewById(R.id.rv_movie_detail_info);
ArrayList<ItemInfo> infoItems = new ArrayList<>();
String overviewValStr = view.getResources().getString(R.string.lorem_ipsum_long);
infoItems.add(new ItemInfo("Overview", overviewValStr));
infoItems.add(new ItemInfo("Tagline", "Divided We Fall"));
infoItems.add(new ItemInfo("Status", "Releases"));
infoItems.add(new ItemInfo("Budget", "250.000.000"));
infoItems.add(new ItemInfo("Revenue", "1.153.304.495"));
infoItems.add(new ItemInfo("Homepage", "http://marvel.com/captainamericapremiere"));
RecyclerAdapter infoAdapter = new RecyclerAdapter<ItemInfo, MovieInfoViewHolder>(
R.layout.item_movie_info, ItemInfo.class, infoItems, MovieInfoViewHolder.class) {
@Override
protected void bindView(MovieInfoViewHolder holder, ItemInfo model, int position) {
holder.getLabel().setText(model.getLabel());
holder.getValue().setText(model.getValue());
}
};
rvInfo.setLayoutManager(new LinearLayoutManager(view.getContext()));
rvInfo.setAdapter(infoAdapter);
rvInfo.addItemDecoration(new MovieInfoViewHolder.ItemDecoration());
}
项目:RunMap
文件:V2MainFragment.java
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearManager = (LinearLayoutManager) layoutManager;
int firstItemPosition = linearManager.findFirstVisibleItemPosition();
if(firstItemPosition == 0 || mContentListAdapter.getItemCount() == 0){
mRefreshLayout.setEnabled(true);
CFLog.e("V2MainFragment", "arrive top");
}
else{
mRefreshLayout.setEnabled(false);
}
}
}
项目:GCSApp
文件:YearDelegate.java
public void setData(ArrayList<FinancingInfo> data,boolean isRefresh) {
if (isRefresh){
mData.clear();
}
mData.addAll(data);
if (null == adapter) {
manager = new LinearLayoutManager(getActivity());
mRec.addItemDecoration(new DividerGridItemDecoration(getActivity()));
adapter = new YearAdapter(mData, getActivity());
mRec.setAdapter(adapter);
mRec.setLayoutManager(manager);
} else {
adapter.notifyDataSetChanged();
}
}
项目:Guanajoven
文件:PromocionFragment.java
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_promociones, container, false);
rvPromociones = (RecyclerView) view.findViewById(R.id.rv_promociones);
textViewEmptyPromociones = (TextView) view.findViewById(R.id.textview_empty_promociones);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
adapter = new RVPromocionAdapter(getContext(), empresa.getPromociones(), empresa);
rvPromociones.setLayoutManager(llm);
rvPromociones.setAdapter(adapter);
if (empresa.getPromociones().isEmpty()) {
textViewEmptyPromociones.setVisibility(View.VISIBLE);
}
return view;
}
项目:Expert-Android-Programming
文件:FollowingFragment.java
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
this.context = getActivity();
list = new ArrayList<>();
recyclerViewAdapter = new FriendAdapter(getActivity(), list);
/* recyclerViewAdapter.setClickListener(new FriendAdapter.ClickListener() {
@Override
public void onItemClickListener(View v, int pos) {
gotoDetailsActivity();
}
@Override
public void onFriendListener(int pos, boolean isFollowing) {
}
});*/
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.setAdapter(recyclerViewAdapter);
getFollowing();
}
项目:SimpleBible
文件:BookSelectionFragment.java
@Override
public void update(Observable observable, Object o) {
mBooks.clear();
if (o instanceof IBookProvider && ((IBookProvider)o).getBooks() != null) {
mBooks.addAll(((IBookProvider)o).getBooks());
mAdapter.notifyDataSetChanged();
if (CurrentSelected.getBook() != null) {
for (IBook book : mBooks) {
if (book.getId().equalsIgnoreCase(CurrentSelected.getBook().getId())) {
((LinearLayoutManager)mRecyclerView.getLayoutManager()).scrollToPositionWithOffset(mBooks.indexOf(book), mRecyclerView.getHeight()/2);
}
}
}
}
}
项目:Aequorea
文件:TagActivity.java
@Override
protected void initView() {
ButterKnife.bind(this);
mToolbar.setNavigationIcon(R.drawable.icon_ab_back_material);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
mToolbar.setTitle(mModel.getTitle());
mCoordinatorLayout.setPadding(0, DisplayUtils.getStatusBarHeight(getResources()), 0, 0);
mAdapter = new SimpleArticleListAdapter(this, null);
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addOnScrollListener(mScrollListener);
setStatusBarStyle();
}
项目:GitHub
文件:RecyclerViewActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
mRecyclerView = (RecyclerView) findViewById(R.id.rv_pop);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
List<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add("");
}
mPopAdapter = new RecyclerPopAdapter();
mPopAdapter.setNewData(list);
mRecyclerView.setAdapter(mPopAdapter);
initPop();
initEvents();
}
项目:mobile-app-dev-book
文件:JournalFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_journal_list, container, false);
// Set the adapter
if (view instanceof RecyclerView) {
FirebaseDatabase dbRef = FirebaseDatabase.getInstance();
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseUser user = auth.getCurrentUser();
DatabaseReference userRef = dbRef.getReference(user.getUid());
userRef.addChildEventListener (chEvListener);
userRef.addValueEventListener(valEvListener);
Context context = view.getContext();
RecyclerView recyclerView = (RecyclerView) view;
if (mColumnCount <= 1) {
recyclerView.setLayoutManager(new LinearLayoutManager(context));
} else {
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
}
adapter = new JournalAdapter(allTrips, mListener);
recyclerView.setAdapter(adapter);
}
return view;
}
项目:QMUI_Android
文件:QDSnapHelperFragment.java
private void showBottomSheetList() {
new QMUIBottomSheet.BottomListSheetBuilder(getActivity())
.addItem("水平方向")
.addItem("垂直方向")
.setOnSheetItemClickListener(new QMUIBottomSheet.BottomListSheetBuilder.OnSheetItemClickListener() {
@Override
public void onClick(QMUIBottomSheet dialog, View itemView, int position, String tag) {
dialog.dismiss();
switch (position) {
case 0:
mPagerLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
break;
case 1:
mPagerLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
break;
default:
break;
}
}
})
.build()
.show();
}
项目:GracefulMovies
文件:OpenLicenseActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_open_license);
ButterKnife.bind(this);
initializeToolbar();
String[] libs = getResources().getStringArray(R.array.libraries);
String[] licenses = getResources().getStringArray(R.array.licenses);
List<OpenModel> list = new ArrayList<>();
OpenModel openModel;
for (int i = 0; i < libs.length; i++) {
openModel = new OpenModel();
openModel.setName(libs[i]);
openModel.setLicense(licenses[i]);
list.add(openModel);
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setAdapter(new LicenseListAdapter(list));
}
项目:GitHub
文件:CardViewRecyclerActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.card_view_recycler_layout);
top_bar_linear_back=(LinearLayout)this.findViewById(R.id.top_bar_linear_back);
top_bar_linear_back.setOnClickListener(new CustomOnClickListener());
top_bar_title=(TextView)this.findViewById(R.id.top_bar_title);
top_bar_title.setText("CardView结合RecyclerView使用实例");
recycler_cardview=(RecyclerView)this.findViewById(R.id.recycler_cardview);
LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this);
linearLayoutManager.setOrientation(OrientationHelper.VERTICAL);
recycler_cardview.setLayoutManager(linearLayoutManager);
recycler_cardview.setAdapter(new CardViewAdapter(this));
}
项目:gdgApp
文件:HomeSection.java
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
recyclerView.setHasFixedSize(true);
LinearLayoutManager manager = new LinearLayoutManager(getContext());
manager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(manager);
recyclerView.setAdapter(adapter);
UpdateMessages();
UpdateEvents();
//noinspection ConstantConditions
typeface = Typeface.createFromAsset(getActivity().getAssets(), Constants.PathConstants.PRODUCT_SANS_FONT);
notificationTitle.setTypeface(typeface);
notificationMessage.setTypeface(typeface);
notificationAuthorTime.setTypeface(typeface);
}
项目:tubik
文件:PopularFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_popular_grid, container, false);
Context context = view.getContext();
RecyclerView gridTracksView = (RecyclerView) view.findViewById(R.id.gridLastFMTopTracks);
mTracksAdapter = new TrackAdapter(getContext(), mListener);
gridTracksView.setLayoutManager(new GridLayoutManager(context, mColumnCount, LinearLayoutManager.HORIZONTAL, false));
gridTracksView.setAdapter(mTracksAdapter);
RecyclerView gridAlbumsView = (RecyclerView) view.findViewById(R.id.gridTopAlbums);
mAlbumsAdapter = new AlbumAdapter(getContext(), mListener);
gridAlbumsView.setLayoutManager(new GridLayoutManager(context, mColumnCount, LinearLayoutManager.HORIZONTAL, false));
gridAlbumsView.setAdapter(mAlbumsAdapter);
return view;
}
项目:OpenEyesReading-android
文件:NewsActivity.java
private int calculateRecyclerViewFirstPosition() {
RecyclerView.LayoutManager manager = mRecyclerView.getLayoutManager();
if (manager instanceof StaggeredGridLayoutManager) {
if (mVisiblePositions == null)
mVisiblePositions = new int[((StaggeredGridLayoutManager) manager).getSpanCount()];
((StaggeredGridLayoutManager) manager).findLastCompletelyVisibleItemPositions(mVisiblePositions);
int max = -1;
for (int pos : mVisiblePositions) {
max = Math.max(max, pos);
}
return max;
} else if (manager instanceof GridLayoutManager) {
return ((GridLayoutManager) manager).findFirstCompletelyVisibleItemPosition();
} else {
return ((LinearLayoutManager) manager).findLastCompletelyVisibleItemPosition();
}
}
项目:recyclerview-android
文件:CursorDatasourceExampleActivity.java
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cursor_datasource_example);
mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator);
mAdapter = new CallsAdapter();
mRecyclerView = (RecyclerView) findViewById(android.R.id.list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
mRecyclerView.setAdapter(mAdapter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this, CALL_LOG_PERMISSION) == PackageManager.PERMISSION_GRANTED) {
onCallLogPermissionGranted();
} else {
ActivityCompat.requestPermissions(this, CALL_LOG_PERMISSIONS,
REQUEST_CODE_CALL_LOG_PERMISSION);
}
} else {
onCallLogPermissionGranted();
}
}
项目:Phoenix-for-VK
文件:SelectSchoolsDialog.java
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
View root = inflater.inflate(R.layout.dialog_country_or_city_select, container, false);
EditText input = root.findViewById(R.id.input);
input.setText(filter);
input.addTextChangedListener(new TextWatcherAdapter() {
@Override
public void afterTextChanged(Editable s) {
filter = s.toString();
mHandler.removeCallbacks(runSearchRunnable);
mHandler.postDelayed(runSearchRunnable, RUN_SEACRH_DELAY);
}
});
mRecyclerView = root.findViewById(R.id.list);
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
return root;
}
项目:black-mirror
文件:NewsWidgetView.java
private void init() {
inflate(getContext(), R.layout.view_news_widget, this);
this.polsatNewsRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_polsat_news);
this.tvnNewsRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_tvn_news);
this.polsatNewsTitle = (TextView) findViewById(R.id.polsat_text);
this.tvnNewsTitle = (TextView) findViewById(R.id.tvn_text);
this.polsatNewsAdapter = new NewsRecyclerAdapter(getContext());
this.tvnNewsAdapter = new NewsRecyclerAdapter(getContext());
tvnNewsRecyclerView.setLayoutManager(new ScrollingLinearLayoutManager(getContext(),
LinearLayoutManager.HORIZONTAL, false, 5000));
tvnNewsRecyclerView.setAdapter(tvnNewsAdapter);
polsatNewsRecyclerView.setAdapter(polsatNewsAdapter);
polsatNewsRecyclerView.setLayoutManager(new ScrollingLinearLayoutManager(getContext(),
LinearLayoutManager.HORIZONTAL, false, 11000));
this.setVisibility(GONE);
}
项目:Gesture
文件:ItemTouchListener.java
private int chooseDropTarget(RecyclerView rv, int dragPosition, int curY) {
LinearLayoutManager layoutManager = ((LinearLayoutManager) rv.getLayoutManager());
int firstVisiblePosition = layoutManager.findFirstVisibleItemPosition();
if (mView.getY() < 0 && firstVisiblePosition == 0) {
return firstVisiblePosition;
}
float referenceUp = mView.getY() - mView.getTranslationY();
if ((referenceUp > curY) && mView.getTranslationY() < 0) {
if (referenceUp - curY > mView.getHeight()) {
return dragPosition - 2;
}
if (referenceUp - curY < mView.getHeight() && referenceUp - curY > 0) {
return dragPosition - 1;
}
}
float referenceDown = mView.getY() - mView.getTranslationY() + mView.getHeight();
if ((referenceDown < curY) && mView.getTranslationY() > 0) {
if (curY - referenceDown > mView.getHeight()) {
return dragPosition + 2;
}
if (curY - referenceDown < mView.getHeight() && curY - referenceDown > 0) {
return dragPosition + 1;
}
}
return -1;
}
项目:Aurora
文件:RecyclerSnapHelper.java
@Override
public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) {
int targetPos = super.findTargetSnapPosition(layoutManager, velocityX, velocityY);
this.position = targetPos;
final View currentView = findSnapView(layoutManager);
if (targetPos != RecyclerView.NO_POSITION && currentView != null) {
int currentPos = layoutManager.getPosition(currentView);
int first = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
int last = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
currentPos = targetPos < currentPos ? last : (targetPos > currentPos ? first : currentPos);
targetPos = targetPos < currentPos ? currentPos - 1 : (targetPos > currentPos ? currentPos + 1 : currentPos);
}
return targetPos;
}
项目:android-dev-challenge
文件:MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*
* Using findViewById, we get a reference to our RecyclerView from xml. This allows us to
* do things like set the adapter of the RecyclerView and toggle the visibility.
*/
mNumbersList = (RecyclerView) findViewById(R.id.rv_numbers);
/*
* A LinearLayoutManager is responsible for measuring and positioning item views within a
* RecyclerView into a linear list. This means that it can produce either a horizontal or
* vertical list depending on which parameter you pass in to the LinearLayoutManager
* constructor. By default, if you don't specify an orientation, you get a vertical list.
* In our case, we want a vertical list, so we don't need to pass in an orientation flag to
* the LinearLayoutManager constructor.
*
* There are other LayoutManagers available to display your data in uniform grids,
* staggered grids, and more! See the developer documentation for more details.
*/
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
mNumbersList.setLayoutManager(layoutManager);
/*
* Use this setting to improve performance if you know that changes in content do not
* change the child layout size in the RecyclerView
*/
mNumbersList.setHasFixedSize(true);
/*
* The GreenAdapter is responsible for displaying each item in the list.
*/
mAdapter = new GreenAdapter(NUM_LIST_ITEMS);
mNumbersList.setAdapter(mAdapter);
}
项目:XFrame
文件:DividerDecoration.java
/**
* 返回条目之间的间隔,例如我们想仿照ListView一样添加分割线,那么就需要设置outRect的下边距。
* @param outRect
* @param view
* @param parent
* @param state
*/
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = parent.getChildAdapterPosition(view);
int orientation = 0;
int headerCount = 0,footerCount = 0;
if (parent.getAdapter() instanceof XRecyclerViewAdapter){
headerCount = ((XRecyclerViewAdapter) parent.getAdapter()).getHeaderCount();
footerCount = ((XRecyclerViewAdapter) parent.getAdapter()).getFooterCount();
}
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (layoutManager instanceof StaggeredGridLayoutManager){
orientation = ((StaggeredGridLayoutManager) layoutManager).getOrientation();
}else if (layoutManager instanceof GridLayoutManager){
orientation = ((GridLayoutManager) layoutManager).getOrientation();
}else if (layoutManager instanceof LinearLayoutManager){
orientation = ((LinearLayoutManager) layoutManager).getOrientation();
}
if (position>=headerCount&&position<parent.getAdapter().getItemCount()-footerCount||mDrawHeaderFooter){
if (orientation == OrientationHelper.VERTICAL){
outRect.bottom = mHeight;
}else {
outRect.right = mHeight;
}
}
}
项目:NoChat
文件:MainActivity.java
private void setupChatAdapter() {
chatAdapter = new ChatAdapter();
LinearLayoutManager manager = new LinearLayoutManager(this);
manager.setStackFromEnd(true);
rvChat.setLayoutManager(manager);
rvChat.setAdapter(chatAdapter);
}
项目:Cash
文件:frmVendaItens.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.frm_venda_itens);
iVenda = getIntent().getExtras().getInt("Venda");
RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.rvItens);
mRecyclerView.setLayoutManager(new LinearLayoutManager(frmVendaItens.this));
mRecyclerView.addItemDecoration(new SpacesItemDecoration(Funcoes.SPACE_BETWEEN_ITEMS));
mAdapter = new adpVendaItens(frmVendaItens.this, mRecyclerView, iVenda);
mRecyclerView.setAdapter(mAdapter);
ImageButton btnAdd = (ImageButton) findViewById(R.id.btnAdd);
btnAdd.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(frmVendaItens.this, frmManutencaoVendaItens.class);
intent.putExtra("Operacao", "I");
intent.putExtra("Venda", iVenda);
startActivity(intent);
}
});
}
项目:CXJPadProject
文件:CombinationActivity.java
public void initSkuDetailBRAdapter() {
skuDetailBRAdapter = new BRAdapter<CombinateQuoteInfo.SKUDetail>(this, R.layout.item_combination_product, combiSkuList) {
@Override
protected void convert(RvHolder holder, CombinateQuoteInfo.SKUDetail skuDetail, int position) {
holder.setText(R.id.tv_proCtgName, skuDetail.getSkuCtgName());
holder.setText(R.id.tv_proNo, skuDetail.getSkuNo());
holder.setText(R.id.tv_proName, skuDetail.getSkuName());
holder.setText(R.id.tv_proPrice, skuDetail.getStdPrice());
holder.setText(R.id.tv_proQuantity, skuDetail.getSkuQuantity());
}
};
yrvCombPro.setLayoutManager(new LinearLayoutManager(this));
yrvCombPro.setAdapter(skuDetailBRAdapter);
}
项目:Tribe
文件:LifeFragment.java
private void initRecyclerView() {
mData = new ArrayList<>();
mAdapter = new LifeAdapter(getContext(),mData,getActivity());
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getContext(),LinearLayoutManager.VERTICAL,false);
mLifeRecyclerView.setLayoutManager(layoutManager);
mLifeRecyclerView.setAdapter(mAdapter);
}
项目:GitHub
文件:FastAdapterDialog.java
/**
* Start the dialog and display it on screen. The window is placed in the
* application layer and opaque. Note that you should not override this
* method to do initialization when the dialog is shown, instead implement
* that in {@link #onStart}.
*/
public void show() {
if (mRecyclerView.getLayoutManager() == null) {
mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
if (mFastItemAdapter == null && mRecyclerView.getAdapter() == null) {
mFastItemAdapter = new FastItemAdapter<>();
mRecyclerView.setAdapter(mFastItemAdapter);
}
super.show();
}
项目:Pigeon
文件:ToolsFragment.java
@Override
public void initData() {
query = new BmobQuery<>();
boolean isCache = query.hasCachedResult(Tools.class);
if(isCache){
query.setCachePolicy(BmobQuery.CachePolicy.CACHE_ELSE_NETWORK); // 如果有缓存的话,则设置策略为CACHE_ELSE_NETWORK
}else{
query.setCachePolicy(BmobQuery.CachePolicy.NETWORK_ELSE_CACHE); // 如果没有缓存的话,则设置策略为NETWORK_ELSE_CACHE
}
query.setMaxCacheAge(TimeUnit.DAYS.toMillis(3));//此表示缓存一天
query.setLimit(10);
query.findObjects(new FindListener<Tools>() {
@Override
public void done(List<Tools> list, BmobException e) {
if (e == null) {
if (list.size() != 0) {
toolsAdapter = new ToolsAdapter(getContext(), list);
mRvTools.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
mRvTools.setAdapter(toolsAdapter);
}
}
}
});
}
项目:Nearby
文件:AllInOneInquiryVitalListCustomAdapter.java
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
if (!loading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
// End has been reached
// Do something
loading = true;
if (onLoadMoreListener != null) {
onLoadMoreListener.onLoadMore();
}
}
// 여기까지 무한 스크롤
if (scrolledDistance > HIDE_THRESHOLD && controlsVisible) {
onHide();
controlsVisible = false;
scrolledDistance = 0;
} else if (scrolledDistance < -HIDE_THRESHOLD && !controlsVisible) {
onShow();
controlsVisible = true;
scrolledDistance = 0;
}
if((controlsVisible && dy>0) || (!controlsVisible && dy<0)) {
scrolledDistance += dy;
}
// 여기까지 툴바 숨기기
}