/** * Gets the title back from the RequestTextDialog and adds a decision branch using the selected * fragment and the title. */ @Override public void onUserSelectValue(String title) { SFL = new ArrayList<StoryFragment>(); HashMap<Integer, StoryFragment> map = SCC.getFragments(); for (Integer key : map.keySet()) { SFL.add(map.get(key)); } SFL.get(pos).getFragmentID(); DecisionBranch db = new DecisionBranch(title, SFL.get(pos).getFragmentID()); DBCC.addDecisionBranch(db); finish(); }
/** Displays a list of fragments. */ private void updateFragmentList() { SFL = new ArrayList<StoryFragment>(); HashMap<Integer, StoryFragment> map = SCC.getFragments(); for (Integer key : map.keySet()) { SFL.add(map.get(key)); } String title = SCC.getStory().getStoryInfo().getTitle(); actionBar = getActionBar(); actionBar.setTitle(title); adapter = new ArrayAdapter<StoryFragment>(this, android.R.layout.simple_list_item_1, SFL); ListView listview = new ListView(this); listview.setBackgroundColor(Color.WHITE); listview.setAdapter(adapter); setContentView(listview); registerForContextMenu(listview); listview.setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View v, int position, long id) { // remember destination fragment pos = position; // get decision branch label DialogFragment newFragment = new RequestTextDialog(); ((RequestTextDialog) newFragment).setParent(DecisionPickerActivity.this); ((RequestTextDialog) newFragment).setHeader("New Decision Branch Label"); ((RequestTextDialog) newFragment).setWarning("Cannot create branch with empty label."); newFragment.show(getFragmentManager(), "addBranch"); } }); }