Skip to content

Commit

Permalink
Completelly removed legacy Butterknife dependency and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
federicoiosue committed May 3, 2023
1 parent 8c9a387 commit fee8a08
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
2 changes: 0 additions & 2 deletions omniNotes/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ dependencies {
transitive = true
exclude group: "com.android.support"
}
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation('org.mnode.ical4j:ical4j:3.0.11') {
exclude group: 'commons.io'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
import android.content.res.TypedArray;
import android.os.AsyncTask;
import androidx.fragment.app.Fragment;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.pixplicity.easyprefs.library.Prefs;
import de.greenrobot.event.EventBus;
import it.feio.android.omninotes.MainActivity;
import it.feio.android.omninotes.R;
import it.feio.android.omninotes.async.bus.NavigationUpdatedEvent;
import it.feio.android.omninotes.databinding.FragmentNavigationDrawerBinding;
import it.feio.android.omninotes.models.NavigationItem;
import it.feio.android.omninotes.models.adapters.NavDrawerAdapter;
import it.feio.android.omninotes.models.misc.DynamicNavigationLookupTable;
import it.feio.android.omninotes.models.views.NonScrollableListView;
import it.feio.android.omninotes.utils.Navigation;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
Expand All @@ -43,18 +41,15 @@

public class MainMenuTask extends AsyncTask<Void, Void, List<NavigationItem>> {

private final WeakReference<Fragment> mFragmentWeakReference;
private final WeakReference<Fragment> fragmentWeakReference;
private final MainActivity mainActivity;
@BindView(R.id.drawer_nav_list)
NonScrollableListView mDrawerList;
@BindView(R.id.drawer_tag_list)
NonScrollableListView mDrawerCategoriesList;

FragmentNavigationDrawerBinding navDrawer;

public MainMenuTask(Fragment mFragment) {
mFragmentWeakReference = new WeakReference<>(mFragment);
this.mainActivity = (MainActivity) mFragment.getActivity();
ButterKnife.bind(this, mFragment.getView());
public MainMenuTask(Fragment fragment) {
fragmentWeakReference = new WeakReference<>(fragment);
mainActivity = (MainActivity) fragment.getActivity();
navDrawer = FragmentNavigationDrawerBinding.inflate(fragment.getLayoutInflater());
}

@Override
Expand All @@ -65,33 +60,31 @@ protected List<NavigationItem> doInBackground(Void... params) {
@Override
protected void onPostExecute(final List<NavigationItem> items) {
if (isAlive()) {
mDrawerList.setAdapter(new NavDrawerAdapter(mainActivity, items));
mDrawerList.setOnItemClickListener((arg0, arg1, position, arg3) -> {
String navigation = mFragmentWeakReference.get().getResources().getStringArray(R.array
navDrawer.drawerNavList.setAdapter(new NavDrawerAdapter(mainActivity, items));
navDrawer.drawerNavList.setOnItemClickListener((arg0, arg1, position, arg3) -> {
String navigation = fragmentWeakReference.get().getResources().getStringArray(R.array
.navigation_list_codes)[items.get(position).getArrayIndex()];
updateNavigation(position, navigation);
});
mDrawerList.justifyListViewHeightBasedOnChildren();
navDrawer.drawerNavList.justifyListViewHeightBasedOnChildren();
}
}

private void updateNavigation(int position, String navigation) {
if (mainActivity.updateNavigation(navigation)) {
mDrawerList.setItemChecked(position, true);
if (mDrawerCategoriesList != null) {
mDrawerCategoriesList.setItemChecked(0, false); // Called to force redraw
}
navDrawer.drawerNavList.setItemChecked(position, true);
navDrawer.drawerTagList.setItemChecked(0, false); // Called to force redraw
mainActivity.getIntent().setAction(Intent.ACTION_MAIN);
EventBus.getDefault()
.post(new NavigationUpdatedEvent(mDrawerList.getItemAtPosition(position)));
.post(new NavigationUpdatedEvent(navDrawer.drawerNavList.getItemAtPosition(position)));
}
}

private boolean isAlive() {
return mFragmentWeakReference.get() != null
&& mFragmentWeakReference.get().isAdded()
&& mFragmentWeakReference.get().getActivity() != null
&& !mFragmentWeakReference.get().getActivity().isFinishing();
return fragmentWeakReference.get() != null
&& fragmentWeakReference.get().isAdded()
&& fragmentWeakReference.get().getActivity() != null
&& !fragmentWeakReference.get().getActivity().isFinishing();
}

private List<NavigationItem> buildMainMenu() {
Expand Down

0 comments on commit fee8a08

Please sign in to comment.