@Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (book != null) {
      bookTitleView.setText(book.getFilename());
      String imageUrl = book.getImageUrl();
      if (!TextUtils.isEmpty(imageUrl)) {
        Picasso.with(getActivity()).load(imageUrl).into(bookImageView);
      }

      downloadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              downloadManager.download(book);
            }
          });
    }

    if (optimizedBooks.size() > 0) {
      optimizedBooksContainer.setVisibility(View.VISIBLE);
      for (OptimizedBook optimizedBook : optimizedBooks) {
        LayoutInflater layoutInflater = getLayoutInflater(savedInstanceState);
        View optimizedBookView = createOptimizedBookView(layoutInflater, optimizedBook);
        optimizedBooksList.addView(optimizedBookView);
      }
    } else {
      optimizedBooksContainer.setVisibility(View.GONE);
    }
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getActivity().setTitle(formField.getLabel());
    final List<FormOption> options = new ArrayList<>();
    final FormOptions formOptions = formField.getOptions();
    final ArrayAdapter<FormOption> adapter =
        new ArrayAdapter<>(getActivity(), R.layout.edx_selectable_list_item, options);
    if (formOptions.getReference() != null) {
      new GetFormOptionsTask(getActivity(), formOptions.getReference()) {
        @Override
        protected void onSuccess(List<FormOption> formOptions) throws Exception {
          options.addAll(formOptions);
          adapter.notifyDataSetChanged();
          selectCurrentOption();
        }
      }.execute();

    } else if (formOptions.getRangeMin() != null && formOptions.getRangeMax() != null) {
      for (int i = formOptions.getRangeMax(); i >= formOptions.getRangeMin(); --i) {
        options.add(new FormOption(String.valueOf(i), String.valueOf(i)));
      }
    } else if (formOptions.getValues() != null && formOptions.getValues().size() > 0) {
      options.addAll(formOptions.getValues());
    }
    if (!TextUtils.isEmpty(formField.getInstructions())) {
      final View instructionsContainer =
          LayoutInflater.from(view.getContext())
              .inflate(R.layout.form_field_instructions_header, listView, false);
      final TextView instructions =
          (TextView) instructionsContainer.findViewById(R.id.instructions);
      final TextView subInstructions =
          (TextView) instructionsContainer.findViewById(R.id.sub_instructions);
      instructions.setText(formField.getInstructions());
      if (TextUtils.isEmpty(formField.getSubInstructions())) {
        subInstructions.setVisibility(View.GONE);
      } else {
        subInstructions.setText(formField.getSubInstructions());
      }
      listView.addHeaderView(instructionsContainer, null, false);
    }
    if (null != formField.getDataType()) {
      switch (formField.getDataType()) {
        case COUNTRY:
          {
            final Locale locale = Locale.getDefault();
            addDetectedValueHeader(
                listView,
                R.string.edit_user_profile_current_location,
                "current_location",
                locale.getDisplayCountry(),
                locale.getCountry(),
                FontAwesomeIcons.fa_map_marker);
            break;
          }
        case LANGUAGE:
          {
            final Locale locale = Locale.getDefault();
            addDetectedValueHeader(
                listView,
                R.string.edit_user_profile_current_language,
                "current_language",
                locale.getDisplayLanguage(),
                locale.getLanguage(),
                FontAwesomeIcons.fa_comment);
            break;
          }
      }
    }
    if (formField.getOptions().isAllowsNone()) {
      final TextView textView =
          (TextView)
              LayoutInflater.from(listView.getContext())
                  .inflate(R.layout.edx_selectable_list_item, listView, false);
      final String label = formField.getOptions().getNoneLabel();
      textView.setText(label);
      listView.addHeaderView(textView, new FormOption(label, null), true);
    }
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final FormOption item = (FormOption) parent.getItemAtPosition(position);
            getActivity()
                .setResult(
                    Activity.RESULT_OK,
                    new Intent()
                        .putExtra(FormFieldActivity.EXTRA_FIELD, formField)
                        .putExtra(FormFieldActivity.EXTRA_VALUE, item.getValue()));
            getActivity().finish();
          }
        });
    selectCurrentOption();
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (isCoursewareAccessible) {
      final LayoutInflater inflater = LayoutInflater.from(getActivity());

      if (courseData.isCertificateEarned()
          && environment.getConfig().areCertificateLinksEnabled()) {
        final View child = inflater.inflate(R.layout.row_course_dashboard_cert, parent, false);
        child
            .findViewById(R.id.get_certificate)
            .setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    environment.getRouter().showCertificate(getActivity(), courseData);
                  }
                });
        parent.addView(child);
      }

      // Implementation Note: - we can create a list view and populate the list.
      // but as number of rows are fixed and each row is different. the only common
      // thing is UI layout. so we reuse the same UI layout programmatically here.
      ViewHolder holder = createViewHolder(inflater, parent);

      holder.typeView.setIcon(Iconify.IconValue.fa_list_alt);
      holder.titleView.setText(R.string.courseware_title);
      holder.subtitleView.setText(R.string.courseware_subtitle);
      holder.rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              environment.getRouter().showCourseContainerOutline(getActivity(), courseData);
            }
          });

      if (courseData != null
          && !TextUtils.isEmpty(courseData.getCourse().getDiscussionUrl())
          && environment.getConfig().isDiscussionsEnabled()) {
        holder = createViewHolder(inflater, parent);

        holder.typeView.setIcon(Iconify.IconValue.fa_comments_o);
        holder.titleView.setText(R.string.discussion_title);
        holder.subtitleView.setText(R.string.discussion_subtitle);
        holder.rowView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                environment.getRouter().showCourseDiscussionTopics(getActivity(), courseData);
              }
            });
      }

      holder = createViewHolder(inflater, parent);

      holder.typeView.setIcon(Iconify.IconValue.fa_file_text_o);
      holder.titleView.setText(R.string.handouts_title);
      holder.subtitleView.setText(R.string.handouts_subtitle);
      holder.rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (courseData != null)
                environment.getRouter().showHandouts(getActivity(), courseData);
            }
          });

      holder = createViewHolder(inflater, parent);

      holder.typeView.setIcon(Iconify.IconValue.fa_bullhorn);
      holder.titleView.setText(R.string.announcement_title);
      holder.subtitleView.setText(R.string.announcement_subtitle);
      holder.rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (courseData != null)
                environment.getRouter().showCourseAnnouncement(getActivity(), courseData);
            }
          });
    } else {
      errorText.setText(R.string.course_not_started);
    }
  }
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    final LayoutInflater inflater = LayoutInflater.from(getActivity());

    // Add "All posts" item
    {
      final TextView header =
          (TextView)
              inflater.inflate(R.layout.row_discussion_topic, discussionTopicsListView, false);
      header.setText(R.string.discussion_posts_filter_all_posts);

      final DiscussionTopic discussionTopic = new DiscussionTopic();
      discussionTopic.setIdentifier(DiscussionTopic.ALL_TOPICS_ID);
      discussionTopic.setName(getString(R.string.discussion_posts_filter_all_posts));
      discussionTopicsListView.addHeaderView(
          header, new DiscussionTopicDepth(discussionTopic, 0, true), true);
    }

    // Add "Posts I'm following" item
    {
      final TextView header =
          (TextView)
              inflater.inflate(R.layout.row_discussion_topic, discussionTopicsListView, false);
      header.setText(R.string.forum_post_i_am_following);
      TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
          header,
          new IconDrawable(getActivity(), Iconify.IconValue.fa_star)
              .colorRes(R.color.edx_grayscale_neutral_dark)
              .sizeRes(R.dimen.edx_base),
          null,
          null,
          null);
      final DiscussionTopic discussionTopic = new DiscussionTopic();
      discussionTopic.setIdentifier(DiscussionTopic.FOLLOWING_TOPICS_ID);
      discussionTopic.setName(getString(R.string.forum_post_i_am_following));
      discussionTopicsListView.addHeaderView(
          header, new DiscussionTopicDepth(discussionTopic, 0, true), true);
    }

    discussionTopicsListView.setAdapter(discussionTopicsAdapter);

    discussionTopicsSearchView.setOnQueryTextListener(
        new SearchView.OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            if (query == null || query.trim().length() == 0) return false;

            router.showCourseDiscussionPostsForSearchQuery(getActivity(), query, courseData);
            return true;
          }

          @Override
          public boolean onQueryTextChange(String newText) {
            return false;
          }
        });

    discussionTopicsListView.setOnItemClickListener(
        new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            router.showCourseDiscussionPostsForDiscussionTopic(
                getActivity(),
                ((DiscussionTopicDepth) parent.getItemAtPosition(position)).getDiscussionTopic(),
                courseData);
          }
        });

    // TODO: Find a better way to hide the keyboard AND take the focus away from the SearchView
    discussionTopicsSearchView.requestFocus();
    discussionTopicsSearchView.clearFocus();

    getTopicList();
  }