Skip to content

Commit

Permalink
Addressed comments by sharadb-amazon
Browse files Browse the repository at this point in the history
  • Loading branch information
pgregorr-amazon committed Jun 2, 2024
1 parent cb82d51 commit 256a608
Show file tree
Hide file tree
Showing 24 changed files with 472 additions and 358 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,8 @@ public void handleCommissioningButtonClicked(DiscoveredNodeData commissioner) {

@Override
public void handleConnectionButtonClicked(
CastingPlayer castingPlayer, Boolean useCommissionerGeneratedPasscode) {
Log.i(
TAG,
"MainActivity.handleConnectionButtonClicked() useCommissionerGeneratedPasscode: "
+ useCommissionerGeneratedPasscode);
CastingPlayer castingPlayer, boolean useCommissionerGeneratedPasscode) {
Log.i(TAG, "MainActivity.handleConnectionButtonClicked()");
showFragment(
ConnectionExampleFragment.newInstance(castingPlayer, useCommissionerGeneratedPasscode));
}
Expand All @@ -83,37 +80,34 @@ public void handleCommissioningComplete() {

@Override
public void handleConnectionComplete(
CastingPlayer castingPlayer, Boolean useCommissionerGeneratedPasscode) {
Log.i(
TAG,
"MainActivity.handleConnectionComplete() useCommissionerGeneratedPasscode: "
+ useCommissionerGeneratedPasscode);
CastingPlayer castingPlayer, boolean useCommissionerGeneratedPasscode) {
Log.i(TAG, "MainActivity.handleConnectionComplete()");
showFragment(
ActionSelectorFragment.newInstance(castingPlayer, useCommissionerGeneratedPasscode));
}

@Override
public void handleContentLauncherLaunchURLSelected(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
showFragment(
ContentLauncherLaunchURLExampleFragment.newInstance(
selectedCastingPlayer, commissionerGeneratedPasscodeExample));
selectedCastingPlayer, useCommissionerGeneratedPasscode));
}

@Override
public void handleApplicationBasicReadVendorIDSelected(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
showFragment(
ApplicationBasicReadVendorIDExampleFragment.newInstance(
selectedCastingPlayer, commissionerGeneratedPasscodeExample));
selectedCastingPlayer, useCommissionerGeneratedPasscode));
}

@Override
public void handleMediaPlaybackSubscribeToCurrentStateSelected(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
showFragment(
MediaPlaybackSubscribeToCurrentStateExampleFragment.newInstance(
selectedCastingPlayer, commissionerGeneratedPasscodeExample));
selectedCastingPlayer, useCommissionerGeneratedPasscode));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,31 @@ public class ActionSelectorFragment extends Fragment {
private static final String TAG = ActionSelectorFragment.class.getSimpleName();

private final CastingPlayer selectedCastingPlayer;
private final Boolean commissionerGeneratedPasscodeExample;
private final boolean useCommissionerGeneratedPasscode;

private View.OnClickListener selectContentLauncherButtonClickListener;
private View.OnClickListener selectApplicationBasicButtonClickListener;
private View.OnClickListener selectMediaPlaybackButtonClickListener;
private View.OnClickListener disconnectButtonClickListener;

public ActionSelectorFragment(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
this.selectedCastingPlayer = selectedCastingPlayer;
this.commissionerGeneratedPasscodeExample = commissionerGeneratedPasscodeExample;
this.useCommissionerGeneratedPasscode = useCommissionerGeneratedPasscode;
}

/**
* Use this factory method to create a new instance of this fragment using the provided
* parameters.
*
* @param selectedCastingPlayer CastingPlayer that the casting app connected to
* @param commissionerGeneratedPasscodeExample Boolean indicating whether this CastingPlayer was
* commissioned using the Commissioner-Generated passcode commissioning flow
* @param useCommissionerGeneratedPasscode Boolean indicating whether this CastingPlayer was
* commissioned using the Commissioner-Generated passcode commissioning flow.
* @return A new instance of fragment SelectActionFragment.
*/
public static ActionSelectorFragment newInstance(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
return new ActionSelectorFragment(selectedCastingPlayer, commissionerGeneratedPasscodeExample);
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
return new ActionSelectorFragment(selectedCastingPlayer, useCommissionerGeneratedPasscode);
}

@Override
Expand All @@ -71,19 +71,19 @@ public View onCreateView(
v -> {
Log.d(TAG, "handle() called on selectContentLauncherButtonClickListener");
callback.handleContentLauncherLaunchURLSelected(
selectedCastingPlayer, commissionerGeneratedPasscodeExample);
selectedCastingPlayer, useCommissionerGeneratedPasscode);
};
this.selectApplicationBasicButtonClickListener =
v -> {
Log.d(TAG, "handle() called on selectApplicationBasicButtonClickListener");
callback.handleApplicationBasicReadVendorIDSelected(
selectedCastingPlayer, commissionerGeneratedPasscodeExample);
selectedCastingPlayer, useCommissionerGeneratedPasscode);
};
this.selectMediaPlaybackButtonClickListener =
v -> {
Log.d(TAG, "handle() called on selectMediaPlaybackButtonClickListener");
callback.handleMediaPlaybackSubscribeToCurrentStateSelected(
selectedCastingPlayer, commissionerGeneratedPasscodeExample);
selectedCastingPlayer, useCommissionerGeneratedPasscode);
};

