Skip to content
This repository was archived by the owner on Oct 27, 2024. It is now read-only.

1. Added ButterKnife 2. Updated gradle #3

Merged
merged 1 commit into from
Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dependencies {
compile 'net.jcip:jcip-annotations:1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.moshi:moshi:1.1.0'
compile 'com.jakewharton:butterknife:7.0.1'

// Dependency Injection
apt 'com.google.dagger:dagger-compiler:2.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@

import javax.inject.Inject;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.esoxjem.movieguide.R.id.trailers_label;

/**
* A simple {@link Fragment} subclass.
*/
Expand All @@ -41,18 +47,34 @@ public class MovieDetailsFragment extends Fragment implements IMovieDetailsView,
@Inject
IMovieDetailsPresenter movieDetailsPresenter;

private ImageView poster;
private TextView title;
private TextView releaseDate;
private TextView rating;
private TextView overview;
private TextView label;
private HorizontalScrollView horizontalScrollView;
private LinearLayout trailers;
private TextView reviews;
private LinearLayout reviewsContainer;
private FloatingActionButton favorite;
private Movie movie;
@Bind(R.id.movie_poster)
ImageView poster;
@Bind(R.id.movie_name)
TextView title;
@Bind(R.id.movie_year)
TextView releaseDate;
@Bind(R.id.movie_rating)
TextView rating;
@Bind(R.id.movie_description)
TextView overview;
@Bind(trailers_label)
TextView label;
@Bind(R.id.trailers_container)
HorizontalScrollView horizontalScrollView;
@Bind(R.id.trailers)
LinearLayout trailers;
@Bind(R.id.reviews_label)
TextView reviews;
@Bind(R.id.reviews)
LinearLayout reviewsContainer;
@Bind(R.id.favorite)
FloatingActionButton favorite;
@Bind(R.id.toolbar)
Toolbar toolbar;
@Bind(R.id.collapsing_toolbar)
CollapsingToolbarLayout collapsingToolbarLayout;

Movie movie;

public MovieDetailsFragment()
{
Expand Down Expand Up @@ -82,8 +104,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View rootView = inflater.inflate(R.layout.fragment_movie_details, container, false);
setToolbar(rootView);
initLayoutReferences(rootView);
ButterKnife.bind(this, rootView);
setToolbar();
return rootView;
}

Expand All @@ -103,33 +125,14 @@ public void onViewCreated(View view, Bundle savedInstanceState)
}
}

private void initLayoutReferences(View rootView)
{
poster = (ImageView) rootView.findViewById(R.id.movie_poster);
title = (TextView) rootView.findViewById(R.id.movie_name);
releaseDate = (TextView) rootView.findViewById(R.id.movie_year);
rating = (TextView) rootView.findViewById(R.id.movie_rating);
overview = (TextView) rootView.findViewById(R.id.movie_description);
label = (TextView) rootView.findViewById(R.id.trailers_label);
horizontalScrollView = (HorizontalScrollView) rootView.findViewById(R.id.trailers_container);
trailers = (LinearLayout) rootView.findViewById(R.id.trailers);
reviews = (TextView) rootView.findViewById(R.id.reviews_label);
reviewsContainer = (LinearLayout) rootView.findViewById(R.id.reviews);
favorite = (FloatingActionButton) rootView.findViewById(R.id.favorite);
favorite.setOnClickListener(this);
}

private void setToolbar(View rootView)
private void setToolbar()
{
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) rootView.findViewById(R.id.collapsing_toolbar);

collapsingToolbarLayout.setContentScrimColor(getResources().getColor(R.color.colorPrimary));
collapsingToolbarLayout.setTitle(getString(R.string.movie_details));
collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.CollapsedToolbar);
collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.ExpandedToolbar);
collapsingToolbarLayout.setTitleEnabled(true);

Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
if (toolbar != null)
{
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
Expand Down Expand Up @@ -245,6 +248,12 @@ public void showUnFavorited()
}
}

@OnClick(R.id.favorite)
public void onFavouriteClicked()
{
onFavoriteClick();
}

@Override
public void onClick(View view)
{
Expand All @@ -258,10 +267,6 @@ public void onClick(View view)
onReviewClick((TextView) view);
break;

case R.id.favorite:
onFavoriteClick();
break;

default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@
import com.esoxjem.movieguide.details.MovieDetailsFragment;
import com.esoxjem.movieguide.Movie;

import butterknife.Bind;
import butterknife.ButterKnife;

public class MoviesListingActivity extends AppCompatActivity implements MoviesListingFragment.Callback
{
public static final String DETAILS_FRAGMENT = "DetailsFragment";
private boolean twoPaneMode;

@Bind(R.id.toolbar)
Toolbar toolbar;

@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
setToolbar();

if (findViewById(R.id.movie_details_container) != null)
Expand All @@ -42,7 +49,6 @@ protected void onCreate(Bundle savedInstanceState)

private void setToolbar()
{
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

if (getSupportActionBar() != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import javax.inject.Inject;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
* @author arun
*/
Expand All @@ -25,7 +28,15 @@ public class SortingDialogFragment extends DialogFragment implements ISortingDia
@Inject
ISortingDialogPresenter sortingDialogPresenter;

private RadioGroup sortingOptionsGroup;
@Bind(R.id.most_popular)
RadioButton mostPopular;
@Bind(R.id.highest_rated)
RadioButton highestRated;
@Bind(R.id.favorites)
RadioButton favorites;
@Bind(R.id.sorting_group)
RadioGroup sortingOptionsGroup;

private static IMoviesListingPresenter moviesListingPresenter;

public static SortingDialogFragment newInstance(IMoviesListingPresenter moviesListingPresenter)
Expand All @@ -49,7 +60,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
{
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.sorting_options, null);
initViews(dialogView);
ButterKnife.bind(this, dialogView);
initViews();

Dialog dialog = new Dialog(getActivity());
dialog.setContentView(dialogView);
Expand All @@ -58,31 +70,27 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
return dialog;
}

private void initViews(View dialogView)
private void initViews()
{
sortingOptionsGroup = (RadioGroup) dialogView.findViewById(R.id.sorting_group);
sortingDialogPresenter.setLastSavedOption();
sortingOptionsGroup.setOnCheckedChangeListener(this);
}

@Override
public void setPopularChecked()
{
RadioButton popular = (RadioButton) sortingOptionsGroup.findViewById(R.id.most_popular);
popular.setChecked(true);
mostPopular.setChecked(true);
}

@Override
public void setHighestRatedChecked()
{
RadioButton highestRated = (RadioButton) sortingOptionsGroup.findViewById(R.id.highest_rated);
highestRated.setChecked(true);
}

@Override
public void setFavoritesChecked()
{
RadioButton favorites = (RadioButton) sortingOptionsGroup.findViewById(R.id.favorites);
favorites.setChecked(true);
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.android.tools.build:gradle:2.2.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down