korre / android-tv-epg

Classic TV electronic program guide (EPG) with multidirectional scroll
MIT License
160 stars 75 forks source link

Inflating in fragment #30

Open parissakalaee opened 2 years ago

parissakalaee commented 2 years ago

Hi there,

I wonder if it would be possible to use this EPG customview in a fragment? I was working all day long, but onDraw isn't be called in fragment, or I don't know how to manage that.

Any clue?

parissakalaee commented 2 years ago

It is like this, onDraw is never called.

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);

        EPG epg = new EPG(container.getContext());
        epg.setEPGClickListener(new EPGClickListener() {
            @Override
            public void onChannelClicked(int channelPosition, EPGChannel epgChannel) {
                Toast.makeText(container.getContext(), epgChannel.getName() + " clicked", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onEventClicked(int channelPosition, int programPosition, EPGEvent epgEvent) {
                Toast.makeText(container.getContext(), epgEvent.getTitle() + " clicked", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onResetButtonClicked() {
                epg.recalculateAndRedraw(true);
            }
        });

        EPGData epgData = new EPGDataImpl(MockDataService.getMockData());
        epg.setEPGData(epgData);
        epg.recalculateAndRedraw(false);

        return epg;
    }