From 017650bf373e3ccc3a45680088297543a1470eff Mon Sep 17 00:00:00 2001 From: Matthew Wong Date: Fri, 8 Jul 2016 22:00:53 -0400 Subject: Fix back button behaviour --- .../main/java/com/zeapo/pwdstore/PasswordFragment.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index 79401fbd..e1046fe2 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -1,7 +1,7 @@ package com.zeapo.pwdstore; -import android.app.Activity; import android.app.Fragment; +import android.content.Context; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -94,24 +94,23 @@ public class PasswordFragment extends Fragment{ } @Override - public void onAttach(final Activity activity) { - super.onAttach(activity); + public void onAttach(final Context context) { + super.onAttach(context); try { mListener = new OnFragmentInteractionListener() { public void onFragmentInteraction(PasswordItem item) { if (item.getType() == PasswordItem.TYPE_CATEGORY) { // push the current password list (non filtered plz!) passListStack.push(pathStack.isEmpty() ? - PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(activity)) : - PasswordRepository.getPasswords(pathStack.peek(), PasswordRepository.getRepositoryDirectory(activity))); - + PasswordRepository.getPasswords(PasswordRepository.getRepositoryDirectory(context)) : + PasswordRepository.getPasswords(pathStack.peek(), PasswordRepository.getRepositoryDirectory(context))); //push the category were we're going pathStack.push(item.getFile()); scrollPosition.push(recyclerView.getVerticalScrollbarPosition()); recyclerView.scrollToPosition(0); recyclerAdapter.clear(); - recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile(), PasswordRepository.getRepositoryDirectory(activity))); + recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile(), PasswordRepository.getRepositoryDirectory(context))); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); } else { @@ -128,7 +127,7 @@ public class PasswordFragment extends Fragment{ } }; } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + throw new ClassCastException(context.toString() + " must implement OnFragmentInteractionListener"); } } -- cgit v1.2.3