diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-04-28 02:46:54 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-04-28 02:46:54 +0000 |
commit | 69e757ff94e3718e40175b9492163848fd0bc625 (patch) | |
tree | 99e97dafefbf7b8e812a12d4a34488c6b08fc50a /app | |
parent | 081c77667422454e2a9b1e97e3c8c7db789109c9 (diff) | |
download | infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.tar infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.tar.gz infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.tar.bz2 infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.tar.lz infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.tar.xz infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.tar.zst infinity-for-reddit-69e757ff94e3718e40175b9492163848fd0bc625.zip |
Migrate to ViewBinding in some activities.
Diffstat (limited to 'app')
4 files changed, 21 insertions, 45 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java index f6f60af0..0e75c367 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchSubredditsResultActivity.java @@ -11,12 +11,8 @@ import android.view.Window; import android.view.WindowManager; import androidx.annotation.NonNull; -import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; -import com.google.android.material.appbar.AppBarLayout; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -25,14 +21,12 @@ import java.util.ArrayList; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySearchSubredditsResultBinding; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.SubredditListingFragment; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; @@ -47,12 +41,6 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti private static final String FRAGMENT_OUT_STATE = "FOS"; - @BindView(R.id.coordinator_layout_search_subreddits_result_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_search_subreddits_result_activity) - AppBarLayout appBarLayout; - @BindView(R.id.toolbar_search_subreddits_result_activity) - Toolbar toolbar; Fragment mFragment; @Inject @Named("default") @@ -62,6 +50,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti SharedPreferences mCurrentAccountSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private ActivitySearchSubredditsResultBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { @@ -69,9 +58,8 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti super.onCreate(savedInstanceState); - setContentView(R.layout.activity_search_subreddits_result); - - ButterKnife.bind(this); + binding = ActivitySearchSubredditsResultBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); @@ -85,7 +73,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSearchSubredditsResultActivity); } if (isImmersiveInterface()) { @@ -94,13 +82,13 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.toolbarSearchSubredditsResultActivity); } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSearchSubredditsResultActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarSearchSubredditsResultActivity); String query = getIntent().getExtras().getString(EXTRA_QUERY); @@ -136,8 +124,8 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSearchSubredditsResultActivity, null, binding.toolbarSearchSubredditsResultActivity); } public void getSelectedSubreddit(String name, String iconUrl) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java index 684e676c..78c9b003 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchUsersResultActivity.java @@ -11,12 +11,8 @@ import android.view.Window; import android.view.WindowManager; import androidx.annotation.NonNull; -import androidx.appcompat.widget.Toolbar; -import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.fragment.app.Fragment; -import com.google.android.material.appbar.AppBarLayout; - import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -25,14 +21,12 @@ import java.util.ArrayList; import javax.inject.Inject; import javax.inject.Named; -import butterknife.BindView; -import butterknife.ButterKnife; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; -import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.slidr.Slidr; +import ml.docilealligator.infinityforreddit.databinding.ActivitySearchUsersResultBinding; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.fragments.UserListingFragment; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; @@ -47,12 +41,6 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT private static final String FRAGMENT_OUT_STATE = "FOS"; - @BindView(R.id.coordinator_layout_search_users_result_activity) - CoordinatorLayout coordinatorLayout; - @BindView(R.id.appbar_layout_search_users_result_activity) - AppBarLayout appBarLayout; - @BindView(R.id.toolbar_search_users_result_activity) - Toolbar toolbar; Fragment mFragment; @Inject @Named("default") @@ -62,15 +50,16 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT SharedPreferences mCurrentAccountSharedPreferences; @Inject CustomThemeWrapper mCustomThemeWrapper; + private ActivitySearchUsersResultBinding binding; @Override protected void onCreate(Bundle savedInstanceState) { ((Infinity) getApplication()).getAppComponent().inject(this); super.onCreate(savedInstanceState); - setContentView(R.layout.activity_search_users_result); - ButterKnife.bind(this); + binding = ActivitySearchUsersResultBinding.inflate(getLayoutInflater()); + setContentView(binding.getRoot()); EventBus.getDefault().register(this); @@ -84,7 +73,7 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT Window window = getWindow(); if (isChangeStatusBarIconColor()) { - addOnOffsetChangedListener(appBarLayout); + addOnOffsetChangedListener(binding.appbarLayoutSearchUsersResultActivity); } if (isImmersiveInterface()) { @@ -93,13 +82,13 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT } else { window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); } - adjustToolbar(toolbar); + adjustToolbar(binding.toolbarSearchUsersResultActivity); } } - setSupportActionBar(toolbar); + setSupportActionBar(binding.toolbarSearchUsersResultActivity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); - setToolbarGoToTop(toolbar); + setToolbarGoToTop(binding.toolbarSearchUsersResultActivity); String query = getIntent().getExtras().getString(EXTRA_QUERY); @@ -135,8 +124,9 @@ public class SearchUsersResultActivity extends BaseActivity implements ActivityT @Override protected void applyCustomTheme() { - coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); - applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); + binding.getRoot().setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); + applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutSearchUsersResultActivity, + null, binding.toolbarSearchUsersResultActivity); } public void getSelectedUser(String name, String iconUrl) { diff --git a/app/src/main/res/layout/activity_search_subreddits_result.xml b/app/src/main/res/layout/activity_search_subreddits_result.xml index 5824e728..e7f0afc8 100644 --- a/app/src/main/res/layout/activity_search_subreddits_result.xml +++ b/app/src/main/res/layout/activity_search_subreddits_result.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_search_subreddits_result_activity" tools:application=".SearchSubredditsResultActivity"> <com.google.android.material.appbar.AppBarLayout diff --git a/app/src/main/res/layout/activity_search_users_result.xml b/app/src/main/res/layout/activity_search_users_result.xml index cdc6ee54..c453755c 100644 --- a/app/src/main/res/layout/activity_search_users_result.xml +++ b/app/src/main/res/layout/activity_search_users_result.xml @@ -4,7 +4,6 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:id="@+id/coordinator_layout_search_users_result_activity" tools:application=".SearchUsersResultActivity"> <com.google.android.material.appbar.AppBarLayout |