Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to view poster image #16

Closed
syedalinaqi opened this issue Sep 3, 2014 · 13 comments
Closed

Unable to view poster image #16

syedalinaqi opened this issue Sep 3, 2014 · 13 comments

Comments

@syedalinaqi
Copy link

i did every thing but i was unable to set the imageview image from poster path

public class showMovieInfo extends AsyncTask<Integer,Integer,String>{

    protected void onPreExecute(Integer f){
        //setting up variables for whole method
    }

    @Override
    protected String doInBackground(Integer... params) {
        Tmdb tmdb = new Tmdb();
        tmdb.setApiKey("76f029219decc8a8e1c6d5474e37d7c9");
        MoviesService movieService = tmdb.moviesService();
        Movie movie = movieService.summary(550);
        //String str = String.valueOf(movie.title);

        return movie.overview;
       ///MenuInflater inflater = new MenuInflater(MainActivity.this);
        //inflater.inflate(android.R.layout.simple_list_item_1, false);


    }
    protected void onProgressUpdated(Integer... progress)
    {
    }
    protected void onPostExecute(String result)
    {
        Imageview.setImage(Picasso.with(this).load(painting.getImageUrl()).into(image);)
    }
}
@UweTrottmann
Copy link
Owner

Did you make sure to build the full URL? The TMDb API only returns the image path, e.g. /8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg. You will have to assemble the full URL by adding the current image base url and a size specifier as described in the docs.

@syedalinaqi
Copy link
Author

how to obtain size using your tmdb???

@UweTrottmann
Copy link
Owner

Either obtain them via the /configuration endpoint or just look at the example response in the docs. You can pretty much hard-code the base url and resolutions as they don't really change.

@syedalinaqi
Copy link
Author

thanks and one more thing how do i use a single async method for returning one id's tiitle,poster path and year.

@UweTrottmann
Copy link
Owner

Can't you just return the whole movie object in 'doInBackground()' instead
of a single property?
On Sep 3, 2014 5:57 PM, "syedalinaqi" notifications@github.com wrote:

thanks and one more thing how do i use a single async method for returning
one id's tiitle,poster path and year.


Reply to this email directly or view it on GitHub
#16 (comment)
.

@syedalinaqi
Copy link
Author

so u r saying that i should use

return movie.toString();

but if i use this then how do i separate the three things i need from the whole thing???

and another thing how do i use the same Async method for multiple tmdb ids??

@syedalinaqi
Copy link
Author

and also how do i extract the titles and posters of the MostPopular movies as it returns a list.

@syedalinaqi
Copy link
Author

 1   Tmdb tmdb = new Tmdb();
 2   tmdb.setApiKey("76f029219decc8a8e1c6d5474e37d7c9");
 3   MoviesService movieService = tmdb.moviesService();
 4   ResultsPage movie = movieService.popular();

 5  return movie.results;

ok after using the above method how do i use the data that comes in a list from the 4 line. how do i view it

@syedalinaqi
Copy link
Author

at leat tell me what type of list it returns

arraylist
string list
etc

@UweTrottmann
Copy link
Owner

Just look at the type? E.g. hover your mouse cursor over it in eclipse, or press Ctrl+Q in Android Studio/IntelliJ.

@syedalinaqi
Copy link
Author

well i did and it said

com.uwetrottmann.tmdb.entities.ResultsPage
public java.util.List<com.uwetrottmann.tmdb.entities.Movie> results

so as i said before it returns a list. SO how do i use it.

@UweTrottmann
Copy link
Owner

It returns a list of Movie objects wrapped into a standard Java List interface (List<Movie>). See the Java documentation for List on how to use it.

@syedalinaqi
Copy link
Author

ok i did exactly as u said but the activity stopped instantly

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

    tv = (TextView) findViewById(R.id.textView);
    new showMovieInfo().execute();
    tv.setText( mplist.get(1).title);

}
public class showMovieInfo extends AsyncTask<Integer,Integer,List> {

    protected void onPreExecute(Integer f){
        //setting up variables for whole method
    }

    @Override
    protected List doInBackground(Integer... params) {
        Tmdb tmdb = new Tmdb();
        tmdb.setApiKey("76f029219decc8a8e1c6d5474e37d7c9");
        MoviesService movieService = tmdb.moviesService();
        ResultsPage movie = movieService.popular();//you can use a String[] array at the place of 550.
        //String str = String.valueOf(movie.title);
        //you can create multiple return statements or u can use if else statement for different commands.
        return movie.results;
        ///MenuInflater inflater = new MenuInflater(MainActivity.this);
        //inflater.inflate(android.R.layout.simple_list_item_1, false);


    }
    protected void onProgressUpdated(Integer... progress)
    {

    }
    protected void onPostExecute(List result)
    {
        mplist = result;
      mplist = new List<Movie>() {
          @Override
          public void add(int location, Movie object) {

          }

          @Override
          public boolean add(Movie object) {
              return false;
          }

          @Override
          public boolean addAll(int location, Collection<? extends Movie> collection) {
              return false;
          }

          @Override
          public boolean addAll(Collection<? extends Movie> collection) {
              return false;
          }

          @Override
          public void clear() {

          }

          @Override
          public boolean contains(Object object) {
              return false;
          }

          @Override
          public boolean containsAll(Collection<?> collection) {
              return false;
          }

          @Override
          public boolean equals(Object object) {
              return false;
          }

          @Override
          public Movie get(int location) {
              return null;
          }

          @Override
          public int hashCode() {
              return 0;
          }

          @Override
          public int indexOf(Object object) {
              return 0;
          }

          @Override
          public boolean isEmpty() {
              return false;
          }

          @Override
          public Iterator<Movie> iterator() {
              return null;
          }

          @Override
          public int lastIndexOf(Object object) {
              return 0;
          }

          @Override
          public ListIterator<Movie> listIterator() {
              return null;
          }

          @Override
          public ListIterator<Movie> listIterator(int location) {
              return null;
          }

          @Override
          public Movie remove(int location) {
              return null;
          }

          @Override
          public boolean remove(Object object) {
              return false;
          }

          @Override
          public boolean removeAll(Collection<?> collection) {
              return false;
          }

          @Override
          public boolean retainAll(Collection<?> collection) {
              return false;
          }

          @Override
          public Movie set(int location, Movie object) {
              return null;
          }

          @Override
          public int size() {
              return 0;
          }

          @Override
          public List<Movie> subList(int start, int end) {
              return null;
          }

          @Override
          public Object[] toArray() {
              return new Object[0];
          }

          @Override
          public <T> T[] toArray(T[] array) {
              return null;
          }
      };
        //you can use s string array here and use stringarray.add(result) to add multiple items to the array and then you can get those items by using stringarray.get(1).
    }
}

ADB Log

09-04 22:13:28.501 4865-4865/com.ITAN.cinematheque E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ITAN.cinematheque/com.ITAN.cinematheque.activities.MainActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
at android.app.ActivityThread.access$700(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:176)
at android.app.ActivityThread.main(ActivityThread.java:5317)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.ITAN.cinematheque.activities.MainActivity.onCreate(MainActivity.java:39)
at android.app.Activity.performCreate(Activity.java:5326)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309)
            at android.app.ActivityThread.access$700(ActivityThread.java:157)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.app.ActivityThread.main(ActivityThread.java:5317)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
            at dalvik.system.NativeStart.main(Native Method)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants