本文整理汇总了Java中com.github.ksoichiro.android.observablescrollview.ObservableScrollView.getViewTreeObserver方法的典型用法代码示例。如果您正苦于以下问题:Java ObservableScrollView.getViewTreeObserver方法的具体用法?Java ObservableScrollView.getViewTreeObserver怎么用?Java ObservableScrollView.getViewTreeObserver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.ksoichiro.android.observablescrollview.ObservableScrollView
的用法示例。
在下文中一共展示了ObservableScrollView.getViewTreeObserver方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.observable_scroll_view_fragment_scrollview, container, false);
final ObservableScrollView scrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
Activity parentActivity = getActivity();
if (parentActivity instanceof ObservableScrollViewCallbacks) {
// Scroll to the specified offset after layout
Bundle args = getArguments();
if (args != null && args.containsKey(ARG_SCROLL_Y)) {
final int scrollY = args.getInt(ARG_SCROLL_Y, 0);
ViewTreeObserver vto = scrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
scrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
scrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
scrollView.scrollTo(0, scrollY);
}
});
}
scrollView.setScrollViewCallbacks((ObservableScrollViewCallbacks) parentActivity);
}
return view;
}
示例2: onCreate
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.observable_scroll_view_activity_flexiblespacewithimagescrollview);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mFlexibleSpaceShowFabOffset = getResources().getDimensionPixelSize(R.dimen.flexible_space_show_fab_offset);
mActionBarSize = getActionBarSize();
mToolbarColor = getResources().getColor(R.color.primary);
mToolbar = findViewById(R.id.toolbar);
if (!TOOLBAR_IS_STICKY) {
mToolbar.setBackgroundColor(Color.TRANSPARENT);
}
mImageView = findViewById(R.id.image);
mOverlayView = findViewById(R.id.overlay);
mScrollView = (ObservableScrollView) findViewById(R.id.scroll);
mScrollView.setScrollViewCallbacks(this);
mTitleView = (TextView) findViewById(R.id.title);
mTitleView.setText(getTitle());
setTitle(null);
mFab = findViewById(R.id.fab);
mFabMargin = getResources().getDimensionPixelSize(R.dimen.margin_standard);
ViewHelper.setScaleX(mFab, 0);
ViewHelper.setScaleY(mFab, 0);
ViewTreeObserver vto = mScrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
mScrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
mScrollView.scrollTo(0, mFlexibleSpaceImageHeight - mActionBarSize);
}
});
}
示例3: onCreateView
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_gcm_specific, container, false);
setRetainInstance(true);
final Integer id = getArguments().getInt("id", 1);
mActivity = ((MainActivity) getActivity());
mActivity.mToolbar.setVisibility(Toolbar.GONE);
mActivity.getDelegate().getSupportActionBar().hide();
frame = (FrameLayout) getActivity().findViewById(R.id.fragment_container);
originalParams = (FrameLayout.LayoutParams) frame.getLayoutParams();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
frame.setLayoutParams(params);
((MainActivity) getActivity()).setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar));
TextView tDisplay = (TextView) view.findViewById(R.id.tDisplay);
TextView dDisplay = (TextView) view.findViewById(R.id.dDisplay);
TextView mDisplay = (TextView) view.findViewById(R.id.mDisplay);
DatabaseHandler dbhandler = DatabaseHandler.getInstance(getActivity());
Notifications notifications = dbhandler.getNotification(id);
final String title = notifications.title;
final String date = notifications.date;
final String message = notifications.message;
mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mIntersectionHeight = getResources().getDimensionPixelSize(R.dimen.intersection_height);
mActionBarSize = getActionBarSize();
mImageHolder = view.findViewById(R.id.image_holder);
mHeader = view.findViewById(R.id.header);
mHeaderBar = view.findViewById(R.id.header_bar);
mHeaderBackground = view.findViewById(R.id.header_background);
mScrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
mScrollView.setScrollViewCallbacks(this);
mActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mActivity.mDrawerToggle.setDrawerIndicatorEnabled(false);
mActivity.getDelegate().getSupportActionBar().setHomeButtonEnabled(true);
mActivity.getDelegate().getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
mActivity.mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mActivity.getSupportFragmentManager().popBackStack();
mActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mActivity.getDelegate().getSupportActionBar().setDisplayHomeAsUpEnabled(false);
mActivity.getDelegate().getSupportActionBar().setDisplayShowTitleEnabled(true);
mActivity.mDrawerToggle.setDrawerIndicatorEnabled(true);
}
});
if (title == null) tDisplay.setVisibility(View.INVISIBLE);
else tDisplay.setText(title);
if (date == null) dDisplay.setVisibility(View.INVISIBLE);
else dDisplay.setText(date);
if (message != null) mDisplay.append(message + "\n");
dbhandler.updateNotifications(new Notifications(id, 1));
ViewTreeObserver vto = mScrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (CompatUtils.isNotLegacyJellyBean()) {
mScrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
onScrollChanged(0, false, false);
}
});
return view;
}
示例4: onCreateView
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_topical_specific, container, false);
setRetainInstance(true);
int topicalId = getArguments().getInt("id");
mActivity = ((MainActivity) getActivity());
mActivity.mToolbar.setVisibility(Toolbar.GONE);
mActivity.getDelegate().getSupportActionBar().hide();
frame = (FrameLayout) getActivity().findViewById(R.id.fragment_container);
originalParams = (FrameLayout.LayoutParams) frame.getLayoutParams();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
frame.setLayoutParams(params);
((MainActivity) getActivity()).setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar));
TextView titleTextView = (TextView) view.findViewById(R.id.titleArticleTopical);
TextView storyTextView = (TextView) view.findViewById(R.id.storyArticleTopical);
DatabaseHandler dbhandler = DatabaseHandler.getInstance(getActivity());
Topical articleTopical = dbhandler.getTopical(topicalId);
String articleTitle = articleTopical.title;
String articleStory = articleTopical.story;
Spanned htmlSpan;
mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mIntersectionHeight = getResources().getDimensionPixelSize(R.dimen.intersection_height);
mActionBarSize = getActionBarSize();
mImageHolder = view.findViewById(R.id.image_holder);
mHeader = view.findViewById(R.id.header);
mHeaderBar = view.findViewById(R.id.header_bar);
mHeaderBackground = view.findViewById(R.id.header_background);
mScrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
mScrollView.setScrollViewCallbacks(this);
mActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mActivity.mDrawerToggle.setDrawerIndicatorEnabled(false);
mActivity.getDelegate().getSupportActionBar().setHomeButtonEnabled(true);
mActivity.getDelegate().getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
mActivity.mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mActivity.getSupportFragmentManager().popBackStack();
mActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mActivity.getDelegate().getSupportActionBar().setDisplayHomeAsUpEnabled(false);
mActivity.getDelegate().getSupportActionBar().setDisplayShowTitleEnabled(true);
mActivity.mDrawerToggle.setDrawerIndicatorEnabled(true);
}
});
titleTextView.setText(articleTitle);
htmlSpan = Html.fromHtml(articleStory);
storyTextView.setText(htmlSpan);
storyTextView.setMovementMethod(LinkMovementMethod.getInstance());
ViewTreeObserver vto = mScrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (CompatUtils.isNotLegacyJellyBean()) {
mScrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
onScrollChanged(0, false, false);
}
});
return view;
}
示例5: onCreateView
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_news_specific, container, false);
setRetainInstance(true);
int newsId = getArguments().getInt("id");
mActivity = ((MainActivity) getActivity());
mActivity.mToolbar.setVisibility(Toolbar.GONE);
mActivity.getDelegate().getSupportActionBar().hide();
frame = (FrameLayout) getActivity().findViewById(R.id.fragment_container);
originalParams = (FrameLayout.LayoutParams) frame.getLayoutParams();
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
frame.setLayoutParams(params);
((MainActivity) getActivity()).setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar));
TextView titleTextView = (TextView) view.findViewById(R.id.titleArticleNews);
storyImageView = (ImageView) view.findViewById(R.id.storyNewsImage);
TextView storyTextView = (TextView) view.findViewById(R.id.storyArticleNews);
DatabaseHandler dbhandler = DatabaseHandler.getInstance(getActivity());
News articleNews = dbhandler.getNews(newsId);
String articleTitle = articleNews.title;
String articleStory = articleNews.story;
String imageUrl = articleNews.imageSrc;
Spanned htmlSpan;
mFlexibleSpaceImageHeight = getResources().getDimensionPixelSize(R.dimen.flexible_space_image_height);
mIntersectionHeight = getResources().getDimensionPixelSize(R.dimen.intersection_height);
mActionBarSize = getActionBarSize();
mImageHolder = view.findViewById(R.id.image_holder);
mHeader = view.findViewById(R.id.header);
mHeaderBar = view.findViewById(R.id.header_bar);
mHeaderBackground = view.findViewById(R.id.header_background);
mScrollView = (ObservableScrollView) view.findViewById(R.id.scroll);
mScrollView.setScrollViewCallbacks(this);
mActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mActivity.mDrawerToggle.setDrawerIndicatorEnabled(false);
mActivity.getDelegate().getSupportActionBar().setHomeButtonEnabled(true);
mActivity.getDelegate().getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);
mActivity.mDrawerToggle.setToolbarNavigationClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mActivity.getSupportFragmentManager().popBackStack();
mActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
mActivity.getDelegate().getSupportActionBar().setDisplayHomeAsUpEnabled(false);
mActivity.getDelegate().getSupportActionBar().setDisplayShowTitleEnabled(true);
mActivity.mDrawerToggle.setDrawerIndicatorEnabled(true);
}
});
titleTextView.setText(articleTitle);
htmlSpan = Html.fromHtml(articleStory);
storyTextView.setText(htmlSpan);
storyTextView.setMovementMethod(LinkMovementMethod.getInstance());
Picasso.with(getActivity()).load(imageUrl)
.transform(PaletteTransformation.instance())
.into(storyImageView, new Callback.EmptyCallback() {
@Override
public void onSuccess() {
Bitmap bitmap = ((BitmapDrawable) storyImageView.getDrawable()).getBitmap();
Palette palette = PaletteTransformation.getPalette(bitmap);
Palette.Swatch vibrantSwatch = palette.getDarkVibrantSwatch();
if (vibrantSwatch != null) {
mHeaderBackground.setBackgroundColor(vibrantSwatch.getRgb());
if (CompatUtils.isNotLegacyLollipop()) {
Window w = getActivity().getWindow();
int statusBarColor = UIUtils.scaleColor(vibrantSwatch.getRgb(), 0.8f, false);
w.setStatusBarColor(statusBarColor);
}
}
}
});
ViewTreeObserver vto = mScrollView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (CompatUtils.isNotLegacyJellyBean()) {
mScrollView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
} else {
mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
}
onScrollChanged(0, false, false);
}
});
return view;
}