use of com.scwang.smartrefresh.internal.ProgressDrawable in project CollapsingRefresh by ckrgithub.
the class ClassicsHeader method initView.
private void initView(Context context, AttributeSet attrs) {
DensityUtil density = new DensityUtil();
setMinimumHeight(density.dip2px(80));
LinearLayout layout = new LinearLayout(context);
layout.setId(android.R.id.widget_frame);
layout.setGravity(Gravity.CENTER_HORIZONTAL);
layout.setOrientation(LinearLayout.VERTICAL);
mHeaderText = new TextView(context);
mHeaderText.setText(REFRESH_HEADER_PULLDOWN);
mHeaderText.setTextColor(0xff666666);
mHeaderText.setTextSize(16);
mLastUpdateText = new TextView(context);
mLastUpdateText.setTextColor(0xff7c7c7c);
mLastUpdateText.setTextSize(12);
LinearLayout.LayoutParams lpHeaderText = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
layout.addView(mHeaderText, lpHeaderText);
LinearLayout.LayoutParams lpUpdateText = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
layout.addView(mLastUpdateText, lpUpdateText);
LayoutParams lpHeaderLayout = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
lpHeaderLayout.addRule(CENTER_IN_PARENT);
addView(layout, lpHeaderLayout);
mProgressView = new ImageView(context);
mProgressView.animate().setInterpolator(new LinearInterpolator());
LayoutParams lpProgress = new LayoutParams(density.dip2px(20), density.dip2px(20));
lpProgress.rightMargin = density.dip2px(20);
lpProgress.addRule(CENTER_VERTICAL);
lpProgress.addRule(LEFT_OF, android.R.id.widget_frame);
addView(mProgressView, lpProgress);
mArrowView = new ImageView(context);
addView(mArrowView, lpProgress);
if (isInEditMode()) {
mArrowView.setVisibility(GONE);
mHeaderText.setText(REFRESH_HEADER_REFRESHING);
} else {
mProgressView.setVisibility(GONE);
}
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ClassicsHeader);
mSpinnerStyle = SpinnerStyle.values()[ta.getInt(R.styleable.ClassicsHeader_srlClassicsSpinnerStyle, mSpinnerStyle.ordinal())];
if (ta.hasValue(R.styleable.ClassicsHeader_srlArrowDrawable)) {
mArrowView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsHeader_srlArrowDrawable));
} else {
mArrowDrawable = new PathsDrawable();
mArrowDrawable.parserColors(0xff666666);
mArrowDrawable.parserPaths("M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z");
mArrowView.setImageDrawable(mArrowDrawable);
}
if (ta.hasValue(R.styleable.ClassicsHeader_srlProgressDrawable)) {
mProgressView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsHeader_srlProgressDrawable));
} else {
mProgressDrawable = new ProgressDrawable();
mProgressDrawable.setColor(0xff666666);
mProgressView.setImageDrawable(mProgressDrawable);
}
int primaryColor = ta.getColor(R.styleable.ClassicsHeader_srlPrimaryColor, 0);
int accentColor = ta.getColor(R.styleable.ClassicsHeader_srlAccentColor, 0);
if (primaryColor != 0) {
if (accentColor != 0) {
setPrimaryColors(primaryColor, accentColor);
} else {
setPrimaryColors(primaryColor);
}
} else if (accentColor != 0) {
setPrimaryColors(0, accentColor);
}
ta.recycle();
try {
// try 不能删除-否则会出现兼容性问题
if (context instanceof FragmentActivity) {
FragmentManager manager = ((FragmentActivity) context).getSupportFragmentManager();
if (manager != null) {
List<Fragment> fragments = manager.getFragments();
if (fragments != null && fragments.size() > 0) {
setLastUpdateTime(new Date());
return;
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
KEY_LAST_UPDATE_TIME += context.getClass().getName();
mShared = context.getSharedPreferences("ClassicsHeader", Context.MODE_PRIVATE);
setLastUpdateTime(new Date(mShared.getLong(KEY_LAST_UPDATE_TIME, System.currentTimeMillis())));
}
use of com.scwang.smartrefresh.internal.ProgressDrawable in project CollapsingRefresh by ckrgithub.
the class ClassicsFooter method initView.
private void initView(Context context, AttributeSet attrs, int defStyleAttr) {
DensityUtil density = new DensityUtil();
setMinimumHeight(density.dip2px(60));
mBottomText = new TextView(context);
mBottomText.setId(android.R.id.widget_frame);
mBottomText.setTextColor(0xff666666);
mBottomText.setTextSize(16);
mBottomText.setText(REFRESH_FOOTER_PULLUP);
LayoutParams lpBottomText = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
lpBottomText.addRule(CENTER_IN_PARENT);
addView(mBottomText, lpBottomText);
mProgressView = new ImageView(context);
mProgressView.animate().setInterpolator(new LinearInterpolator());
LayoutParams lpPathView = new LayoutParams(density.dip2px(18), density.dip2px(18));
lpPathView.rightMargin = density.dip2px(20);
lpPathView.addRule(CENTER_VERTICAL);
lpPathView.addRule(LEFT_OF, android.R.id.widget_frame);
addView(mProgressView, lpPathView);
mArrowView = new ImageView(context);
addView(mArrowView, lpPathView);
if (!isInEditMode()) {
mProgressView.setVisibility(GONE);
} else {
mArrowView.setVisibility(GONE);
}
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ClassicsFooter);
mSpinnerStyle = SpinnerStyle.values()[ta.getInt(R.styleable.ClassicsFooter_srlClassicsSpinnerStyle, mSpinnerStyle.ordinal())];
if (ta.hasValue(R.styleable.ClassicsFooter_srlArrowDrawable)) {
mArrowView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsFooter_srlArrowDrawable));
} else {
mArrowDrawable = new PathsDrawable();
mArrowDrawable.parserColors(0xff666666);
mArrowDrawable.parserPaths("M20,12l-1.41,-1.41L13,16.17V4h-2v12.17l-5.58,-5.59L4,12l8,8 8,-8z");
mArrowView.setImageDrawable(mArrowDrawable);
}
if (ta.hasValue(R.styleable.ClassicsFooter_srlProgressDrawable)) {
mProgressView.setImageDrawable(ta.getDrawable(R.styleable.ClassicsFooter_srlProgressDrawable));
} else {
mProgressDrawable = new ProgressDrawable();
mProgressDrawable.setColor(0xff666666);
mProgressView.setImageDrawable(mProgressDrawable);
}
if (ta.hasValue(R.styleable.ClassicsFooter_srlPrimaryColor)) {
setPrimaryColor(ta.getColor(R.styleable.ClassicsFooter_srlPrimaryColor, 0));
}
if (ta.hasValue(R.styleable.ClassicsFooter_srlAccentColor)) {
setAccentColor(ta.getColor(R.styleable.ClassicsFooter_srlAccentColor, 0));
}
ta.recycle();
}
Aggregations