diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-05-07 17:31:14 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-05-07 17:31:14 +0000 |
commit | fcfdee935379f1116a9978cd6b118f2bbeb7b1e1 (patch) | |
tree | 9d3af0b361d2888c987d61466d6802998f13cef9 /app | |
parent | 6933d911aeae2f687602c9110f83c31d7d99d822 (diff) | |
download | infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.tar infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.tar.gz infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.tar.bz2 infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.tar.lz infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.tar.xz infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.tar.zst infinity-for-reddit-fcfdee935379f1116a9978cd6b118f2bbeb7b1e1.zip |
Migrate to ViewBinding in all bottom sheet fragments.
Diffstat (limited to 'app')
22 files changed, 274 insertions, 540 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java index d4852e04..2d01d37f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CopyTextBottomSheetFragment.java @@ -19,12 +19,11 @@ import androidx.fragment.app.FragmentManager; import com.google.android.material.dialog.MaterialAlertDialogBuilder; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentCopyTextBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; /** @@ -34,15 +33,6 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS public static final String EXTRA_RAW_TEXT = "ERT"; public static final String EXTRA_MARKDOWN = "EM"; - @BindView(R.id.copy_raw_text_text_view_copy_text_bottom_sheet_fragment) - TextView copyRawTextTextView; - @BindView(R.id.copy_markdown_text_view_copy_text_bottom_sheet_fragment) - TextView copyMarkdownTextView; - @BindView(R.id.copy_all_raw_text_text_view_copy_text_bottom_sheet_fragment) - TextView copyAllRawTextTextView; - @BindView(R.id.copy_all_markdown_text_view_copy_text_bottom_sheet_fragment) - TextView copyAllMarkdownTextView; - private BaseActivity baseActivity; private ViewRedditGalleryActivity viewRedditGalleryActivity; private String markdownText; @@ -66,52 +56,51 @@ public class CopyTextBottomSheetFragment extends LandscapeExpandedRoundedBottomS } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_copy_text_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentCopyTextBottomSheetBinding binding = FragmentCopyTextBottomSheetBinding.inflate(inflater, container, false); String rawText = getArguments().getString(EXTRA_RAW_TEXT, null); markdownText = getArguments().getString(EXTRA_MARKDOWN, null); if (rawText != null) { - copyRawTextTextView.setOnClickListener(view -> { + binding.copyRawTextTextViewCopyTextBottomSheetFragment.setOnClickListener(view -> { showCopyDialog(rawText); dismiss(); }); - copyAllRawTextTextView.setOnClickListener(view -> { + binding.copyAllRawTextTextViewCopyTextBottomSheetFragment.setOnClickListener(view -> { copyText(rawText); dismiss(); }); } else { - copyRawTextTextView.setVisibility(View.GONE); - copyAllRawTextTextView.setVisibility(View.GONE); + binding.copyRawTextTextViewCopyTextBottomSheetFragment.setVisibility(View.GONE); + binding.copyAllRawTextTextViewCopyTextBottomSheetFragment.setVisibility(View.GONE); } if (markdownText != null) { - copyMarkdownTextView.setOnClickListener(view -> { + binding.copyMarkdownTextViewCopyTextBottomSheetFragment.setOnClickListener(view -> { showCopyDialog(markdownText); dismiss(); }); - copyAllMarkdownTextView.setOnClickListener(view -> { + binding.copyAllMarkdownTextViewCopyTextBottomSheetFragment.setOnClickListener(view -> { copyText(markdownText); dismiss(); }); } else { - copyMarkdownTextView.setVisibility(View.GONE); - copyAllMarkdownTextView.setVisibility(View.GONE); + binding.copyMarkdownTextViewCopyTextBottomSheetFragment.setVisibility(View.GONE); + binding.copyAllMarkdownTextViewCopyTextBottomSheetFragment.setVisibility(View.GONE); } if (baseActivity != null && baseActivity.typeface != null) { - Utils.setFontToAllTextViews(rootView, baseActivity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), baseActivity.typeface); } else if (viewRedditGalleryActivity != null && viewRedditGalleryActivity.typeface != null) { - Utils.setFontToAllTextViews(rootView, viewRedditGalleryActivity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), viewRedditGalleryActivity.typeface); } - return rootView; + return binding.getRoot(); } private void showCopyDialog(String text) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CreateThemeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CreateThemeBottomSheetFragment.java index a025db0b..495dfbeb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CreateThemeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CreateThemeBottomSheetFragment.java @@ -6,17 +6,15 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentCreateThemeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; /** @@ -24,14 +22,6 @@ import ml.docilealligator.infinityforreddit.utils.Utils; */ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { - @BindView(R.id.import_theme_text_view_create_theme_bottom_sheet_fragment) - TextView importTextView; - @BindView(R.id.light_theme_text_view_create_theme_bottom_sheet_fragment) - TextView lightThemeTextView; - @BindView(R.id.dark_theme_text_view_create_theme_bottom_sheet_fragment) - TextView darkThemeTextView; - @BindView(R.id.amoled_theme_text_view_create_theme_bottom_sheet_fragment) - TextView amoledThemeTextView; private BaseActivity activity; public interface SelectBaseThemeBottomSheetFragmentListener { @@ -43,17 +33,16 @@ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBott } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_create_theme_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentCreateThemeBottomSheetBinding binding = FragmentCreateThemeBottomSheetBinding.inflate(inflater, container, false); - importTextView.setOnClickListener(view -> { + binding.importThemeTextViewCreateThemeBottomSheetFragment.setOnClickListener(view -> { ((SelectBaseThemeBottomSheetFragmentListener) activity).importTheme(); dismiss(); }); - lightThemeTextView.setOnClickListener(view -> { + binding.lightThemeTextViewCreateThemeBottomSheetFragment.setOnClickListener(view -> { Intent intent = new Intent(activity, CustomizeThemeActivity.class); intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); @@ -62,7 +51,7 @@ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBott dismiss(); }); - darkThemeTextView.setOnClickListener(view -> { + binding.darkThemeTextViewCreateThemeBottomSheetFragment.setOnClickListener(view -> { Intent intent = new Intent(activity, CustomizeThemeActivity.class); intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); @@ -71,7 +60,7 @@ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBott dismiss(); }); - amoledThemeTextView.setOnClickListener(view -> { + binding.amoledThemeTextViewCreateThemeBottomSheetFragment.setOnClickListener(view -> { Intent intent = new Intent(activity, CustomizeThemeActivity.class); intent.putExtra(CustomizeThemeActivity.EXTRA_CREATE_THEME, true); intent.putExtra(CustomizeThemeActivity.EXTRA_IS_PREDEFIINED_THEME, true); @@ -81,9 +70,9 @@ public class CreateThemeBottomSheetFragment extends LandscapeExpandedRoundedBott }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java index 28d2d388..fe446683 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/CustomThemeOptionsBottomSheetFragment.java @@ -6,17 +6,14 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.CustomizeThemeActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentCustomThemeOptionsBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; /** @@ -25,16 +22,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils; public class CustomThemeOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public static final String EXTRA_THEME_NAME = "ETN"; - @BindView(R.id.theme_name_text_view_custom_theme_options_bottom_sheet_fragment) - TextView themeNameTextView; - @BindView(R.id.edit_theme_text_view_custom_theme_options_bottom_sheet_fragment) - TextView editThemeTextView; - @BindView(R.id.share_theme_text_view_custom_theme_options_bottom_sheet_fragment) - TextView shareThemeTextView; - @BindView(R.id.change_theme_name_text_view_custom_theme_options_bottom_sheet_fragment) - TextView changeThemeNameTextView; - @BindView(R.id.delete_theme_text_view_custom_theme_options_bottom_sheet_fragment) - TextView deleteTextView; + private String themeName; private BaseActivity activity; @@ -49,41 +37,40 @@ public class CustomThemeOptionsBottomSheetFragment extends LandscapeExpandedRoun } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_custom_theme_options_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentCustomThemeOptionsBottomSheetBinding binding = FragmentCustomThemeOptionsBottomSheetBinding.inflate(inflater, container, false); themeName = getArguments().getString(EXTRA_THEME_NAME); - themeNameTextView.setText(themeName); + binding.themeNameTextViewCustomThemeOptionsBottomSheetFragment.setText(themeName); - editThemeTextView.setOnClickListener(view -> { + binding.editThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { Intent intent = new Intent(activity, CustomizeThemeActivity.class); intent.putExtra(CustomizeThemeActivity.EXTRA_THEME_NAME, themeName); startActivity(intent); dismiss(); }); - shareThemeTextView.setOnClickListener(view -> { + binding.shareThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { ((CustomThemeOptionsBottomSheetFragmentListener) activity).shareTheme(themeName); dismiss(); }); - changeThemeNameTextView.setOnClickListener(view -> { + binding.changeThemeNameTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { ((CustomThemeOptionsBottomSheetFragmentListener) activity).changeName(themeName); dismiss(); }); - deleteTextView.setOnClickListener(view -> { + binding.deleteThemeTextViewCustomThemeOptionsBottomSheetFragment.setOnClickListener(view -> { ((CustomThemeOptionsBottomSheetFragmentListener) activity).delete(themeName); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FilteredThingFABMoreOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FilteredThingFABMoreOptionsBottomSheetFragment.java index b88249cc..24e85ac1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FilteredThingFABMoreOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FilteredThingFABMoreOptionsBottomSheetFragment.java @@ -6,15 +6,12 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentFilteredThingFabMoreOptionsBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { @@ -22,10 +19,6 @@ public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExp public static final int FAB_OPTION_FILTER = 0; public static final int FAB_OPTION_HIDE_READ_POSTS = 1; - @BindView(R.id.filter_text_view_filtered_thing_fab_more_options_bottom_sheet_fragment) - TextView filterTextView; - @BindView(R.id.hide_read_posts_text_view_filtered_thing_fab_more_options_bottom_sheet_fragment) - TextView hideReadPostsTextView; private FABOptionSelectionCallback activity; public FilteredThingFABMoreOptionsBottomSheetFragment() { @@ -33,19 +26,18 @@ public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExp } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_filtered_thing_fab_more_options_bottom_sheet, container, false); + FragmentFilteredThingFabMoreOptionsBottomSheetBinding binding = + FragmentFilteredThingFabMoreOptionsBottomSheetBinding.inflate(inflater, container, false); - ButterKnife.bind(this, rootView); - - filterTextView.setOnClickListener(view -> { + binding.filterTextViewFilteredThingFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> { activity.fabOptionSelected(FAB_OPTION_FILTER); dismiss(); }); - hideReadPostsTextView.setOnClickListener(view -> { + binding.hideReadPostsTextViewFilteredThingFabMoreOptionsBottomSheetFragment.setOnClickListener(view -> { activity.fabOptionSelected(FAB_OPTION_HIDE_READ_POSTS); dismiss(); }); @@ -53,11 +45,11 @@ public class FilteredThingFABMoreOptionsBottomSheetFragment extends LandscapeExp Activity baseActivity = getActivity(); if (baseActivity instanceof BaseActivity) { if (((BaseActivity) baseActivity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((BaseActivity) baseActivity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((BaseActivity) baseActivity).typeface); } } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java index 0e258550..75f88bbc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/FlairBottomSheetFragment.java @@ -6,12 +6,9 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ProgressBar; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import androidx.recyclerview.widget.RecyclerView; import com.google.android.material.bottomsheet.BottomSheetBehavior; @@ -22,8 +19,6 @@ import java.util.ArrayList; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.FetchFlairs; import ml.docilealligator.infinityforreddit.Flair; import ml.docilealligator.infinityforreddit.Infinity; @@ -32,6 +27,7 @@ import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.adapters.FlairBottomSheetRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentFlairBottomSheetBinding; import ml.docilealligator.infinityforreddit.events.FlairSelectedEvent; import ml.docilealligator.infinityforreddit.utils.Utils; import retrofit2.Retrofit; @@ -44,12 +40,6 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog public static final String EXTRA_SUBREDDIT_NAME = "ESN"; public static final String EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID = "EPFI"; - @BindView(R.id.progress_bar_flair_bottom_sheet_fragment) - ProgressBar progressBar; - @BindView(R.id.error_text_view_flair_bottom_sheet_fragment) - TextView errorTextView; - @BindView(R.id.recycler_view_bottom_sheet_fragment) - RecyclerView recyclerView; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -58,6 +48,7 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog private String mSubredditName; private BaseActivity mActivity; private FlairBottomSheetRecyclerViewAdapter mAdapter; + private FragmentFlairBottomSheetBinding binding; public FlairBottomSheetFragment() { // Required empty public constructor @@ -66,14 +57,12 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_flair_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + binding = FragmentFlairBottomSheetBinding.inflate(inflater, container, false); ((Infinity) mActivity.getApplication()).getAppComponent().inject(this); if (mActivity.typeface != null) { - Utils.setFontToAllTextViews(rootView, mActivity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), mActivity.typeface); } long viewPostFragmentId = getArguments().getLong(EXTRA_VIEW_POST_DETAIL_FRAGMENT_ID, -1); @@ -87,13 +76,13 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog dismiss(); }); - recyclerView.setAdapter(mAdapter); + binding.recyclerViewBottomSheetFragment.setAdapter(mAdapter); mSubredditName = getArguments().getString(EXTRA_SUBREDDIT_NAME); fetchFlairs(); - return rootView; + return binding.getRoot(); } private void fetchFlairs() { @@ -101,22 +90,22 @@ public class FlairBottomSheetFragment extends LandscapeExpandedBottomSheetDialog mSubredditName, new FetchFlairs.FetchFlairsInSubredditListener() { @Override public void fetchSuccessful(ArrayList<Flair> flairs) { - progressBar.setVisibility(View.GONE); + binding.progressBarFlairBottomSheetFragment.setVisibility(View.GONE); if (flairs == null || flairs.size() == 0) { - errorTextView.setVisibility(View.VISIBLE); - errorTextView.setText(R.string.no_flair); + binding.errorTextViewFlairBottomSheetFragment.setVisibility(View.VISIBLE); + binding.errorTextViewFlairBottomSheetFragment.setText(R.string.no_flair); } else { - errorTextView.setVisibility(View.GONE); + binding.errorTextViewFlairBottomSheetFragment.setVisibility(View.GONE); mAdapter.changeDataset(flairs); } } @Override public void fetchFailed() { - progressBar.setVisibility(View.GONE); - errorTextView.setVisibility(View.VISIBLE); - errorTextView.setText(R.string.error_loading_flairs); - errorTextView.setOnClickListener(view -> fetchFlairs()); + binding.progressBarFlairBottomSheetFragment.setVisibility(View.GONE); + binding.errorTextViewFlairBottomSheetFragment.setVisibility(View.VISIBLE); + binding.errorTextViewFlairBottomSheetFragment.setText(R.string.error_loading_flairs); + binding.errorTextViewFlairBottomSheetFragment.setOnClickListener(view -> fetchFlairs()); } }); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/MultiRedditOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/MultiRedditOptionsBottomSheetFragment.java index 37cca62a..c28ba9b2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/MultiRedditOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/MultiRedditOptionsBottomSheetFragment.java @@ -8,18 +8,16 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.EditMultiRedditActivity; import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentMultiRedditOptionsBottomSheetBinding; import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -30,12 +28,6 @@ public class MultiRedditOptionsBottomSheetFragment extends LandscapeExpandedRoun public static final String EXTRA_MULTI_REDDIT = "EMR"; - @BindView(R.id.copy_multi_reddit_path_text_view_multi_reddit_options_bottom_sheet_fragment) - TextView copyMultiredditPathTextView; - @BindView(R.id.edit_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment) - TextView editMultiRedditTextView; - @BindView(R.id.delete_multi_reddit_text_view_multi_reddit_options_bottom_sheet_fragment) - TextView deleteMultiRedditTextView; private SubscribedThingListingActivity subscribedThingListingActivity; public MultiRedditOptionsBottomSheetFragment() { @@ -46,13 +38,11 @@ public class MultiRedditOptionsBottomSheetFragment extends LandscapeExpandedRoun @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_multi_reddit_options_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + FragmentMultiRedditOptionsBottomSheetBinding binding = FragmentMultiRedditOptionsBottomSheetBinding.inflate(inflater, container, false); MultiReddit multiReddit = getArguments().getParcelable(EXTRA_MULTI_REDDIT); - copyMultiredditPathTextView.setOnClickListener(view -> { + binding.copyMultiRedditPathTextViewMultiRedditOptionsBottomSheetFragment.setOnClickListener(view -> { if (multiReddit != null) { ClipboardManager clipboard = (ClipboardManager) subscribedThingListingActivity.getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard != null) { @@ -66,7 +56,7 @@ public class MultiRedditOptionsBottomSheetFragment extends LandscapeExpandedRoun dismiss(); }); - editMultiRedditTextView.setOnClickListener(view -> { + binding.editMultiRedditTextViewMultiRedditOptionsBottomSheetFragment.setOnClickListener(view -> { if (multiReddit != null) { Intent editIntent = new Intent(subscribedThingListingActivity, EditMultiRedditActivity.class); editIntent.putExtra(EditMultiRedditActivity.EXTRA_MULTI_PATH, multiReddit.getPath()); @@ -75,16 +65,16 @@ public class MultiRedditOptionsBottomSheetFragment extends LandscapeExpandedRoun dismiss(); }); - deleteMultiRedditTextView.setOnClickListener(view -> { + binding.deleteMultiRedditTextViewMultiRedditOptionsBottomSheetFragment.setOnClickListener(view -> { subscribedThingListingActivity.deleteMultiReddit(multiReddit); dismiss(); }); if (subscribedThingListingActivity.typeface != null) { - Utils.setFontToAllTextViews(rootView, subscribedThingListingActivity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), subscribedThingListingActivity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewPostFilterUsageBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewPostFilterUsageBottomSheetFragment.java index 9157da44..da631802 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewPostFilterUsageBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/NewPostFilterUsageBottomSheetFragment.java @@ -5,30 +5,17 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentNewPostFilterUsageBottomSheetBinding; import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage; import ml.docilealligator.infinityforreddit.utils.Utils; public class NewPostFilterUsageBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { - @BindView(R.id.home_text_view_new_post_filter_usage_bottom_sheet_fragment) - TextView homeTextView; - @BindView(R.id.subreddit_text_view_new_post_filter_usage_bottom_sheet_fragment) - TextView subredditTextView; - @BindView(R.id.user_text_view_new_post_filter_usage_bottom_sheet_fragment) - TextView userTextView; - @BindView(R.id.multireddit_text_view_new_post_filter_usage_bottom_sheet_fragment) - TextView multiRedditTextView; - @BindView(R.id.search_text_view_new_post_filter_usage_bottom_sheet_fragment) - TextView searchTextView; private PostFilterUsageListingActivity activity; public NewPostFilterUsageBottomSheetFragment() { @@ -39,40 +26,38 @@ public class NewPostFilterUsageBottomSheetFragment extends LandscapeExpandedRoun public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_new_post_filter_usage_bottom_sheet, container, false); + FragmentNewPostFilterUsageBottomSheetBinding binding = FragmentNewPostFilterUsageBottomSheetBinding.inflate(inflater, container, false); - ButterKnife.bind(this, rootView); - - homeTextView.setOnClickListener(view -> { + binding.homeTextViewNewPostFilterUsageBottomSheetFragment.setOnClickListener(view -> { activity.newPostFilterUsage(PostFilterUsage.HOME_TYPE); dismiss(); }); - subredditTextView.setOnClickListener(view -> { + binding.subredditTextViewNewPostFilterUsageBottomSheetFragment.setOnClickListener(view -> { activity.newPostFilterUsage(PostFilterUsage.SUBREDDIT_TYPE); dismiss(); }); - userTextView.setOnClickListener(view -> { + binding.userTextViewNewPostFilterUsageBottomSheetFragment.setOnClickListener(view -> { activity.newPostFilterUsage(PostFilterUsage.USER_TYPE); dismiss(); }); - multiRedditTextView.setOnClickListener(view -> { + binding.multiredditTextViewNewPostFilterUsageBottomSheetFragment.setOnClickListener(view -> { activity.newPostFilterUsage(PostFilterUsage.MULTIREDDIT_TYPE); dismiss(); }); - searchTextView.setOnClickListener(view -> { + binding.searchTextViewNewPostFilterUsageBottomSheetFragment.setOnClickListener(view -> { activity.newPostFilterUsage(PostFilterUsage.SEARCH_TYPE); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PlaybackSpeedBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PlaybackSpeedBottomSheetFragment.java index f5fc9279..099e4ecf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PlaybackSpeedBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PlaybackSpeedBottomSheetFragment.java @@ -6,18 +6,16 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity; import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity; import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentPlaybackSpeedBinding; import ml.docilealligator.infinityforreddit.fragments.ViewImgurVideoFragment; import ml.docilealligator.infinityforreddit.fragments.ViewRedditGalleryVideoFragment; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -26,22 +24,6 @@ public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBo public static final String EXTRA_PLAYBACK_SPEED = "EPS"; - @BindView(R.id.playback_speed_025_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed025TextView; - @BindView(R.id.playback_speed_050_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed050TextView; - @BindView(R.id.playback_speed_075_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed075TextView; - @BindView(R.id.playback_speed_normal_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeedNormalTextView; - @BindView(R.id.playback_speed_125_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed125TextView; - @BindView(R.id.playback_speed_150_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed150TextView; - @BindView(R.id.playback_speed_175_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed175TextView; - @BindView(R.id.playback_speed_200_text_view_playback_speed_bottom_sheet_fragment) - TextView playbackSpeed200TextView; private Activity activity; public PlaybackSpeedBottomSheetFragment() { @@ -52,91 +34,90 @@ public class PlaybackSpeedBottomSheetFragment extends LandscapeExpandedRoundedBo public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_playback_speed, container, false); + FragmentPlaybackSpeedBinding binding = FragmentPlaybackSpeedBinding.inflate(inflater, container, false); - ButterKnife.bind(this, rootView); int playbackSpeed = getArguments().getInt(EXTRA_PLAYBACK_SPEED, ViewVideoActivity.PLAYBACK_SPEED_NORMAL); switch (playbackSpeed) { case ViewVideoActivity.PLAYBACK_SPEED_25: - playbackSpeed025TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed025TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_50: - playbackSpeed050TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed050TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_75: - playbackSpeed075TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed075TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_NORMAL: - playbackSpeedNormalTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeedNormalTextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_125: - playbackSpeed125TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed125TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_150: - playbackSpeed150TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed150TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_175: - playbackSpeed175TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed175TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; case ViewVideoActivity.PLAYBACK_SPEED_200: - playbackSpeed200TextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); + binding.playbackSpeed200TextViewPlaybackSpeedBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_playback_speed_24dp, 0); break; } - playbackSpeed025TextView.setOnClickListener(view -> { + binding.playbackSpeed025TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_25); dismiss(); }); - playbackSpeed050TextView.setOnClickListener(view -> { + binding.playbackSpeed050TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_50); dismiss(); }); - playbackSpeed075TextView.setOnClickListener(view -> { + binding.playbackSpeed075TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_75); dismiss(); }); - playbackSpeedNormalTextView.setOnClickListener(view -> { + binding.playbackSpeedNormalTextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_NORMAL); dismiss(); }); - playbackSpeed125TextView.setOnClickListener(view -> { + binding.playbackSpeed125TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_125); dismiss(); }); - playbackSpeed150TextView.setOnClickListener(view -> { + binding.playbackSpeed150TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_150); dismiss(); }); - playbackSpeed175TextView.setOnClickListener(view -> { + binding.playbackSpeed175TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_175); dismiss(); }); - playbackSpeed200TextView.setOnClickListener(view -> { + binding.playbackSpeed200TextViewPlaybackSpeedBottomSheetFragment.setOnClickListener(view -> { setPlaybackSpeed(ViewVideoActivity.PLAYBACK_SPEED_200); dismiss(); }); if (activity instanceof ViewVideoActivity) { if (((ViewVideoActivity) activity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewVideoActivity) activity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewVideoActivity) activity).typeface); } } else if (activity instanceof ViewImgurMediaActivity) { if (((ViewImgurMediaActivity) activity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewImgurMediaActivity) activity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewImgurMediaActivity) activity).typeface); } } else if (activity instanceof ViewRedditGalleryActivity) { if (((ViewRedditGalleryActivity) activity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewRedditGalleryActivity) activity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewRedditGalleryActivity) activity).typeface); } } - return rootView; + return binding.getRoot(); } private void setPlaybackSpeed(int playbackSpeed) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java index cba93f23..7d396c3c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java @@ -8,19 +8,17 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentPostCommentSortTypeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; /** @@ -30,22 +28,6 @@ public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRou public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; - @BindView(R.id.best_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView confidenceTypeTextView; - @BindView(R.id.top_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.new_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.controversial_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView controversialTypeTextView; - @BindView(R.id.old_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView oldTypeTextView; - @BindView(R.id.random_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView randomTypeTextView; - @BindView(R.id.qa_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView qaTypeTextView; - @BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment) - TextView liveTypeTextView; private BaseActivity activity; public PostCommentSortTypeBottomSheetFragment() { @@ -62,81 +44,80 @@ public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRou @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_post_comment_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentPostCommentSortTypeBottomSheetBinding binding = FragmentPostCommentSortTypeBottomSheetBinding.inflate(inflater, container, false); SortType.Type currentSortType = (SortType.Type) getArguments().getSerializable(EXTRA_CURRENT_SORT_TYPE); if (currentSortType.equals(SortType.Type.BEST) || currentSortType.equals(SortType.Type.CONFIDENCE)) { - confidenceTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(confidenceTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.bestTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.bestTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.TOP)) { - topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.topTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.topTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.NEW)) { - newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.newTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.newTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.CONTROVERSIAL)) { - controversialTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(controversialTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.controversialTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.controversialTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.OLD)) { - oldTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(oldTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.oldTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.oldTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.RANDOM)) { - randomTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(randomTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.randomTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.randomTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.QA)) { - qaTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(qaTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.qaTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.qaTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.LIVE)) { - liveTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(liveTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.liveTypeTextViewPostCommentSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.liveTypeTextViewPostCommentSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } - confidenceTypeTextView.setOnClickListener(view -> { + binding.bestTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.CONFIDENCE)); dismiss(); }); - topTypeTextView.setOnClickListener(view -> { + binding.topTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.TOP)); dismiss(); }); - newTypeTextView.setOnClickListener(view -> { + binding.newTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); dismiss(); }); - controversialTypeTextView.setOnClickListener(view -> { + binding.controversialTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.CONTROVERSIAL)); dismiss(); }); - oldTypeTextView.setOnClickListener(view -> { + binding.oldTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.OLD)); dismiss(); }); - randomTypeTextView.setOnClickListener(view -> { + binding.randomTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM)); dismiss(); }); - qaTypeTextView.setOnClickListener(view -> { + binding.qaTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.QA)); dismiss(); }); - liveTypeTextView.setOnClickListener(view -> { + binding.liveTypeTextViewPostCommentSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.LIVE)); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterUsageOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterUsageOptionsBottomSheetFragment.java index a3225959..853133f5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterUsageOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostFilterUsageOptionsBottomSheetFragment.java @@ -5,15 +5,12 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.PostFilterUsageListingActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentPostFilterUsageOptionsBottomSheetBinding; import ml.docilealligator.infinityforreddit.postfilter.PostFilterUsage; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -21,10 +18,6 @@ public class PostFilterUsageOptionsBottomSheetFragment extends LandscapeExpanded public static final String EXTRA_POST_FILTER_USAGE = "EPFU"; - @BindView(R.id.edit_text_view_post_filter_usage_options_bottom_sheet_fragment) - TextView editTextView; - @BindView(R.id.delete_text_view_post_filter_usage_options_bottom_sheet_fragment) - TextView deleteTextView; private PostFilterUsageListingActivity activity; public PostFilterUsageOptionsBottomSheetFragment() { @@ -32,34 +25,32 @@ public class PostFilterUsageOptionsBottomSheetFragment extends LandscapeExpanded } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_post_filter_usage_options_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + FragmentPostFilterUsageOptionsBottomSheetBinding binding = FragmentPostFilterUsageOptionsBottomSheetBinding.inflate(inflater, container, false); PostFilterUsage postFilterUsage = getArguments().getParcelable(EXTRA_POST_FILTER_USAGE); if (postFilterUsage.usage == PostFilterUsage.HOME_TYPE || postFilterUsage.usage == PostFilterUsage.SEARCH_TYPE) { - editTextView.setVisibility(View.GONE); + binding.editTextViewPostFilterUsageOptionsBottomSheetFragment.setVisibility(View.GONE); } else { - editTextView.setOnClickListener(view -> { + binding.editTextViewPostFilterUsageOptionsBottomSheetFragment.setOnClickListener(view -> { activity.editPostFilterUsage(postFilterUsage); dismiss(); }); } - deleteTextView.setOnClickListener(view -> { + binding.deleteTextViewPostFilterUsageOptionsBottomSheetFragment.setOnClickListener(view -> { activity.deletePostFilterUsage(postFilterUsage); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java index bc410123..6ab4e3cf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostTypeBottomSheetFragment.java @@ -8,16 +8,13 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentPostTypeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -32,18 +29,7 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS public static final int TYPE_VIDEO = 3; public static final int TYPE_GALLERY = 4; public static final int TYPE_POLL = 5; - @BindView(R.id.text_type_linear_layout_post_type_bottom_sheet_fragment) - TextView textTypeTextView; - @BindView(R.id.link_type_linear_layout_post_type_bottom_sheet_fragment) - TextView linkTypeTextView; - @BindView(R.id.image_type_linear_layout_post_type_bottom_sheet_fragment) - TextView imageTypeTextView; - @BindView(R.id.video_type_linear_layout_post_type_bottom_sheet_fragment) - TextView videoTypeTextView; - @BindView(R.id.gallery_type_linear_layout_post_type_bottom_sheet_fragment) - TextView galleryTypeTextView; - @BindView(R.id.poll_type_linear_layout_post_type_bottom_sheet_fragment) - TextView pollTypeTextView; + private BaseActivity activity; public PostTypeBottomSheetFragment() { @@ -51,51 +37,50 @@ public class PostTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_post_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentPostTypeBottomSheetBinding binding = FragmentPostTypeBottomSheetBinding.inflate(inflater, container, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } - textTypeTextView.setOnClickListener(view -> { + binding.textTypeLinearLayoutPostTypeBottomSheetFragment.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_TEXT); dismiss(); }); - linkTypeTextView.setOnClickListener(view -> { + binding.linkTypeLinearLayoutPostTypeBottomSheetFragment.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_LINK); dismiss(); }); - imageTypeTextView.setOnClickListener(view -> { + binding.imageTypeLinearLayoutPostTypeBottomSheetFragment.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_IMAGE); dismiss(); }); - videoTypeTextView.setOnClickListener(view -> { + binding.videoTypeLinearLayoutPostTypeBottomSheetFragment.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_VIDEO); dismiss(); }); - galleryTypeTextView.setOnClickListener(view -> { + binding.galleryTypeLinearLayoutPostTypeBottomSheetFragment.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_GALLERY); dismiss(); }); - pollTypeTextView.setOnClickListener(view -> { + binding.pollTypeLinearLayoutPostTypeBottomSheetFragment.setOnClickListener(view -> { ((PostTypeSelectionCallback) activity).postTypeSelected(TYPE_POLL); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RandomBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RandomBottomSheetFragment.java index 3cb0360b..a31db90b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RandomBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RandomBottomSheetFragment.java @@ -6,15 +6,12 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentRandomBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { @@ -25,15 +22,6 @@ public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomShe public static final int RANDOM_NSFW_SUBREDDIT = 2; public static final int RANDOM_NSFW_POST = 3; - @BindView(R.id.random_subreddit_text_view_random_bottom_sheet_fragment) - TextView randomSubredditTextView; - @BindView(R.id.random_post_text_view_random_bottom_sheet_fragment) - TextView randomPostTextView; - @BindView(R.id.random_nsfw_subreddit_text_view_random_bottom_sheet_fragment) - TextView randomNSFWSubredditTextView; - @BindView(R.id.random_nsfw_post_text_view_random_bottom_sheet_fragment) - TextView randomNSFWPostTextView; - private RandomOptionSelectionCallback activity; public RandomBottomSheetFragment() { @@ -41,36 +29,34 @@ public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomShe } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_random_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + FragmentRandomBottomSheetBinding binding = FragmentRandomBottomSheetBinding.inflate(inflater, container, false); boolean isNSFW = getArguments().getBoolean(EXTRA_IS_NSFW, false); if (!isNSFW) { - randomNSFWSubredditTextView.setVisibility(View.GONE); - randomNSFWPostTextView.setVisibility(View.GONE); + binding.randomNsfwSubredditTextViewRandomBottomSheetFragment.setVisibility(View.GONE); + binding.randomNsfwPostTextViewRandomBottomSheetFragment.setVisibility(View.GONE); } else { - randomNSFWSubredditTextView.setOnClickListener(view -> { + binding.randomNsfwSubredditTextViewRandomBottomSheetFragment.setOnClickListener(view -> { activity.randomOptionSelected(RANDOM_NSFW_SUBREDDIT); dismiss(); }); - randomNSFWPostTextView.setOnClickListener(view -> { + binding.randomNsfwPostTextViewRandomBottomSheetFragment.setOnClickListener(view -> { activity.randomOptionSelected(RANDOM_NSFW_POST); dismiss(); }); } - randomSubredditTextView.setOnClickListener(view -> { + binding.randomSubredditTextViewRandomBottomSheetFragment.setOnClickListener(view -> { activity.randomOptionSelected(RANDOM_SUBREDDIT); dismiss(); }); - randomPostTextView.setOnClickListener(view -> { + binding.randomPostTextViewRandomBottomSheetFragment.setOnClickListener(view -> { activity.randomOptionSelected(RANDOM_POST); dismiss(); }); @@ -78,11 +64,11 @@ public class RandomBottomSheetFragment extends LandscapeExpandedRoundedBottomShe Activity baseActivity = getActivity(); if (baseActivity instanceof BaseActivity) { if (((BaseActivity) activity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((BaseActivity) activity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((BaseActivity) activity).typeface); } } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java index 618701fa..f07a41db 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java @@ -8,19 +8,17 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentSearchPostSortTypeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -31,16 +29,6 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; - @BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView relevanceTypeTextView; - @BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; - @BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) - TextView commentsTypeTextView; private BaseActivity activity; public SearchPostSortTypeBottomSheetFragment() { // Required empty public constructor @@ -57,57 +45,56 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentSearchPostSortTypeBottomSheetBinding binding = FragmentSearchPostSortTypeBottomSheetBinding.inflate(inflater, container, false); String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); if (currentSortType.equals(SortType.Type.RELEVANCE.fullName)) { - relevanceTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(relevanceTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.relevanceTypeTextViewSearchSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.relevanceTypeTextViewSearchSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.HOT.fullName)) { - hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.hotTypeTextViewSearchSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.hotTypeTextViewSearchSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.TOP.fullName)) { - topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.topTypeTextViewSearchSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.topTypeTextViewSearchSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.NEW.fullName)) { - newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.newTypeTextViewSearchSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.newTypeTextViewSearchSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.RISING.fullName)) { - commentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(commentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.commentsTypeTextViewSearchSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.commentsTypeTextViewSearchSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } - relevanceTypeTextView.setOnClickListener(view -> { + binding.relevanceTypeTextViewSearchSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.RELEVANCE.name()); dismiss(); }); - hotTypeTextView.setOnClickListener(view -> { + binding.hotTypeTextViewSearchSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.HOT.name()); dismiss(); }); - topTypeTextView.setOnClickListener(view -> { + binding.topTypeTextViewSearchSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); dismiss(); }); - newTypeTextView.setOnClickListener(view -> { + binding.newTypeTextViewSearchSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); dismiss(); }); - commentsTypeTextView.setOnClickListener(view -> { + binding.commentsTypeTextViewSearchSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.COMMENTS.name()); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java index 56498538..978ff641 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java @@ -8,19 +8,17 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentSearchUserAndSubredditSortTypeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -32,10 +30,6 @@ public class SearchUserAndSubredditSortTypeBottomSheetFragment extends Landscape public static final String EXTRA_FRAGMENT_POSITION = "EFP"; public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; - @BindView(R.id.relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) - TextView relevanceTypeTextView; - @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) - TextView activityTypeTextView; private BaseActivity activity; public SearchUserAndSubredditSortTypeBottomSheetFragment() { @@ -52,44 +46,43 @@ public class SearchUserAndSubredditSortTypeBottomSheetFragment extends Landscape } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentSearchUserAndSubredditSortTypeBottomSheetBinding binding = FragmentSearchUserAndSubredditSortTypeBottomSheetBinding.inflate(inflater, container, false); String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); if (currentSortType.equals(SortType.Type.RELEVANCE.fullName)) { - relevanceTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(relevanceTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.relevanceTypeTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.relevanceTypeTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.ACTIVITY.fullName)) { - activityTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(activityTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.activityTypeTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.activityTypeTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } int position = getArguments() != null ? getArguments().getInt(EXTRA_FRAGMENT_POSITION) : -1; if(position < 0) { dismiss(); - return rootView; + return binding.getRoot(); } - relevanceTypeTextView.setOnClickListener(view -> { + binding.relevanceTypeTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(new SortType(SortType.Type.RELEVANCE), position); dismiss(); }); - activityTypeTextView.setOnClickListener(view -> { + binding.activityTypeTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(new SortType(SortType.Type.ACTIVITY), position); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectSubredditsOrUsersOptionsBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectSubredditsOrUsersOptionsBottomSheetFragment.java index 7b94b051..7e007a83 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectSubredditsOrUsersOptionsBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SelectSubredditsOrUsersOptionsBottomSheetFragment.java @@ -5,23 +5,16 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.SelectedSubredditsAndUsersActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentSelectSubredditsOrUsersOptionsBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; public class SelectSubredditsOrUsersOptionsBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { - @BindView(R.id.select_subreddits_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) - TextView selectSubredditsTextView; - @BindView(R.id.select_users_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) - TextView selectUsersTextView; private SelectedSubredditsAndUsersActivity activity; public SelectSubredditsOrUsersOptionsBottomSheetFragment() { @@ -29,28 +22,26 @@ public class SelectSubredditsOrUsersOptionsBottomSheetFragment extends Landscape } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_select_subreddits_or_users_options_bottom_sheet, container, false); + FragmentSelectSubredditsOrUsersOptionsBottomSheetBinding binding = FragmentSelectSubredditsOrUsersOptionsBottomSheetBinding.inflate(inflater, container, false); - ButterKnife.bind(this, rootView); - - selectSubredditsTextView.setOnClickListener(view -> { + binding.selectSubredditsTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.setOnClickListener(view -> { activity.selectSubreddits(); dismiss(); }); - selectUsersTextView.setOnClickListener(view -> { + binding.selectUsersTextViewSearchUserAndSubredditSortTypeBottomSheetFragment.setOnClickListener(view -> { activity.selectUsers(); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SetAsWallpaperBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SetAsWallpaperBottomSheetFragment.java index e2ca8536..ea2e96a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SetAsWallpaperBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SetAsWallpaperBottomSheetFragment.java @@ -7,30 +7,21 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SetAsWallpaperCallback; import ml.docilealligator.infinityforreddit.activities.ViewImgurMediaActivity; import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity; import ml.docilealligator.infinityforreddit.activities.ViewVideoActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentSetAsWallpaperBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; public class SetAsWallpaperBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public static final String EXTRA_VIEW_PAGER_POSITION = "EVPP"; - @BindView(R.id.home_screen_text_view_set_as_wallpaper_bottom_sheet_fragment) - TextView homeScreenTextvView; - @BindView(R.id.lock_screen_text_view_set_as_wallpaper_bottom_sheet_fragment) - TextView lockScreenTextView; - @BindView(R.id.both_text_view_set_as_wallpaper_bottom_sheet_fragment) - TextView bothTextView; private Activity mActivity; public SetAsWallpaperBottomSheetFragment() { @@ -38,15 +29,14 @@ public class SetAsWallpaperBottomSheetFragment extends LandscapeExpandedRoundedB } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_set_as_wallpaper_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentSetAsWallpaperBottomSheetBinding binding = FragmentSetAsWallpaperBottomSheetBinding.inflate(inflater, container, false); Bundle bundle = getArguments(); int viewPagerPosition = bundle == null ? -1 : bundle.getInt(EXTRA_VIEW_PAGER_POSITION); - bothTextView.setOnClickListener(view -> { + binding.bothTextViewSetAsWallpaperBottomSheetFragment.setOnClickListener(view -> { if (mActivity instanceof SetAsWallpaperCallback) { ((SetAsWallpaperCallback) mActivity).setToBoth(viewPagerPosition); } @@ -54,17 +44,17 @@ public class SetAsWallpaperBottomSheetFragment extends LandscapeExpandedRoundedB }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - homeScreenTextvView.setVisibility(View.VISIBLE); - lockScreenTextView.setVisibility(View.VISIBLE); + binding.homeScreenTextViewSetAsWallpaperBottomSheetFragment.setVisibility(View.VISIBLE); + binding.lockScreenTextViewSetAsWallpaperBottomSheetFragment.setVisibility(View.VISIBLE); - homeScreenTextvView.setOnClickListener(view -> { + binding.homeScreenTextViewSetAsWallpaperBottomSheetFragment.setOnClickListener(view -> { if (mActivity instanceof SetAsWallpaperCallback) { ((SetAsWallpaperCallback) mActivity).setToHomeScreen(viewPagerPosition); } dismiss(); }); - lockScreenTextView.setOnClickListener(view -> { + binding.lockScreenTextViewSetAsWallpaperBottomSheetFragment.setOnClickListener(view -> { if (mActivity instanceof SetAsWallpaperCallback) { ((SetAsWallpaperCallback) mActivity).setToLockScreen(viewPagerPosition); } @@ -74,19 +64,19 @@ public class SetAsWallpaperBottomSheetFragment extends LandscapeExpandedRoundedB if (mActivity instanceof ViewVideoActivity) { if (((ViewVideoActivity) mActivity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewVideoActivity) mActivity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewVideoActivity) mActivity).typeface); } } else if (mActivity instanceof ViewImgurMediaActivity) { if (((ViewImgurMediaActivity) mActivity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewImgurMediaActivity) mActivity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewImgurMediaActivity) mActivity).typeface); } } else if (mActivity instanceof ViewRedditGalleryActivity) { if (((ViewRedditGalleryActivity) mActivity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewRedditGalleryActivity) mActivity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewRedditGalleryActivity) mActivity).typeface); } } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/ShareLinkBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/ShareLinkBottomSheetFragment.java index db0cb4e4..35632d3a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/ShareLinkBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/ShareLinkBottomSheetFragment.java @@ -8,17 +8,15 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentShareLinkBottomSheetBinding; import ml.docilealligator.infinityforreddit.post.Post; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -30,19 +28,6 @@ public class ShareLinkBottomSheetFragment extends LandscapeExpandedRoundedBottom public static final String EXTRA_MEDIA_LINK = "EML"; public static final String EXTRA_MEDIA_TYPE = "EMT"; - @BindView(R.id.post_link_text_view_share_link_bottom_sheet_fragment) - TextView postLinkTextView; - @BindView(R.id.share_post_link_text_view_share_link_bottom_sheet_fragment) - TextView sharePostLinkTextView; - @BindView(R.id.copy_post_link_text_view_share_link_bottom_sheet_fragment) - TextView copyPostLinkTextView; - @BindView(R.id.media_link_text_view_share_link_bottom_sheet_fragment) - TextView mediaLinkTextView; - @BindView(R.id.share_media_link_text_view_share_link_bottom_sheet_fragment) - TextView shareMediaLinkTextView; - @BindView(R.id.copy_media_link_text_view_share_link_bottom_sheet_fragment) - TextView copyMediaLinkTextView; - private BaseActivity activity; public ShareLinkBottomSheetFragment() { @@ -51,75 +36,73 @@ public class ShareLinkBottomSheetFragment extends LandscapeExpandedRoundedBottom @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment - View rootView = inflater.inflate(R.layout.fragment_share_link_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + FragmentShareLinkBottomSheetBinding binding = FragmentShareLinkBottomSheetBinding.inflate(inflater, container, false); String postLink = getArguments().getString(EXTRA_POST_LINK); String mediaLink = getArguments().containsKey(EXTRA_MEDIA_LINK) ? getArguments().getString(EXTRA_MEDIA_LINK) : null; - postLinkTextView.setText(postLink); + binding.postLinkTextViewShareLinkBottomSheetFragment.setText(postLink); if (mediaLink != null) { - mediaLinkTextView.setVisibility(View.VISIBLE); - shareMediaLinkTextView.setVisibility(View.VISIBLE); - copyMediaLinkTextView.setVisibility(View.VISIBLE); + binding.mediaLinkTextViewShareLinkBottomSheetFragment.setVisibility(View.VISIBLE); + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setVisibility(View.VISIBLE); + binding.copyMediaLinkTextViewShareLinkBottomSheetFragment.setVisibility(View.VISIBLE); - mediaLinkTextView.setText(mediaLink); + binding.mediaLinkTextViewShareLinkBottomSheetFragment.setText(mediaLink); int mediaType = getArguments().getInt(EXTRA_MEDIA_TYPE); switch (mediaType) { case Post.IMAGE_TYPE: - shareMediaLinkTextView.setText(R.string.share_image_link); - copyMediaLinkTextView.setText(R.string.copy_image_link); - shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.share_image_link); + binding.copyMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.copy_image_link); + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds( activity.getDrawable(R.drawable.ic_image_24dp), null, null, null); break; case Post.GIF_TYPE: - shareMediaLinkTextView.setText(R.string.share_gif_link); - copyMediaLinkTextView.setText(R.string.copy_gif_link); - shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.share_gif_link); + binding.copyMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.copy_gif_link); + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds( activity.getDrawable(R.drawable.ic_image_24dp), null, null, null); break; case Post.VIDEO_TYPE: - shareMediaLinkTextView.setText(R.string.share_video_link); - copyMediaLinkTextView.setText(R.string.copy_video_link); - shareMediaLinkTextView.setCompoundDrawablesWithIntrinsicBounds( + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.share_video_link); + binding.copyMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.copy_video_link); + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setCompoundDrawablesWithIntrinsicBounds( activity.getDrawable(R.drawable.ic_outline_video_24dp), null, null, null); break; case Post.LINK_TYPE: case Post.NO_PREVIEW_LINK_TYPE: - shareMediaLinkTextView.setText(R.string.share_link); - copyMediaLinkTextView.setText(R.string.copy_link); + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.share_link); + binding.copyMediaLinkTextViewShareLinkBottomSheetFragment.setText(R.string.copy_link); break; } - shareMediaLinkTextView.setOnClickListener(view -> { + binding.shareMediaLinkTextViewShareLinkBottomSheetFragment.setOnClickListener(view -> { shareLink(mediaLink); dismiss(); }); - copyMediaLinkTextView.setOnClickListener(view -> { + binding.copyMediaLinkTextViewShareLinkBottomSheetFragment.setOnClickListener(view -> { copyLink(mediaLink); dismiss(); }); } - sharePostLinkTextView.setOnClickListener(view -> { + binding.sharePostLinkTextViewShareLinkBottomSheetFragment.setOnClickListener(view -> { shareLink(postLink); dismiss(); }); - copyPostLinkTextView.setOnClickListener(view -> { + binding.copyPostLinkTextViewShareLinkBottomSheetFragment.setOnClickListener(view -> { copyLink(postLink); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } private void shareLink(String link) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java index a595ec85..71768040 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTimeBottomSheetFragment.java @@ -8,18 +8,15 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; -import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentSortTimeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; /** @@ -29,18 +26,6 @@ public class SortTimeBottomSheetFragment extends LandscapeExpandedRoundedBottomS public static final String EXTRA_SORT_TYPE = "EST"; - @BindView(R.id.hour_text_view_sort_time_bottom_sheet_fragment) - TextView hourTextView; - @BindView(R.id.day_text_view_sort_time_bottom_sheet_fragment) - TextView dayTextView; - @BindView(R.id.week_text_view_sort_time_bottom_sheet_fragment) - TextView weekTextView; - @BindView(R.id.month_text_view_sort_time_bottom_sheet_fragment) - TextView monthTextView; - @BindView(R.id.year_text_view_sort_time_bottom_sheet_fragment) - TextView yearTextView; - @BindView(R.id.all_time_text_view_sort_time_bottom_sheet_fragment) - TextView allTimeTextView; private BaseActivity activity; public SortTimeBottomSheetFragment() { // Required empty public constructor @@ -48,64 +33,62 @@ public class SortTimeBottomSheetFragment extends LandscapeExpandedRoundedBottomS @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_sort_time_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + FragmentSortTimeBottomSheetBinding binding = FragmentSortTimeBottomSheetBinding.inflate(inflater, container, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } String sortType = getArguments() != null ? getArguments().getString(EXTRA_SORT_TYPE) : null; if (sortType == null) { dismiss(); - return rootView; + return binding.getRoot(); } - hourTextView.setOnClickListener(view -> { + binding.hourTextViewSortTimeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity) .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.HOUR)); dismiss(); }); - dayTextView.setOnClickListener(view -> { + binding.dayTextViewSortTimeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity) .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.DAY)); dismiss(); }); - weekTextView.setOnClickListener(view -> { + binding.weekTextViewSortTimeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity) .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.WEEK)); dismiss(); }); - monthTextView.setOnClickListener(view -> { + binding.monthTextViewSortTimeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity) .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.MONTH)); dismiss(); }); - yearTextView.setOnClickListener(view -> { + binding.yearTextViewSortTimeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity) .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.YEAR)); dismiss(); }); - allTimeTextView.setOnClickListener(view -> { + binding.allTimeTextViewSortTimeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity) .sortTypeSelected(new SortType(SortType.Type.valueOf(sortType), SortType.Time.ALL)); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java index 4c35cde7..3d21f8c6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java @@ -8,19 +8,17 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentSortTypeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -32,18 +30,6 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS public static final String EXTRA_NO_BEST_TYPE = "ENBT"; public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; - @BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment) - TextView bestTypeTextView; - @BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; - @BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.rising_type_text_view_sort_type_bottom_sheet_fragment) - TextView risingTypeTextView; - @BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.controversial_type_text_view_sort_type_bottom_sheet_fragment) - TextView controversialTypeTextView; private BaseActivity activity; public SortTypeBottomSheetFragment() { // Required empty public constructor @@ -61,18 +47,17 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_sort_type_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentSortTypeBottomSheetBinding binding = FragmentSortTypeBottomSheetBinding.inflate(inflater, container, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } if (getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) { - bestTypeTextView.setVisibility(View.GONE); + binding.bestTypeTextViewSortTypeBottomSheetFragment.setVisibility(View.GONE); } else { - bestTypeTextView.setOnClickListener(view -> { + binding.bestTypeTextViewSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.BEST)); dismiss(); }); @@ -80,49 +65,49 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); if (currentSortType.equals(SortType.Type.BEST.fullName)) { - bestTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(bestTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.bestTypeTextViewSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.bestTypeTextViewSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.HOT.fullName)) { - hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.hotTypeTextViewSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.hotTypeTextViewSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.NEW.fullName)) { - newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.newTypeTextViewSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.newTypeTextViewSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.RISING.fullName)) { - risingTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(risingTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.risingTypeTextViewSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.risingTypeTextViewSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.TOP.fullName)) { - topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.topTypeTextViewSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.topTypeTextViewSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.CONTROVERSIAL.fullName)) { - controversialTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(controversialTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.controversialTypeTextViewSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.controversialTypeTextViewSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } - hotTypeTextView.setOnClickListener(view -> { + binding.hotTypeTextViewSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); dismiss(); }); - newTypeTextView.setOnClickListener(view -> { + binding.newTypeTextViewSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); dismiss(); }); - risingTypeTextView.setOnClickListener(view -> { + binding.risingTypeTextViewSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING)); dismiss(); }); - topTypeTextView.setOnClickListener(view -> { + binding.topTypeTextViewSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); dismiss(); }); - controversialTypeTextView.setOnClickListener(view -> { + binding.controversialTypeTextViewSortTypeBottomSheetFragment.setOnClickListener(view -> { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name()); dismiss(); }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UploadedImagesBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UploadedImagesBottomSheetFragment.java index f2288bf9..2ff9fb31 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UploadedImagesBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UploadedImagesBottomSheetFragment.java @@ -28,7 +28,7 @@ public class UploadedImagesBottomSheetFragment extends LandscapeExpandedRoundedB } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment FragmentUploadedImagesBottomSheetBinding binding = FragmentUploadedImagesBottomSheetBinding.inflate(inflater, container, false); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UrlMenuBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UrlMenuBottomSheetFragment.java index ac9d1fdf..4ce185c0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UrlMenuBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UrlMenuBottomSheetFragment.java @@ -11,32 +11,22 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; -import androidx.fragment.app.FragmentManager; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity; import ml.docilealligator.infinityforreddit.activities.ViewRedditGalleryActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentUrlMenuBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; public class UrlMenuBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public static final String EXTRA_URL = "EU"; - @BindView(R.id.link_text_view_url_menu_bottom_sheet_fragment) - TextView linkTextView; - @BindView(R.id.open_link_text_view_url_menu_bottom_sheet_fragment) - TextView openLinkTextView; - @BindView(R.id.copy_link_text_view_url_menu_bottom_sheet_fragment) - TextView copyLinkTextView; - @BindView(R.id.share_link_text_view_url_menu_bottom_sheet_fragment) - TextView shareLinkTextView; + private Activity activity; private String url; @@ -54,10 +44,9 @@ public class UrlMenuBottomSheetFragment extends LandscapeExpandedRoundedBottomSh } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_url_menu_bottom_sheet, container, false); - ButterKnife.bind(this, rootView); + FragmentUrlMenuBottomSheetBinding binding = FragmentUrlMenuBottomSheetBinding.inflate(inflater, container, false); url = getArguments().getString(EXTRA_URL); @@ -66,16 +55,16 @@ public class UrlMenuBottomSheetFragment extends LandscapeExpandedRoundedBottomSh url = "https://www.reddit.com" + url; } - linkTextView.setText(url); + binding.linkTextViewUrlMenuBottomSheetFragment.setText(url); - openLinkTextView.setOnClickListener(view -> { + binding.openLinkTextViewUrlMenuBottomSheetFragment.setOnClickListener(view -> { Intent intent = new Intent(activity, LinkResolverActivity.class); intent.setData(Uri.parse(url)); activity.startActivity(intent); dismiss(); }); - copyLinkTextView.setOnClickListener(view -> { + binding.copyLinkTextViewUrlMenuBottomSheetFragment.setOnClickListener(view -> { ClipboardManager clipboard = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); if (clipboard != null) { ClipData clip = ClipData.newPlainText("simple text", url); @@ -89,7 +78,7 @@ public class UrlMenuBottomSheetFragment extends LandscapeExpandedRoundedBottomSh dismiss(); }); - shareLinkTextView.setOnClickListener(view -> { + binding.shareLinkTextViewUrlMenuBottomSheetFragment.setOnClickListener(view -> { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, url); @@ -105,15 +94,15 @@ public class UrlMenuBottomSheetFragment extends LandscapeExpandedRoundedBottomSh if (activity instanceof BaseActivity) { if (((BaseActivity) activity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((BaseActivity) activity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((BaseActivity) activity).typeface); } } else if (activity instanceof ViewRedditGalleryActivity) { if (((ViewRedditGalleryActivity) activity).typeface != null) { - Utils.setFontToAllTextViews(rootView, ((ViewRedditGalleryActivity) activity).typeface); + Utils.setFontToAllTextViews(binding.getRoot(), ((ViewRedditGalleryActivity) activity).typeface); } } - return rootView; + return binding.getRoot(); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java index 63175be1..85c21fdd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java @@ -8,19 +8,17 @@ import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.SortType; import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback; import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment; +import ml.docilealligator.infinityforreddit.databinding.FragmentUserThingSortTypeBottomSheetBinding; import ml.docilealligator.infinityforreddit.utils.Utils; @@ -31,14 +29,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; - @BindView(R.id.new_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView newTypeTextView; - @BindView(R.id.hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView hotTypeTextView; - @BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView topTypeTextView; - @BindView(R.id.controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment) - TextView controversialTypeTextView; private BaseActivity activity; public UserThingSortTypeBottomSheetFragment() { @@ -56,48 +46,46 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View rootView = inflater.inflate(R.layout.fragment_user_thing_sort_type_bottom_sheet, container, false); - - ButterKnife.bind(this, rootView); + FragmentUserThingSortTypeBottomSheetBinding binding = FragmentUserThingSortTypeBottomSheetBinding.inflate(inflater, container, false); String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); if (currentSortType.equals(SortType.Type.NEW.fullName)) { - newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.newTypeTextViewUserThingSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.newTypeTextViewUserThingSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.HOT.fullName)) { - hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.hotTypeTextViewUserThingSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.hotTypeTextViewUserThingSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.TOP.fullName)) { - topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.topTypeTextViewUserThingSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.topTypeTextViewUserThingSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } else if (currentSortType.equals(SortType.Type.CONTROVERSIAL.fullName)) { - controversialTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(controversialTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); + binding.controversialTypeTextViewUserThingSortTypeBottomSheetFragment.setCompoundDrawablesRelativeWithIntrinsicBounds(binding.controversialTypeTextViewUserThingSortTypeBottomSheetFragment.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { - rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); + binding.getRoot().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); } - newTypeTextView.setOnClickListener(view -> { + binding.newTypeTextViewUserThingSortTypeBottomSheetFragment.setOnClickListener(view -> { if (activity != null) { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW)); } dismiss(); }); - hotTypeTextView.setOnClickListener(view -> { + binding.hotTypeTextViewUserThingSortTypeBottomSheetFragment.setOnClickListener(view -> { if (activity != null) { ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); } dismiss(); }); - topTypeTextView.setOnClickListener(view -> { + binding.topTypeTextViewUserThingSortTypeBottomSheetFragment.setOnClickListener(view -> { if (activity != null) { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.TOP.name()); } dismiss(); }); - controversialTypeTextView.setOnClickListener(view -> { + binding.controversialTypeTextViewUserThingSortTypeBottomSheetFragment.setOnClickListener(view -> { if (activity != null) { ((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name()); } @@ -105,10 +93,10 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override |