diff options
| author | zeapo <mohamed@zenadi.com> | 2014-08-17 01:13:46 +0200 |
|---|---|---|
| committer | zeapo <mohamed@zenadi.com> | 2014-08-17 01:13:46 +0200 |
| commit | 1858fb5e52eb764924d1b57dcd6c395ead54cbc3 (patch) | |
| tree | 5eb506679c2b108a151388798e8be495fc1df0e3 /app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java | |
| parent | 3debc057071e4468921f99f2ebeb59f54eae9307 (diff) | |
| download | HardenedPass-1858fb5e52eb764924d1b57dcd6c395ead54cbc3.tar.gz HardenedPass-1858fb5e52eb764924d1b57dcd6c395ead54cbc3.zip | |
major ui improvement to the list using SwipeListView
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java | 131 |
1 files changed, 110 insertions, 21 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index db214cc5..d9346892 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -1,20 +1,27 @@ package com.zeapo.pwdstore; import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.Animation; +import android.view.animation.ScaleAnimation; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ExpandableListAdapter; import android.widget.ExpandableListView; +import android.widget.LinearLayout; import android.widget.ListAdapter; import android.widget.ListView; +import com.fortysevendeg.swipelistview.BaseSwipeListViewListener; +import com.fortysevendeg.swipelistview.SwipeListView; +import com.fortysevendeg.swipelistview.SwipeListViewListener; import com.zeapo.pwdstore.utils.PasswordAdapter; import com.zeapo.pwdstore.utils.PasswordItem; import com.zeapo.pwdstore.utils.PasswordRepository; @@ -29,14 +36,14 @@ import java.util.List; * with a GridView. * <p /> */ -public class PasswordFragment extends Fragment implements ExpandableListView.OnGroupClickListener { +public class PasswordFragment extends Fragment implements SwipeListViewListener { private OnFragmentInteractionListener mListener; /** * The fragment's ListView/GridView. */ - private ExpandableListView mListView; + private SwipeListView mListView; /** * The Adapter which will be used to populate the ListView/GridView with @@ -64,11 +71,11 @@ public class PasswordFragment extends Fragment implements ExpandableListView.OnG View view = inflater.inflate(R.layout.fragment_password, container, false); // Set the adapter - mListView = (ExpandableListView) view.findViewById(R.id.pass_list); - mListView.setAdapter((android.widget.ExpandableListAdapter) mAdapter); - + mListView = (SwipeListView) view.findViewById(R.id.pass_list); + ((AdapterView<ListAdapter>) mListView).setAdapter(mAdapter); // Set OnItemClickListener so we can be notified on item clicks - mListView.setOnGroupClickListener(this); +// mListView.setOnItemClickListener(this); + mListView.setSwipeListViewListener(this); mListView.setSelectionFromTop(getArguments().getInt("Position"), 0); return view; @@ -98,23 +105,105 @@ public class PasswordFragment extends Fragment implements ExpandableListView.OnG } +// @Override + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { + PasswordItem item = mAdapter.getItem(position); + if (item.getType() == PasswordItem.TYPE_PASSWORD) { +// if (item.selected) { +// item.selected = false; +// } else { +// View right = view.findViewById(R.id.row_buttons); +// ScaleAnimation animation = new ScaleAnimation(view.getX(), 0, view.getY(), 0, Animation.RELATIVE_TO_SELF, (float)0.5, Animation.RELATIVE_TO_SELF, (float)0.5); +// right.setAnimation(animation); +// item.selected = true; +// } + } else if (null != mListener) { + // Notify the active callbacks interface (the activity, if the + // fragment is attached to one) that an item has been selected. + mListener.onFragmentInteraction(mAdapter.getItem(position)); + } + + } + + @Override + public void onOpened(int i, boolean b) { + + } + + @Override + public void onClosed(int i, boolean b) { + + } + + @Override + public void onListChanged() { + + } + + @Override + public void onMove(int i, float v) { + + } + + @Override + public void onStartOpen(int i, int i2, boolean b) { + + } + + @Override + public void onStartClose(int i, boolean b) { + + } + @Override - public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) { - if( ((PasswordItem) mAdapter.getGroup(i)).getType() == PasswordItem.TYPE_CATEGORY ){ - if (null != mListener) { - // Notify the active callbacks interface (the activity, if the - // fragment is attached to one) that an item has been selected. - mListener.onFragmentInteraction(mAdapter.getItem(i)); - } - } else { - if (expandableListView.isGroupExpanded(i)) { - expandableListView.collapseGroup(i); - } else { - expandableListView.expandGroup(i); - } + public void onClickFrontView(int i) { + if (mAdapter.getItem(i).getType() == PasswordItem.TYPE_PASSWORD) { + mListView.openAnimate(i); + } else if (null != mListener) { + // Notify the active callbacks interface (the activity, if the + // fragment is attached to one) that an item has been selected. + mListener.onFragmentInteraction(mAdapter.getItem(i)); } + } + + @Override + public void onClickBackView(int i) { + mListView.closeAnimate(i); + } + + @Override + public void onDismiss(int[] ints) { + + } + + @Override + public int onChangeSwipeMode(int i) { + return 0; + } + + @Override + public void onChoiceChanged(int i, boolean b) { + + } + + @Override + public void onChoiceStarted() { + + } + + @Override + public void onChoiceEnded() { + + } + + @Override + public void onFirstListItem() { + + } + + @Override + public void onLastListItem() { - return true; } public interface OnFragmentInteractionListener { @@ -125,7 +214,7 @@ public class PasswordFragment extends Fragment implements ExpandableListView.OnG public void updateAdapter() { mAdapter.clear(); mAdapter.addAll(PasswordRepository.getPasswords(new File(getArguments().getString("Path")))); - mListView.setAdapter((ExpandableListAdapter) mAdapter); + mListView.setAdapter((ListAdapter) mAdapter); } } |
