private void showBlogPostView(boolean show) { if (this.isWideScreen) { return; } if (show) { this.exampleMainContent.setVisibility(View.INVISIBLE); this.selectedBlogPostView.setVisibility(View.VISIBLE); actionModeTitleView.setText(""); long id = adapter.getCurrentItemId(); int position = adapter.getPosition(id); getActivity().startActionMode(new BlogPostViewCallback(position)); } else { this.exampleMainContent.setVisibility(View.VISIBLE); this.selectedBlogPostView.setVisibility(View.GONE); } }
@Override public View onCreateView( LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_list_view_selection, container, false); this.adapter = new BlogPostAdapter(new ArrayList<BlogPost>()); this.listView = (RadListView) rootView.findViewById(R.id.listView); this.listView.setAdapter(this.adapter); this.listView.addItemClickListener(new ListViewClickListener()); this.reorderBehavior = new ReorderWithHandlesBehavior(R.id.imgReorder); this.swipeExecuteBehavior = new SwipeExecuteBehavior(); this.swipeExecuteBehavior.addListener(new SwipeListener()); this.swipeExecuteBehavior.setAutoDissolve(false); this.listView.addBehavior(this.swipeExecuteBehavior); this.selectionBehavior = new SelectionBehavior(); this.selectionBehavior.addListener(new ListViewSelectionListener()); this.listView.addBehavior(this.selectionBehavior); this.collapsibleGroupsBehavior = new CollapsibleGroupsBehavior(); this.listView.addBehavior(collapsibleGroupsBehavior); this.initExampleSettings(rootView); boolean isAllSelected = true; boolean isInReorder = false; List<BlogPost> allItems = null; if (savedInstanceState != null) { allItems = savedInstanceState.getParcelableArrayList("allItems"); bindListView(allItems); isInReorder = savedInstanceState.getBoolean("isInReorder"); isAllSelected = savedInstanceState.getBoolean("isAllSelected"); long currentId = savedInstanceState.getLong("currentItemId"); boolean wasFullScreen = savedInstanceState.getBoolean("isFullScreen"); int position = adapter.getPosition(currentId); if (position < 0) { loadBlogPostContent(); } else { loadBlogPostContent(position); } if (!isWideScreen && currentId != INVALID_ID && wasFullScreen) { showBlogPostView(true); } } if (allItems == null || allItems.size() == 0) { this.initMenu(rootView, true); BlogPostLoaderTask blogPostsLoader = new BlogPostLoaderTask(); blogPostsLoader.execute(); } else { this.initMenu(rootView, isAllSelected); if (!isAllSelected) { switchFilter(true); } if (isInReorder) { enterReorderMode(); } } return rootView; }