Advertisement
kernel_memory_dump

ComediaTest_Leon

May 9th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.68 KB | None | 0 0
  1. package com.comedia.use;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.Timer;
  6. import java.util.TimerTask;
  7.  
  8. import android.app.Activity;
  9. import android.app.Dialog;
  10. import android.content.ComponentName;
  11. import android.content.Context;
  12. import android.content.DialogInterface;
  13. import android.content.DialogInterface.OnKeyListener;
  14. import android.content.Intent;
  15. import android.content.ServiceConnection;
  16. import android.dtv.basic_types.LongHolder;
  17. import android.dtv.route.DecoderDescriptor;
  18. import android.dtv.route.DemuxDescriptor;
  19. import android.dtv.route.FrontendDescriptor;
  20. import android.dtv.route.MassStorageDescriptor;
  21. import android.dtv.route.OutputDescriptor;
  22. import android.dtv.route.RouteErrorCode;
  23. import android.dtv.service.SERVICE_TYPE;
  24. import android.dtv.service.Service;
  25. import android.dtv.service.ServiceInfo;
  26. import android.dtv.service.ZappingEvent;
  27. import android.dtv.setup.Conversions;
  28. import android.dtv.setup.TimeFromStream;
  29. import android.media.AudioManager;
  30. import android.net.Uri;
  31. import android.os.Build;
  32. import android.os.Bundle;
  33. import android.os.DeadObjectException;
  34. import android.os.Handler;
  35. import android.os.IBinder;
  36. import android.os.IChannelsCallback;
  37. import android.os.IDTVManager;
  38. import android.os.IEventsCallback;
  39. import android.os.RemoteException;
  40. import android.util.Log;
  41. import android.view.KeyEvent;
  42. import android.view.LayoutInflater;
  43. import android.view.View;
  44. import android.view.ViewGroup;
  45. import android.view.Window;
  46. import android.view.WindowManager;
  47. import android.view.animation.Animation;
  48. import android.view.animation.AnimationUtils;
  49. import android.widget.ArrayAdapter;
  50. import android.widget.Button;
  51. import android.widget.EditText;
  52. import android.widget.ImageView;
  53. import android.widget.LinearLayout;
  54. import android.widget.ListView;
  55. import android.widget.ProgressBar;
  56. import android.widget.SeekBar;
  57. import android.widget.TextView;
  58. import android.widget.Toast;
  59. import android.widget.VideoView;
  60.  
  61. public class ComediaTestActivity extends Activity {
  62.  
  63.     private final String LOG_TAG = "ComediaTestActivity";
  64.  
  65.     private VideoView video;
  66.     private Button btnInitPlayer;
  67.     private Button btnListOfChannels;
  68.     private Button btnChangeChannel;
  69.     private Button btnNext;
  70.     private Button btnPrevious;
  71.     private Button btnScan;
  72.     private Button btnAbortScan;
  73.     private Button btnServiceInformation;
  74.     public static EditText edittextChannelNumber;
  75.     public static Dialog dialogOptions;
  76.  
  77.     private Intent remoteServiceIntent;
  78.     private BinderServiceConnection conn;
  79.     public static IDTVManager service = null;
  80.  
  81.     public static Activity activity;
  82.    
  83.     //Channel Info
  84.     public static Dialog chanellInfo;
  85.     public static Timer channelInforTimer;
  86.     public static Timer channelInfoTimer;
  87.     public static ProgressBar progressBar;
  88.     public static ProgressBar progressBarGoogle, progressBarFace,
  89.     progressBarWiki, progressBarYou;
  90.     public static int mProgressRegister = 0;
  91.     public static int durationRegister = 0;
  92.     public static Animation animShow;
  93.     public static Animation animHide;
  94.     public static Animation menuShow;
  95.     public static Animation menuHide;
  96.     public static LinearLayout popup;
  97.     public static LinearLayout popdown;
  98.     public static Timer popupTimer;
  99.     public static int mProgressStatus = 0;
  100.     public static Integer duration = 0;
  101.     public static Handler mHandler1 = new Handler();
  102.     public static Handler mHandler2 = new Handler();
  103.     public static Handler channelInfoHandler = new Handler();
  104.     public static Handler progressBarHandler = new Handler();
  105.     public static TextView textview_start;
  106.     private static TextView textview_stop;
  107.     public static int broj = 0;
  108.     public static Thread background;
  109.     public static TextView textID, textImeKanala, textNow, textNext,
  110.     textChannelTime, textTeletext, textSubtitle, textAudio, textVideo;
  111.    
  112.     public static int screenWidth, screenHeight;
  113.     public static int[] location;
  114.    
  115.     //Channel List
  116.     public static Dialog channelList;
  117.     public static int listNumber;
  118.     public static ListView list;
  119.     TextView naslov;
  120.     public static List<Object> listItems = new ArrayList<Object>();
  121.     public static int lengthCurrentList;
  122.     ListItemsAdapter adapter = null;
  123.    
  124.     //Volume
  125.     public static Dialog volumeDialog;
  126.     public static SeekBar volumeBar;
  127.     public static Timer volumeTimer = new Timer();
  128.     public static TimerTask volumeTimerTask;
  129.    
  130.     protected static Handler callbackHandler = new Handler();
  131.  
  132.     public static long liveRouteID = 0; // route for live TV
  133.     public static long installRouteID = 0; // route for installing services
  134.     public static long recRouteID = 0; // route for using pvr
  135.     public static long playRouteID = 0; // route for using pvr
  136.  
  137.     /** Called when the activity is first created. */
  138.     @Override
  139.     public void onCreate(Bundle savedInstanceState) {
  140.         super.onCreate(savedInstanceState);
  141.         requestWindowFeature(Window.FEATURE_NO_TITLE);
  142.         getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  143.         getWindow().clearFlags(
  144.                 WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
  145.         setContentView(R.layout.main);
  146.         initValues();
  147.         initKeyListeners();
  148.         initVideo();
  149.         initChannelList();
  150.         initChannelInfo();
  151.         initVolume();
  152.         connectWithServer();
  153.     }
  154.  
  155.     @Override
  156.     protected void onPause() {
  157.         super.onPause();
  158.  
  159.         try {
  160.             activity.unbindService(conn);
  161.         } catch (Exception e) {
  162.             Log.e("unbind on pause", "exception");
  163.         }
  164.  
  165.         if (service != null) {
  166.             try {
  167.                 service.getVideoControl().deinitPlayer(liveRouteID);
  168.             } catch (Exception e) {
  169.             }
  170.         } else {
  171.             Log.e("Java", "deinitPlayer: service is null");
  172.         }
  173.         android.os.Process.killProcess(android.os.Process.myPid());
  174.     }
  175.  
  176.     private void connectWithServer() {
  177.         remoteServiceIntent = new Intent("com.rtrk.REMOTE_SERVICE_COMEDIA");
  178.         conn = new BinderServiceConnection();
  179.         bindService(remoteServiceIntent, conn, Context.BIND_IMPORTANT);
  180.     }
  181.  
  182.     class BinderServiceConnection implements ServiceConnection {
  183.         public static final String TAG = "BinderServiceConnection";
  184.  
  185.         public void onServiceConnected(ComponentName className,
  186.                 IBinder boundService) {
  187.             service = IDTVManager.Stub.asInterface((IBinder) boundService);
  188.             try {
  189.                 initializeRouteIds();
  190.             } catch (RemoteException e1) {
  191.                 // TODO Auto-generated catch block
  192.                 e1.printStackTrace();
  193.             }
  194.            
  195.             Log.e(TAG, "onServiceConnected");
  196.             if (service != null) {
  197.                 try {
  198.                     service.getSetupControl().setEventsCallback(
  199.                             eventsCallback.asBinder());
  200.                     service.getSetupControl().setChannelsCallback(liveRouteID,
  201.                             channelsCallback.asBinder());
  202.                 } catch (DeadObjectException ex) {
  203.                     Log.e(TAG, "DeadObjectException");
  204.                 } catch (RemoteException e) {
  205.                     e.printStackTrace();
  206.                 }
  207.             } else {
  208.                 Log.e("Java", "onServiceConnected: service is null");
  209.             }
  210.             try {
  211.                 service.getVideoControl().initPlayer(liveRouteID,1);
  212.             } catch (RemoteException e) {
  213.                 // TODO Auto-generated catch block
  214.                 e.printStackTrace();
  215.             }
  216.            
  217.             fillListChannel();
  218.  
  219.         }
  220.  
  221.         public void onServiceDisconnected(ComponentName className) {
  222.             service = null;
  223.             Log.d(TAG, "onServiceDisconnected");
  224.         }
  225.     };
  226.  
  227.     private IChannelsCallback.Stub channelsCallback = new IChannelsCallback.Stub() {
  228.  
  229.         @Override
  230.         public void signalStrength(int arg0) throws RemoteException {
  231.             // TODO Auto-generated method stub
  232.  
  233.         }
  234.  
  235.         @Override
  236.         public void signalQuality(int arg0) throws RemoteException {
  237.             // TODO Auto-generated method stub
  238.  
  239.         }
  240.  
  241.         @Override
  242.         public void signalBer(int arg0) throws RemoteException {
  243.             // TODO Auto-generated method stub
  244.  
  245.         }
  246.  
  247.         @Override
  248.         public void selectingComponent(boolean arg0) throws RemoteException {
  249.             // TODO Auto-generated method stub
  250.  
  251.         }
  252.  
  253.         @Override
  254.         public void scanTunFrequency(int arg0) throws RemoteException {
  255.             // TODO Auto-generated method stub
  256.  
  257.         }
  258.  
  259.         @Override
  260.         public void scanProgressChanged(int arg0) throws RemoteException {
  261.             Log.e(LOG_TAG, "scanProgressChanged:" + arg0);
  262.         }
  263.  
  264.         @Override
  265.         public void scanFinished() throws RemoteException {
  266.             callbackHandler.post(new Runnable() {
  267.                 public void run() {
  268.  
  269.                     Toast.makeText(getApplicationContext(), "scan finished",
  270.                             Toast.LENGTH_LONG).show();
  271.                 }
  272.             });
  273.             service.getVideoControl().initPlayer(liveRouteID, 0);
  274.         }
  275.  
  276.         @Override
  277.         public void mhegStarted(boolean arg0) throws RemoteException {
  278.             // TODO Auto-generated method stub
  279.  
  280.         }
  281.  
  282.         @Override
  283.         public void installServiceTVNumber(int arg0) throws RemoteException {
  284.             // TODO Auto-generated method stub
  285.  
  286.         }
  287.  
  288.         @Override
  289.         public void installServiceTVName(String arg0) throws RemoteException {
  290.             Log.e(LOG_TAG, "Installed TV service:" + arg0);
  291.         }
  292.  
  293.         @Override
  294.         public void installServiceRADIONumber(int arg0) throws RemoteException {
  295.             // TODO Auto-generated method stub
  296.         }
  297.  
  298.         @Override
  299.         public void installServiceRADIOName(String arg0) throws RemoteException {
  300.             Log.e(LOG_TAG, "Installed radio service:" + arg0);
  301.  
  302.         }
  303.  
  304.        
  305.  
  306.         @Override
  307.         public void antennaConnected(boolean arg0) throws RemoteException {
  308.             // TODO Auto-generated method stub
  309.  
  310.         }
  311.  
  312.         @Override
  313.         public void channelZapping(ZappingEvent arg0) throws RemoteException {
  314.             callbackHandler.post(new Runnable() {
  315.                 public void run() {
  316.                     long index = 0;
  317.                     String scrambled = "";
  318.                     try {
  319.                         index = service.getServiceLists().getList(0)
  320.                                 .getCurrentServiceIndex(liveRouteID);
  321.                         Service channel = service.getServiceLists().getList(0)
  322.                                 .getService(liveRouteID, (int) index);
  323.  
  324.                         if (channel.isScrambled()) {
  325.                             scrambled = "scrambled";
  326.                         } else {
  327.                             scrambled = "";
  328.                         }
  329.  
  330.                         int indexDisplay = (int) index + 1;
  331.                         Toast.makeText(
  332.                                 getApplicationContext(),
  333.                                 indexDisplay + ". " + channel.getName() + " "
  334.                                         + scrambled, Toast.LENGTH_LONG).show();
  335.                     } catch (RemoteException e) {
  336.                         // TODO Auto-generated catch block
  337.                         e.printStackTrace();
  338.                     }
  339.                 }
  340.             });        
  341.         }
  342.     };
  343.  
  344.     private IEventsCallback.Stub eventsCallback = new IEventsCallback.Stub() {
  345.  
  346.         @Override
  347.         public void nowNextChanged() throws RemoteException {
  348.             Log.e(LOG_TAG, "Now/next changed");
  349.         }
  350.  
  351.         @Override
  352.         public void EpgEventsChanged() throws RemoteException {
  353.             callbackHandler.post(new Runnable() {
  354.                 public void run() {
  355.                     Toast.makeText(getApplicationContext(),
  356.                             "Epg events changed", Toast.LENGTH_LONG).show();
  357.                 }
  358.             });
  359.         }
  360.     };
  361.  
  362.     private void initValues() {
  363.  
  364.         activity = ComediaTestActivity.this;
  365.  
  366.         dialogOptions = new Dialog(this, R.style.SpecialDialog);
  367.         dialogOptions.setContentView(R.layout.options_menu);
  368.  
  369.         video = (VideoView) findViewById(R.id.videoView1);
  370.         btnInitPlayer = (Button) dialogOptions
  371.                 .findViewById(R.id.buttonInitPlayer);
  372.         btnListOfChannels = (Button) dialogOptions
  373.                 .findViewById(R.id.buttonListOfChannels);
  374.         edittextChannelNumber = (EditText) dialogOptions
  375.                 .findViewById(R.id.editTextChannelNumber);
  376.         btnChangeChannel = (Button) dialogOptions
  377.                 .findViewById(R.id.buttonChangeChannel);
  378.         btnPrevious = (Button) dialogOptions.findViewById(R.id.buttonPrevious);
  379.         btnNext = (Button) dialogOptions.findViewById(R.id.buttonNext);
  380.         btnScan = (Button) dialogOptions.findViewById(R.id.buttonScan);
  381.         btnAbortScan = (Button) dialogOptions.findViewById(R.id.buttonAbort);
  382.         btnServiceInformation = (Button) dialogOptions
  383.                 .findViewById(R.id.buttonChannelInformation);
  384.         channelInfoTimer = new Timer();
  385.         screenHeight = getWindowManager().getDefaultDisplay().getHeight();
  386.         screenWidth = getWindowManager().getDefaultDisplay().getWidth();
  387.     }
  388.  
  389.     private void initKeyListeners() {
  390.         video.setOnKeyListener(new MyOnKeyListener());
  391.         btnInitPlayer.setOnKeyListener(new MyOnKeyListener());
  392.         btnListOfChannels.setOnKeyListener(new MyOnKeyListener());
  393.         btnChangeChannel.setOnKeyListener(new MyOnKeyListener());
  394.         btnAbortScan.setOnKeyListener(new MyOnKeyListener());
  395.         btnPrevious.setOnKeyListener(new MyOnKeyListener());
  396.         btnNext.setOnKeyListener(new MyOnKeyListener());
  397.         btnScan.setOnKeyListener(new MyOnKeyListener());
  398.         btnServiceInformation.setOnKeyListener(new MyOnKeyListener());
  399.  
  400.     }
  401.  
  402.     private void initVideo() {
  403.  
  404.         video.setVideoURI(Uri.parse("mrvl://"));
  405.         video.start();
  406.         video.requestFocus();
  407.  
  408.     }
  409.  
  410.     @Override
  411.     public void onBackPressed() {
  412.         super.onBackPressed();
  413.         finish();
  414.     }
  415.  
  416.     private void initializeRouteIds() throws RemoteException {
  417.         FrontendDescriptor fDescriptor = new FrontendDescriptor();
  418.         RouteErrorCode rError = null;
  419.         rError = service.getRouteControl()
  420.                 .GetFrontendDescriptor(0, fDescriptor);
  421.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  422.             Log.e("TAG", "GetFrontendDescriptor error");
  423.             return;
  424.         }
  425.  
  426.         DemuxDescriptor dDescriptor = new DemuxDescriptor();
  427.         rError = null;
  428.         rError = service.getRouteControl().GetDemuxDescriptor(0, dDescriptor);
  429.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  430.             Log.e("TAG", "GetDemuxDescriptor error");
  431.             return;
  432.         }
  433.  
  434.         DecoderDescriptor dDecDescriptor = new DecoderDescriptor();
  435.         rError = null;
  436.         rError = service.getRouteControl().GetDecoderDescriptor(0,
  437.                 dDecDescriptor);
  438.  
  439.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  440.             Log.e("TAG", "GetDecoderDescriptor error");
  441.             return;
  442.         }
  443.  
  444.         OutputDescriptor oDescriptor = new OutputDescriptor();
  445.         rError = null;
  446.         rError = service.getRouteControl().GetOutputDescriptor(0, oDescriptor);
  447.  
  448.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  449.             Log.e("TAG", "GetOutputDescriptor error");
  450.             return;
  451.         }
  452.  
  453.         MassStorageDescriptor mDescriptor = new MassStorageDescriptor();
  454.         rError = null;
  455.         rError = service.getRouteControl().GetMassStorageDescriptor(0,
  456.                 mDescriptor);
  457.  
  458.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  459.             Log.e("TAG", "GetMassStorageDescriptor error");
  460.             // no pvr
  461.         }
  462.  
  463.         LongHolder route = new LongHolder();
  464.         rError = null;
  465.         rError = service.getRouteControl()
  466.                 .GetLiveRoute(fDescriptor.getFrontendId(),
  467.                         dDescriptor.getDemuxId(),
  468.                         dDecDescriptor.getDecoderId(),
  469.                         oDescriptor.getOutputId(), route);
  470.  
  471.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  472.             Log.e("TAG", "GetLiveRoute error");
  473.             return;
  474.         } else {
  475.             liveRouteID = route.getLongValue();
  476.         }
  477.  
  478.         rError = null;
  479.         rError = service.getRouteControl().GetInstallRoute(
  480.                 fDescriptor.getFrontendId(), dDescriptor.getDemuxId(), route);
  481.  
  482.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  483.             Log.e("TAG", "GetInstallRoute error");
  484.             return;
  485.         } else {
  486.             installRouteID = route.getLongValue();
  487.         }
  488.  
  489.         rError = null;
  490.         rError = service.getRouteControl().GetRecordRoute(
  491.                 fDescriptor.getFrontendId(), dDescriptor.getDemuxId(),
  492.                 mDescriptor.getMassStorageId(), route);
  493.  
  494.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  495.             Log.e("TAG", "GetRecordRoute error");
  496.             // no pvr
  497.         } else {
  498.             recRouteID = route.getLongValue();
  499.         }
  500.  
  501.         rError = null;
  502.         rError = service.getRouteControl()
  503.                 .GetPlaybackRoute(mDescriptor.getMassStorageId(),
  504.                         dDescriptor.getDemuxId(),
  505.                         dDecDescriptor.getDecoderId(),
  506.                         oDescriptor.getOutputId(), route);
  507.  
  508.         if (rError != RouteErrorCode.ROUTE_ERRORCODE_NO_ERROR) {
  509.             Log.e("TAG", "GetPlaybackRoute error");
  510.             // no pvr
  511.         } else {
  512.             playRouteID = route.getLongValue();
  513.         }
  514.  
  515.     }
  516.    
  517.     public static void initChannelInfo() {
  518.        
  519.         channelInforTimer = new Timer();
  520.         progressBar = new ProgressBar(activity);
  521.  
  522.         chanellInfo = new Dialog(activity, com.comedia.use.R.style.SpecialDialog);
  523.  
  524.         chanellInfo.setContentView(com.comedia.use.R.layout.channel_info);
  525.         chanellInfo.getWindow().getAttributes().width = screenWidth * 4 / 5;
  526.         chanellInfo.getWindow().getAttributes().y = screenHeight / 2;
  527.  
  528.         progressBar = ((ProgressBar) chanellInfo
  529.                 .findViewById(com.comedia.use.R.id.progressBar1));
  530.  
  531.         textview_start = (TextView) chanellInfo
  532.                 .findViewById(com.comedia.use.R.id.textView_start);
  533.         textview_stop = (TextView) chanellInfo
  534.                 .findViewById(com.comedia.use.R.id.textView_stop);
  535.  
  536.         popup = (LinearLayout) chanellInfo
  537.                 .findViewById(com.comedia.use.R.id.RelativeLayout1);
  538.        
  539.         popup.setVisibility(View.GONE);
  540.         channelInforTimer = new Timer();
  541.         popupTimer = new Timer();
  542.  
  543.         menuShow = AnimationUtils.loadAnimation(activity,
  544.                 com.comedia.use.R.anim.menu_show);
  545.         menuHide = AnimationUtils.loadAnimation(activity,
  546.                 com.comedia.use.R.anim.menu_hide);
  547.  
  548.         animShow = AnimationUtils.loadAnimation(activity,
  549.                 com.comedia.use.R.anim.popup_show);
  550.         animHide = AnimationUtils.loadAnimation(activity,
  551.                 com.comedia.use.R.anim.popup_hide);
  552.  
  553.         textID = (TextView) chanellInfo.findViewById(com.comedia.use.R.id.textView3);
  554.         textImeKanala = (TextView) chanellInfo
  555.                 .findViewById(com.comedia.use.R.id.textView2);
  556.         textNow = (TextView) chanellInfo.findViewById(com.comedia.use.R.id.textView6);
  557.         textNext = (TextView) chanellInfo
  558.                 .findViewById(com.comedia.use.R.id.textView7);
  559.         textChannelTime = (TextView) chanellInfo
  560.                 .findViewById(com.comedia.use.R.id.textViewChannelTime);
  561.  
  562.         textTeletext = (TextView) chanellInfo
  563.                 .findViewById(com.comedia.use.R.id.textViewTeletext);
  564.         textSubtitle = (TextView) chanellInfo
  565.                 .findViewById(com.comedia.use.R.id.textViewSubtitle);
  566.         textAudio = (TextView) chanellInfo
  567.                 .findViewById(com.comedia.use.R.id.textViewAudio);
  568.         textVideo = (TextView) chanellInfo
  569.                 .findViewById(com.comedia.use.R.id.textViewVideo);
  570.  
  571.     }
  572.    
  573.     public static void displayChanellInfo(boolean wait) {
  574.  
  575.         ServiceInfo currentServiceInfo = null;
  576.  
  577.         if (wait) {
  578.             try {
  579.                 Thread.sleep(4000);
  580.             } catch (InterruptedException e) {
  581.                 e.printStackTrace();
  582.             }
  583.         }
  584.         try {
  585.             Service currentService;
  586.             if (service != null) {
  587.                 currentService = service
  588.                         .getServiceLists()
  589.                         .getList(Service.MAIN_LIST_INDEX)
  590.                         .getService(
  591.                                 liveRouteID,
  592.                                 (int) service.getServiceLists()
  593.                                         .getList(Service.MAIN_LIST_INDEX)
  594.                                         .getCurrentServiceIndex(liveRouteID));
  595.  
  596.             } else {
  597.                 currentService = new Service();
  598.                 Log.i("Java", "current service: service is null");
  599.             }
  600.             if (service != null) {
  601.                 currentServiceInfo = service
  602.                         .getServiceLists()
  603.                         .getList(Service.MAIN_LIST_INDEX)
  604.                         .getServiceInfo(
  605.                                 (int) service.getServiceLists()
  606.                                         .getList(Service.MAIN_LIST_INDEX)
  607.                                         .getCurrentServiceIndex(liveRouteID));
  608.             } else {
  609.                 currentServiceInfo = new ServiceInfo();
  610.                 Log.i("Java", "current service info: service is null");
  611.             }
  612.  
  613.             textID.setText("" + (currentService.getIndex() + 1));
  614.  
  615.             String[] nowStartTime = new String[2];
  616.             nowStartTime = currentServiceInfo.getNow().getStartTime()
  617.                     .split(" ");
  618.  
  619.             textview_start.setText(nowStartTime[0]);
  620.  
  621.             nowStartTime = currentServiceInfo.getNext().getStartTime()
  622.                     .split(" ");
  623.  
  624.             textview_stop.setText(nowStartTime[0]);
  625.  
  626.             int audioCount = currentService.getComponentCountAudio();
  627.             int videoCount = currentService.getComponentCountVideo();
  628.             int subtitleCount = currentService.getComponentCountSubtitle();
  629.             int txtCount = currentService.getComponentCountTeletext();
  630.             Log.i("Java", "audio:" + audioCount);
  631.             Log.i("Java", "video:" + videoCount);
  632.             Log.i("Java", "subtitle:" + subtitleCount);
  633.             Log.i("Java", "teletext:" + txtCount);
  634.             if (audioCount > 0) {
  635.                 textAudio.setTextColor(activity.getResources().getColor(
  636.                         com.comedia.use.R.color.transparent));
  637.             } else {
  638.                 textAudio.setTextColor(activity.getResources().getColor(
  639.                         com.comedia.use.R.color.serviceComponentDisabled));
  640.             }
  641.  
  642.             if (subtitleCount > 0) {
  643.                 textSubtitle.setTextColor(activity.getResources().getColor(
  644.                         com.comedia.use.R.color.transparent));
  645.             } else {
  646.                 textSubtitle.setTextColor(activity.getResources().getColor(
  647.                         com.comedia.use.R.color.serviceComponentDisabled));
  648.             }
  649.             if (txtCount > 0) {
  650.                 textTeletext.setTextColor(activity.getResources().getColor(
  651.                         com.comedia.use.R.color.transparent));
  652.             } else {
  653.                 textTeletext.setTextColor(activity.getResources().getColor(
  654.                         com.comedia.use.R.color.serviceComponentDisabled));
  655.             }
  656.  
  657.             if (videoCount > 0) {
  658.                 textVideo.setTextColor(activity.getResources().getColor(
  659.                         com.comedia.use.R.color.transparent));
  660.             } else
  661.                 textVideo.setTextColor(activity.getResources().getColor(
  662.                         com.comedia.use.R.color.serviceComponentDisabled));
  663.  
  664.             String[] output = currentService.getName().split(" ");
  665.             if (output.length > 2) {
  666.                 textImeKanala.setText(output[0] + " " + output[1] + " ...");
  667.             } else {
  668.                 textImeKanala.setText(currentService.getName());
  669.             }
  670.  
  671.             textNow.setText(currentServiceInfo.getNow().getName());
  672.             textNext.setText(currentServiceInfo.getNext().getName());
  673.  
  674.         } catch (Exception e) {
  675.             e.printStackTrace();
  676.         }
  677.         String returnValue = new String();
  678.         TimeFromStream time;
  679.         if (service != null) {
  680.             try {
  681.                 time = service.getSetupControl().getTimeDateFromStream();
  682.                 if (time == null) {
  683.                     returnValue = "00:00:00 00/00/0000";
  684.                 } else {
  685.                     returnValue = time.getHour() + ":" + time.getMin() + ":"
  686.                             + time.getSec() + " " + time.getDay() + "/"
  687.                             + time.getMonth() + "/" + time.getYear();
  688.                 }
  689.                 textChannelTime.setText(returnValue);
  690.             } catch (Exception e) {
  691.                 // TODO: handle exception
  692.             }
  693.         } else {
  694.             textChannelTime.setText("");
  695.             Log.i("Java", "channel time: service is null");
  696.         }
  697.  
  698.         final int channelInfoProgressValue = Conversions.getEventPassedPercent(
  699.                 currentServiceInfo.getNow().getStartTime(), currentServiceInfo
  700.                         .getNow().getEndTime(), returnValue);
  701.  
  702.         progressBarHandler.post(new Runnable() {
  703.  
  704.             @Override
  705.             public void run() {
  706.                 // TODO Auto-generated method stub
  707.                 progressBar.setProgress(channelInfoProgressValue);
  708.  
  709.             }
  710.         });
  711.  
  712.         channelInforTimer.cancel();
  713.         popupTimer.cancel();
  714.  
  715.         /////////////////////POPUP
  716.         chanellInfo.show();
  717.         popup.setVisibility(View.VISIBLE);
  718.         popup.startAnimation(animShow);
  719.         Log.e("TAG", "\n\n\nsetVisibility startAnimation\n\n\n");
  720.         channelInforTimer = new Timer();
  721.         channelInforTimer.schedule(new TimerTask() {
  722.  
  723.             @Override
  724.             public void run() {
  725.                 mHandler1.post(new Runnable() {
  726.                     @Override
  727.                     public void run() {
  728.                         popup.startAnimation(animHide);
  729.                         Timer timer = new Timer();
  730.                         timer.schedule(new TimerTask() {
  731.  
  732.                             @Override
  733.                             public void run() {
  734.                                 chanellInfo.cancel();
  735.                             }
  736.                         }, 1300);
  737.                     }
  738.                 });
  739.  
  740.             }
  741.         }, 7000);
  742.     }
  743.    
  744.     void initChannelList()
  745.     {
  746.         channelList = new Dialog(activity, com.comedia.use.R.style.SpecialDialog);
  747.         channelList.requestWindowFeature(Window.FEATURE_NO_TITLE);
  748.  
  749.         channelList.getWindow().setFlags(
  750.                 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED,
  751.                 WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
  752.         channelList.setContentView(com.comedia.use.R.layout.chanell_list);
  753.         channelList.setCancelable(true);
  754.        
  755.         channelList.getWindow().getAttributes().width = screenWidth;
  756.         channelList.getWindow().getAttributes().y = screenHeight / 2;
  757.         channelList.getWindow().getAttributes().height = screenHeight * 11 / 12;
  758.         channelList.getWindow().getAttributes().x = -screenWidth / 2;
  759.        
  760.         listNumber = 0;
  761.         naslov = (TextView) channelList
  762.                 .findViewById(com.comedia.use.R.id.SelektovanaOpcija);
  763.         naslov.setText("All channels");
  764.     }
  765.    
  766.     public void fillListChannel() {
  767.         listItems = new ArrayList<Object>();
  768.         switch (listNumber) {
  769.         case 0: {
  770.             try {
  771.                 lengthCurrentList = service.getServiceLists()
  772.                         .getList(Service.MAIN_LIST_INDEX).getServiceListCount();
  773.             } catch (RemoteException e) {
  774.                 // TODO Auto-generated catch block
  775.                 e.printStackTrace();
  776.             }
  777.             break;
  778.         }
  779.         default:
  780.  
  781.             break;
  782.         }
  783.         try {
  784.  
  785.             for (int i = 0; i < lengthCurrentList; i++) {
  786.                 Object object = new Object();
  787.                 listItems.add(object);
  788.             }
  789.             list = (ListView) channelList.findViewById(com.comedia.use.R.id.list);
  790.             list.getBackground().setAlpha(150);
  791.             adapter = new ListItemsAdapter(listItems);
  792.             list.setAdapter(adapter);
  793.             list.setSelection(0);
  794.             list.requestFocus();
  795.             list.setOnItemClickListener(new OnListItemClickListener() {
  796.             });
  797.         } catch (Exception e) {
  798.             Log.d("FillListChannel", "SOMETHING failed");
  799.         }
  800.     }
  801.    
  802.     public void initVolume() {
  803.        
  804.         volumeDialog = new Dialog(ComediaTestActivity.this,
  805.                 com.comedia.use.R.style.Volume_Dialog);
  806.         volumeDialog.getWindow().getAttributes().y = screenHeight / 2;
  807.  
  808.         volumeDialog.setContentView(com.comedia.use.R.layout.seekbar);
  809.         volumeDialog.setCancelable(true);
  810.         volumeDialog.setOnKeyListener(new OnKeyListener() {
  811.            
  812.             @Override
  813.             public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
  814.                 if(keyCode == KeyEvent.KEYCODE_VOLUME_UP)
  815.                 {
  816.                     Log.e("LOG_TAG", "VOLUME UP");
  817.                     try {
  818.                         double currentVolume = service.getAudioControl().getCurrentVolume(liveRouteID);
  819.                         double nextVolume = currentVolume+1;
  820.                         if(nextVolume>100)
  821.                         {
  822.                             nextVolume = 100;
  823.                         }
  824.                         if(!service.getAudioControl().
  825.                                 setCurrentVolume(liveRouteID, nextVolume))
  826.                         {
  827.                             Log.e("LOG_TAG", "Error setting volume");
  828.                         }
  829.                         setVolume((int)nextVolume);
  830.                     } catch (RemoteException e) {
  831.                         // TODO Auto-generated catch block
  832.                         e.printStackTrace();
  833.                     }
  834.                     return true;
  835.                 }else if(keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
  836.                 {
  837.                     Log.e("LOG_TAG", "VOLUME DOWN");
  838.                     try {
  839.                         double currentVolume = service.getAudioControl().getCurrentVolume(liveRouteID);
  840.                         double nextVolume = currentVolume-1;
  841.                         if(nextVolume<0)
  842.                         {
  843.                             nextVolume = 0;
  844.                         }
  845.                         if(!service.getAudioControl().setCurrentVolume(liveRouteID, nextVolume))
  846.                         {
  847.                             Log.e("LOG_TAG", "Error setting volume");
  848.                         }
  849.                         setVolume((int)nextVolume);
  850.                     } catch (RemoteException e) {
  851.                         // TODO Auto-generated catch block
  852.                         e.printStackTrace();
  853.                     }
  854.                     return true;
  855.                 }
  856.                 return false;
  857.             }
  858.         });
  859.  
  860.         volumeBar = (SeekBar) volumeDialog
  861.                 .findViewById(com.comedia.use.R.id.seek_bar);
  862.         volumeBar.setMax(100);
  863.         volumeBar.setProgress(50);
  864.         volumeBar.setFocusable(false);
  865.     }
  866.    
  867.     public static void changeChannel(int index) throws RemoteException
  868.     {
  869.         try {
  870.             service
  871.             .getServiceLists()
  872.             .getList(0)
  873.             .setCurrentServiceByIndex(
  874.                     liveRouteID,
  875.                     index);
  876.             displayChanellInfo(true);
  877.         } catch (RemoteException e) {
  878.             // TODO Auto-generated catch block
  879.             e.printStackTrace();
  880.         }
  881.     }
  882.    
  883.     public static void setVolume(int value)
  884.     {
  885.         if (volumeDialog.isShowing())
  886.         {
  887.             volumeTimerTask.cancel();
  888.             volumeBar.setProgress(value);
  889.         } else
  890.         {
  891.             volumeBar.setProgress(value);
  892.             volumeDialog.show();
  893.         }
  894.        
  895.         volumeTimerTask = new TimerTask() {
  896.             @Override
  897.             public void run() {
  898.                 volumeDialog.cancel();
  899.             }
  900.         };
  901.         volumeTimer.schedule(volumeTimerTask, 1500);
  902.     }
  903. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement