@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_home, container, false); try { mFormView = view.findViewById(R.id.HomeForm); mProgressView = view.findViewById(R.id.HomeProgress); mAction = new ArrayList<>(); if (!CatalogoServicio.getInstance().ExistsZones()) { DoAction(1); } if (!CatalogoServicio.getInstance().ExistsTerritories()) { DoAction(2); } if (!CatalogoServicio.getInstance().ExistsBusinessTypes()) { DoAction(3); } ChangeLog cl = new ChangeLog(mContext); if (cl.firstRun()) cl.getLogDialog().show(); } catch (CustomException ex) { BaseClass.ToastAlert(ex.getMessage(), mContext); } catch (Exception ex) { LogErrorRepository.BuildLogError(ex, mContext); BaseClass.ToastAlert(getString(R.string.Mensaje_ErrorInterno), mContext); } return view; }
@Override protected Boolean doInBackground(Void... params) { try { mAction.remove((Integer) accion); if (accion == 1) { CatalogoServicio.getInstance().GetZones(); } else if (accion == 2) { CatalogoServicio.getInstance().GetTerritories(); } else if (accion == 3) { CatalogoServicio.getInstance().GetBusinessTypes(); } else if (accion == 4) { if (NegocioServicio.getInstance().ExistsUpdate()) return true; else { message = "Ya tiene la ultima versión disponible"; return false; } } else if (accion == 5) { NegocioServicio.getInstance().UpdateApp(); } } catch (CustomException ex) { message = ex.getMessage(); return false; } catch (Exception ex) { LogErrorRepository.BuildLogError(ex, mContext); message = getString(R.string.Mensaje_ErrorInterno); return false; } return true; }