package com.npaw.youbora.lib6.theoplayer.demo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ListViewActivity extends Activity {
    private ListView listView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sample_chooser_activity);
        listView = findViewById(R.id.listView);
        setAdapter();
    }

    private void setAdapter() {
        String[] data = {"DASH VoD", "HLS VoD", "HLS Live"};
        final String[] url = {"http://bitdash-a.akamaihd.net/content/sintel/sintel.mpd",
        "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8",
        "http://cdn3.viblast.com/streams/hls/airshow/playlist.m3u8"};
        ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.list_item,
                R.id.tv_title, data);
        listView.setAdapter(adapter);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent(getApplication(), MainActivity.class);
                intent.putExtra("url", url[i]);
                startActivity(intent);
            }
        });
    }
}
