Ronan Ronan - 2 months ago 33
Android Question

Image not loading with Picasso using Rx Observable and Retrofit2

I am learning RxJava (Observable) and Retrofit2. I landed in a situation where the Picasso is not loading the images from the URL. Details below:

public class IntentKeys {
public static final long INTERCEPTOR_TIMEOUT = 15;
public static final String POPULAR_MOVIES_SERVICE_ENDPOINT = "http://api.themoviedb.org/3/";
public static final String POPULAR_MOVIES_POSTER_ENDPOINT = "http://image.tmdb.org/t/p/w300/";
public static final String POPULAR_MOVIES_API_KEY = "key";

}


The Recyclerview adapter:

public class GridViewAdapter extends RecyclerView.Adapter<GridViewAdapter.GridVieHolder> {

private static final String TAG = GridViewAdapter.class.getSimpleName();
private static final int SPAN_COUNT = 2;
private static final float THUMBNAIL_RATIO = 1.5f;
private List<Result> movies = new ArrayList<>();
private Context context;

public GridViewAdapter(List<Result> movies, Context context) {
this.movies = movies;
this.context = context;
}

@Override
public GridVieHolder onCreateViewHolder(ViewGroup parent, int viewType) {

View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.movies_grid_view, parent, false);
// view.getLayoutParams().height = (int) (parent.getWidth() / SPAN_COUNT * THUMBNAIL_RATIO);
return new GridVieHolder(view);
}

@Override
public void onBindViewHolder(GridVieHolder holder, int position) {

GridVieHolder posterHolder = (GridVieHolder) holder;
posterHolder.bind(movies.get(position));

/* Result popularMovies = movies.get(position);
String moviePoster = popularMovies.getPosterPath();
String moviePosterUrl = IntentKeys.POPULAR_MOVIES_POSTER_ENDPOINT + moviePoster;

Picasso.with(context).load(moviePosterUrl.trim())
.config(Bitmap.Config.RGB_565)
.into(posters);*/
}

@Override
public int getItemCount() {
return movies.size();
}

public class GridVieHolder extends RecyclerView.ViewHolder {

ImageView posters;

public GridVieHolder(View itemView) {
super(itemView);

posters = (ImageView) itemView.findViewById(R.id.movies_poster_grid_view);
}

public void bind(final Result result) {


Uri uri = Uri.parse(IntentKeys.POPULAR_MOVIES_POSTER_ENDPOINT).buildUpon()
.appendPath(ImageSize.w185.getValue())
.appendPath(result.getPosterPath().replace("/", ""))
.build();
Picasso.with(itemView.getContext()).load(uri).into(posters);
}
}

}


Below, is how I have defined the service and retrofit manager:

public interface PopularMoviesService {
@GET("movie/popular")
Observable<Result> getPopularMovies(@Query("api_key") String apiKey);
}

public class PopularMoviesRetrofitManager {


private PopularMoviesService service;
private static Retrofit retrofit = null;

private static HttpLoggingInterceptor getLoggingInterceptor() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
return interceptor;
}

private static OkHttpClient getOkHttpClient(HttpLoggingInterceptor loggingInterceptor) {
return new OkHttpClient.Builder()
.addInterceptor(loggingInterceptor)
.connectTimeout(IntentKeys.INTERCEPTOR_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(IntentKeys.INTERCEPTOR_TIMEOUT, TimeUnit.SECONDS)
.build();
}

public static Retrofit getMoviesClient() {

OkHttpClient client = getOkHttpClient(getLoggingInterceptor());

if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(IntentKeys.POPULAR_MOVIES_SERVICE_ENDPOINT)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.client(client)
.build();
}
return retrofit;
}

}


Finally the adapter and the fragment classes. In the Activity class, I have the
getSupportFragmentManager()
to load the fragment.

public class GridViewAdapter extends RecyclerView.Adapter<GridViewAdapter.GridVieHolder> {

private static final String TAG = GridViewAdapter.class.getSimpleName();
private static final int SPAN_COUNT = 2;
private static final float THUMBNAIL_RATIO = 1.5f;
private List<Result> movies = new ArrayList<>();
private Context context;

public GridViewAdapter(List<Result> movies, Context context) {
this.movies = movies;
this.context = context;
}

@Override
public GridVieHolder onCreateViewHolder(ViewGroup parent, int viewType) {

View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.movies_grid_view, parent, false);
// view.getLayoutParams().height = (int) (parent.getWidth() / SPAN_COUNT * THUMBNAIL_RATIO);
return new GridVieHolder(view);
}

