android.support.v17.leanback.app.BackgroundManager Java Examples

The following examples show how to use android.support.v17.leanback.app.BackgroundManager. 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: BrowseFragment.java    From Amphitheatre with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: TVVideoDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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 #3
Source File: VerticalGridFragment.java    From Amphitheatre with Apache License 2.0 6 votes vote down vote up
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 vote down vote up
@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: ListenerModule.java    From leanback-showcase with Apache License 2.0 6 votes vote down vote up
@PerFragment
@Provides
@IntoMap
@ListenerModuleKey(LiveDataFragment.class)
public OnItemViewSelectedListener provideOnItemViewSelectedListener(final Activity activity,
        final DisplayMetrics metrics, final BackgroundManager backgroundManager,
        final RequestOptions defaultPlaceHolder, final Drawable finalDrawable, final Handler mainHandler) {
    return new OnItemViewSelectedListener() {
        @Override
        public void onItemSelected(Presenter.ViewHolder itemViewHolder, Object item,
                RowPresenter.ViewHolder rowViewHolder, Row row) {
            VideoEntity selectedVideo = (VideoEntity) item;
            RunnableClass backgroundRunnable = new RunnableClass(selectedVideo, activity,
                    metrics, backgroundManager, defaultPlaceHolder, finalDrawable);

            if (lastTime != null) {
                mainHandler.removeCallbacks(lastTime);
            }
            mainHandler.postDelayed(backgroundRunnable, BACKGROUND_UPDATE_DELAY);
            lastTime = backgroundRunnable;
        }
    };
}
 
Example #6
Source File: TVVideoDetailsFragment.java    From BuildingForAndroidTV with MIT License 6 votes vote down vote up
@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 #7
Source File: LeanbackFragment.java    From CumulusTV with MIT License 5 votes vote down vote up
private void prepareBackgroundManager() {
    try {
        mBackgroundManager = BackgroundManager.getInstance(getActivity());
        mBackgroundManager.attach(getActivity().getWindow());
        mDefaultBackground = getResources().getDrawable(R.drawable.c_background5);
        mBackgroundManager.setDrawable(getResources().getDrawable(R.drawable.c_background5));
        mMetrics = new DisplayMetrics();
        getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
    } catch(Exception ignored) {
    }
}
 
Example #8
Source File: BackgroundHelper.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(mActivity);
    mBackgroundManager.attach(mActivity.getWindow());
    mBackgroundTarget = new PicassoBackgroundManagerTarget(mBackgroundManager);
    mDefaultBackground = ContextCompat.getDrawable(mActivity, R.drawable.default_background);
    mMetrics = new DisplayMetrics();
    mActivity.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #9
Source File: DynamicRowsFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
/**
 * Helper functions for background image loading and associated animation
 */

private void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #10
Source File: DisplayModule.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@PerFragment
@Provides
public BackgroundManager provideBackgroundManager(Activity activity) {

    final BackgroundManager backgroundManager = BackgroundManager.getInstance(activity);

    // backgroundManager.attach(activity.getWindow());
    return backgroundManager;
}
 
Example #11
Source File: ListenerModule.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
public RunnableClass(VideoEntity selectedVideo, final Activity activity,
        DisplayMetrics metrics, BackgroundManager backgroundManager,
        RequestOptions defaultPlaceHolder, final Drawable drawable) {
    mSelectedVideo = selectedVideo;
    mActivity = activity;
    mDisplayMetrics = metrics;
    mBackgroundManager = backgroundManager;
    mDefaultPlaceHolder = defaultPlaceHolder;
    mDrawable = drawable;
}
 
Example #12
Source File: ListenerModule.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
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: AppDetailsFragment.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
private void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #14
Source File: MainFragment.java    From TvAppRepo with Apache License 2.0 5 votes vote down vote up
private void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #15
Source File: PageAndListRowFragment.java    From leanback-showcase with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setupUi();
    loadData();
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    getMainFragmentRegistry().registerFragment(PageRow.class,
            new PageRowFragmentFactory(mBackgroundManager));
}
 
Example #16
Source File: BackgroundHelper.java    From android-tv-leanback with Apache License 2.0 5 votes vote down vote up
public void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(mActivity);
    mBackgroundManager.attach(mActivity.getWindow());
    mBackgroundTarget = new PicassoBackgroundManagerTarget(mBackgroundManager);
    mDefaultBackground = ContextCompat.getDrawable(mActivity, R.drawable.default_background);
    mMetrics = new DisplayMetrics();
    mActivity.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #17
Source File: MainFragment.java    From leanback-extensions with Apache License 2.0 5 votes vote down vote up
private void prepareBackgroundManager() {
	mBackgroundManager = BackgroundManager.getInstance(getActivity());
	mBackgroundManager.attach(getActivity().getWindow());
	mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
	mMetrics = new DisplayMetrics();
	getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #18
Source File: MovieDetailsFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #19
Source File: VideoDetailsFragment.java    From CumulusTV with MIT License 5 votes vote down vote up
private void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    mDefaultBackground = getResources().getDrawable(R.drawable.c_background5);
    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #20
Source File: DetailFragment.java    From TuentiTV with Apache License 2.0 5 votes vote down vote up
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 #21
Source File: MainFragment.java    From TuentiTV with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: VideoDetailsFragment.java    From AndroidDemoProjects with Apache License 2.0 5 votes vote down vote up
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 #23
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
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 #24
Source File: TVDemoFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
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 #25
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
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 #26
Source File: TVDemoFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
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 #27
Source File: TVGridFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
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 #28
Source File: TVDemoFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
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 #29
Source File: MainFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
private void prepareBackgroundManager() {
    mBackgroundManager = BackgroundManager.getInstance(getActivity());
    mBackgroundManager.attach(getActivity().getWindow());
    mDefaultBackground = getResources().getDrawable(R.drawable.default_background);
    mMetrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(mMetrics);
}
 
Example #30
Source File: PicassoBackgroundManager.java    From alltv with MIT License 5 votes vote down vote up
public PicassoBackgroundManager(Activity activity) {
    mActivity = activity;
    mDefaultBackground = activity.getDrawable(DEFAULT_BACKGROUND_RES_ID);
    mBackgroundManager = BackgroundManager.getInstance(activity);
    mBackgroundManager.attach(activity.getWindow());
    mBackgroundTarget = new PicassoBackgroundManagerTarget(mBackgroundManager);
    mMetrics = new DisplayMetrics();
    activity.getWindowManager().getDefaultDisplay().getMetrics(mMetrics);

}