PageRenderTime 53ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/BMovil_v940/app/src/main/java/suitebancomer/aplicaciones/bmovil/classes/gui/controllers/OpcionesTransferViewController.java

https://gitlab.com/edddea/api_contratacion_arq
Java | 309 lines | 214 code | 47 blank | 48 comment | 45 complexity | 270195f014c880dc82b5d9864afec8b4 MD5 | raw file
  1. package suitebancomer.aplicaciones.bmovil.classes.gui.controllers;
  2. import java.util.ArrayList;
  3. import suitebancomer.aplicaciones.bmovil.classes.common.Autenticacion;
  4. import bancomer.api.common.commons.Constants;
  5. import suitebancomer.aplicaciones.bmovil.classes.common.Session;
  6. import suitebancomer.aplicaciones.bmovil.classes.common.Tools;
  7. import suitebancomer.aplicaciones.bmovil.classes.gui.delegates.DineroMovilDelegate;
  8. import suitebancomer.aplicaciones.bmovil.classes.gui.delegates.TransferirDelegate;
  9. import suitebancomer.aplicaciones.bmovil.classes.io.Server;
  10. import suitebancomer.aplicaciones.bmovil.classes.io.ServerResponse;
  11. import suitebancomer.aplicaciones.bmovil.classes.model.Account;
  12. import suitebancomer.classes.common.GuiTools;
  13. import suitebancomer.classes.gui.controllers.BaseViewController;
  14. import suitebancomer.classes.gui.views.ListaSeleccionViewController;
  15. import android.os.Bundle;
  16. import android.util.Log;
  17. import android.widget.LinearLayout;
  18. import android.widget.LinearLayout.LayoutParams;
  19. import android.widget.TextView;
  20. import com.bancomer.mbanking.R;
  21. import com.bancomer.mbanking.SuiteApp;
  22. import java.util.HashMap;
  23. import java.util.Map;
  24. import tracking.TrackingHelper;
  25. public class OpcionesTransferViewController extends BaseViewController {
  26. LinearLayout vista;
  27. ListaSeleccionViewController listaSeleccion;
  28. TextView titulo;
  29. ArrayList<Object> lista;
  30. TransferirDelegate delegate;
  31. Bundle extras;
  32. BmovilViewsController parentManager;
  33. @Override
  34. public void onCreate(Bundle savedInstanceState) {
  35. super.onCreate(savedInstanceState, SHOW_HEADER | SHOW_TITLE,
  36. R.layout.layout_bmovil_opciones_transfer);
  37. extras = getIntent().getExtras();
  38. setTitle(extras.getInt(Constants.PANTALLA_BASE_TITULO),
  39. extras.getInt(Constants.PANTALLA_BASE_ICONO));
  40. SuiteApp suiteApp = (SuiteApp) getApplication();
  41. setParentViewsController(suiteApp.getBmovilApplication()
  42. .getBmovilViewsController());
  43. setDelegate(parentViewsController
  44. .getBaseDelegateForKey(TransferirDelegate.TRANSFERIR_DELEGATE_ID));
  45. delegate = (TransferirDelegate) getDelegate();
  46. if(delegate==null){
  47. delegate = new TransferirDelegate();
  48. parentViewsController.addDelegateToHashMap(TransferirDelegate.TRANSFERIR_DELEGATE_ID,delegate);
  49. setDelegate(delegate);
  50. }
  51. delegate.setControladorTransferencias(this);
  52. delegate.setTipoOperacion(extras
  53. .getString(Constants.PANTALLA_BASE_TIPO_OPERACION));
  54. vista = (LinearLayout) findViewById(R.id.opciones_transfer_layout);
  55. init();
  56. //AMZ
  57. parentManager = SuiteApp.getInstance().getBmovilApplication().getBmovilViewsController();
  58. TrackingHelper.trackState("transferir", parentManager.estados);
  59. }
  60. public void init() {
  61. cargaListaSeleccionComponent();
  62. }
  63. @SuppressWarnings("deprecation")
  64. public void cargaListaSeleccionComponent() {
  65. ArrayList<String> titulos = new ArrayList<String>();
  66. titulos.add(getString(extras.getInt(Constants.PANTALLA_BASE_SUBTITULO)));
  67. lista = delegate.cargarListasMenu();
  68. /*
  69. * LinearLayout.LayoutParams params = new
  70. * LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
  71. * params.topMargin = getResources().getDimensionPixelOffset(R.dimen.
  72. * cuenta_origen_list_border_margin); params.leftMargin =
  73. * getResources().
  74. * getDimensionPixelOffset(R.dimen.cuenta_origen_list_side_margin);
  75. * params.rightMargin = getResources().getDimensionPixelOffset(R.dimen.
  76. * cuenta_origen_list_side_margin);
  77. */
  78. GuiTools guiTools = GuiTools.getCurrent();
  79. guiTools.init(getWindowManager());
  80. guiTools.scalePaddings(vista);
  81. LinearLayout.LayoutParams params = new LayoutParams(
  82. LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
  83. listaSeleccion = new ListaSeleccionViewController(this, params,
  84. parentViewsController);
  85. listaSeleccion.setDelegate(delegate);
  86. listaSeleccion.setLista(lista);
  87. listaSeleccion.setNumeroColumnas(1);
  88. listaSeleccion.setTitle(getString(extras
  89. .getInt(Constants.PANTALLA_BASE_SUBTITULO)));
  90. listaSeleccion.setOpcionSeleccionada(-1);
  91. listaSeleccion.setSeleccionable(false);
  92. listaSeleccion.setAlturaFija(false);
  93. listaSeleccion.cargarTabla();
  94. vista.addView(listaSeleccion);
  95. }
  96. @Override
  97. protected void onResume() {
  98. super.onResume();
  99. if (parentViewsController.consumeAccionesDeReinicio()) {
  100. return;
  101. }
  102. getParentViewsController().setCurrentActivityApp(this);
  103. if (delegate != null) {
  104. delegate.setControladorTransferencias(this);
  105. }
  106. }
  107. @Override
  108. protected void onPause() {
  109. super.onPause();
  110. parentViewsController.consumeAccionesDePausa();
  111. }
  112. @Override
  113. public void goBack() {
  114. parentViewsController
  115. .removeDelegateFromHashMap(TransferirDelegate.TRANSFERIR_DELEGATE_ID);
  116. super.goBack();
  117. }
  118. public void opcionSeleccionada(String opcionSeleccionada) {
  119. //ARR
  120. Map<String,Object> inicioOperacionMap = new HashMap<String, Object>();
  121. Session session = Session.getInstance(SuiteApp.getInstance());
  122. if (opcionSeleccionada
  123. .equals(Constants.OPERACION_TRANSFERENCIA_MIS_CUENTAS_TYPE)) {
  124. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController",
  125. "Entraste a transferencias entre mis cuentas");
  126. if (Autenticacion.getInstance().operarOperacion(Constants.Operacion.transferirPropias, session.getClientProfile())) {
  127. //ARR
  128. inicioOperacionMap.put("evento_inicio", "event45");
  129. inicioOperacionMap.put("&&products", "operaciones;transferencias+mis cuentas");
  130. inicioOperacionMap.put("eVar12", "inicio");
  131. TrackingHelper.trackInicioOperacion(inicioOperacionMap);
  132. if (Session.getInstance(SuiteApp.appContext).getAccounts().length > Constants.CUENTAS_PROPIAS_LENGTH) {
  133. ((BmovilViewsController) parentViewsController).showTransferirMisCuentas();
  134. } else {
  135. this.showInformationAlert(R.string.opcionesTransfer_alerta_texto);
  136. }
  137. } else {
  138. // NO esta permitido
  139. }
  140. } else if (opcionSeleccionada.equals(Constants.INTERNAL_TRANSFER_DEBIT_TYPE)) {
  141. if (Autenticacion.getInstance().operarOperacion(Constants.Operacion.transferirBancomer, session.getClientProfile())) {
  142. if (Session.getInstance(SuiteApp.appContext).puedeOperarConTDCEje()) {
  143. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController", "Entraste a transferencias otras cuentas BBVA");
  144. //ARR
  145. inicioOperacionMap.put("evento_inicio", "event45");
  146. inicioOperacionMap.put("&&products", "operaciones;transferencias+otra cuenta bbva bancomer");
  147. inicioOperacionMap.put("eVar12", "inicio");
  148. TrackingHelper.trackInicioOperacion(inicioOperacionMap);;
  149. ((BmovilViewsController) parentViewsController).showTransferViewController(Constants.Operacion.transferirBancomer.value,false, false);
  150. } else {
  151. showInformationAlert(R.string.opcionesTransfer_alerta_texto_tdc);
  152. }
  153. } else {
  154. // NO esta permitido
  155. }
  156. }/*SPEI else if (opcionSeleccionada
  157. .equals(Constants.INTERNAL_TRANSFER_EXPRESS_TYPE)) {
  158. if (Autenticacion.getInstance().operarOperacion(Constants.Operacion.transferirBancomer, session.getClientProfile())) {
  159. if (Session.getInstance(SuiteApp.appContext).puedeOperarConTDCEje()) {
  160. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController","Entraste a transferencias cuenta express");
  161. ((BmovilViewsController) parentViewsController).showTransferViewController(Constants.Operacion.transferirBancomer.value,true, false);
  162. } else {
  163. showInformationAlert(R.string.opcionesTransfer_alerta_texto_tdc);
  164. }
  165. } else {
  166. // NO esta permitido
  167. }
  168. }Termina SPEI*/
  169. else if (opcionSeleccionada.equals(Constants.EXTERNAL_TRANSFER_TYPE)) {
  170. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController","Entraste a transferencias otros bancos Indicator");
  171. //ARR
  172. inicioOperacionMap.put("evento_inicio", "event45");
  173. inicioOperacionMap.put("&&products", "operaciones;transferencias+otros bancos");
  174. inicioOperacionMap.put("eVar12", "inicio");
  175. TrackingHelper.trackInicioOperacion(inicioOperacionMap);
  176. if (Autenticacion.getInstance().operarOperacion(Constants.Operacion.transferirInterbancaria, session.getClientProfile())) {
  177. if (delegate.isOpenHours()) {
  178. if(Server.ALLOW_LOG) Log.e("Entra", "Entra");
  179. ((BmovilViewsController) parentViewsController).showTransferViewController(Constants.Operacion.transferirInterbancaria.value,false, false);
  180. } else {
  181. if(Session.getListA().size()<=0 && Session.getInstance(SuiteApp.getInstance()).isWeekend())
  182. this.showInformationAlert(Session.getInstance(SuiteApp.getInstance()).notAssociatedMessage());
  183. else
  184. this.showInformationAlert(delegate.textoMensajeAlerta());
  185. }
  186. } else {
  187. // NO esta permitido
  188. }
  189. } else if (opcionSeleccionada
  190. .equals(Constants.OPERACION_EFECTIVO_MOVIL_TYPE)) {
  191. if (Autenticacion.getInstance().operarOperacion(Constants.Operacion.dineroMovil,session.getClientProfile())) {
  192. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController", "Entraste a dinero móvil");
  193. //ARR
  194. inicioOperacionMap.put("evento_inicio", "event45");
  195. inicioOperacionMap.put("&&products", "operaciones;transferencias+dinero movil");
  196. inicioOperacionMap.put("eVar12", "inicio");
  197. TrackingHelper.trackInicioOperacion(inicioOperacionMap);
  198. if (Session.getInstance(SuiteApp.appContext).puedeOperarConTDCEje()) {
  199. ((BmovilViewsController) parentViewsController).showTransferViewController(Constants.Operacion.dineroMovil.value,false, false);
  200. } else {
  201. showInformationAlert(R.string.opcionesTransfer_alerta_texto_tdc);
  202. }
  203. }else {
  204. // EA#9 Caso de Uso Transferir Dinero Movil
  205. // DineroMovilDelegate dineroMovilDelegate = new DineroMovilDelegate();
  206. // dineroMovilDelegate.comprobarRecortado();
  207. delegate.opcionRetiroSinTarjeta=false;
  208. delegate.comprobarRecortado();
  209. }
  210. }
  211. /*else if (opcionSeleccionada.equals(Constants.OPERACION_SPEI_MOVIL)) {
  212. if (Session.getInstance(SuiteApp.appContext).puedeOperarConTDCEje()) {
  213. if(Server.ALLOW_LOG) Log.d(this.getClass().getSimpleName(), "Entraste a SPEI mÛvil");
  214. ((BmovilViewsController)parentViewsController).showOtrosBBVASpeiViewController(Constants.Operacion.transferirBancomer, false, false);
  215. }
  216. }Termina SPEI*/
  217. else if (opcionSeleccionada
  218. .equals(Constants.OPERACION_RETIRO_SINTARJETA)) {
  219. if (Autenticacion.getInstance().operarOperacion(Constants.Operacion.retiroSinTarjeta,session.getClientProfile())) {
  220. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController","Entraste a retiro sin tarjeta");
  221. //ARR
  222. inicioOperacionMap.put("evento_inicio", "event45");
  223. inicioOperacionMap.put("&&products", "operaciones;transferencias+dinero movil");
  224. inicioOperacionMap.put("eVar12", "inicio");
  225. TrackingHelper.trackInicioOperacion(inicioOperacionMap);
  226. if (existenCuentasParaRetiro()) {
  227. //((BmovilViewsController) parentViewsController).showTransferViewController(Constants.Operacion.retiroSinTarjeta.value,false, false);
  228. ((BmovilViewsController)parentViewsController).showRetiroSinTarjetaViewController();
  229. } else {
  230. showInformationAlert(R.string.opcionesTransfer_alerta_texto_tdc);
  231. }
  232. }else {
  233. // EA#9 Caso de Uso Transferir Dinero Movil
  234. // DineroMovilDelegate dineroMovilDelegate = new DineroMovilDelegate();
  235. // dineroMovilDelegate.comprobarRecortado();
  236. delegate.opcionRetiroSinTarjeta=true;
  237. delegate.comprobarRecortado();
  238. }
  239. }
  240. else {
  241. if(Server.ALLOW_LOG) Log.d("OpcionesTransferViewController",
  242. "Opciones a validar para los menus de comprar y pagar");
  243. }
  244. }
  245. private boolean existenCuentasParaRetiro() {
  246. Constants.Perfil profile = Session.getInstance(SuiteApp.appContext).getClientProfile();
  247. Account[] accounts = Session.getInstance(SuiteApp.appContext).getAccounts();
  248. Boolean existenCuentas=true;
  249. Account cuentaEje = Tools.obtenerCuentaEje();
  250. //si el usuario es basico y su cuenta eje es TDC o no es basico pero solo tiene una cuenta y es TDC
  251. if ((((profile == Constants.Perfil.basico))|| (accounts.length == 1) ) && (cuentaEje.getType().equals(Constants.CREDIT_TYPE))){ //cuentaEjeTDC) ){
  252. existenCuentas=false;
  253. }
  254. return existenCuentas;
  255. }
  256. @Override
  257. public void processNetworkResponse(int operationId, ServerResponse response) {
  258. delegate.analyzeResponse(operationId, response);
  259. }
  260. }