// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_movies);
// 
//         initializeToolBar();
// 
//         if (savedInstanceState == null) {
//             showDetailFragment();
//         }
//     }
// 
//     private void showDetailFragment() {
//         MoviesFragment fragment = new MoviesFragment();
// 
//         getSupportFragmentManager().beginTransaction()
//                 .add(R.id.movies_list_container, fragment)
//                 .commit();
//     }
// 
//     private void initializeToolBar() {
//         Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//         setSupportActionBar(toolbar);
//     }
// }
// 
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
//         extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
// 
//     public interface OnMovieClickListener {
//         void onItemClick(View view, Movie movie);
//     }
// 
//     private OnMovieClickListener onMovieClickListener;
// 
//     public List<Movie> movies = new ArrayList<>();
// 
//     public void setMovies(List<Movie> movies) {
//         this.movies = movies;
//         notifyDataSetChanged();
//     }
// 
//     public void clearMovies() {
//         movies = new ArrayList<>();
//         notifyDataSetChanged();
//     }
// 
//     public void setOnMovieClickListener(OnMovieClickListener listener) {
//         onMovieClickListener = listener;
//     }
// 
//     @Override
//     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View view = LayoutInflater.from(parent.getContext())
//                 .inflate(R.layout.item_movies, parent, false);
// 
//         return new ViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(final ViewHolder holder, final int position) {
//         holder.movieItem = movies.get(position);
// 
//         Picasso.with(holder.movieImageView.getContext())
//                 .load(holder.movieItem.getImage())
//                 .into(holder.movieImageView);
// 
//         holder.titleTextView.setText(holder.movieItem .getTitle());
// 
//         holder.itemView.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View view) {
//                 Movie clickedItem = movies.get(position);
// 
//                 onMovieClickListener.onItemClick(view, clickedItem);
//             }
//         });
//     }
// 
//     @Override
//     public int getItemCount() {
//         return movies.size();
//     }
// 
//     public class ViewHolder extends RecyclerView.ViewHolder {
//         public final ImageView movieImageView;
//         public final TextView titleTextView;
// 
//         public Movie movieItem;
// 
//         public ViewHolder(View view) {
//             super(view);
// 
//             movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
//             titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
//         }
//     }
// }
// 
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/util/idlingresource/ProgressbarIdlingResource.java
// public class ProgressbarIdlingResource implements IdlingResource {
// 
//     private Activity activity;
//     private ResourceCallback callback;
// 
//     public ProgressbarIdlingResource(Activity activity){
//         this.activity = activity;
//     }
// 
//     @Override
//     public String getName() {
//         return "ProgressbarIdlingResource";
//     }
// 
//     @Override
//     public boolean isIdleNow() {
// 
//         View view = activity.findViewById(R.id.pb_loading);
// 
//         boolean loadingHide = !view.isShown();
// 
//         if (loadingHide)
//             callback.onTransitionToIdle();
// 
//         return loadingHide;
//     }
// 
//     @Override
//     public void registerIdleTransitionCallback(ResourceCallback callback) {
//         this.callback = callback;
//     }
// }


import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import android.graphics.drawable.Drawable;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
import com.xurxodev.moviesandroidkata.util.idlingresource.ProgressbarIdlingResource;
package com.xurxodev.moviesandroidkata.robot;





public class MoviesRobot {
    private MoviesActivity activity;
    RecyclerView recyclerView;
    ProgressbarIdlingResource progressbarIdlingResource;

