Stepper blank in Android Studio

0

I am using the android-material-stepper library to load a claim in my application, it consists of several parts: Applicant Data, Claim Data, Location and Images. Each of them is included in a Fragment individual. There is a Fragment (NvoReclamoFragment) that is responsible for the logic (contains the xml where the StepperLayout is located, creates the necessary adapter and so on). When I enter for the first time, it is ok, the problem occurs when I enter for the 2nd time, there I still have the blank screen despite going through the 1st Fragment methods. I would not be finding the error, if someone has an idea I appreciate it. I leave the code and some orientation images.

public class NvoReclamoFragment extends Fragment implements StepperLayout.StepperListener  {

@BindView(R.id.stepperLayout) StepperLayout mStepperLayout;
private Unbinder unbinder;
private StepperAdapterReclamo mStepperAdapter;

public NvoReclamoFragment() {}

@Override
public void onDestroy() {
    super.onDestroy();
    unbinder.unbind();
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_new_reclamo, container, false);
    unbinder = ButterKnife.bind(this,v);

    mStepperAdapter = new StepperAdapterReclamo(getFragmentManager(), getContext());
    mStepperLayout.setAdapter(mStepperAdapter);
    mStepperLayout.setListener(this);
    return v;
}

@Override
public void onCompleted(View completeButton) {
    Toast.makeText(getActivity(), "onCompleted!", Toast.LENGTH_SHORT).show();
    // redirigir a mis reclamos
}

@Override
public void onError(VerificationError verificationError) {
    Toast.makeText(getActivity(), "onError! -> " + verificationError.getErrorMessage(), Toast.LENGTH_SHORT).show();
}

@Override
public void onStepSelected(int newStepPosition) {}

@Override
public void onReturn() {
    getActivity().finish();
}

Adartador

public class StepperAdapterReclamo extends AbstractFragmentStepAdapter {
private static final String CURRENT_STEP_POSITION_KEY = "messageResourceId";
public static Reclamo reclamo;

public StepperAdapterReclamo(FragmentManager fm, Context context) {
    super(fm, context);
}

@Override
public Step createStep(int position) {
    Bundle bb = new Bundle();
    bb.putInt(CURRENT_STEP_POSITION_KEY, position);

    switch (position) {
        case 0:
            ReclamoSolicitanteFragment solicitante = new ReclamoSolicitanteFragment();
            solicitante.setArguments(bb);
            return solicitante;
        case 1:
            ReclamoDatosFragment datos = new ReclamoDatosFragment();
            datos.setArguments(bb);
            return datos;
        case 2:
            ReclamoUbicacionFragment ubicacion = new ReclamoUbicacionFragment();
            ubicacion.setArguments(bb);
            return ubicacion;
        case 3:
            ReclamoImgFragment img = new ReclamoImgFragment();
            img.setArguments(bb);
            return img;
    }
    return null;
}

@Override
public int getCount() {
    return 4;
}

@NonNull
@Override
public StepViewModel getViewModel(@IntRange(from = 0) int position) {

    StepViewModel.Builder builder = new StepViewModel.Builder(context);

    switch (position) {
        case 0:
            builder.setEndButtonLabel(R.string.sig)
                    .setBackButtonStartDrawableResId(StepViewModel.NULL_DRAWABLE);
            break;
        case 1:
            builder.setBackButtonLabel(R.string.ant)
                    .setEndButtonLabel(R.string.sig);
            break;
        case 2:
            builder.setBackButtonLabel(R.string.ant)
                    .setEndButtonLabel(R.string.sig);
            break;
        case 3:
            builder.setEndButtonLabel(R.string.guardar)
                    .setBackButtonLabel(R.string.ant);
            break;
    }
    return builder.create();
}

When entering the App, select New Claim (1) and it is displayed correctly as in (2), if I leave that fragment and later I return to select the same option it is displayed as in (3)

    
asked by DavidC 10.05.2018 в 17:19
source

0 answers