butterknife view binding
This commit is contained in:
@@ -17,6 +17,14 @@ android {
|
|||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lintOptions {
|
||||||
|
disable 'InvalidPackage'
|
||||||
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
exclude 'META-INF/services/javax.annotation.processing.Processor'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -29,4 +37,6 @@ dependencies {
|
|||||||
compile 'com.squareup.picasso:picasso:2.5.2'
|
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||||
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
|
compile 'com.squareup.retrofit:retrofit:2.0.0-beta2'
|
||||||
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
|
compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
|
||||||
|
|
||||||
|
compile 'com.jakewharton:butterknife:7.0.1'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ import android.widget.TextView;
|
|||||||
import net.headlezz.udacityproject1.tmdbapi.Movie;
|
import net.headlezz.udacityproject1.tmdbapi.Movie;
|
||||||
import net.headlezz.udacityproject1.tmdbapi.TMDBApi;
|
import net.headlezz.udacityproject1.tmdbapi.TMDBApi;
|
||||||
|
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment to show the details of a movie
|
* Fragment to show the details of a movie
|
||||||
*/
|
*/
|
||||||
@@ -22,11 +25,11 @@ public class MovieDetailsFragment extends Fragment {
|
|||||||
public static final String TAG = MovieDetailsFragment.class.getSimpleName();
|
public static final String TAG = MovieDetailsFragment.class.getSimpleName();
|
||||||
public static final String BUNDLE_ARG_MOVIE = "movie";
|
public static final String BUNDLE_ARG_MOVIE = "movie";
|
||||||
|
|
||||||
ImageView ivPoster;
|
@Bind(R.id.movie_details_ivPoster) ImageView ivPoster;
|
||||||
TextView tvTitle;
|
@Bind(R.id.movie_details_tvTitle) TextView tvTitle;
|
||||||
TextView tvOverview;
|
@Bind(R.id.movie_details_tvOverview) TextView tvOverview;
|
||||||
TextView tvReleaseDate;
|
@Bind(R.id.movie_details_tvReleaseDate) TextView tvReleaseDate;
|
||||||
TextView tvRating;
|
@Bind(R.id.movie_details_tvRating) TextView tvRating;
|
||||||
|
|
||||||
Movie mMovie;
|
Movie mMovie;
|
||||||
|
|
||||||
@@ -52,11 +55,7 @@ public class MovieDetailsFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_movie_details, container, false);
|
View view = inflater.inflate(R.layout.fragment_movie_details, container, false);
|
||||||
ivPoster = (ImageView) view.findViewById(R.id.movie_details_ivPoster);
|
ButterKnife.bind(this, view);
|
||||||
tvTitle = (TextView) view.findViewById(R.id.movie_details_tvTitle);
|
|
||||||
tvOverview = (TextView) view.findViewById(R.id.movie_details_tvOverview);
|
|
||||||
tvReleaseDate = (TextView) view.findViewById(R.id.movie_details_tvReleaseDate);
|
|
||||||
tvRating = (TextView) view.findViewById(R.id.movie_details_tvRating);
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import android.widget.Toast;
|
|||||||
import net.headlezz.udacityproject1.tmdbapi.MovieList;
|
import net.headlezz.udacityproject1.tmdbapi.MovieList;
|
||||||
import net.headlezz.udacityproject1.tmdbapi.TMDBApi;
|
import net.headlezz.udacityproject1.tmdbapi.TMDBApi;
|
||||||
|
|
||||||
|
import butterknife.Bind;
|
||||||
|
import butterknife.ButterKnife;
|
||||||
import retrofit.Call;
|
import retrofit.Call;
|
||||||
import retrofit.Callback;
|
import retrofit.Callback;
|
||||||
import retrofit.Response;
|
import retrofit.Response;
|
||||||
@@ -44,8 +46,8 @@ public class MovieListFragment extends Fragment implements Callback<MovieList> {
|
|||||||
|
|
||||||
private MovieList mMovieList;
|
private MovieList mMovieList;
|
||||||
|
|
||||||
RecyclerView mMovieGridView;
|
@Bind(R.id.movie_list_grid) RecyclerView mMovieGridView;
|
||||||
ProgressBar mProgressBar;
|
@Bind(R.id.movie_list_progressBar) ProgressBar mProgressBar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holding a reference to running api calls. This makes it possible to cancel them if
|
* Holding a reference to running api calls. This makes it possible to cancel them if
|
||||||
@@ -62,8 +64,7 @@ public class MovieListFragment extends Fragment implements Callback<MovieList> {
|
|||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_movie_list, container, false);
|
View view = inflater.inflate(R.layout.fragment_movie_list, container, false);
|
||||||
mMovieGridView = (RecyclerView) view.findViewById(R.id.movie_list_grid);
|
ButterKnife.bind(this, view);
|
||||||
mProgressBar = (ProgressBar) view.findViewById(R.id.movie_list_progressBar);
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user