Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7ca48e0 authored by stefan-niedermann's avatar stefan-niedermann
Browse files

Use requireX instead of Objects.requireNonNull

parent bd0f3fc8
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class AccountChooserDialogFragment extends AppCompatDialogFragment implem
    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        View view = Objects.requireNonNull(getActivity()).getLayoutInflater().inflate(R.layout.dialog_choose_account, null);
        View view = requireActivity().getLayoutInflater().inflate(R.layout.dialog_choose_account, null);
        ButterKnife.bind(this, view);

        NoteSQLiteOpenHelper db = NoteSQLiteOpenHelper.getInstance(getActivity());
@@ -67,7 +67,7 @@ public class AccountChooserDialogFragment extends AppCompatDialogFragment implem
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Objects.requireNonNull(Objects.requireNonNull(getDialog()).getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
        Objects.requireNonNull(requireDialog().getWindow()).setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
        return super.onCreateView(inflater, container, savedInstanceState);
    }

+2 −2
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
    public void onCreateOptionsMenu(@NonNull Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.menu_note_fragment, menu);

        if (isRequestPinShortcutSupported(Objects.requireNonNull(getActivity())) && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        if (isRequestPinShortcutSupported(requireActivity()) && android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            menu.add(Menu.NONE, MENU_ID_PIN, 110, R.string.pin_to_homescreen);
        }
    }
@@ -214,7 +214,7 @@ public abstract class BaseNoteFragment extends Fragment implements CategoryDialo
                return false;
            case MENU_ID_PIN:
                if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                    ShortcutManager shortcutManager = Objects.requireNonNull(getActivity()).getSystemService(ShortcutManager.class);
                    ShortcutManager shortcutManager = requireActivity().getSystemService(ShortcutManager.class);

                    if (shortcutManager.isRequestPinShortcutSupported()) {
                        Intent intent = new Intent(getActivity(), EditNoteActivity.class);
+2 −2
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class CategoryDialogFragment extends AppCompatDialogFragment {
    @NonNull
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        View dialogView = Objects.requireNonNull(getActivity()).getLayoutInflater().inflate(R.layout.dialog_change_category, null);
        View dialogView = requireActivity().getLayoutInflater().inflate(R.layout.dialog_change_category, null);
        ButterKnife.bind(this, dialogView);

        if (savedInstanceState == null) {
@@ -98,7 +98,7 @@ public class CategoryDialogFragment extends AppCompatDialogFragment {
            editCategory.setText(savedInstanceState.getString(STATE_CATEGORY));
        }

        adapter = new CategoryAdapter(Objects.requireNonNull(getContext()), new CategoryAdapter.CategoryListener() {
        adapter = new CategoryAdapter(requireContext(), new CategoryAdapter.CategoryListener() {
            @Override
            public void onCategoryChosen(String category) {
                listener.onCategoryChosen(category);
+5 −7
Original line number Diff line number Diff line
@@ -28,15 +28,13 @@ import com.yydcdut.markdown.MarkdownProcessor;
import com.yydcdut.markdown.MarkdownTextView;
import com.yydcdut.markdown.syntax.text.TextFactory;

import java.util.Objects;

import butterknife.BindView;
import butterknife.ButterKnife;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.android.activity.EditNoteActivity;
import it.niedermann.owncloud.notes.model.ISyncCallback;
import it.niedermann.owncloud.notes.persistence.NoteSQLiteOpenHelper;
import it.niedermann.owncloud.notes.util.DisplayUtils;
import it.niedermann.owncloud.notes.model.ISyncCallback;
import it.niedermann.owncloud.notes.util.MarkDownUtil;
import it.niedermann.owncloud.notes.util.NoteLinksUtils;

@@ -113,8 +111,8 @@ public class NoteReadonlyFragment extends SearchableBaseNoteFragment {
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        ButterKnife.bind(this, Objects.requireNonNull(getView()));
        markdownProcessor = new MarkdownProcessor(Objects.requireNonNull(getActivity()));
        ButterKnife.bind(this, requireView());
        markdownProcessor = new MarkdownProcessor(requireActivity());
        markdownProcessor.factory(TextFactory.create());
        markdownProcessor.config(
                MarkDownUtil.getMarkDownConfiguration(noteContent.getContext())
@@ -122,7 +120,7 @@ public class NoteReadonlyFragment extends SearchableBaseNoteFragment {
                            if (NoteLinksUtils.isNoteLink(link)) {
                                long noteRemoteId = NoteLinksUtils.extractNoteRemoteId(link);
                                long noteLocalId = db.getLocalIdByRemoteId(this.note.getAccountId(), noteRemoteId);
                                Intent intent = new Intent(getActivity().getApplicationContext(), EditNoteActivity.class);
                                Intent intent = new Intent(requireActivity().getApplicationContext(), EditNoteActivity.class);
                                intent.putExtra(EditNoteActivity.PARAM_NOTE_ID, noteLocalId);
                                startActivity(intent);
                            } else {
@@ -144,7 +142,7 @@ public class NoteReadonlyFragment extends SearchableBaseNoteFragment {
        db = NoteSQLiteOpenHelper.getInstance(getActivity());
        swipeRefreshLayout.setEnabled(false);

        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(Objects.requireNonNull(getActivity()).getApplicationContext());
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(requireActivity().getApplicationContext());
        noteContent.setTextSize(TypedValue.COMPLEX_UNIT_PX, getFontSizeFromPreferences(sp));
        if (sp.getBoolean(getString(R.string.pref_key_font), false)) {
            noteContent.setTypeface(Typeface.MONOSPACE);