private void setListeners() { setOnItemViewClickedListener(mOnItemViewClickedListener); setOnItemViewSelectedListener(mOnItemViewSelectedListener); if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException error) { Timber.e(error, "Cannot find activity for speech recognizer"); } } }); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.search); mFragment = (SearchFragment) getFragmentManager().findFragmentById(R.id.search_fragment); if (USE_INTERNAL_SPEECH_RECOGNIZER) { mSpeechRecognitionCallback = new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { if (DEBUG) { Log.v(TAG, "recognizeSpeech"); } startActivityForResult(mFragment.getRecognizerIntent(), REQUEST_SPEECH); } }; mFragment.setSpeechRecognitionCallback(mSpeechRecognitionCallback); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tv_search); mFragment = (SearchFragment) getFragmentManager() .findFragmentById(R.id.search_fragment); SpeechRecognitionCallback speechRecognitionCallback = new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { startActivityForResult(mFragment.getRecognizerIntent(), REQUEST_SPEECH); } }; mFragment.setSpeechRecognitionCallback(speechRecognitionCallback); }
private void setListeners() { setOnItemViewClickedListener(mOnItemViewClickedListener); setOnItemViewSelectedListener(mOnItemViewSelectedListener); if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException e) { Timber.e("Cannot find activity for speech recognizer", e); } } }); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setSearchResultProvider(this); setOnItemViewClickedListener(new ItemViewClickedListener()); if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { // SpeechRecognitionCallback is not required and if not provided recognition will be handled // using internal speech recognizer, in which case you must have RECORD_AUDIO permission setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { if (DEBUG) Log.v(TAG, "recognizeSpeech"); try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException e) { Log.e(TAG, "Cannot find activity for speech recognizer", e); } } }); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); mVideoCursorAdapter.setMapper(new VideoCursorMapper()); setSearchResultProvider(this); setOnItemViewClickedListener(new ItemViewClickedListener()); if (DEBUG) { Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " + hasPermission(Manifest.permission.RECORD_AUDIO)); } if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { if (DEBUG) { Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback"); } // SpeechRecognitionCallback is not required and if not provided recognition will be // handled using internal speech recognizer, in which case you must have RECORD_AUDIO // permission setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException e) { Log.e(TAG, "Cannot find activity for speech recognizer", e); } } }); } else if (DEBUG) { Log.d(TAG, "We DO have RECORD_AUDIO"); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mScraper = new Scraper(getActivity()); mSearchExecutor = new SerialExecutor(); ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector(); rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector); setBadgeDrawable(getResources().getDrawable(R.mipmap.video2)); setSearchResultProvider(this); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof BaseTags) { saveTagsAndFinish((BaseTags) item); } } }); mSpeechRecognitionCallback = new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { // ACTION_RECOGNIZE_SPEECH try{ startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE); }catch (ActivityNotFoundException e){/*non google device*/} } }; setSpeechRecognitionCallback(mSpeechRecognitionCallback); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSpinnerFragment = new SpinnerFragment(); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); mVideoCursorAdapter.setMapper(new VideoCursorMapper()); setSearchResultProvider(this); setOnItemViewClickedListener(new ItemViewClickedListener()); if (DEBUG) { Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " + hasPermission(Manifest.permission.RECORD_AUDIO)); } if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { if (DEBUG) { Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback"); } // SpeechRecognitionCallback is not required and if not provided recognition will be // handled using internal speech recognizer, in which case you must have RECORD_AUDIO // permission setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException e) { Log.e(TAG, "Cannot find activity for speech recognizer", e); } } }); } else if (DEBUG) { Log.d(TAG, "We DO have RECORD_AUDIO"); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setSearchResultProvider(this); setOnItemViewClickedListener(new ItemViewClickedListener()); if (DEBUG) { Log.d(TAG, "User is initiating a search. Do we have RECORD_AUDIO permission? " + hasPermission(Manifest.permission.RECORD_AUDIO)); } if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { if (DEBUG) { Log.d(TAG, "Does not have RECORD_AUDIO, using SpeechRecognitionCallback"); } // SpeechRecognitionCallback is not required and if not provided recognition will be // handled using internal speech recognizer, in which case you must have RECORD_AUDIO // permission setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException e) { Log.e(TAG, "Cannot find activity for speech recognizer", e); } } }); } else if (DEBUG) { Log.d(TAG, "We DO have RECORD_AUDIO"); } }
private void initFragment() { fragment = (SearchFragment) getSupportFragmentManager() .findFragmentById(R.id.ondemand_search_fragment); fragment.setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { Log.d(TAG, "recognizeSpeech"); startActivityForResult(fragment.getRecognizerIntent(), SPEECH_REQUEST_CODE); } }); }
/** * Set this callback to have the fragment pass speech recognition requests * to the activity rather than using an internal recognizer. */ public void setSpeechRecognitionCallback(SpeechRecognitionCallback callback) { mSpeechRecognitionCallback = callback; if (mSearchBar != null) { mSearchBar.setSpeechRecognitionCallback(mSpeechRecognitionCallback); } if (callback != null) { releaseRecognizer(); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ClassPresenterSelector rowsPresenterSelector = new ClassPresenterSelector(); rowsPresenterSelector.addClassPresenter(ListRow.class, new ListRowPresenter()); rowsPresenterSelector.addClassPresenter(ShadowLessListRow.class, new ShadowLessRowPresenter()); mRowsAdapter = new ArrayObjectAdapter(rowsPresenterSelector); mSpeechRecognitionCallback = new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { // ACTION_RECOGNIZE_SPEECH try { startActivityForResult(getRecognizerIntent(), SEARCH_REQUEST_CODE); }catch (android.content.ActivityNotFoundException e){ //no google device } } }; setSpeechRecognitionCallback(mSpeechRecognitionCallback); setSearchResultProvider(this); setOnItemViewClickedListener(new VideoViewClickedListener(getActivity())); setBadgeDrawable(getResources().getDrawable(R.mipmap.video2)); mDelayedLoad = new SearchRunnable(); int searchMode = getArguments() != null ? getArguments().getInt(VideoSearchActivity.EXTRA_SEARCH_MODE, VideoSearchActivity.SEARCH_MODE_ALL) : VideoSearchActivity.SEARCH_MODE_ALL; if (searchMode == VideoSearchActivity.SEARCH_MODE_MOVIE) { setTitle(getString(R.string.movies)); mSearchLoader = new SearchMovieLoader(getActivity()); } else if (searchMode == VideoSearchActivity.SEARCH_MODE_NON_SCRAPED) { setTitle(getString(R.string.videos)); mSearchLoader = new SearchNonScrapedVideoLoader(getActivity()); } else { setTitle(getString(R.string.videos)); mSearchLoader = new SearchVideoLoader(getActivity()); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mRowsAdapter = new ArrayObjectAdapter(new ListRowPresenter()); setSearchResultProvider(this); setOnItemViewClickedListener(new OnItemViewClickedListener() { @Override public void onItemClicked(Presenter.ViewHolder itemViewHolder, Object item, RowPresenter.ViewHolder rowViewHolder, Row row) { if (item instanceof Track) { String trackUri = ((Track) item).uri; SpotifyPlayerController spotifyPlayerController = SpotifyTvApplication.getInstance().getSpotifyPlayerController(); if (spotifyPlayerController.getPlayingState().isCurrentTrack(trackUri)) { spotifyPlayerController.togglePauseResume(); } else { // get song and following ones List<TrackSimple> tracks = new ArrayList<>(); List<String> trackUris = new ArrayList<>(); for (int i = mTrackRowAdapter.indexOf(item); i < mTrackRowAdapter.size() && i < Constants.MAX_SONGS_PLAYED; i++) { tracks.add((TrackSimple) mTrackRowAdapter.get(i)); trackUris.add(((Track) mTrackRowAdapter.get(i)).uri); } spotifyPlayerController.play(trackUri, trackUris, tracks); } } else { SpotifyTvApplication.getInstance().launchDetailScreen(getActivity(), item); } } }); mDelayedLoad = new SearchRunnable(); if (!hasPermission(Manifest.permission.RECORD_AUDIO)) { // SpeechRecognitionCallback is not required and if not provided recognition will be handled // using internal speech recognizer, in which case you must have RECORD_AUDIO permission setSpeechRecognitionCallback(new SpeechRecognitionCallback() { @Override public void recognizeSpeech() { Log.v(TAG, "recognizeSpeech"); try { startActivityForResult(getRecognizerIntent(), REQUEST_SPEECH); } catch (ActivityNotFoundException e) { Log.e(TAG, "Cannot find activity for speech recognizer", e); } } }); } }