Java Code Examples for com.google.android.gms.cast.framework.CastState#NO_DEVICES_AVAILABLE

The following examples show how to use com.google.android.gms.cast.framework.CastState#NO_DEVICES_AVAILABLE . 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: 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 3
Source File: GoogleCastDelegate.java    From edx-app-android with Apache License 2.0 6 votes vote down vote up
public void showIntroductoryOverlay(@NonNull Activity activity, @Nullable final MenuItem mediaRouteMenuItem) {
    if (castContext.getCastState() != CastState.NO_DEVICES_AVAILABLE) {
        if (introductoryOverlay != null) {
            introductoryOverlay.remove();
        }
        if (mediaRouteMenuItem != null && mediaRouteMenuItem.isVisible()) {
            new Handler().post(() -> {
                introductoryOverlay = new IntroductoryOverlay.Builder(
                        activity, mediaRouteMenuItem)
                        .setTitleText(context.getString(R.string.introducing_cast_text))
                        .setSingleTime()
                        .setOnOverlayDismissedListener(
                                () -> introductoryOverlay = null)
                        .build();
                introductoryOverlay.show();
            });
        }
    }
}
 
Example 4
Source File: MainActivity.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
@Override
public void onCastStateChanged(int newState) {
    Log.e("Tuts+", "onCastStateChanged");

    switch( newState ) {
        case CastState.CONNECTED: {

            break;
        } case CastState.CONNECTING: {

            break;
        } case CastState.NOT_CONNECTED: {

            break;
        } case CastState.NO_DEVICES_AVAILABLE: {

        }
    }

    if (newState != CastState.NO_DEVICES_AVAILABLE) {
        showIntroductoryOverlay();
    }
}
 
Example 5
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 6
Source File: GoogleCastButtonManager.java    From react-native-google-cast with MIT License 5 votes vote down vote up
private void updateButtonState(MediaRouteButton button, int state) {
  // hide the button when no device available (default behavior is show it
  // disabled)
  if (CastState.NO_DEVICES_AVAILABLE == state) {
    button.setVisibility(View.GONE);
  } else {
    button.setVisibility(View.VISIBLE);
  }
}
 
Example 7
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);
}