Ejemplo n.º 1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity());
    backgroundManager.attach(getActivity().getWindow());
    mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager);

    mDefaultBackground = getResources().getDrawable(R.drawable.amphitheatre);

    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);

    Video video = (Video) getActivity().getIntent().getSerializableExtra(Constants.VIDEO);

    if (video.isMovie()) {
      new DetailRowBuilderTask(getActivity(), this).execute(video);
    } else {
      List<Video> videos =
          Select.from(Video.class)
              .where(Condition.prop("name").eq(video.getName()), Condition.prop("is_movie").eq(0))
              .list();

      Map<String, List<Video>> groups =
          new TreeMap<String, List<Video>>(Collections.reverseOrder());

      for (Video vid : videos) {
        // if an Episode item exists then categorize it
        // otherwise, add it to the uncategorized list
        if (vid.getTvShow() != null && vid.getTvShow().getEpisode() != null) {
          int seasonNumber = vid.getTvShow().getEpisode().getSeasonNumber();
          String key = String.format(getString(R.string.season_number), seasonNumber);

          if (groups.containsKey(key)) {
            List<Video> subVideos = groups.get(key);
            subVideos.add(vid);
          } else {
            List<Video> list = new ArrayList<Video>();
            list.add(vid);
            groups.put(key, list);
          }
        } else {
          String key = getString(R.string.uncategorized);

          if (groups.containsKey(key)) {
            groups.get(key).add(vid);
          } else {
            List<Video> list = new ArrayList<Video>();
            list.add(vid);
            groups.put(key, list);
          }
        }
      }

      new DetailRowBuilderTask(getActivity(), groups, this).execute(video);
    }

    setOnItemClickedListener(getDefaultItemClickedListener());
    updateBackground(video.getBackgroundImageUrl());
  }
 private void prepareBackgroundManager() {
   mBackgroundManager = BackgroundManager.getInstance(getActivity());
   mBackgroundManager.attach(getActivity().getWindow());
   mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
   mMetrics = new DisplayMetrics();
   getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
 }
 public void prepareBackgroundManager() {
   mBackgroundManager = BackgroundManager.getInstance(mActivity);
   mBackgroundManager.attach(mActivity.getWindow());
   mBackgroundTarget = new PicassoBackgroundManagerTarget(mBackgroundManager);
   mDefaultBackground = ContextCompat.getDrawable(mActivity, R.drawable.default_background);
   mMetrics = new DisplayMetrics();
   mActivity.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
 }
Ejemplo n.º 4
0
 private void prepareBackgroundManager() {
   mBackgroundManager = BackgroundManager.getInstance(getActivity());
   mBackgroundManager.attach(getActivity().getWindow());
   mDefaultBackground = new ColorDrawable(ContextCompat.getColor(getActivity(), R.color.bg_grey));
   mBackgroundManager.setColor(ContextCompat.getColor(getActivity(), R.color.bg_grey));
   mMetrics = new DisplayMetrics();
   getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "onCreate DetailsFragment");
    super.onCreate(savedInstanceState);

    BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity());
    backgroundManager.attach(getActivity().getWindow());
    mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager);

    mDefaultBackground = getResources().getDrawable(R.drawable.default_background);

    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);

    selectedMovie = (Movie) getActivity().getIntent().getSerializableExtra(MOVIE);
    new DetailRowBuilderTask().execute(selectedMovie);

    setOnItemClickedListener(getDefaultItemClickedListener());
    updateBackground(selectedMovie.getBackgroundImageURI());
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    PicassoBackgroundManagerTarget that = (PicassoBackgroundManagerTarget) o;

    if (!mBackgroundManager.equals(that.mBackgroundManager)) return false;

    return true;
  }
 public void release() {
   mHandler.removeCallbacksAndMessages(null);
   mBackgroundManager.release();
 }
 protected void clearBackground() {
   BackgroundManager.getInstance(mActivity).setDrawable(mDefaultBackground);
 }
 protected void updateBackground(Drawable drawable) {
   BackgroundManager.getInstance(mActivity).setDrawable(drawable);
 }
 @Override
 public int hashCode() {
   return mBackgroundManager.hashCode();
 }
Ejemplo n.º 11
0
 @Override
 public void onStop() {
   super.onStop();
   mBackgroundManager.release();
   mIsStopping = true;
 }
 @Override
 public void onStop() {
   mBackgroundManager.release();
   super.onStop();
 }