use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project UltimateAndroid by cymcsg.
the class ScrollFromBottomRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.observable_scroll_view_activity_toolbarcontrolrecyclerview);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
mHeaderView = findViewById(R.id.header);
ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation));
mToolbarView = findViewById(R.id.toolbar);
mRecyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
mRecyclerView.setScrollViewCallbacks(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(false);
ArrayList<String> items = new ArrayList<String>();
for (int i = 1; i <= 100; i++) {
items.add("Item " + i);
}
View headerView = LayoutInflater.from(this).inflate(R.layout.observable_scroll_view_recycler_header, null);
mRecyclerView.setAdapter(new SimpleHeaderRecyclerAdapter(this, items, headerView));
ViewTreeObserver vto = mRecyclerView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
mRecyclerView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mRecyclerView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
int count = mRecyclerView.getAdapter().getItemCount() - 1;
int position = count == 0 ? 1 : count > 0 ? count : 0;
mRecyclerView.scrollToPosition(position);
}
});
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project UltimateAndroid by cymcsg.
the class ToolbarControlRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.observable_scroll_view_activity_toolbarcontrolrecyclerview);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
mHeaderView = findViewById(R.id.header);
ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation));
mToolbarView = findViewById(R.id.toolbar);
mRecyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
mRecyclerView.setScrollViewCallbacks(this);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.setHasFixedSize(false);
ArrayList<String> items = new ArrayList<String>();
for (int i = 1; i <= 100; i++) {
items.add("Item " + i);
}
View headerView = LayoutInflater.from(this).inflate(R.layout.observable_scroll_view_recycler_header, null);
mRecyclerView.setAdapter(new SimpleHeaderRecyclerAdapter(this, items, headerView));
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project UltimateAndroid by cymcsg.
the class ActionBarControlRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.observable_scroll_view_activity_actionbarcontrolrecyclerview);
ObservableRecyclerView recyclerView = (ObservableRecyclerView) findViewById(R.id.recycler);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
recyclerView.setScrollViewCallbacks(this);
ArrayList<String> items = new ArrayList<String>();
for (int i = 1; i <= 100; i++) {
items.add("Item " + i);
}
recyclerView.setAdapter(new SimpleRecyclerAdapter(this, items));
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project remusic by aa112901.
the class ArtistInfoMusicFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_recyclerview, container, false);
if (getArguments() != null) {
mList = getArguments().getParcelableArrayList("list");
}
Activity parentActivity = getActivity();
recyclerView = (ObservableRecyclerView) view.findViewById(R.id.scroll);
recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
recyclerView.setHasFixedSize(true);
mAdapter = new PlaylistDetailAdapter(getActivity(), mList);
recyclerView.setAdapter(mAdapter);
if (parentActivity instanceof ObservableScrollViewCallbacks) {
// Scroll to the specified offset after layout
Bundle args = getArguments();
if (args != null && args.containsKey(ARG_INITIAL_POSITION)) {
final int initialPosition = args.getInt(ARG_INITIAL_POSITION, 0);
ScrollUtils.addOnGlobalLayoutListener(recyclerView, new Runnable() {
@Override
public void run() {
// recyclerView.scrollVerticallyToPosition(0);
}
});
}
// TouchInterceptionViewGroup should be a parent view other than ViewPager.
// This is a workaround for the issue #117:
// https://github.com/ksoichiro/Android-ObservableScrollView/issues/117
recyclerView.setTouchInterceptionViewGroup((ViewGroup) parentActivity.findViewById(R.id.root));
recyclerView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
}
return view;
}
use of com.github.ksoichiro.android.observablescrollview.ObservableRecyclerView in project Android-ObservableScrollView by ksoichiro.
the class HandleTouchRecyclerViewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_handletouchrecyclerview);
ObservableRecyclerView recyclerView = (ObservableRecyclerView) findViewById(R.id.scroll);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
recyclerView.setScrollViewCallbacks(this);
recyclerView.setAdapter(new CustomAdapter(this, getDummyData()));
}
Aggregations