@Override public boolean onNavigationItemSelected(int position, long idItem) { try { IntraUserLoginIdentity intraUserLoginIdentity = moduleManager.showAvailableLoginIdentities().get(position); moduleManager.login(intraUserLoginIdentity.getPublicKey()); // TODO: para despues // adapter.changeDataSet(intraUserModuleManager.getAllIntraUsers()); // mientras tanto testeo // adapter.changeDataSet(IntraUserConnectionListItem.getTestData(getResources())); return true; } catch (CantShowLoginIdentitiesException e) { e.printStackTrace(); } catch (CantLoginIntraUserException e) { e.printStackTrace(); } return false; }
@Override public void onClick(View v) { int i = v.getId(); if (i == R.id.positive_button) { try { // image null if (intraUserInformation != null && identity != null) { getSession() .getModuleManager() .disconnectIntraUSer(identity.getPublicKey(), intraUserInformation.getPublicKey()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.edit().putBoolean("Connected", true).apply(); Intent broadcast = new Intent(Constants.LOCAL_BROADCAST_CHANNEL); broadcast.putExtra(Constants.BROADCAST_DISCONNECTED_UPDATE, true); sendLocalBroadcast(broadcast); Toast.makeText(getContext(), "Disconnected", Toast.LENGTH_SHORT).show(); } else { super.toastDefaultError(); } dismiss(); } catch (final IntraUserDisconnectingFailedException e) { super.getErrorManager() .reportUnexpectedUIException(UISource.VIEW, UnexpectedUIExceptionSeverity.UNSTABLE, e); super.toastDefaultError(); } dismiss(); } else if (i == R.id.negative_button) { dismiss(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { _executor = Executors.newFixedThreadPool(2); setHasOptionsMenu(true); // setting up module moduleManager = appSession.getModuleManager(); errorManager = appSession.getErrorManager(); intraUserSubAppSession = appSession; try { intraUserWalletSettings = moduleManager.loadAndGetSettings(intraUserSubAppSession.getAppPublicKey()); } catch (Exception e) { intraUserWalletSettings = null; } if (intraUserSubAppSession.getAppPublicKey() != null) // the identity not exist yet { if (intraUserWalletSettings == null) { intraUserWalletSettings = new IntraUserWalletSettings(); intraUserWalletSettings.setIsPresentationHelpEnabled(true); intraUserSubAppSession .getModuleManager() .persistSettings(intraUserSubAppSession.getAppPublicKey(), intraUserWalletSettings); } } mNotificationsCount = moduleManager.getIntraUsersWaitingYourAcceptanceCount(); new FetchCountTask().execute(); toolbar = getToolbar(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { toolbar.setElevation(10); } // consult net work status _executor.submit( new Runnable() { @Override public void run() { try { handler.postDelayed( new Runnable() { public void run() { NetworkStatus networkStatus = null; try { networkStatus = getFermatNetworkStatus(); } catch (CantGetCommunicationNetworkStatusException e) { e.printStackTrace(); } switch (networkStatus) { case CONNECTED: // setUpReferences(); break; case DISCONNECTED: showErrorFermatNetworkDialog(); break; } } }, 500); } catch (Exception e) { e.printStackTrace(); } } }); // getting location and setting device locacion location = moduleManager.getLocationManager(); if (location == null) { // showErrorGPS(); Toast.makeText(getActivity(), "Please, turn ON your GPS", Toast.LENGTH_SHORT); } IntraUserLoginIdentity identity = moduleManager.getActiveIntraUserIdentity(); distance = identity.getAccuracy(); // turnGPSOn(); } catch (Exception ex) { CommonLogger.exception(TAG, ex.getMessage(), ex); errorManager.reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.CRASH, ex); } }