aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wong <wongma7@outlook.com>2016-07-21 20:49:41 -0400
committerMatthew Wong <wongma7@outlook.com>2016-07-21 20:49:41 -0400
commitca104469141c01cb5b4b22fe3225b58066f5649a (patch)
tree01a6db4164e0868edfe9f187f2666d143864a336
parent1e5303a142ef66643a5b054a611effad0f09bd15 (diff)
Use support library fragment (to avoid onAttach deprecation problems, etc)
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java16
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.java6
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java4
3 files changed, 12 insertions, 14 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java
index 83191e50..b08db439 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.support.v4.app.Fragment;
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
@@ -94,23 +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 {
@@ -127,7 +127,7 @@ public class PasswordFragment extends Fragment{
}
};
} catch (ClassCastException e) {
- throw new ClassCastException(activity.toString()
+ throw new ClassCastException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
index 3be6419b..e33addc3 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java
@@ -2,8 +2,8 @@ package com.zeapo.pwdstore;
import android.Manifest;
import android.app.Activity;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -331,7 +331,7 @@ public class PasswordStore extends AppCompatActivity {
}
private void checkLocalRepository(File localDir) {
- FragmentManager fragmentManager = getFragmentManager();
+ FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
if (localDir != null && settings.getBoolean("repository_initialized", false)) {
Log.d("PASS", "Check, dir: " + localDir.getAbsolutePath());
diff --git a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java
index 38d0a5d1..ab245746 100644
--- a/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java
+++ b/app/src/main/java/com/zeapo/pwdstore/ToCloneOrNot.java
@@ -1,9 +1,7 @@
package com.zeapo.pwdstore;
-import android.app.Activity;
-import android.net.Uri;
import android.os.Bundle;
-import android.app.Fragment;
+import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;