this.disconnectButtonClickListener =
Expand Down Expand Up @@ -117,15 +117,15 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
public interface Callback {
/** Notifies listener to trigger transition on selection of Content Launcher cluster */
void handleContentLauncherLaunchURLSelected(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample);
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode);

/** Notifies listener to trigger transition on selection of Application Basic cluster */
void handleApplicationBasicReadVendorIDSelected(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample);
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode);

/** Notifies listener to trigger transition on selection of Media PLayback cluster */
void handleMediaPlaybackSubscribeToCurrentStateSelected(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample);
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode);

/** Notifies listener to trigger transition on click of the Disconnect button */
void handleDisconnect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,32 @@
public class ApplicationBasicReadVendorIDExampleFragment extends Fragment {
private static final String TAG =
ApplicationBasicReadVendorIDExampleFragment.class.getSimpleName();
private static final int DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW = 1;

private final CastingPlayer selectedCastingPlayer;
private final Boolean commissionerGeneratedPasscodeExample;
private final boolean useCommissionerGeneratedPasscode;

private View.OnClickListener readButtonClickListener;

public ApplicationBasicReadVendorIDExampleFragment(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
this.selectedCastingPlayer = selectedCastingPlayer;
this.commissionerGeneratedPasscodeExample = commissionerGeneratedPasscodeExample;
this.useCommissionerGeneratedPasscode = useCommissionerGeneratedPasscode;
}

/**
* Use this factory method to create a new instance of this fragment using the provided
* parameters.
*
* @param selectedCastingPlayer CastingPlayer that the casting app connected to
* @param selectedCastingPlayer CastingPlayer that the casting app connected to.
* @param useCommissionerGeneratedPasscode Boolean indicating whether this CastingPlayer was
* commissioned using the Commissioner-Generated Passcode (CGP) commissioning flow.
* @return A new instance of fragment ApplicationBasicReadVendorIDExampleFragment.
*/
public static ApplicationBasicReadVendorIDExampleFragment newInstance(
CastingPlayer selectedCastingPlayer, Boolean commissionerGeneratedPasscodeExample) {
CastingPlayer selectedCastingPlayer, boolean useCommissionerGeneratedPasscode) {
return new ApplicationBasicReadVendorIDExampleFragment(
selectedCastingPlayer, commissionerGeneratedPasscodeExample);
selectedCastingPlayer, useCommissionerGeneratedPasscode);
}

@Override
Expand All @@ -73,8 +76,10 @@ public View onCreateView(
this.readButtonClickListener =
v -> {
Endpoint endpoint;
if (commissionerGeneratedPasscodeExample) {
endpoint = EndpointSelectorExample.selectFirstEndpoint(selectedCastingPlayer);
if (useCommissionerGeneratedPasscode) {
endpoint =
EndpointSelectorExample.selectEndpointById(
selectedCastingPlayer, DEFAULT_ENDPOINT_ID_FOR_CGP_FLOW);
} else {
endpoint = EndpointSelectorExample.selectFirstEndpointByVID(selectedCastingPlayer);
}
Expand Down
Loading

0 comments on commit 256a608

Please sign in to comment.