mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 22:39:12 +00:00
Replaced custom ItemClickListener and added ripple
This commit is contained in:
parent
5783066e38
commit
847d8acdd4
4 changed files with 12 additions and 17 deletions
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
|
@ -37,7 +37,7 @@
|
|||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
|
|
@ -30,8 +30,6 @@ import me.impy.aegis.helpers.ItemClickListener;
|
|||
public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.KeyProfileHolder> implements RVHAdapter {
|
||||
private ArrayList<KeyProfile> mKeyProfiles;
|
||||
private final List<KeyProfileHolder> lstHolders;
|
||||
private final ItemClickListener itemClickListener;
|
||||
|
||||
|
||||
private Handler mHandler = new Handler();
|
||||
private Runnable updateRemainingTimeRunnable = new Runnable() {
|
||||
|
@ -118,11 +116,10 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
|
|||
}
|
||||
|
||||
// Provide a suitable constructor (depends on the kind of dataset)
|
||||
public KeyProfileAdapter(ArrayList<KeyProfile> keyProfiles, @NonNull ItemClickListener listener) {
|
||||
public KeyProfileAdapter(ArrayList<KeyProfile> keyProfiles) {
|
||||
mKeyProfiles = keyProfiles;
|
||||
lstHolders = new ArrayList<>();
|
||||
|
||||
this.itemClickListener = listener;
|
||||
startUpdateTimer();
|
||||
}
|
||||
|
||||
|
@ -144,13 +141,7 @@ public class KeyProfileAdapter extends RecyclerView.Adapter<KeyProfileAdapter.Ke
|
|||
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_keyprofile, parent, false);
|
||||
// set the view's size, margins, paddings and layout parameters
|
||||
|
||||
final KeyProfileHolder vh = new KeyProfileHolder(v);
|
||||
v.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
itemClickListener.onItemClicked(vh.keyProfile, view);
|
||||
}
|
||||
});
|
||||
KeyProfileHolder vh = new KeyProfileHolder(v);
|
||||
return vh;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.yarolegovich.lovelydialog.LovelyTextInputDialog;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import github.nisrulz.recyclerviewhelper.RVHItemClickListener;
|
||||
import github.nisrulz.recyclerviewhelper.RVHItemDividerDecoration;
|
||||
import github.nisrulz.recyclerviewhelper.RVHItemTouchHelperCallback;
|
||||
import me.impy.aegis.crypto.KeyInfo;
|
||||
|
@ -66,18 +67,18 @@ public class MainActivity extends AppCompatActivity {
|
|||
rvKeyProfiles.setLayoutManager(mLayoutManager);
|
||||
|
||||
final Context context = this.getApplicationContext();
|
||||
ItemClickListener itemClickListener = new ItemClickListener() {
|
||||
rvKeyProfiles.addOnItemTouchListener(new RVHItemClickListener(this, new RVHItemClickListener.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClicked(Object item, Object view) {
|
||||
public void onItemClick(View view, int position) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("text/plain", ((KeyProfile)item).Code);
|
||||
ClipData clip = ClipData.newPlainText("text/plain", mKeyProfiles.get(position).Code);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
|
||||
Toast.makeText(context, "Code successfully copied to the clipboard", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
mKeyProfileAdapter = new KeyProfileAdapter(mKeyProfiles, itemClickListener);
|
||||
mKeyProfileAdapter = new KeyProfileAdapter(mKeyProfiles);
|
||||
rvKeyProfiles.addItemDecoration(new RVHItemDividerDecoration(this, LinearLayoutManager.VERTICAL));
|
||||
|
||||
ItemTouchHelper.Callback callback = new RVHItemTouchHelperCallback(mKeyProfileAdapter, true, false, false);
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
|
|
Loading…
Add table
Reference in a new issue