This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void blur(final Context context, final float radius, final BitmapBlurCallback callback) { | |
mBlurTask = new AsyncTask< Integer, Void, Bitmap >() { | |
@Override | |
protected Bitmap doInBackground(Integer... params) { | |
if (sRS == null) { | |
sRS = RenderScript.create(context); | |
} | |
Allocation srcAlloc = Allocation.createFromBitmap(sRS, mSrc); | |
Allocation dstAlloc = Allocation.createTyped(sRS, srcAlloc.getType()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void createCircularShader(Bitmap bm) { | |
// Shader must be based on Bitmap width/height because parent applies scale type. | |
float w = bm.getWidth(); | |
float h = bm.getHeight(); | |
float cx = 0.5f * w; | |
float cy = 0.5f * h; | |
int[] colors = { 0xffffffff, 0xffffffff, 0x00000000 }; | |
float[] positions = { 0.0f, 0.99f, 1.0f }; | |
RadialGradient gradient = new RadialGradient(cx, cy, 0.5f * Math.min(w, h), colors, positions, Shader.TileMode.CLAMP); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface TabHolderScrollingContent { | |
/** | |
* Adjust content scroll position based on sticky tab bar position. | |
*/ | |
void adjustScroll(int tabBarTop); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void adjustScroll(int tabBarTop) { | |
if (tabBarTop == 0 && mScrollView.getScrollY() > mTopImageHeight - mTabBarHeight) { | |
// ScrollView does not need to manually adjust scroll, as the top Tab bar is at its sticky position | |
return; | |
} | |
mScrollView.scrollTo(mScrollView.getScrollX(), -tabBarTop + mTopImageHeight - mTabBarHeight); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mainView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { | |
private int mLastViewHeight; | |
@Override | |
public void onGlobalLayout() { | |
int newHeight = mainView.getHeight(); | |
if (newHeight != mLastViewHeight) { | |
SparseArrayCompat< TabHolderScrollingContent > tabHolderScrollingContent = mViewPagerAdapter.getTabHolderScrollingContent(); | |
TabHolderScrollingContent content = tabHolderScrollingContent.valueAt(mViewPager.getCurrentItem()); | |
content.adjustScroll(mStickyTabBar.getTop()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void adjustScroll(int tabBarTop) { | |
if (tabBarTop == 0 && mListView.getFirstVisiblePosition() >= 1) { | |
// ListView does not need to adjust scroll, as the top tab bar is its sticky position | |
return; | |
} | |
mListView.setSelectionFromTop(1, tabBarTop); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { | |
@Override | |
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { | |
// Update content that just became visible | |
int currentItem = mViewPager.getCurrentItem(); | |
if (positionOffsetPixels > 0) { | |
SparseArrayCompat< TabHolderScrollingContent > tabHolderScrollingContent = mViewPagerAdapter.getTabHolderScrollingContent(); | |
TabHolderScrollingContent fragmentContent = null; |