// Path: app/src/main/java/android/support/v17/leanback/streamingapp/utils/Utils.java
// public class Utils {
// 
//     public static int convertDpToPixel(Context ctx, int dp) {
//         float density = ctx.getResources().getDisplayMetrics().density;
//         return Math.round((float) dp * density);
//     }
// 
//     /**
//      * Will read the content from a given {@link InputStream} and return it as a {@link String}.
//      *
//      * @param inputStream The {@link InputStream} which should be read.
//      * @return Returns <code>null</code> if the the {@link InputStream} could not be read. Else
//      * returns the content of the {@link InputStream} as {@link String}.
//      */
//     public static String inputStreamToString(InputStream inputStream) {
//         try {
//             byte[] bytes = new byte[inputStream.available()];
//             inputStream.read(bytes, 0, bytes.length);
//             String json = new String(bytes);
//             return json;
//         } catch (IOException e) {
//             return null;
//         }
//     }
// 
//     public static Uri getResourceUri(Context context, int resID) {
//         return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
//                                  context.getResources().getResourcePackageName(resID) + '/' +
//                                  context.getResources().getResourceTypeName(resID) + '/' +
//                                  context.getResources().getResourceEntryName(resID));
//     }
// 
//     public static boolean hasPermission(final Context context, final String permission) {
//         return PackageManager.PERMISSION_GRANTED == context.getPackageManager().checkPermission(
//                 permission, context.getPackageName());
//     }
// }


import android.Manifest;
import android.content.ActivityNotFoundException;
import android.os.Bundle;
import android.support.v17.leanback.streamingapp.utils.Utils;
import android.support.v17.leanback.widget.ArrayObjectAdapter;
import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.ObjectAdapter;
import android.support.v17.leanback.widget.SpeechRecognitionCallback;
import android.util.Log;
package android.support.v17.leanback.streamingapp.app.search;


public class SearchFragment extends android.support.v17.leanback.app.SearchFragment implements android.support.v17.leanback.app.SearchFragment.SearchResultProvider {

    private static final int REQUEST_SPEECH = 0x00000010;
    private ArrayObjectAdapter mRowsAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

        Log.d("Mokto", "start Activity");
        setSearchResultProvider(this);

// Path: app/src/main/java/android/support/v17/leanback/streamingapp/utils/Utils.java
// public class Utils {
// 
//     public static int convertDpToPixel(Context ctx, int dp) {
//         float density = ctx.getResources().getDisplayMetrics().density;
//         return Math.round((float) dp * density);
//     }
// 
//     /**
//      * Will read the content from a given {@link InputStream} and return it as a {@link String}.
//      *
//      * @param inputStream The {@link InputStream} which should be read.
//      * @return Returns <code>null</code> if the the {@link InputStream} could not be read. Else
//      * returns the content of the {@link InputStream} as {@link String}.
//      */
//     public static String inputStreamToString(InputStream inputStream) {
//         try {
//             byte[] bytes = new byte[inputStream.available()];
//             inputStream.read(bytes, 0, bytes.length);
//             String json = new String(bytes);
//             return json;
//         } catch (IOException e) {
//             return null;
//         }
//     }
// 
//     public static Uri getResourceUri(Context context, int resID) {
//         return Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" +
//                                  context.getResources().getResourcePackageName(resID) + '/' +
//                                  context.getResources().getResourceTypeName(resID) + '/' +
//                                  context.getResources().getResourceEntryName(resID));
//     }
// 
//     public static boolean hasPermission(final Context context, final String permission) {
//         return PackageManager.PERMISSION_GRANTED == context.getPackageManager().checkPermission(
//                 permission, context.getPackageName());
//     }
// }


// Path: app/src/main/java/android/support/v17/leanback/streamingapp/app/search/SearchFragment.java
import android.Manifest;
import android.content.ActivityNotFoundException;
import android.os.Bundle;
import android.support.v17.leanback.streamingapp.utils.Utils;
import android.support.v17.leanback.widget.ArrayObjectAdapter;
import android.support.v17.leanback.widget.ListRowPresenter;
import android.support.v17.leanback.widget.ObjectAdapter;
import android.support.v17.leanback.widget.SpeechRecognitionCallback;
import android.util.Log;

package android.support.v17.leanback.streamingapp.app.search;


public class SearchFragment extends android.support.v17.leanback.app.SearchFragment implements android.support.v17.leanback.app.SearchFragment.SearchResultProvider {

    private static final int REQUEST_SPEECH = 0x00000010;
    private ArrayObjectAdapter mRowsAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter());

        Log.d("Mokto", "start Activity");
        setSearchResultProvider(this);

        if (!Utils.hasPermission(getActivity(), Manifest.permission.RECORD_AUDIO)) {