@Override
public void onBindViewHolder(GridVieHolder holder, int position) {

GridVieHolder posterHolder = (GridVieHolder) holder;
posterHolder.bind(movies.get(position));

/* Result popularMovies = movies.get(position);
String moviePoster = popularMovies.getPosterPath();
String moviePosterUrl = IntentKeys.POPULAR_MOVIES_POSTER_ENDPOINT + moviePoster;

Picasso.with(context).load(moviePosterUrl.trim())
.config(Bitmap.Config.RGB_565)
.into(posters);*/
}

@Override
public int getItemCount() {
return movies.size();
}

public class GridVieHolder extends RecyclerView.ViewHolder {

ImageView posters;

public GridVieHolder(View itemView) {
super(itemView);

posters = (ImageView) itemView.findViewById(R.id.movies_poster_grid_view);
}

public void bind(final Result result) {


Uri uri = Uri.parse(IntentKeys.POPULAR_MOVIES_POSTER_ENDPOINT).buildUpon()
.appendPath(ImageSize.w185.getValue())
.appendPath(result.getPosterPath().replace("/", ""))
.build();
Picasso.with(itemView.getContext()).load(uri).into(posters);
}
}

}

public class PopularMoviesFragment extends Fragment {

private static final String TAG = PopularMoviesFragment.class.getCanonicalName();
private GridViewAdapter gridViewAdapter;
private List<Result> resultItems = new ArrayList<>();;
private Subscription movieSubscription;
private RecyclerView recyclerView;
private PopularMoviesService service
= PopularMoviesRetrofitManager.getMoviesClient().create(PopularMoviesService.class);

public PopularMoviesFragment() {
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View view = inflater.inflate(R.layout.fragment_popular_movies, container, false);

recyclerView = (RecyclerView) view.findViewById(R.id.popular_movies_recycler_view);
recyclerView.setHasFixedSize(true);
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getContext(), 2);
recyclerView.setLayoutManager(layoutManager);

gridViewAdapter = new GridViewAdapter(resultItems, getContext());
recyclerView.setAdapter(gridViewAdapter);

return (view);
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}

@Override
public void onStart() {
super.onStart();
getMoviesSubscription();
}

private void getMoviesSubscription() {
movieSubscription = service.getPopularMovies(IntentKeys.POPULAR_MOVIES_API_KEY)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
new Action1<Result>() {
@Override
public void call(Result popularMovies) {

}

}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {

}
}, new Action0() {
@Override
public void call() {
displayPosters();
Log.i(TAG, "getMoviesSubscription: Completed");
}
}
);
}

@Override
public void onDestroyView() {
super.onDestroyView();
if (movieSubscription != null && movieSubscription.isUnsubscribed()) {
movieSubscription.unsubscribe();
}
}

private void displayPosters() {
gridViewAdapter = new GridViewAdapter(resultItems, getContext());
recyclerView.setAdapter(gridViewAdapter);
recyclerView.invalidate();
}

}


The problem is, the Picasso is not loading the images in a GridView from the API call. Any here would be highly appreciated.

Here is the JSON format:

