Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Nullability Annotations to Java Classes] Add Missing Nullability Annotations to All SDK Override Methods for Fragments #19004

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7899a65
Analysis: Add missing n-a to sdk override methods for editor abstract
ParaskP7 Aug 17, 2023
bf3811e
Analysis: Add missing n-a to sdk override methods for aztec editor
ParaskP7 Aug 17, 2023
794a9ac
Analysis: Add missing n-a to sdk override methods for gutenberg editor
ParaskP7 Aug 17, 2023
fb618ef
Analysis: Add missing n-a to sdk override methods for gutenberg ctr
ParaskP7 Aug 17, 2023
9fcf281
Analysis: Add missing n-a to sdk override methods for shared intent rec
ParaskP7 Aug 17, 2023
d382dd5
Analysis: Add missing n-a to sdk override methods for login epilogue
ParaskP7 Aug 17, 2023
1d2776e
Analysis: Add missing n-a to sdk override methods for signup epilogue
ParaskP7 Aug 17, 2023
28135d1
Analysis: Add missing n-a to sdk override methods for comment detail
ParaskP7 Aug 18, 2023
24e283a
Analysis: Add missing n-a to sdk override methods for history detail
ParaskP7 Aug 18, 2023
b85771d
Analysis: Add missing n-a to sdk override methods for media grid
ParaskP7 Aug 18, 2023
a34eb19
Analysis: Add missing n-a to sdk override methods for media preview
ParaskP7 Aug 18, 2023
021ee48
Analysis: Add missing n-a to sdk override methods for people invite
ParaskP7 Aug 18, 2023
2b493e1
Analysis: Add missing n-a to sdk override methods for people list
ParaskP7 Aug 18, 2023
61a9fbb
Analysis: Add missing n-a to sdk override methods for person detail
ParaskP7 Aug 18, 2023
19cf29a
Analysis: Add missing n-a to sdk override methods for plugin list
ParaskP7 Aug 18, 2023
1b619a9
Analysis: Add missing n-a to sdk override methods for edit post settings
ParaskP7 Aug 18, 2023
a4521c7
Analysis: Add missing n-a to sdk override methods for tags
ParaskP7 Aug 18, 2023
625c4d7
Analysis: Add missing n-a to sdk override methods for my profile
ParaskP7 Aug 18, 2023
0eac8cc
Analysis: Add missing n-a to sdk override methods for site settings td
ParaskP7 Aug 18, 2023
d4f1612
Analysis: Add missing n-a to sdk override methods for publicize detail
ParaskP7 Aug 18, 2023
02d7972
Analysis: Add missing n-a to sdk override methods for publicize list
ParaskP7 Aug 18, 2023
ee20b57
Analysis: Add missing n-a to sdk override methods for publicize web view
ParaskP7 Aug 18, 2023
cb7ff06
Analysis: Add missing n-a to sdk override methods for reader blog
ParaskP7 Aug 18, 2023
d4bd5e5
Analysis: Add missing n-a to sdk override methods for reader photo vwr
ParaskP7 Aug 18, 2023
4bc6b33
Analysis: Add missing n-a to sdk override methods for reader post list
ParaskP7 Aug 18, 2023
d21db1d
Analysis: Add missing n-a to sdk override methods for reader post wvc
ParaskP7 Aug 18, 2023
c171a7a
Analysis: Add missing n-a to sdk override methods for reader tag
ParaskP7 Aug 18, 2023
cdbfd2b
Analysis: Add missing n-a to sdk override methods for stock media rtn
ParaskP7 Aug 18, 2023
164ee6b
Analysis: Add missing n-a to sdk override methods for them browser
ParaskP7 Aug 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand Down Expand Up @@ -57,7 +58,7 @@ public static ShareIntentReceiverFragment newInstance(boolean sharingMediaFile,
}

@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof ShareIntentFragmentListener) {
mShareIntentFragmentListener = (ShareIntentFragmentListener) context;
Expand All @@ -76,7 +77,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
ViewGroup layout = (ViewGroup) inflater.inflate(R.layout.share_intent_receiver_fragment, container, false);
initButtonsContainer(layout);
Expand All @@ -95,14 +96,14 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
loadSavedState(savedInstanceState);
}

