Android Open Source - UpcomingMoviesMVP Movie Details Fragment






From Project

Back to project page UpcomingMoviesMVP.

License

The source code is released under:

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Defi...

If you think the Android project UpcomingMoviesMVP listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.jlmd.android.newfilmsmvp.ui.fragment;
//from ww  w  . jav  a  2s .  c o m
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jlmd.android.newfilmsmvp.R;
import com.jlmd.android.newfilmsmvp.domain.formatter.GenresFormatter;
import com.jlmd.android.newfilmsmvp.domain.model.Image;
import com.jlmd.android.newfilmsmvp.domain.model.Movie;
import com.jlmd.android.newfilmsmvp.domain.model.MovieDetails;
import com.jlmd.android.newfilmsmvp.mvp.presenter.MovieDetailsPresenter;
import com.jlmd.android.newfilmsmvp.mvp.view.MovieDetailsView;
import com.jlmd.android.newfilmsmvp.utils.Constants;
import com.squareup.picasso.Picasso;

import javax.inject.Inject;

import butterknife.InjectView;

/**
 * @author jlmd
 */
public class MovieDetailsFragment extends BaseFragment implements MovieDetailsView {

    @Inject
    protected MovieDetailsPresenter movieDetails;

    @InjectView(R.id.iv_backdrop_image)
    protected ImageView ivBackDrop;
    @InjectView(R.id.tv_title)
    protected TextView tvTitle;
    @InjectView(R.id.tv_genres)
    protected TextView tvGenres;
    @InjectView(R.id.tv_description)
    protected TextView tvDescription;

    private static final String TAG = MovieDetailsFragment.class.getName();

    public static MovieDetailsFragment newInstance(Movie movie) {
        MovieDetailsFragment movieDetailsFragment = new MovieDetailsFragment();
        Bundle bundle = new Bundle();
        bundle.putParcelable(Constants.KEY_MOVIE_DETAILS, movie);
        movieDetailsFragment.setArguments(bundle);
        return movieDetailsFragment;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initPresenter();
        movieDetails.onMovieReceive(getMovie());
    }

    private void initPresenter() {
        movieDetails.setView(this);
        movieDetails.initialize();
    }

    private Movie getMovie() {
        return getArguments().getParcelable(Constants.KEY_MOVIE_DETAILS);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_movie_details, container, false);
    }

    @Override
    public void showLoading() {
        // Empty
    }

    @Override
    public void hideLoading() {
        // Empty
    }

    @Override
    public void renderMovie(MovieDetails movieDetails) {
       Picasso.with(getActivity().getApplicationContext())
            .load(getImageUrl(movieDetails.getMovie().getBackdropImage()))
            .into(ivBackDrop);
        tvTitle.setText(movieDetails.getMovie().getTitle());
        tvGenres.setText(new GenresFormatter().format(movieDetails.getGenres()));
        tvDescription.setText(movieDetails.getMovie().getOverview());
    }

    private String getImageUrl(Image image) {
        return isLandscape() ? image.getHighResolutionImgUrl() : image.getLowResolutionImgUrl();
    }

    private boolean isLandscape() {
        return getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
    }

}




Java Source Code List

