1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View v = inflater.inflate(R.layout.tv_fragment_channel_list, container);
adapter = new AdapterChannelList(getActivity(), ( (List<Category>) User.getInstance().getTV() ).get(0).getContent());
list = (ListView) v.findViewById(R.id.channelListview);
list.setAdapter(adapter);
list.setOnKeyListener(new OnKeyListener()
{
// super.onKey(View v, int keyCode, KeyEvent event);
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (keyCode)
{
/*case 61 :
getZappingBannerFragment().loadChannelInfo(fillMaps.get(
ListId).get("id"), false);
getZappingBannerFragment().justShow();
return true;*/
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
{
((MainActivity) getActivity()).loadVideo(mLiveTv.get(
ListId).getUrl(),"TV");
getZappingBannerFragment().loadChannelInfo(mLiveTv.get(
ListId).getId(), true);
((MainActivity) getActivity()).findViewById(R.id.tvpannel).setVisibility(View.INVISIBLE);
MainActivity.shouldfocus = R.id.videoView1;
return true;
}
case KeyEvent.KEYCODE_DPAD_DOWN:
{
if (ListId >= /*6*/mLiveTv.size() -1)
return true;
if (ListPos == 10)
{
reduce(ListPos);
}
else if (ListId > 10)
reduce(ListPos);
else
reduce(ListId);
ListId++;
ListPos++;
if (ListPos == 10)
{
reduce(ListPos - 1);
enlarge(ListPos);
list.setSelectionFromTop(ListId, 0);
ListPos = 0;
}
else if (ListId > 10)
enlarge(ListPos);
else
enlarge(ListId);
//list.setSelectionFromTop(ListId, 0);
//list.scrollBy(0, 250);
return true;
}
case KeyEvent.KEYCODE_DPAD_UP:
{
// list.scrollBy(0, -250);
if (ListId > 0)
{
reduce(ListId);
ListId--;
ListPos--;
}
if (ListPos < 0)
{
enlarge(ListId);
list.setSelectionFromTop(ListPos, 0);
ListPos = 0;
}
else
{
enlarge(ListId);
}
//list.setSelectionFromTop(ListId, 0);
//list.setSelection(ListId);
return true;
}
case KeyEvent.KEYCODE_BACK:
{
//getZappingBannerFragment().justShow();
((MainActivity) getActivity()).findViewById(R.id.tvpannel).setVisibility(View.INVISIBLE);
((MainActivity) getActivity()).findViewById(R.id.menu_principal).setVisibility(View.VISIBLE);
MainActivity.shouldfocus = R.id.menu_principal;
return true;
}
}
}
return true;
}
});
return v;
} |
Partager