How to use method of a class in an activity?

0

I need to use the following method, which is located in the VodPlayerAdapter class in an Activity PlayerActivity:

 public void changeVideo(Video video, boolean playWhenReady) {
    finalizePlayer();
    this.video = video;
    VodSource.getInstance().getImageLoader().get(VodSource.URL_SERVER + this.video.getThumb(), new DescriptionImageListener(thumb));
    if(playWhenReady) {
        startVideo(playWhenReady);
    }
    else {
        rebuildThumb();
    }
}

This class that is abstract is instantiated twice, one in PlaylistActivity, which interests me, like this:

vodPlayerAdapter = new VodPlayerAdapter(view, video, getWindow(), VodPlayerAdapter.PLAYLIST_MODE, true) {
        @Override
        public void refreshVideoInfor() {
            refreshVideoInfo();
        }
    };

The above method is in the PlaylistActivity that calls the PlayerActivity. When I click on a button, it finishes the PlaylistActivity, and at this point it initializes the PlayerActivity ... In PlaylistActivity I create an instance of the object of my VodPlayerAdapter class, I can use its methods etc, but in this other activity I can not anymore, and because it is an adapter with information of the previous state that was in the PlaylistActivity, I believe that I can not give new again only to use where I want, even tried and gives error. That way, I'd like to know somehow that I could use this method of the VodPlayerAdapter class in Playeractivity without creating a new instance.

    
asked by anonymous 07.04.2016 / 01:53

1 answer

0

If you just want to use the method, instantiate a class that inherits from VodPlayerAdapter , implement the method this way

@Override
public void refreshVideoInfor() {
      refreshVideoInfo();
}

And instantiate this class in both PlaylistActivity and PlayerActivity . Both will perform the same method. If the problem is the parameters, pass them properly from PlaylistActivity to PlayerActivity and pass them in this child class of VodPlayerAdapter .

    
07.04.2016 / 04:01