{
"page":1,
"results":[
{
"poster_path":"\/5N20rQURev5CNDcMjHVUZhpoCNC.jpg",
"adult":false,
"overview":"Following the events of Age of Ultron, the collective governments of the world pass an act designed to regulate all superhuman activity. This polarizes opinion amongst the Avengers, causing two factions to side with Iron Man or Captain America, which causes an epic battle between former allies.",
"release_date":"2016-04-27",
"genre_ids":[
28,
53,
878
],
"id":271110,
"original_title":"Captain America: Civil War",
"original_language":"en",
"title":"Captain America: Civil War",
"backdrop_path":"\/rqAHkvXldb9tHlnbQDwOzRi0yVD.jpg",
"popularity":49.819238,
"vote_count":2787,
"video":false,
"vote_average":6.93
},
{
"poster_path":"\/e1mjopzAS2KNsvpbpahQ1a6SkSn.jpg",


Here,
poster_path
is where I should be getting the images from.

At last, I have the following console output. I do see that i am getting the response and its 200. As well as, I do get all the data in the response. Below is the console output.

I: Not late-enabling -Xcheck:jni (already on)
W: ClassLoader referenced unknown path: /data/app/com.example.mchapagai-1/lib/x86_64
W: ClassLoader referenced unknown path: /data/app/com.example.mchapagai-1/lib/x86_64
W: Suspending all threads took: 12.383ms
W: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
W: Suspending all threads took: 5.149ms
D: --> GET http://api.themoviedb.org/3/movie/popular?api_key=key http/1.1
D: --> END GET
D: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

[ 09-12 23:35:40.797 2740: 2740 D/ ]
HostConnection::get() New Host Connection established 0x7f351415d640, tid 2740


[ 09-12 23:35:40.878 2740: 2873 D/ ]
HostConnection::get() New Host Connection established 0x7f351819e3c0, tid 2873
I: Initialized EGL, version 1.4
D: <-- 200 OK http://api.themoviedb.org/3/movie/popular?api_key=key (176ms)
D: Access-Control-Allow-Origin: *
D: Cache-Control: public, max-age=21600
D: Content-Type: application/json;charset=utf-8
D: Date: Tue, 13 Sep 2016 03:35:41 GMT
D: Server: openresty
D: Vary: Accept-Encoding
D: X-RateLimit-Limit: 40
D: X-RateLimit-Remaining: 39
D: X-RateLimit-Reset: 1473737742
D: Connection: keep-alive
D: {"page":1,"results":[{"poster_path":"\/5N20rQURev5CNDcMjHVUZhpoCNC.jpg","adult":false,"overview":"Following the events of Age of Ultron, the collective governments of the world pass an act designed to regulate all superhuman activity. This polarizes opinion amongst the Avengers, causing two factions to side with Iron Man or Captain America, which causes an epic battle between former allies.","release_date":"2016-04-27","genre_ids":[28,53,878],"id":271110,"original_title":"Captain America: Civil War","original_language":"en","title":"Captain America: Civil War","backdrop_path":"\/rqAHkvXldb9tHlnbQDwOzRi0yVD.jpg","popularity":48.757871,"vote_count":2810,"video":false,"vote_average":6.92},{"poster_path":"\/e1mjopzAS2KNsvpbpahQ1a6SkSn.jpg","adult":false,"overview":"From DC Comics comes the Suicide Squad, an antihero team of incarcerated supervillains who act as deniable assets for the United States government, undertaking high-risk black ops missions in exchange for commuted prison sentences.","release_date":"2016-08-03","genre_ids":[28,80,14],"id":297761,"original_title":"Suicide Squad","original_language":"en","title":"Suicide Squad","backdrop_path":"\/ndlQ2Cuc3cjTL7lTynw6I4boP4S.jpg","popularity":31.917737,"vote_count":1792,"video":false,"vote_average":5.9},{"poster_path":"\/zSouWWrySXshPCT4t3UKCQGayyo.jpg","adult":false,"overview":"After the re-emergence of the world's first mutant, world-destroyer Apocalypse, the X-Men must unite to defeat his extinction level plan.","release_date":"2016-05-18","genre_ids":[28,12,14,878],"id":246655,"original_title":"X-Men: Apocalypse","original_language":"en","title":"X-Men: Apocalypse","backdrop_path":"\/oQWWth5AOtbWG9o8SCAviGcADed.jpg","popularity":25.105112,"vote_count":1735,"video":false,"vote_average":6.1},{"poster_path":"\/tgfRDJs5PFW20Aoh1orEzuxW8cN.jpg","adult":false,"overview":"Arthur Bishop thought he had put his murderous past behind him when his most formidable foe kidnaps the love of his life. Now he is forced to travel the globe to complete three impossible assassinations, and do what he does best, make them look like accidents.","release_date":"2016-08-25","genre_ids":[80,28,53],"id":278924,"original_title":"Mechanic: Resurrection","original_language":"en","title":"Mechanic: Resurrection","backdrop_path":"\/3oRHlbxMLBXHfMqUsx1emwqiuQ3.jpg","popularity":24.229983,"vote_count":244,"video":false,"vote_average":4.52},{"poster_path":"\/h28t2JNNGrZx0fIuAw8aHQFhIxR.jpg","adult":false,"overview":"A recently cheated on married woman falls for a younger man who has moved in next door, but their torrid affair soon takes a dangerous turn.","release_date":"2015-01-23","genre_ids":[53],"id":241251,"original_title":"The Boy Next Door","original_language":"en","title":"The Boy Next Door","backdrop_path":"\/vj4IhmH4HCMZYYjTMiYBybTWR5o.jpg","popularity":23.428895,"vote_count":704,"video":false,"vote_average":4.04},{"poster_path":"\/hU0E130tsGdsYa4K9lc3Xrn5Wyt.jpg","adult":false,"overview":"One year after outwitting the FBI and winning the public’s adulation with their mind-bending spectacles, the Four Horsemen resurface only to find themselves face to face with a new enemy who enlists them to pull off their most dangerous heist yet.","release_date":"2016-06-02","genre_ids":[28,12,35,80,9648,53],"id":291805,"original_title":"Now You See Me 2","original_language":"en","title":"Now You See Me 2","backdrop_path":"\/zrAO2OOa6s6dQMQ7zsUbDyIBrAP.jpg","popularity":20.653696,"vote_count":855,"video":false,"vote_average":6.63},{"poster_path":"\/vOipe2myi26UDwP978hsYOrnUWC.jpg","adult":false,"overview":"After a threat from the tiger Shere Khan forces him to flee the jungle, a man-cub named Mowgli embarks on a journey of self discovery with the help of panther, Bagheera, and free spirited bear, Baloo.","release_date":"2016-04-07","genre_ids":[12,18,14],"id":278927,"original_title":"The Jungle Book","original_language":"en","title":"The Jungle Book","backdrop_path":"\/eIOTsGg9FCVrBc4r2nXaV61JF4F.jpg","popul
D: arity":18.080481,"vote_count":1203,"video":false,"vote_average":6.35},{"poster_path":"\/lFSSLTlFozwpaGlO31OoUeirBgQ.jpg","adult":false,"overview":"The most dangerous former operative of the CIA is drawn out of hiding to uncover hidden truths about his past.","release_date":"2016-07-27","genre_ids":[28,53],"id":324668,"original_title":"Jason Bourne","original_language":"en","title":"Jason Bourne","backdrop_path":"\/AoT2YrJUJlg5vKE3iMOLvHlTd3m.jpg","popularity":17.155962,"vote_count":813,"video":false,"vote_average":5.4},{"poster_path":"\/cGOPbv9wA5gEejkUN892JrveARt.jpg","adult":false,"overview":"Fearing the actions of a god-like Super Hero left unchecked, Gotham City’s own formidable, forceful vigilante takes on Metropolis’s most revered, modern-day savior, while the world wrestles with what sort of hero it really needs. And with Batman and Superman at war with one another, a new threat quickly arises, putting mankind in greater danger than it’s ever known before.","release_date":"2016-03-23","genre_ids":[28,12,14],"id":209112,"original_title":"Batman v Superman: Dawn of Justice","original_language":"en","title":"Batman v Superman: Dawn of Justice","backdrop_path":"\/vsjBeMPZtyB7yNsYY56XYxifaQZ.jpg","popularity":15.824763,"vote_count":3605,"video":false,"vote_average":5.52},{"poster_path":"\/lw0IqOSMsQcy1QnVIEIDppLmNwk.jpg","adult":false,"overview":"A group of teens break into a blind man's home thinking they'll get away with the perfect crime. They're wrong.","release_date":"2016-08-25","genre_ids":[27,53],"id":300669,"original_title":"Don't Breathe","original_language":"en","title":"Don't Breathe","backdrop_path":"\/bCThHXQ3aLLDU3KFST0rC8mTan5.jpg","popularity":15.694377,"vote_count":116,"video":false,"vote_average":6.02},{"poster_path":"\/kqjL17yufvn9OVLyXYpvtyrFfak.jpg","adult":false,"overview":"An apocalyptic story set in the furthest reaches of our planet, in a stark desert landscape where humanity is broken, and most everyone is crazed fighting for the necessities of life. Within this world exist two rebels on the run who just might be able to restore order. There's Max, a man of action and a man of few words, who seeks peace of mind following the loss of his wife and child in the aftermath of the chaos. And Furiosa, a woman of action and a woman who believes her path to survival may be achieved if she can make it across the desert back to her childhood homeland.","release_date":"2015-05-13","genre_ids":[28,12,878,53],"id":76341,"original_title":"Mad Max: Fury Road","original_language":"en","title":"Mad Max: Fury Road","backdrop_path":"\/tbhdm8UJAb4ViCTsulYFL3lxMCd.jpg","popularity":15.483048,"vote_count":5303,"video":false,"vote_average":7.25},{"poster_path":"\/y31QB9kn3XSudA15tV7UWQ9XLuW.jpg","adult":false,"overview":"Light years from Earth, 26 years after being abducted, Peter Quill finds himself the prime target of a manhunt after discovering an orb wanted by Ronan the Accuser.","release_date":"2014-07-30","genre_ids":[28,878,12],"id":118340,"original_title":"Guardians of the Galaxy","original_language":"en","title":"Guardians of the Galaxy","backdrop_path":"\/bHarw8xrmQeqf3t8HpuMY7zoK4x.jpg","popularity":14.648276,"vote_count":5075,"video":false,"vote_average":7.96},{"poster_path":"\/t2mZzQXjpQxmqtJOPpe8Dr2YpMl.jpg","adult":false,"overview":"An island populated entirely by happy, flightless birds or almost entirely. In this paradise, Red, a bird with a temper problem, speedy Chuck, and the volatile Bomb have always been outsiders. But when the island is visited by mysterious green piggies, it’s up to these unlikely outcasts to figure out what the pigs are up to.","release_date":"2016-05-11","genre_ids":[28,16,35,10751],"id":153518,"original_title":"The Angry Birds Movie","original_language":"en","title":"The Angry Birds Movie","backdrop_path":"\/3mJcfL2lPfRky16EPi95d2YrKqu.jpg","popularity":14.41007,"vote_count":398,"video":false,"vote_average":5.8},{"poster_path":"\/jjBgi2r5cRt36xF6iNUEhzscEcb.jpg","adult":false,"o
D: verview":"Twenty-two years after the events of Jurassic Park, Isla Nublar now features a fully functioning dinosaur theme park, Jurassic World, as originally envisioned by John Hammond.","release_date":"2015-06-09","genre_ids":[28,12,878,53],"id":135397,"original_title":"Jurassic World","original_language":"en","title":"Jurassic World","backdrop_path":"\/dkMD5qlogeRMiEixC4YNPUvax2T.jpg","popularity":13.944027,"vote_count":4982,"video":false,"vote_average":6.59},{"poster_path":"\/inVq3FRqcYIRl2la8iZikYYxFNR.jpg","adult":false,"overview":"Based upon Marvel Comics’ most unconventional anti-hero, DEADPOOL tells the origin story of former Special Forces operative turned mercenary Wade Wilson, who after being subjected to a rogue experiment that leaves him with accelerated healing powers, adopts the alter ego Deadpool. Armed with his new abilities and a dark, twisted sense of humor, Deadpool hunts down the man who nearly destroyed his life.","release_date":"2016-02-09","genre_ids":[28,12,35,10749],"id":293660,"original_title":"Deadpool","original_language":"en","title":"Deadpool","backdrop_path":"\/nbIrDhOtUpdD9HKDBRy02a8VhpV.jpg","popularity":12.340182,"vote_count":4954,"video":false,"vote_average":7.17},{"poster_path":"\/nBNZadXqJSdt05SHLqgT0HuC5Gm.jpg","adult":false,"overview":"Interstellar chronicles the adventures of a group of explorers who make use of a newly discovered wormhole to surpass the limitations on human space travel and conquer the vast distances involved in an interstellar voyage.","release_date":"2014-11-05","genre_ids":[12,18,878],"id":157336,"original_title":"Interstellar","original_language":"en","title":"Interstellar","backdrop_path":"\/xu9zaAevzQ5nnrsXN6JcahLnG4i.jpg","popularity":11.912163,"vote_count":5670,"video":false,"vote_average":8.11},{"poster_path":"\/5TQ6YDmymBpnF005OyoB7ohZps9.jpg","adult":false,"overview":"After the cataclysmic events in New York with The Avengers, Steve Rogers, aka Captain America is living quietly in Washington, D.C. and trying to adjust to the modern world. But when a S.H.I.E.L.D. colleague comes under attack, Steve becomes embroiled in a web of intrigue that threatens to put the world at risk. Joining forces with the Black Widow, Captain America struggles to expose the ever-widening conspiracy while fighting off professional assassins sent to silence him at every turn. When the full scope of the villainous plot is revealed, Captain America and the Black Widow enlist the help of a new ally, the Falcon. However, they soon find themselves up against an unexpected and formidable enemy—the Winter Soldier.","release_date":"2014-03-20","genre_ids":[28,12,878],"id":100402,"original_title":"Captain America: The Winter Soldier","original_language":"en","title":"Captain America: The Winter Soldier","backdrop_path":"\/4qfXT9BtxeFuamR4F49m2mpKQI1.jpg","popularity":11.900067,"vote_count":3532,"video":false,"vote_average":7.58},{"poster_path":"\/oDL2ryJ0sV2bmjgshVgJb3qzvwp.jpg","adult":false,"overview":"The city needs heroes. Darkness has settled over New York City as Shredder and his evil Foot Clan have an iron grip on everything from the police to the politicians. The future is grim until four unlikely outcast brothers rise from the sewers and discover their destiny as Teenage Mutant Ninja Turtles. The Turtles must work with fearless reporter April and her wise-cracking cameraman Vern Fenwick to save the city and unravel Shredder's diabolical plan.","release_date":"2014-08-07","genre_ids":[878,28,12,14,35],"id":98566,"original_title":"Teenage Mutant Ninja Turtles","original_language":"en","title":"Teenage Mutant Ninja Turtles","backdrop_path":"\/OqCXGt5nl1cHPeotxCDvXLLe6p.jpg","popularity":11.83151,"vote_count":1659,"video":false,"vote_average":5.9},{"poster_path":"\/WLQN5aiQG8wc9SeKwixW7pAR8K.jpg","adult":false,"overview":"The quiet life of a terrier named Max is upended when his owner takes in Duke, a stray whom Max instantly dislikes.","release_date":"2016-06-24","genre_ids":[12,16,35,
D: 10751],"id":328111,"original_title":"The Secret Life of Pets","original_language":"en","title":"The Secret Life of Pets","backdrop_path":"\/3DrUqTAPjriEasoGrz5G8sPJtDU.jpg","popularity":11.676955,"vote_count":704,"video":false,"vote_average":5.78},{"poster_path":"\/6vuxwCfBejPfUjMxrPgk0ANmVFq.jpg","adult":false,"overview":"An injured surfer stranded on a buoy needs to get back to shore, but the great white shark stalking her might have other ideas.","release_date":"2016-06-24","genre_ids":[27,18,53],"id":332567,"original_title":"The Shallows","original_language":"en","title":"The Shallows","backdrop_path":"\/lEkHdk4g0nAKtMcHBtSmC1ON3O1.jpg","popularity":11.653164,"vote_count":271,"video":false,"vote_average":6.12}],"total_results":19589,"total_pages":980}
D: <-- END HTTP (12779-byte body)
I: getMoviesSubscription: Completed


Thanks in advance for all the support I will be getting to resolve this problem.

Sorry, I almost forgot the layout:
movies_grid_view.xml


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical">

<ImageView
android:id="@+id/movies_poster_grid_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

Answer

I think the problem is with the Uri passed to Picasso

Uri uri = Uri.parse(IntentKeys.POPULAR_MOVIES_POSTER_ENDPOINT).buildUpon()
                .appendPath(ImageSize.w185.getValue())
                .appendPath(result.getPosterPath().replace("/", ""))
                .build();

It should have the key as a query parameter.

Comments