com.google.android.gms.cast.framework.CastStateListener Java Examples

The following examples show how to use com.google.android.gms.cast.framework.CastStateListener. 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: VideoBrowserActivity.java    From CastVideos-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.video_browser);
    setupActionBar();

    mCastStateListener = new CastStateListener() {
        @Override
        public void onCastStateChanged(int newState) {
            if (newState != CastState.NO_DEVICES_AVAILABLE) {
                showIntroductoryOverlay();
            }
        }
    };
    mCastContext = CastContext.getSharedInstance(this);
}
 
Example #2
Source File: GoogleCastButtonManager.java    From react-native-google-cast with MIT License 6 votes vote down vote up
@Override
public MediaRouteButton createViewInstance(ThemedReactContext context) {
  CastContext castContext = CastContext.getSharedInstance(context);

  final MediaRouteButton button = new ColorableMediaRouteButton(context);
  googleCastButtonManagerInstance = button;

  CastButtonFactory.setUpMediaRouteButton(context, button);

  updateButtonState(button, castContext.getCastState());

  castContext.addCastStateListener(new CastStateListener() {
    @Override
    public void onCastStateChanged(int newState) {
      GoogleCastButtonManager.this.updateButtonState(button, newState);
    }
  });

  return button;
}
 
Example #3
Source File: VideoBrowserActivity.java    From cast-videos-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.video_browser);
    setupActionBar();

    mCastStateListener = new CastStateListener() {
        @Override
        public void onCastStateChanged(int newState) {
            if (newState != CastState.NO_DEVICES_AVAILABLE) {
                showIntroductoryOverlay();
            }
        }
    };

    mCastContext = CastContext.getSharedInstance(this);
}
 
Example #4
Source File: Casty.java    From Casty with MIT License 5 votes vote down vote up
@NonNull
private CastStateListener createCastStateListener() {
    return new CastStateListener() {
        @Override
        public void onCastStateChanged(int state) {
            if (state != CastState.NO_DEVICES_AVAILABLE && introductionOverlay != null) {
                showIntroductionOverlay();
            }
        }
    };
}
 
Example #5
Source File: GoogleCastDelegate.java    From edx-app-android with Apache License 2.0 5 votes vote down vote up
public void addCastStateListener(@NonNull CastStateListener stateListener) {
    if (castContext != null) {
        castContext.addCastStateListener(stateListener);
    }
    if (castSession == null) {
        init();
    }
}
 
Example #6
Source File: WatchLaterVideosFragment.java    From Loop with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

    final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
    if(ab != null){
        ab.setHomeAsUpIndicator(R.drawable.ic_menu_light);
        ab.setDisplayHomeAsUpEnabled(true);
        ab.setTitle(TrestleUtility.getFormattedText(getString(R.string.watch_later), font));
    }

    castStateListener = new CastStateListener() {
        @Override
        public void onCastStateChanged(int newState) {
            if (newState != CastState.NO_DEVICES_AVAILABLE) {
                showIntroductoryOverlay();
            }
        }
    };

    setUpRxBusSubscription();

    layoutManager = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(layoutManager);
    videosAdapter = new VideosAdapter();
    videosAdapter.setOnItemClickListener(this);
    videosAdapter.setOnReloadClickListener(this);

    recyclerView.setItemAnimator(new SlideInUpAnimator());
    recyclerView.setAdapter(videosAdapter);

    // Pagination
    recyclerView.addOnScrollListener(recyclerViewOnScrollListener);

    Call findWatchLaterVideosCall = vimeoService.findWatchLaterVideos(null,
            sortByValue,
            sortOrderValue,
            currentPage,
            PAGE_SIZE);
    calls.add(findWatchLaterVideosCall);
    findWatchLaterVideosCall.enqueue(findVideosFirstFetchCallback);
}
 
Example #7
Source File: GoogleCastDelegate.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
public void removeCastStateListener(@NonNull CastStateListener stateListener) {
    if (castContext != null) {
        castContext.removeCastStateListener(stateListener);
    }
}