com.jlmd.android.newfilmsmvp.ApplicationTest.java
com.jlmd.android.newfilmsmvp.api.mapper.Mapper.java
com.jlmd.android.newfilmsmvp.api.mapper.MovieDetailsMapper.java
com.jlmd.android.newfilmsmvp.api.mapper.UpcomingMoviesMapper.java
com.jlmd.android.newfilmsmvp.api.mock.MockedMovieDetailsApi.java
com.jlmd.android.newfilmsmvp.api.mock.MockedUpcomingMoviesApi.java
com.jlmd.android.newfilmsmvp.api.moviedetails.MovieDetailsApi.java
com.jlmd.android.newfilmsmvp.api.moviedetails.model.BelongsToCollection.java
com.jlmd.android.newfilmsmvp.api.moviedetails.model.Genre.java
com.jlmd.android.newfilmsmvp.api.moviedetails.model.MovieDetailsResult.java
com.jlmd.android.newfilmsmvp.api.moviedetails.model.ProductionCompany.java
com.jlmd.android.newfilmsmvp.api.moviedetails.model.ProductionCountry.java
com.jlmd.android.newfilmsmvp.api.moviedetails.model.SpokenLanguage.java
com.jlmd.android.newfilmsmvp.api.retrofit.moviedetails.MovieDetailsService.java
com.jlmd.android.newfilmsmvp.api.retrofit.moviedetails.RetrofitMovieDetailsApi.java
com.jlmd.android.newfilmsmvp.api.retrofit.upcomingmovies.RetrofitUpcomingMoviesApi.java
com.jlmd.android.newfilmsmvp.api.retrofit.upcomingmovies.UpcomingMoviesService.java
com.jlmd.android.newfilmsmvp.api.upcomingmovies.UpcomingMoviesApi.java
com.jlmd.android.newfilmsmvp.api.upcomingmovies.model.Dates.java
com.jlmd.android.newfilmsmvp.api.upcomingmovies.model.Result.java
com.jlmd.android.newfilmsmvp.api.upcomingmovies.model.UpcomingMoviesResult.java
com.jlmd.android.newfilmsmvp.bus.event.MovieSelectedEvent.java
com.jlmd.android.newfilmsmvp.di.AppApplication.java
com.jlmd.android.newfilmsmvp.di.module.ComparatorModule.java
com.jlmd.android.newfilmsmvp.di.module.PresenterModule.java
com.jlmd.android.newfilmsmvp.di.module.RepositoryModule.java
com.jlmd.android.newfilmsmvp.di.module.RootModule.java
com.jlmd.android.newfilmsmvp.domain.comparator.MovieDateComparator.java
com.jlmd.android.newfilmsmvp.domain.comparator.MovieTitleComparator.java
com.jlmd.android.newfilmsmvp.domain.formatter.Formatter.java
com.jlmd.android.newfilmsmvp.domain.formatter.GenresFormatter.java
com.jlmd.android.newfilmsmvp.domain.formatter.RatingFormatter.java
com.jlmd.android.newfilmsmvp.domain.formatter.ReleaseDateFormatter.java
com.jlmd.android.newfilmsmvp.domain.model.Image.java
com.jlmd.android.newfilmsmvp.domain.model.MovieDetails.java
com.jlmd.android.newfilmsmvp.domain.model.Movie.java
com.jlmd.android.newfilmsmvp.mvp.presenter.MovieDetailsPresenterImp.java
com.jlmd.android.newfilmsmvp.mvp.presenter.MovieDetailsPresenter.java
com.jlmd.android.newfilmsmvp.mvp.presenter.MoviesListPresenterImp.java
com.jlmd.android.newfilmsmvp.mvp.presenter.MoviesListPresenter.java
com.jlmd.android.newfilmsmvp.mvp.presenter.Presenter.java
com.jlmd.android.newfilmsmvp.mvp.view.MovieDetailsView.java
com.jlmd.android.newfilmsmvp.mvp.view.MoviesListView.java
com.jlmd.android.newfilmsmvp.mvp.view.View.java
com.jlmd.android.newfilmsmvp.ui.activity.BaseActivity.java
com.jlmd.android.newfilmsmvp.ui.activity.MainActivity.java
com.jlmd.android.newfilmsmvp.ui.activity.MovieDetailsActivity.java
com.jlmd.android.newfilmsmvp.ui.adapter.BaseRecyclerViewHolder.java
com.jlmd.android.newfilmsmvp.ui.adapter.MoviesListRecyclerAdapter.java
com.jlmd.android.newfilmsmvp.ui.fragment.BaseFragment.java
com.jlmd.android.newfilmsmvp.ui.fragment.MovieDetailsFragment.java
com.jlmd.android.newfilmsmvp.ui.fragment.MoviesListFragment.java
com.jlmd.android.newfilmsmvp.ui.view.ClickItemTouchListener.java
com.jlmd.android.newfilmsmvp.ui.view.ClickRecyclerView.java
com.jlmd.android.newfilmsmvp.utils.Constants.java
com.jlmd.android.newfilmsmvp.utils.Utils.java