use of android.support.v4.widget.NestedScrollView in project GeekNews by codeestX.
the class ZhihuDetailActivity method initEventAndData.
@Override
protected void initEventAndData() {
super.initEventAndData();
setToolBar(viewToolbar, "");
Intent intent = getIntent();
id = intent.getExtras().getInt(Constants.IT_ZHIHU_DETAIL_ID);
isNotTransition = intent.getBooleanExtra("isNotTransition", false);
mPresenter.queryLikeData(id);
mPresenter.getDetailData(id);
mPresenter.getExtraData(id);
stateLoading();
WebSettings settings = wvDetailContent.getSettings();
if (mPresenter.getNoImageState()) {
settings.setBlockNetworkImage(true);
}
if (mPresenter.getAutoCacheState()) {
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
if (SystemUtil.isNetworkConnected()) {
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
} else {
settings.setCacheMode(WebSettings.LOAD_CACHE_ONLY);
}
}
settings.setJavaScriptEnabled(true);
settings.setLoadWithOverviewMode(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setSupportZoom(true);
wvDetailContent.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
nsvScroller.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
if (scrollY - oldScrollY > 0 && isBottomShow) {
// 下移隐藏
isBottomShow = false;
llDetailBottom.animate().translationY(llDetailBottom.getHeight());
} else if (scrollY - oldScrollY < 0 && !isBottomShow) {
// 上移出现
isBottomShow = true;
llDetailBottom.animate().translationY(0);
}
}
});
(getWindow().getSharedElementEnterTransition()).addListener(new Transition.TransitionListener() {
@Override
public void onTransitionStart(Transition transition) {
}
@Override
public void onTransitionEnd(Transition transition) {
/**
* 测试发现部分手机(如红米note2)上加载图片会变形,没有达到centerCrop效果
* 查阅资料发现Glide配合SharedElementTransition是有坑的,需要在Transition动画结束后再加载图片
* https://github.com/TWiStErRob/glide-support/blob/master/src/glide3/java/com/bumptech/glide/supportapp/github/_847_shared_transition/DetailFragment.java
*/
isTransitionEnd = true;
if (imgUrl != null) {
isImageShow = true;
ImageLoader.load(mContext, imgUrl, detailBarImage);
}
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
});
}
use of android.support.v4.widget.NestedScrollView in project bdcodehelper by boredream.
the class FlingBehavior method onNestedFling.
@Override
public boolean onNestedFling(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, float velocityX, float velocityY, boolean consumed) {
if (target instanceof RecyclerView && velocityY < 0) {
final RecyclerView recyclerView = (RecyclerView) target;
final View firstChild = recyclerView.getChildAt(0);
final int childAdapterPosition = recyclerView.getChildAdapterPosition(firstChild);
consumed = childAdapterPosition > TOP_CHILD_FLING_THRESHOLD;
}
// prevent fling flickering when going up
if (target instanceof NestedScrollView && velocityY > 0) {
consumed = true;
}
if (Math.abs(velocityY) < OPTIMAL_FLING_VELOCITY) {
velocityY = OPTIMAL_FLING_VELOCITY * (velocityY < 0 ? -1 : 1);
}
return super.onNestedFling(coordinatorLayout, child, target, velocityX, velocityY, consumed);
}
use of android.support.v4.widget.NestedScrollView in project smoke by textbrowser.
the class FireChannel method scrollMessagesView.
private void scrollMessagesView() {
if (m_view == null)
return;
final NestedScrollView nestedScrollView = (NestedScrollView) m_view.findViewById(R.id.chat_scrollview);
nestedScrollView.post(new Runnable() {
@Override
public void run() {
nestedScrollView.fullScroll(NestedScrollView.FOCUS_DOWN);
}
});
final TextView textView1 = (TextView) m_view.findViewById(R.id.chat_message);
textView1.post(new Runnable() {
@Override
public void run() {
textView1.requestFocus();
}
});
}
Aggregations