welcome to linkAR technical documentation

previous

Adding Poster Images


In SDdataParser.java we make use of another AsyncTask to process movies data. For each file we obtain the movie information and we add it into the array.

  private class loadMovieDataFromSDandAddImagesToThePool extends AsyncTask<Void,Integer,Void>    
  {
    ...
 
    @Override
    protected Void doInBackground(Void... v) {
 
      MovieInfo movieInfo = null;
      ...
      try {									
        JSONArray moviesArray = new JSONArray(jsonMovieInfo);								
	JSONObject jsonObj = moviesArray.getJSONObject(0);
 
	movieInfo.id = jsonObj.getString("id");
	movieInfo.language = jsonObj.getString("language");
	movieInfo.name = jsonObj.getString("original_name");
	movieInfo.overview = jsonObj.getString("overview");
	movieInfo.rating = jsonObj.getString("rating");
	movieInfo.released_date = jsonObj.getString("released");
	movieInfo.runtime = jsonObj.getString("runtime");
	movieInfo.tagline = jsonObj.getString("tagline");
	movieInfo.trailer = jsonObj.getString("trailer");
        movieInfo.web_link = jsonObj.getString("url");
 
 
	Bitmap posterImage = getBitmapFromSD(movieInfo.id+".png");
 
        //1
        if(posterImage != null)
	{						
          //2			
	  int id = aRmatcher.addImage(posterImage);
          //3										
	  if (id != -1)
	  {										
	    movieInfo.imagePoolid = id;																						
	    movieInfo.image = posterImage;																			
 
            //4
            MoviesArray.add(movieInfo);
	  }													
        }						 
      } catch (Exception e) {  }					 					     				     
      ...
    }
    ...
 }
  1. We ensure the image has been downloaded properly.
  2. We add the image into the library. It is important to assign the returned value into a variable.
  3. If the returned value is not (-1), then the image was added into the pool. If the value is (-1), then the image does not have the library quality requirements.
  4. Save the image id into the movie object, and add the movie into the MoviesArray.

previous