@Override protected Item doInBackground(Object... params) { MyDatabaseHelper databaseHelper = new MyDatabaseHelper(getActivity()); rootItem.setParentItemId(parentItem); rootItem.setParentMindMapId(CurrentUser.getInsctance().getMindMapId()); databaseHelper.addItem(rootItem); return rootItem; }
@Nullable @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.inflate(R.layout.dialog_create_mind_map, container); rootItem = new Item.Builder() .parentItemId(parentItem) .angle(0) .background(getResources().getColor(R.color.primary_darker)) .foreground(getResources().getColor(R.color.white)) .image(null) .parentMindMapId(CurrentUser.getInsctance().getMindMapId()) .text("Идея") .create(); rootItem.setContent("Идея"); sectionsPagerAdapter = new CreateItemDialogSectionsPagerAdapter(getChildFragmentManager()); button = (Button) view.findViewById(R.id.create); viewPager = (ViewPager) view.findViewById(R.id.pager); viewPager.setAdapter(sectionsPagerAdapter); viewPager.addOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels) {} @Override public void onPageSelected(int position) { switch (position) { case 0: ((EditTextFragment) viewPager .getAdapter() .instantiateItem(viewPager, viewPager.getCurrentItem())) .update(); break; case 1: ((EditForegroundFragment) viewPager .getAdapter() .instantiateItem(viewPager, viewPager.getCurrentItem())) .update(); break; case 2: ((EditBackgroundFragment) viewPager .getAdapter() .instantiateItem(viewPager, viewPager.getCurrentItem())) .update(); break; case 3: ((EditBitmapFragment) viewPager .getAdapter() .instantiateItem(viewPager, viewPager.getCurrentItem())) .update(); break; } } @Override public void onPageScrollStateChanged(int state) {} }); button.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { new AddItem().execute(rootItem); } }); return view; }