private void setEmptyView() { if (emptyStateRelativeLayout == null) { view = inflater.inflate(R.layout.progress_empty_view, null); emptyStateRelativeLayout = (RelativeLayout) view.findViewById(R.id.emptyStateRelativeLayout); emptyStateRelativeLayout.setTag(TAG_EMPTY); emptyStateImageView = (ImageView) view.findViewById(R.id.emptyStateImageView); emptyStateContentTextView = (TextView) view.findViewById(R.id.emptyStateContentTextView); //Set empty state image width and height emptyStateImageView.getLayoutParams().width = emptyStateImageWidth; emptyStateImageView.getLayoutParams().height = emptyStateImageHeight; emptyStateImageView.requestLayout(); emptyStateContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, emptyStateContentTextSize); emptyStateContentTextView.setTextColor(emptyStateContentTextColor); //Set background color if not TRANSPARENT if (emptyStateBackgroundColor != Color.TRANSPARENT) { this.setBackgroundColor(emptyStateBackgroundColor); } layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.addRule(CENTER_IN_PARENT); addView(emptyStateRelativeLayout, layoutParams); } else { emptyStateRelativeLayout.setVisibility(VISIBLE); } }
private void setErrorView() { if (errorStateRelativeLayout == null) { view = inflater.inflate(R.layout.progress_error_view, null); errorStateRelativeLayout = (RelativeLayout) view.findViewById(R.id.errorStateRelativeLayout); errorStateRelativeLayout.setTag(TAG_ERROR); errorStateImageView = (ImageView) view.findViewById(R.id.errorStateImageView); errorStateContentTextView = (TextView) view.findViewById(R.id.errorStateContentTextView); errorStateButton = (Button) view.findViewById(R.id.errorStateButton); //Set error state image width and height errorStateImageView.getLayoutParams().width = errorStateImageWidth; errorStateImageView.getLayoutParams().height = errorStateImageHeight; errorStateImageView.requestLayout(); errorStateContentTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, errorStateContentTextSize); errorStateContentTextView.setTextColor(errorStateContentTextColor); errorStateButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, errorStateButtonTextSize); errorStateButton.setTextColor(errorStateButtonTextColor); //Set background color if not TRANSPARENT if (errorStateBackgroundColor != Color.TRANSPARENT) { this.setBackgroundColor(errorStateBackgroundColor); } layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.addRule(CENTER_IN_PARENT); addView(errorStateRelativeLayout, layoutParams); } else { errorStateRelativeLayout.setVisibility(VISIBLE); } }
private void setLoadingView() { if (loadingStateRelativeLayout == null) { view = inflater.inflate(R.layout.progress_loading_view, null); loadingStateRelativeLayout = (RelativeLayout) view.findViewById(R.id.loadingStateRelativeLayout); loadingStateRelativeLayout.setTag(TAG_LOADING); loadingStateProgressBar = (ProgressWheel) view.findViewById(R.id.loadingStateProgressBar); loadingStateProgressBar.getLayoutParams().width = loadingStateProgressBarRadius; loadingStateProgressBar.getLayoutParams().height = loadingStateProgressBarRadius; loadingStateProgressBar.setBarWidth(loadingStateProgressBarSpinWidth); if (loadingStateProgressBarColor != Color.TRANSPARENT) { loadingStateProgressBar.setBarColor(loadingStateProgressBarColor); } loadingStateProgressBar.requestLayout(); //Set background color if not TRANSPARENT if (loadingStateBackgroundColor != Color.TRANSPARENT) { this.setBackgroundColor(loadingStateBackgroundColor); } layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.addRule(CENTER_IN_PARENT); addView(loadingStateRelativeLayout, layoutParams); } else { loadingStateRelativeLayout.setVisibility(VISIBLE); } }