    public MoviesRobot(MoviesActivity activity) {
        this.activity = activity;
        this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/activity/MoviesActivity.java
// public class MoviesActivity extends AppCompatActivity {
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_movies);
// 
//         initializeToolBar();
// 
//         if (savedInstanceState == null) {
//             showDetailFragment();
//         }
//     }
// 
//     private void showDetailFragment() {
//         MoviesFragment fragment = new MoviesFragment();
// 
//         getSupportFragmentManager().beginTransaction()
//                 .add(R.id.movies_list_container, fragment)
//                 .commit();
//     }
// 
//     private void initializeToolBar() {
//         Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
//         setSupportActionBar(toolbar);
//     }
// }
// 
// Path: app/src/main/java/com/xurxodev/moviesandroidkata/presentation/view/adapter/MoviesAdapter.java
// public class MoviesAdapter
//         extends RecyclerView.Adapter<MoviesAdapter.ViewHolder> {
// 
//     public interface OnMovieClickListener {
//         void onItemClick(View view, Movie movie);
//     }
// 
//     private OnMovieClickListener onMovieClickListener;
// 
//     public List<Movie> movies = new ArrayList<>();
// 
//     public void setMovies(List<Movie> movies) {
//         this.movies = movies;
//         notifyDataSetChanged();
//     }
// 
//     public void clearMovies() {
//         movies = new ArrayList<>();
//         notifyDataSetChanged();
//     }
// 
//     public void setOnMovieClickListener(OnMovieClickListener listener) {
//         onMovieClickListener = listener;
//     }
// 
//     @Override
//     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//         View view = LayoutInflater.from(parent.getContext())
//                 .inflate(R.layout.item_movies, parent, false);
// 
//         return new ViewHolder(view);
//     }
// 
//     @Override
//     public void onBindViewHolder(final ViewHolder holder, final int position) {
//         holder.movieItem = movies.get(position);
// 
//         Picasso.with(holder.movieImageView.getContext())
//                 .load(holder.movieItem.getImage())
//                 .into(holder.movieImageView);
// 
//         holder.titleTextView.setText(holder.movieItem .getTitle());
// 
//         holder.itemView.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View view) {
//                 Movie clickedItem = movies.get(position);
// 
//                 onMovieClickListener.onItemClick(view, clickedItem);
//             }
//         });
//     }
// 
//     @Override
//     public int getItemCount() {
//         return movies.size();
//     }
// 
//     public class ViewHolder extends RecyclerView.ViewHolder {
//         public final ImageView movieImageView;
//         public final TextView titleTextView;
// 
//         public Movie movieItem;
// 
//         public ViewHolder(View view) {
//             super(view);
// 
//             movieImageView = (ImageView) view.findViewById(R.id.item_movie_poster);
//             titleTextView = (TextView) view.findViewById(R.id.item_movie_title);
//         }
//     }
// }
// 
// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/util/idlingresource/ProgressbarIdlingResource.java
// public class ProgressbarIdlingResource implements IdlingResource {
// 
//     private Activity activity;
//     private ResourceCallback callback;
// 
//     public ProgressbarIdlingResource(Activity activity){
//         this.activity = activity;
//     }
// 
//     @Override
//     public String getName() {
//         return "ProgressbarIdlingResource";
//     }
// 
//     @Override
//     public boolean isIdleNow() {
// 
//         View view = activity.findViewById(R.id.pb_loading);
// 
//         boolean loadingHide = !view.isShown();
// 
//         if (loadingHide)
//             callback.onTransitionToIdle();
// 
//         return loadingHide;
//     }
// 
//     @Override
//     public void registerIdleTransitionCallback(ResourceCallback callback) {
//         this.callback = callback;
//     }
// }


// Path: app/src/androidTest/java/com/xurxodev/moviesandroidkata/robot/MoviesRobot.java
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.CoreMatchers.not;
import android.graphics.drawable.Drawable;
import android.support.test.espresso.Espresso;
import android.support.test.espresso.contrib.RecyclerViewActions;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.widget.ProgressBar;
import com.xurxodev.moviesandroidkata.R;
import com.xurxodev.moviesandroidkata.presentation.view.activity.MoviesActivity;
import com.xurxodev.moviesandroidkata.presentation.view.adapter.MoviesAdapter;
import com.xurxodev.moviesandroidkata.util.idlingresource.ProgressbarIdlingResource;

package com.xurxodev.moviesandroidkata.robot;





public class MoviesRobot {
    private MoviesActivity activity;
    RecyclerView recyclerView;
    ProgressbarIdlingResource progressbarIdlingResource;

    public MoviesRobot(MoviesActivity activity) {
        this.activity = activity;
        this.recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerview_movies);
        this.progressbarIdlingResource = new ProgressbarIdlingResource(activity);