Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. private class backgroundLoadList extends AsyncTask<Void, Integer, ArrayList<CustomDataStructure>> {
  2.  
  3. @Override
  4. protected void onPreExecute() {
  5. super.onPreExecute();
  6. mSpinner.setVisibility(View.VISIBLE);
  7. }
  8.  
  9. @Override
  10. protected ArrayList<CustomDataStructure> doInBackground(Void... voids) {
  11. ArrayList<CustomDataStructure> result = getTabNetworkList();
  12. return result;
  13. }
  14.  
  15. @Override
  16. protected void onPostExecute(ArrayList<CustomDataStructure> customDataStructures) {
  17. adapter.listItems.retainAll(customDataStructures);
  18. adapter.listItems.addAll(customDataStructures);
  19. adapter.notifyDataSetChanged();
  20. mSpinner.setVisibility(View.GONE);
  21. super.onPostExecute(customDataStructures);
  22. }
  23. }
  24.  
  25. private ArrayList<CustomDataStructure> getTabNetworkList() {
  26. CustomDataStructure item;
  27. ArrayList<CustomDataStructure> items = new ArrayList<>();
  28. try {
  29. item = new CustomDataStructure(getResources().getString(R.string.itemDescType), networkRoaming);
  30. items.add(item);
  31. // long list with further items is added below...
  32. } catch (SecurityException e) {
  33. // Exception occurs on the next line because the context is not available anymore for getting the resources...
  34. item = new CustomDataStructure(getResources().getString(R.string.itemInfo), getResources().getString(R.string.textNotAvailable));
  35. items.add(item);
  36. }
  37. return items;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement