下面列出了android.widget.ProgressBar#setIndeterminateDrawable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress);
PathProgressDrawable pathProgressDrawable = new PathProgressDrawable();
pathProgressDrawable.setAnimatedPoints(10);
progressBar.setIndeterminateDrawable(pathProgressDrawable);
progressBar.setIndeterminate(true);
RectProgressDrawable drawable = new RectProgressDrawable();
drawable.setPoints(7);
ProgressBar progressBar2 = (ProgressBar) findViewById(R.id.progress2);
progressBar2.setIndeterminateDrawable(drawable);
progressBar2.setIndeterminate(true);
CircleProgressDrawable drawableCircle = new CircleProgressDrawable();
drawableCircle.setPoints(6);
drawableCircle.setAnimatedPoints(20);
ProgressBar progressBar3 = (ProgressBar) findViewById(R.id.progress3);
progressBar3.setIndeterminateDrawable(drawableCircle);
progressBar3.setIndeterminate(true);
}
protected BuildBean buildMdLoadingHorizontal(BuildBean bean) {
AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress_light));
tvMsg.setTextColor(Color.WHITE);
}
builder.setView(root);
AlertDialog dialog = builder.create();
bean.alertDialog = dialog;
return bean;
}
protected BuildBean buildLoadingVertical(BuildBean bean) {
Dialog dialog = new Dialog(bean.mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
bean.dialog = dialog;
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_vertical, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_rotate_mum_light));
tvMsg.setTextColor(Color.WHITE);
}
bean.dialog.setContentView(root);
return bean;
}
protected BuildBean buildLoadingHorizontal(BuildBean bean) {
Dialog dialog = new Dialog(bean.mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
bean.dialog = dialog;
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress_light));
tvMsg.setTextColor(Color.WHITE);
}
bean.dialog.setContentView(root);
return bean;
}
protected BuildBean buildMdLoadingHorizontal(BuildBean bean) {
AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress_light));
tvMsg.setTextColor(Color.WHITE);
}
builder.setView(root);
AlertDialog dialog = builder.create();
bean.alertDialog = dialog;
return bean;
}
private void initUI(Context context)
{
inflate(context, R.layout.layout_ptrview_def_view, this);
setWillNotDraw(false);
mAnimRotateDown = AnimationUtils.loadAnimation(context, R.anim.arrow_rotate_down);
mAnimRotateUp = AnimationUtils.loadAnimation(context, R.anim.arrow_rotate_up);
mTvStatus = (TextView) findViewById(R.id.tv_ptrview_def_view_status);
mImgStatus = (ImageView) findViewById(R.id.img_ptrview_def_view_status);
mPgbLoading = (ProgressBar) findViewById(R.id.pgb_ptrview_def_view_loading);
mImgArrow = (ImageView) findViewById(R.id.img_ptrview_def_view_arrow);
mTvStatus.setTextColor(mTvColor);
mPgbLoading.setIndeterminateDrawable(getResources().getDrawable(mPgbDrawable));
}
protected BuildBean buildLoadingHorizontal(BuildBean bean) {
Dialog dialog = new Dialog(bean.mContext);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
bean.dialog = dialog;
View root = View.inflate(bean.mContext, R.layout.dialogui_loading_horizontal, null);
View llBg = (View) root.findViewById(R.id.dialogui_ll_bg);
ProgressBar pbBg = (ProgressBar) root.findViewById(R.id.pb_bg);
TextView tvMsg = (TextView) root.findViewById(R.id.dialogui_tv_msg);
tvMsg.setText(bean.msg);
if (bean.isWhiteBg) {
llBg.setBackgroundResource(R.drawable.dialogui_shape_wihte_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress));
tvMsg.setTextColor(bean.mContext.getResources().getColor(R.color.text_black));
} else {
llBg.setBackgroundResource(R.drawable.dialogui_shape_gray_round_corner);
pbBg.setIndeterminateDrawable(bean.mContext.getResources().getDrawable(R.drawable.dialogui_shape_progress_light));
tvMsg.setTextColor(Color.WHITE);
}
bean.dialog.setContentView(root);
return bean;
}
public PRTHeader(Context context) {
super(context);
int[] size = R.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.d(TAG, "onCreate() start");
super.onCreate(savedInstanceState);
setContentView(R.layout.files_folder_picker);
if (savedInstanceState == null) {
createFragments();
}
fpToolbar = (Toolbar) findViewById(R.id.toolbar);
if (fpToolbar != null)
{
setSupportActionBar(fpToolbar);
}
// sets callback listeners for UI elements
initControls();
// Action bar setup
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mProgressBar.setIndeterminateDrawable(
getResources().getDrawable(
R.drawable.actionbar_progress_indeterminate_horizontal));
mProgressBar.setIndeterminate(mSyncInProgress);
// always AFTER setContentView(...) ; to work around bug in its implementation
// sets message for empty list of folders
setBackgroundText();
Log_OC.d(TAG, "onCreate() end");
}
public PRTHeader(Context context) {
super(context);
int[] size = ResHelper.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
public PRTHeader(Context context) {
super(context);
int[] size = ResHelper.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
public PRTHeader(Context context) {
super(context);
int[] size = R.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
public PRTHeader(Context context) {
super(context);
int[] size = R.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
public PRTHeader(Context context) {
super(context);
int[] size = ResHelper.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = ResHelper.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = ResHelper.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
public PRTHeader(Context context) {
super(context);
int[] size = R.getScreenSize(context);
float screenWidth = size[0] < size[1] ? size[0] : size[1];
float ratio = screenWidth / DESIGN_SCREEN_WIDTH;
setOrientation(VERTICAL);
LinearLayout llInner = new LinearLayout(context);
LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_HORIZONTAL;
addView(llInner, lp);
ivArrow = new RotateImageView(context);
int resId = R.getBitmapRes(context, "ssdk_oks_ptr_ptr");
if (resId > 0) {
ivArrow.setImageResource(resId);
}
int avatarWidth = (int) (ratio * DESIGN_AVATAR_WIDTH);
lp = new LayoutParams(avatarWidth, avatarWidth);
lp.gravity = Gravity.CENTER_VERTICAL;
int avataPadding = (int) (ratio * DESIGN_AVATAR_PADDING);
lp.topMargin = lp.bottomMargin = avataPadding;
llInner.addView(ivArrow, lp);
pbRefreshing = new ProgressBar(context);
resId = R.getBitmapRes(context, "ssdk_oks_classic_progressbar");
Drawable pbdrawable = context.getResources().getDrawable(resId);
pbRefreshing.setIndeterminateDrawable(pbdrawable);
llInner.addView(pbRefreshing, lp);
pbRefreshing.setVisibility(View.GONE);
tvHeader = new TextView(getContext());
tvHeader.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
tvHeader.setPadding(avataPadding, 0, avataPadding, 0);
tvHeader.setTextColor(0xff09bb07);
lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
lp.gravity = Gravity.CENTER_VERTICAL;
llInner.addView(tvHeader, lp);
}
@Override
public View createProgressView() {
mProgressBar = new ProgressBar(mContext);
mProgressBar.setLayoutParams(new ViewGroup.LayoutParams(mLoadingSize, mLoadingSize));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
&& mIndeterminateDrawable == null) {
mProgressBar.setIndeterminateTintList(ColorStateList.valueOf(mLoadingColor));
}
if (mIndeterminateDrawable != null) {
mProgressBar.setIndeterminateDrawable(mIndeterminateDrawable);
}
return mProgressBar;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
Log_OC.v(TAG, "onCreate() start");
super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account
// is valid
/// grant that FileObserverService is watching favorite files
if (savedInstanceState == null) {
Intent initObserversIntent = FileObserverService.makeInitIntent(this);
startService(initObserversIntent);
}
/// Load of saved instance state
if (savedInstanceState != null) {
mWaitingToPreview = savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_PREVIEW);
mSyncInProgress = savedInstanceState.getBoolean(KEY_SYNC_IN_PROGRESS);
mWaitingToSend = savedInstanceState.getParcelable(FileDisplayActivity.KEY_WAITING_TO_SEND);
} else {
mWaitingToPreview = null;
mSyncInProgress = false;
mWaitingToSend = null;
}
// Shared application prefrences
mAppPreferences = PreferenceManager.getDefaultSharedPreferences(this);
// Layout View
// Set layout icon if not alrady set
if (mAppPreferences.getInt("layoutMode", 0) == 0) {
SharedPreferences.Editor editor = mAppPreferences.edit();
editor.putInt("layoutMode", R.drawable.ic_list);
editor.apply();
}
/// USER INTERFACE
// Inflate and set the layout view
setContentView(R.layout.files);
// Toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {
// set toolbar and navigation drawer
setSupportActionBar(toolbar);
}
// Navigation Drawer
initDrawer();
mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mProgressBar.setIndeterminateDrawable(
ContextCompat.getDrawable(this,
R.drawable.actionbar_progress_indeterminate_horizontal));
mDualPane = getResources().getBoolean(R.bool.large_land_layout);
mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
mRightFragmentContainer = findViewById(R.id.right_fragment_container);
if (savedInstanceState == null) {
createMinFragments();
}
// Action bar setup
if (getSupportActionBar() != null) {
getSupportActionBar().setHomeButtonEnabled(true); // mandatory since Android ICS,
}
mProgressBar.setIndeterminate(mSyncInProgress);
// always AFTER setContentView(...) ; to work around bug in its implementation
setBackgroundText();
Log_OC.v(TAG, "onCreate() end");
}
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent)
{
convertView = mViews[position];
if(convertView == null){
AnimatedScaleDrawable drawable = new AnimatedScaleDrawable(
parent.getContext().getResources().getDrawable(R.drawable.heart));
drawable.setInterpolator(new BounceInterpolator());
drawable.setInvertTransformation(true);
drawable.setDuration(500);
FrameLayout frame = (FrameLayout)LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_frame, parent, false);
if(position == 0){
// ProgressBar example
ProgressBar progress = (ProgressBar)LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_progress, frame, false);
progress.setIndeterminateDrawable(drawable);
frame.addView(progress);
}
else{
if(position == 1 || position == 2){
// Background drawable example
frame.setBackgroundDrawable(drawable);
if(position == 2){
drawable.setUseBounds(false);
}
}else{
// Foreground's with Gravity example
frame.setForeground(drawable);
frame.setForegroundGravity(mGravity[position - 3]);
}
// no need to call drawable.start() for ProgressBar widgets
drawable.start();
}
TextView textView = (TextView)frame.findViewById(R.id.text);
textView.setText(String.format("#%02d %s", position, mNames[position]));
convertView = frame;
}
return convertView;
}
private static void copyFile(final Activity activity,File srcFile, final File exportFile) {
View view = LayoutInflater.from(activity).inflate(R.layout.dialog_progress, null);
ProgressBar progressBar = (ProgressBar) view.findViewById(android.R.id.progress);
TextView textView = (TextView) view.findViewById(R.id.content);
//改变Progress的背景为MaterialDesigner规范的样式
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
progressBar.setIndeterminateDrawable(new CircularProgressDrawable(Utils.getColorWarp(activity, R.color.colorAccent), activity.getResources().getDimension(R.dimen.loading_border_width)));
}
final AlertDialog progressDialog = DialogUtil.getProgressDialog(activity,activity.getString(R.string.title_point),activity.getString(R.string.please_wait));
progressDialog.show();
try {
FileUtil.copyFileUsingFileChannelsAsyn(srcFile, exportFile)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
progressDialog.dismiss();
String contentInfo = String.format(activity.getString(R.string.dialog_message_export_finish), exportFile.getName(), exportFile.getParentFile().getAbsolutePath());
new AlertDialog.Builder(activity)
.setTitle(R.string.title_export_finish)
.setMessage(contentInfo)
.setPositiveButton(R.string.dialog_confirm_watch, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
RxBus.getInstance().send(new RxEvent(EEvent.OPEN_EXPORT_DIR));
if(!(activity instanceof MainActivity)){
activity.finish();
}
}
})
.setNegativeButton(R.string.dialog_cancel_watch, null)
.show();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
public void setProgressDrawable(Drawable drawable){
ProgressBar prog = (ProgressBar)findViewById(R.id.pull_header_prog);
prog.setIndeterminateDrawable(drawable);
}