Skip to content

Commit

Permalink
fix(#338): Refactor OpenSettingsDialogFragment class to have a empty …
Browse files Browse the repository at this point in the history
…constructor
  • Loading branch information
sugat009 committed Jun 26, 2024
1 parent 04d3cdd commit 9378619
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void onReceiveValue(String result) {
container = findViewById(R.id.wbvMain);
getFragmentManager()
.beginTransaction()
.add(new OpenSettingsDialogFragment(container), OpenSettingsDialogFragment.class.getName())
.add(new OpenSettingsDialogFragment(), OpenSettingsDialogFragment.class.getName())
.commit();

configureUserAgent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@

import java.time.Clock;

@SuppressLint("ValidFragment")
public class OpenSettingsDialogFragment extends Fragment {

private final View view;
private int fingerTapCount = 0;
private long lastTimeTap = 0;
private GestureHandler swipeGesture;
private static final int TIME_BETWEEN_TAPS = 500;

public OpenSettingsDialogFragment() {
}

private final OnTouchListener onTouchListener = new OnTouchListener() {
@SuppressLint("ClickableViewAccessibility")
@Override
Expand All @@ -32,13 +33,10 @@ public boolean onTouch(View view, MotionEvent event) {
}
};

public OpenSettingsDialogFragment(View view) {
this.view = view;
}

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = getActivity().findViewById(R.id.wbvMain);
view.setOnTouchListener(onTouchListener);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ public void setup() {
doNothing().when(view).setOnTouchListener(argsOnTouch.capture());

MockSettings fragmentSettings = withSettings()
.useConstructor(view)
.useConstructor()
.defaultAnswer(CALLS_REAL_METHODS);

openSettingsDialogFragment = mock(OpenSettingsDialogFragment.class, fragmentSettings);
when(openSettingsDialogFragment.getActivity()).thenReturn(activity);
when(openSettingsDialogFragment.getActivity().findViewById(R.id.wbvMain)).thenReturn(view);
argsStartActivity = ArgumentCaptor.forClass(Intent.class);
doNothing().when(openSettingsDialogFragment).startActivity(argsStartActivity.capture());

Expand Down

0 comments on commit 9378619

Please sign in to comment.