public static void store( Bundle bundle ){ Bundle docBundle = new Bundle(); for ( Document doc : values()){ ArrayList<String> pages = new ArrayList<>(); for (String page : doc.pages()){ if (doc.pages.get(page)){ pages.add(page); } } if (!pages.isEmpty()) { docBundle.put(doc.name(), pages.toArray(new String[0])); } } bundle.put( DOCUMENTS, docBundle ); }
public static void store( Bundle bundle ){ Bundle docBundle = new Bundle(); for ( Document doc : values()){ ArrayList<String> pages = new ArrayList<>(); for (String page : doc.pages()){ if (doc.pages.get(page)){ pages.add(page); } } if (!pages.isEmpty()) { docBundle.put(doc.name(), pages.toArray(new String[0])); } } bundle.put( DOCUMENTS, docBundle ); }
@SuppressWarnings("unchecked") @Override public void restoreFromBundle( Bundle bundle ) { pos = bundle.getInt( POS ); seen = bundle.getBoolean( SEEN ); type = Type.valueOf( bundle.getString( TYPE ) ); items = new LinkedList<Item>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS )) ); items.removeAll(Collections.singleton(null)); //remove any document pages that either don't exist anymore or that the player already has for (Item item : items.toArray(new Item[0])){ if (item instanceof DocumentPage && ( !((DocumentPage) item).document().pages().contains(((DocumentPage) item).page()) || ((DocumentPage) item).document().hasPage(((DocumentPage) item).page()))){ items.remove(item); } } haunted = bundle.getBoolean( HAUNTED ); }
@SuppressWarnings("unchecked") @Override public void restoreFromBundle( Bundle bundle ) { pos = bundle.getInt( POS ); seen = bundle.getBoolean( SEEN ); type = Type.valueOf( bundle.getString( TYPE ) ); items = new LinkedList( bundle.getCollection( ITEMS ) ); items.removeAll(Collections.singleton(null)); //remove any document pages that either don't exist anymore or that the player already has for (Item item : items.toArray(new Item[0])){ if (item instanceof DocumentPage && ( !((DocumentPage) item).document().pages().contains(((DocumentPage) item).page()) || ((DocumentPage) item).document().hasPage(((DocumentPage) item).page()))){ items.remove(item); } } haunted = bundle.getBoolean( HAUNTED ); }
Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages(); ArrayList<String> missingPages = new ArrayList<>(); for ( String page : allPages){
Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages(); ArrayList<String> missingPages = new ArrayList<>(); for ( String page : allPages){
Collection<String> allPages = Document.ALCHEMY_GUIDE.pages(); ArrayList<String> missingPages = new ArrayList<>(); for ( String page : allPages){
for (String page : Document.ADVENTURERS_GUIDE.pages()){ GuideItem item = new GuideItem( page );
for (String page : Document.ADVENTURERS_GUIDE.pages()){ GuideItem item = new GuideItem( page );
Collection<String> allPages = Document.ALCHEMY_GUIDE.pages(); ArrayList<String> missingPages = new ArrayList<>(); for ( String page : allPages){
for (String page : doc.pages()){ docPage item = new docPage( doc, page );
for (String page : doc.pages()){ docPage item = new docPage( doc, page );