private void loadSavedState(Bundle savedInstanceState) {
private void loadSavedState(@Nullable Bundle savedInstanceState) {
if (savedInstanceState != null) {
mLastUsedBlogLocalId = savedInstanceState.getInt(ARG_LAST_USED_BLOG_LOCAL_ID);
}
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
int selectedItemLocalId = mAdapter.getSelectedItemLocalId();
if (selectedItemLocalId != -1) {
Expand All @@ -129,7 +130,7 @@ private void initShareActionMediaButton(final ViewGroup layout, boolean sharingM
private void addShareActionListener(final Button button, final ShareAction shareAction) {
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
public void onClick(@NonNull View v) {
mShareIntentFragmentListener.share(shareAction, mAdapter.getSelectedItemLocalId());
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected void setupBottomButton(Button button) {
}

@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

mDoLoginUpdate = requireArguments().getBoolean(ARG_DO_LOGIN_UPDATE, false);
Expand All @@ -165,7 +165,7 @@ public void onCreate(Bundle savedInstanceState) {
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initViewModel();
}
Expand Down Expand Up @@ -301,7 +301,7 @@ public boolean onSiteLongClick(SiteRecord site) {
}

@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);
if (context instanceof LoginEpilogueListener) {
mLoginEpilogueListener = (LoginEpilogueListener) context;
Expand Down Expand Up @@ -370,15 +370,15 @@ private void bindFooterViewHolder(LoginFooterViewHolder holder, SiteList sites)
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) {
}

@Override
public void afterTextChanged(Editable s) {
public void afterTextChanged(@NonNull Editable s) {
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ protected void setupContent(ViewGroup rootView) {
headerAvatarLayout.setEnabled(mIsEmailSignup);
headerAvatarLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
public void onClick(@NonNull View v) {
mUnifiedLoginTracker.trackClick(Click.SELECT_AVATAR);
mMediaPickerLauncher.showGravatarPicker(SignupEpilogueFragment.this);
}
});
headerAvatarLayout.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
public boolean onLongClick(@NonNull View v) {
ToastUtils.showToast(getActivity(), getString(R.string.content_description_add_avatar),
ToastUtils.Duration.SHORT);
return true;
Expand All @@ -214,15 +214,15 @@ public boolean onLongClick(View view) {
mEditTextDisplayName.setText(mDisplayName);
mEditTextDisplayName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) {
}

@Override
public void afterTextChanged(Editable s) {
public void afterTextChanged(@NonNull Editable s) {
mDisplayName = s.toString();
mHeaderDisplayName.setText(mDisplayName);
}
Expand All @@ -232,22 +232,22 @@ public void afterTextChanged(Editable s) {
mEditTextUsername.setText(mUsername);
mEditTextUsername.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
public void onClick(@NonNull View v) {
mUnifiedLoginTracker.trackClick(Click.EDIT_USERNAME);
launchDialog();
}
});
mEditTextUsername.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean hasFocus) {
public void onFocusChange(@NonNull View v, boolean hasFocus) {
if (hasFocus) {
launchDialog();
}
}
});
mEditTextUsername.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int keyCode, KeyEvent event) {
public boolean onKey(@NonNull View v, int keyCode, @NonNull KeyEvent event) {
// Consume keyboard events except for Enter (i.e. click/tap) and Tab (i.e. focus/navigation).
// The onKey method returns true if the listener has consumed the event and false otherwise
// allowing hardware keyboard users to tap and navigate, but not input text as expected.
Expand All @@ -269,7 +269,8 @@ public boolean onKey(View view, int keyCode, KeyEvent event) {
(OnScrollChangeListener) (v, scrollX, scrollY, oldScrollX, oldScrollY) -> showBottomShadowIfNeeded());
// We must use onGlobalLayout here otherwise canScrollVertically will always return false
mScrollView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override public void onGlobalLayout() {
@Override
public void onGlobalLayout() {
mScrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
showBottomShadowIfNeeded();
}
Expand All @@ -289,15 +290,15 @@ private void showBottomShadowIfNeeded() {
protected void setupBottomButton(Button button) {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
public void onClick(@NonNull View v) {
mUnifiedLoginTracker.trackClick(Click.CONTINUE);
updateAccountOrContinue();
}
});
}

@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((WordPress) getActivity().getApplication()).component().inject(this);
mDispatcher.dispatch(AccountActionBuilder.newFetchAccountAction());
Expand Down Expand Up @@ -364,7 +365,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) {

@Override
@SuppressWarnings("deprecation")
public void onActivityResult(int requestCode, int resultCode, Intent data) {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (isAdded()) {
Expand Down Expand Up @@ -434,7 +435,7 @@ public void doNext(Uri uri) {
}

@Override
public void onAttach(Context context) {
public void onAttach(@NonNull Context context) {
super.onAttach(context);

if (context instanceof SignupEpilogueListener) {
Expand Down Expand Up @@ -468,7 +469,7 @@ public void onShown() {
}

@Override
public void onSaveInstanceState(Bundle outState) {
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(KEY_PHOTO_URL, mPhotoUrl);
outState.putString(KEY_DISPLAY_NAME, mDisplayName);
Expand All @@ -482,15 +483,15 @@ public void onSaveInstanceState(Bundle outState) {
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) {
}

@Override
public void afterTextChanged(Editable s) {
public void afterTextChanged(@NonNull Editable s) {
}

@Override
Expand Down Expand Up @@ -665,7 +666,7 @@ private void populateViews() {
protected void showErrorDialog(String message) {
DialogInterface.OnClickListener dialogListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
public void onClick(@Nullable DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_NEGATIVE:
undoChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static CommentDetailFragment newInstance(final String noteId, final Strin
}

@Override
public void onCreate(Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((WordPress) getActivity().getApplication()).component().inject(this);

Expand Down Expand Up @@ -277,9 +277,11 @@ public void onDestroy() {
}

// touching the file resulted in the MethodLength, it's suppressed until we get time to refactor this method
@SuppressWarnings("checkstyle:MethodLength")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@SuppressWarnings("checkstyle:MethodLength")
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.comment_detail_fragment, container, false);

mMediumOpacity = ResourcesCompat.getFloat(
Expand Down Expand Up @@ -337,15 +339,15 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mEditReply.initializeWithPrefix('@');
mEditReply.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
public void beforeTextChanged(@NonNull CharSequence s, int start, int count, int after) {
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
public void onTextChanged(@NonNull CharSequence s, int start, int before, int count) {
}

@Override
public void afterTextChanged(Editable s) {
public void afterTextChanged(@NonNull Editable s) {
mSubmitReplyBtn.setEnabled(!TextUtils.isEmpty(s.toString().trim()));
}
});
Expand Down Expand Up @@ -641,7 +643,7 @@ public void onPause() {

@Override
@SuppressWarnings("deprecation")
public void onActivityResult(int requestCode, int resultCode, Intent data) {
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == INTENT_COMMENT_EDITOR && resultCode == Activity.RESULT_OK) {
reloadComment();
Expand Down Expand Up @@ -1639,8 +1641,9 @@ private void showSnackBar(String message) {
}
}

@Nullable
@Override
@Nullable public View getScrollableViewForUniqueIdProvision() {
public View getScrollableViewForUniqueIdProvision() {
return mNestedScrollView;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ public static HistoryDetailContainerFragment newInstance(final Revision revision
return fragment;
}

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.history_detail_container_fragment, container, false);

mIsFragmentRecreated = savedInstanceState != null;
Expand Down Expand Up @@ -227,20 +229,20 @@ public void onSaveInstanceState(@NonNull Bundle outState) {
}

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.history_detail, menu);
}

@Override
public void onPrepareOptionsMenu(Menu menu) {
public void onPrepareOptionsMenu(@NonNull Menu menu) {
super.onPrepareOptionsMenu(menu);
MenuItem viewMode = menu.findItem(R.id.history_toggle_view);
viewMode.setTitle(isInVisualPreview() ? R.string.history_preview_html : R.string.history_preview_visual);
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.history_load) {
Intent intent = new Intent();
intent.putExtra(KEY_REVISION, mRevision);
Expand Down Expand Up @@ -353,6 +355,7 @@ private class HistoryDetailFragmentAdapter extends FragmentStatePagerAdapter {
mRevisions = (ArrayList<Revision>) revisions.clone();
}

@NonNull
@Override
public Fragment getItem(int position) {
return HistoryDetailFragment.Companion.newInstance(mRevisions.get(position));
Expand All @@ -364,14 +367,15 @@ public int getCount() {
}

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
public void restoreState(@Nullable Parcelable state, @Nullable ClassLoader loader) {
try {
super.restoreState(state, loader);
} catch (IllegalStateException exception) {
AppLog.e(T.EDITOR, exception);
}
}

@Nullable
@Override
public Parcelable saveState() {
Bundle bundle = (Bundle) super.saveState();
Expand Down
Loading