@Override protected void initViews(View rootView) { super.initViews(rootView); toolbar = getToolbar(); toolbar.setTitle("Crypto wallet users"); // searchView = inflater.inflate(R.layout.search_edit_text, null); // Set up RecyclerView rootView.setOnKeyListener( new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { worker.shutdownNow(); return true; } return false; } }); // searchEditText = (EditText) searchView.findViewById(R.id.search); // closeSearch = (ImageView) searchView.findViewById(R.id.close_search); // recyclerView = (RecyclerView) rootView.findViewById(R.id.gridView); // recyclerView.setHasFixedSize(true); layoutManager = new GridLayoutManager(getActivity(), 3, LinearLayoutManager.VERTICAL, false); // recyclerView.setLayoutManager(layoutManager); // adapter = new AppListAdapter(getActivity(), lstIntraUserInformations); adapter = new AvailableActorsListAdapter(getActivity(), lstIntraUserInformations); // recyclerView.setAdapter(adapter); adapter.setFermatListEventListener(this); swipeRefresh = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe); swipeRefresh.setOnRefreshListener(this); swipeRefresh.setColorSchemeColors(Color.BLUE, Color.BLUE); rootView.setBackgroundColor(Color.parseColor("#000b12")); emptyView = (LinearLayout) rootView.findViewById(R.id.empty_view); searchEmptyView = (LinearLayout) rootView.findViewById(R.id.search_empty_view); noNetworkView = (LinearLayout) rootView.findViewById(R.id.no_connection_view); noFermatNetworkView = (LinearLayout) rootView.findViewById(R.id.no_fermat_connection_view); // showEmpty(true, emptyView); // load cache user and online users try { if (intraUserWalletSettings.isPresentationHelpEnabled()) { showDialogHelp(); } else { onRefresh(); /*if (!isRefreshing) { isRefreshing = true; //Get Fermat User Cache List First worker = new FermatWorker() { @Override protected Object doInBackground() throws Exception { return getSuggestionCache(); } }; worker.setContext(getActivity()); worker.setCallBack(new FermatWorkerCallBack() { @SuppressWarnings("unchecked") @Override public void onPostExecute(Object... result) { //notificationsProgressDialog.dismiss(); isRefreshing = false; if (swipeRefresh != null) swipeRefresh.setRefreshing(false); if (result != null && result.length > 0) { if (getActivity() != null && adapter != null) { lstIntraUserInformations = (ArrayList<IntraUserInformation>) result[0]; if (lstIntraUserInformations != null) { if (lstIntraUserInformations.isEmpty()) { showEmpty(true, emptyView); showEmpty(false, searchEmptyView); } else { adapter.changeDataSet(lstIntraUserInformations); ((EndlessScrollListener) scrollListener).notifyDataSetChanged(); showEmpty(false, emptyView); showEmpty(false, searchEmptyView); } } else { showEmpty(true, emptyView); showEmpty(false, searchEmptyView); } } } else { showEmpty(true, emptyView); showEmpty(false, searchEmptyView); } //get Fermat User list getActivity().runOnUiThread(new Runnable() { public void run() { adapter.changeDataSet(lstIntraUserInformations); Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { onRefresh(); } }, 800); } }); } @Override public void onErrorOccurred(Exception ex) { // notificationsProgressDialog.dismiss(); isRefreshing = false; if (swipeRefresh != null) swipeRefresh.setRefreshing(false); if (getActivity() != null) Toast.makeText(getActivity(), ex.getMessage(), Toast.LENGTH_LONG).show(); ex.printStackTrace(); } }); worker.execute(); }*/ } } catch (Exception ex) { errorManager.reportUnexpectedUIException( UISource.ACTIVITY, UnexpectedUIExceptionSeverity.CRASH, FermatException.wrapException(ex)); Toast.makeText( getActivity().getApplicationContext(), "Oooops! recovering from system error", Toast.LENGTH_SHORT) .show(); } }
@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); } }