Good day to all, I would like to listen to experienced developers how to correctly implement fragments similar in content. The fragments are distinguished by their texts, colors and action. Look, here I have created a basic fragment.

public abstract class BaseSetupFragment extends Fragment { private static final long DELAY_MILLIS = 1500L; private static final long ANIM_DURATION = 200L; private MaterialProgressBar progress; public FragmentActivity activity; private TextView status; private ProgressBar spinner; private View success, error; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { activity = getActivity(); View base = inflater.inflate(R.layout.base_setup, container, false); View header = base.findViewById(R.id.setup_header); TextView title = (TextView) base.findViewById(R.id.setup_title); TextView desc = (TextView) base.findViewById(R.id.setup_desc); ImageView icon = (ImageView) base.findViewById(R.id.setup_icon); progress = (MaterialProgressBar)base.findViewById(R.id.setup_progress); spinner = (ProgressBar) base.findViewById(R.id.setup_spinner); success = base.findViewById(R.id.setup_success); error = base.findViewById(R.id.setup_error); status = (TextView) base.findViewById(R.id.setup_status); int color = ContextCompat.getColor(activity, getHeaderColor()); header.setBackgroundColor(color); progress.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_ATOP); spinner.getIndeterminateDrawable().setColorFilter(color, PorterDuff.Mode.SRC_ATOP); title.setText(getTitle()); desc.setText(getDescription()); status.setText(getResultProcess()); icon.setImageResource(getIcon()); new Handler().postDelayed(new Runnable(){ @Override public void run() { final boolean result = startAction(); progress.setVisibility(View.INVISIBLE); spinner.animate(). scaleX(0). scaleY(0). setDuration(ANIM_DURATION). withStartAction(new Runnable(){ @Override public void run() { status.animate(). alpha(0). setDuration(ANIM_DURATION). start(); } }). withEndAction(new Runnable(){ @Override public void run() { if (result) { status.setText(getSuccessResult()); status.setTextColor(ContextCompat.getColor(activity, R.color.green_light)); } else { status.setText(getErrorResult()); status.setTextColor(ContextCompat.getColor(activity, R.color.red_light)); } reaction(result); } }). start(); } }, DELAY_MILLIS); return base; } private void reaction(final boolean result) { (result ? success : error).animate() .scaleX(1). scaleY(1). setDuration(ANIM_DURATION). withStartAction(new Runnable(){ @Override public void run() { status.animate(). alpha(1). setDuration(ANIM_DURATION). start(); } }). start(); } abstract int getErrorResult(); abstract int getResultProcess(); abstract int getSuccessResult(); abstract int getHeaderColor(); abstract int getTitle(); abstract int getDescription(); abstract int getIcon(); abstract boolean startAction(); } 

To create a fragment, I inherit the class from this class, override the startAction methods and startAction in which I check or do something (whether the application is installed, unarchiving files, requesting runtime permissions, granting root rights) and returning the result of the check / execution.

Did I do ok?

    0