Ejemplo n.º 1
0
  @Override
  public void showStartResult() {
    if (!isInShowCalculateMode) {
      return;
    }

    isInShowCalculateMode = false;
    equalsFloatingActionButton.setSelected(false);
  }
Ejemplo n.º 2
0
  @Override
  public void showCalculate() {
    if (isInShowCalculateMode) {
      return;
    }

    isInShowCalculateMode = true;
    equalsFloatingActionButton.setSelected(true);
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_article_detail, container, false);

    // Show the Article content
    if (mItem != null) {
      Picasso.with(getActivity())
          .load(mItem.getImageUrl())
          .error(R.drawable.ckl_logo)
          .placeholder(R.drawable.ckl_logo)
          .into(((ImageView) rootView.findViewById(R.id.articleImageDetail)));

      ((TextView) rootView.findViewById(R.id.articleTitleDetail)).setText(mItem.getTitle());
      ((TextView) rootView.findViewById(R.id.articleAuthorDetail)).setText(mItem.getAuthors());
      ((TextView) rootView.findViewById(R.id.articleWebsiteDetail)).setText(mItem.getWebsite());
      String date = new JsonDateConverter().getDateFormat().format(mItem.getDate());
      ((TextView) rootView.findViewById(R.id.articleDateDetail)).setText(date);
      ((TextView) rootView.findViewById(R.id.articleContentDetail)).setText(mItem.getContent());

      FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.fabRead);
      fab.setSelected(mItem.getRead());
      fab.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              boolean val = !mItem.getRead();
              mItem.setRead(val);

              Snackbar.make(
                      v,
                      val
                          ? R.string.snackbar_message_mark_read
                          : R.string.snackbar_message_unmark_read,
                      Snackbar.LENGTH_SHORT)
                  .show();
              v.setSelected(val);

              ArticleDAO.getInstance().updateReadState(mItem);
            }
          });
    }

    // Prevent from exception when toolbar is half-way collapsed and a touch is made on image
    final CollapsingToolbarLayout collapsingToolbarLayout =
        (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setOnTouchListener(
        new View.OnTouchListener() {
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    return rootView;
  }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      long movieId = ContentUris.parseId(mUri);
      title = data.getString(COL_MOVIE_TITLE);
      // fetch meta data from async task
      new TmdbApiTask(getActivity(), textView_runtime).execute(String.valueOf(movieId));

      // fetch trailer list
      new TmdbApiTask(
              getActivity(),
              listView_trailers,
              Constants.FETCH_VIDEOS,
              new TmdbApiTask.AsyncResponse() {
                @Override
                public void processFinish(String result) {
                  listView_trailers.setEmptyView(textView_empty_trailer_list);
                  if (mShareActionProvider != null) {
                    Intent shareIntent = createShareVideoIntent(result);
                    mShareActionProvider.setShareIntent(shareIntent);
                  }
                }
              })
          .execute(String.valueOf(movieId));

      // fetch reviews list
      new TmdbApiTask(
              getActivity(),
              linearListView,
              Constants.FETCH_REVIEWS,
              new TmdbApiTask.AsyncResponse() {
                @Override
                public void processFinish(String str) {
                  progressBar.setVisibility(View.GONE);
                  linearListView.setEmptyView(textView_empty_list_item);
                }
              })
          .execute(String.valueOf(movieId));

      if (getActivity().findViewById(R.id.gridView_tiles) == null) {
        // single pane
        getActivity().setTitle(title);
      }

      String year = data.getString(COL_MOVIE_DATE);

      textView_release_year.setText(title + " \n\n" + Utility.getYear(year));

      String overview = data.getString(COL_MOVIE_SYNOPSIS);
      textView_overview.setText(overview);

      String rating = data.getString(COL_MOVIE_RATING);
      textView_vote_average.setText(rating + "/10");

      String poster = data.getString(COL_MOVIE_POSTER);

      imageView_poster_detail.setContentDescription(title);
      Picasso.with(getContext())
          .load(Utility.getPoster_path(Constants.DEFAULT_POSTER_WIDTH, poster))
          .into(imageView_poster_detail);

      Boolean fav = data.getInt(COL_MOVIE_FAV) > 0;
      if (fav) {
        myFab.setSelected(true);
        myFab.setImageResource(R.drawable.ic_favorite_black_24dp);
      } else {
        myFab.setSelected(false);
        myFab.setImageResource(R.drawable.ic_favorite_border_black_24dp);
      }
    }
  }