use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IMeasurablePagerTitleView in project MagicIndicator by hackware1993.
the class CommonNavigator method preparePositionData.
/**
* 获取title的位置信息,为打造不同的指示器、各种效果提供可能
*/
private void preparePositionData() {
mPositionDataList.clear();
for (int i = 0, j = mNavigatorHelper.getTotalCount(); i < j; i++) {
PositionData data = new PositionData();
View v = mTitleContainer.getChildAt(i);
if (v != null) {
data.mLeft = v.getLeft();
data.mTop = v.getTop();
data.mRight = v.getRight();
data.mBottom = v.getBottom();
if (v instanceof IMeasurablePagerTitleView) {
IMeasurablePagerTitleView view = (IMeasurablePagerTitleView) v;
data.mContentLeft = view.getContentLeft();
data.mContentTop = view.getContentTop();
data.mContentRight = view.getContentRight();
data.mContentBottom = view.getContentBottom();
} else {
data.mContentLeft = data.mLeft;
data.mContentTop = data.mTop;
data.mContentRight = data.mRight;
data.mContentBottom = data.mBottom;
}
}
mPositionDataList.add(data);
}
}
use of net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IMeasurablePagerTitleView in project MagicIndicator by hackware1993.
the class BadgePagerTitleView method onLayout.
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mInnerPagerTitleView instanceof View && mBadgeView != null) {
// 14种角标定位方式
int[] position = new int[14];
View v = (View) mInnerPagerTitleView;
position[0] = v.getLeft();
position[1] = v.getTop();
position[2] = v.getRight();
position[3] = v.getBottom();
if (mInnerPagerTitleView instanceof IMeasurablePagerTitleView) {
IMeasurablePagerTitleView view = (IMeasurablePagerTitleView) mInnerPagerTitleView;
position[4] = view.getContentLeft();
position[5] = view.getContentTop();
position[6] = view.getContentRight();
position[7] = view.getContentBottom();
} else {
for (int i = 4; i < 8; i++) {
position[i] = position[i - 4];
}
}
position[8] = v.getWidth() / 2;
position[9] = v.getHeight() / 2;
position[10] = position[4] / 2;
position[11] = position[5] / 2;
position[12] = position[6] + (position[2] - position[6]) / 2;
position[13] = position[7] + (position[3] - position[7]) / 2;
// 根据设置的BadgeRule调整角标的位置
if (mXBadgeRule != null) {
int x = position[mXBadgeRule.getAnchor().ordinal()];
int offset = mXBadgeRule.getOffset();
int newLeft = x + offset;
mBadgeView.offsetLeftAndRight(newLeft - mBadgeView.getLeft());
}
if (mYBadgeRule != null) {
int y = position[mYBadgeRule.getAnchor().ordinal()];
int offset = mYBadgeRule.getOffset();
int newTop = y + offset;
mBadgeView.offsetTopAndBottom(newTop - mBadgeView.getTop());
}
}
}
Aggregations