Java Code Examples for android.support.v17.leanback.app.BackgroundManager#attach()
The following examples show how to use
android.support.v17.leanback.app.BackgroundManager#attach() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TVVideoDetailsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate DetailsFragment"); super.onCreate(savedInstanceState); BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); selectedMovie = (Movie) getActivity().getIntent().getSerializableExtra(MOVIE); new DetailRowBuilderTask().execute(selectedMovie); setOnItemClickedListener(getDefaultItemClickedListener()); updateBackground(selectedMovie.getBackgroundImageURI()); }
Example 2
Source File: BrowseFragment.java From Amphitheatre with Apache License 2.0 | 6 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.amphitheatre); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); Picasso.with(getActivity()) .load(R.drawable.amphitheatre) .resize(mMetrics.widthPixels, mMetrics.heightPixels) .centerCrop() .skipMemoryCache() .into(mBackgroundTarget); }
Example 3
Source File: VerticalGridFragment.java From Amphitheatre with Apache License 2.0 | 6 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.amphitheatre); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); Picasso.with(getActivity()) .load(R.drawable.amphitheatre) .resize(mMetrics.widthPixels, mMetrics.heightPixels) .centerCrop() .skipMemoryCache() .into(mBackgroundTarget); }
Example 4
Source File: TVVideoDetailsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate DetailsFragment"); super.onCreate(savedInstanceState); BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); selectedMovie = (Movie) getActivity().getIntent().getSerializableExtra(MOVIE); new DetailRowBuilderTask().execute(selectedMovie); setOnItemClickedListener(getDefaultItemClickedListener()); updateBackground(selectedMovie.getBackgroundImageURI()); }
Example 5
Source File: TVVideoDetailsFragment.java From BuildingForAndroidTV with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { Log.i(TAG, "onCreate DetailsFragment"); super.onCreate(savedInstanceState); BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); selectedMovie = (Movie) getActivity().getIntent().getSerializableExtra(MOVIE); new DetailRowBuilderTask().execute(selectedMovie); setOnItemClickedListener(getDefaultItemClickedListener()); updateBackground(selectedMovie.getBackgroundImageURI()); }
Example 6
Source File: TVGridFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); }
Example 7
Source File: TVDemoFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); }
Example 8
Source File: TVGridFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); }
Example 9
Source File: TVDemoFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); }
Example 10
Source File: TVGridFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); }
Example 11
Source File: TVDemoFragment.java From BuildingForAndroidTV with MIT License | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mDefaultBackground = getResources().getDrawable(R.drawable.default_background); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); }
Example 12
Source File: ListenerModule.java From leanback-showcase with Apache License 2.0 | 5 votes |
private void loadAndSetBackgroundImageParameter(VideoEntity selectedVideo, final Activity activity, DisplayMetrics metrics, final BackgroundManager backgroundManager, RequestOptions defaultPlaceHolder, Drawable defualtDrawble) { if (selectedVideo == null) { return; } String url1 = selectedVideo.getVideoBgImageLocalStorageUrl(); String url2 = selectedVideo.getBgImageUrl(); String loadedUri; if (url1.isEmpty()) { loadedUri = url2; } else { loadedUri = url1; } // wait until runtime the activity has window if (!backgroundManager.isAttached()) { backgroundManager.attach(activity.getWindow()); } // glide on error Glide.with(activity) .asBitmap() .load(loadedUri) .apply(defaultPlaceHolder) .into(new SimpleTarget<Bitmap>(metrics.widthPixels, metrics.heightPixels) { @Override public void onResourceReady(Bitmap resource, Transition<? super Bitmap> glideAnimation) { backgroundManager.setDrawable( new BitmapDrawable(activity.getResources(), resource)); } }); }
Example 13
Source File: VideoDetailsFragment.java From AndroidDemoProjects with Apache License 2.0 | 5 votes |
private void initBackground() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget( backgroundManager ); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); if( mSelectedMovie != null && !TextUtils.isEmpty( mSelectedMovie.getBackgroundImageUrl() ) ) { try { updateBackground(new URI(mSelectedMovie.getBackgroundImageUrl())); } catch (URISyntaxException e) { } } }
Example 14
Source File: MainFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
private void prepareBackgroundManager() { BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); backgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); metrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); }
Example 15
Source File: DetailFragment.java From TuentiTV with Apache License 2.0 | 5 votes |
private void configureBackground() { metrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); backgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); }
Example 16
Source File: MainFragment.java From AndroidDemoProjects with Apache License 2.0 | 4 votes |
private void setBackground() { BackgroundManager backgroundManager = BackgroundManager.getInstance( getActivity() ); backgroundManager.attach( getActivity().getWindow() ); backgroundManager.setDrawable( getResources().getDrawable( R.drawable.default_background ) ); }
Example 17
Source File: VideoDetailsFragment.java From Amphitheatre with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBlurTransformation = new BlurTransform(getActivity()); BackgroundManager backgroundManager = BackgroundManager.getInstance(getActivity()); backgroundManager.attach(getActivity().getWindow()); mBackgroundTarget = new PicassoBackgroundManagerTarget(backgroundManager); mMetrics = new DisplayMetrics(); getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics); boolean isVideo = getActivity().getIntent().getBooleanExtra(Constants.IS_VIDEO, true); Video video; if (isVideo) { video = (Video) getActivity().getIntent().getSerializableExtra(Constants.VIDEO); if (video.getTvShow() != null && video.getTvShow().getEpisode() != null) { updateBackground(video.getTvShow().getEpisode().getStillPath()); } else { updateBackground(video.getBackgroundImageUrl()); } Map<String, List<Video>> relatedVideos = Collections.emptyMap(); if (video.isMovie()) { relatedVideos = getRelatedMovies(video); } else if (video.getTvShow() != null && video.getTvShow().getEpisode() != null) { relatedVideos = getRelatedTvShows(video); } new DetailRowBuilderTask(getActivity(), relatedVideos, true, this).execute(video); } else { VideoGroup videoGroup = (VideoGroup) getActivity().getIntent().getSerializableExtra(Constants.VIDEO_GROUP); video = videoGroup.getVideo(); updateBackground(video.getBackgroundImageUrl()); new DetailRowBuilderTask(getActivity(), getRelatedTvShows(video), false, this).execute(video); } setOnItemClickedListener(getDefaultItemClickedListener()); }