Remove the ActionMode with hint
Was thinking about this for a while and as it solves a part of #83 now did it
This commit is contained in:
parent
f672e5edfd
commit
a27226c15f
3 changed files with 3 additions and 71 deletions
|
@ -1,12 +1,10 @@
|
|||
package org.ligi.passandroid.ui;
|
||||
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.view.ActionMode;
|
||||
import android.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import java.util.List;
|
||||
|
@ -33,8 +31,6 @@ public class PassAdapter extends RecyclerView.Adapter<PassViewHolder> {
|
|||
protected final AppCompatActivity passListActivity;
|
||||
private final PassStoreProjection passStoreProjection;
|
||||
|
||||
ActionMode actionMode;
|
||||
|
||||
public PassAdapter(AppCompatActivity passListActivity, PassStoreProjection passStoreProjection) {
|
||||
this.passStoreProjection = passStoreProjection;
|
||||
App.component().inject(this);
|
||||
|
@ -65,7 +61,6 @@ public class PassAdapter extends RecyclerView.Adapter<PassViewHolder> {
|
|||
root.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
root.setCardElevation(v.getContext().getResources().getDimension(R.dimen.card_longclick_elevation));
|
||||
passStore.setCurrentPass(pass);
|
||||
AXT.at(passListActivity).startCommonIntent().activityFromClass(PassViewActivity.class);
|
||||
}
|
||||
|
@ -74,54 +69,8 @@ public class PassAdapter extends RecyclerView.Adapter<PassViewHolder> {
|
|||
root.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
|
||||
final Pass pass = getList().get(viewHolder.getAdapterPosition());
|
||||
|
||||
if (actionMode != null) {
|
||||
final boolean clickedOnDifferentItem = actionMode.getTag() == null || !actionMode.getTag().equals(pass);
|
||||
if (clickedOnDifferentItem) {
|
||||
actionMode.finish();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
actionMode = passListActivity.startSupportActionMode(new ActionMode.Callback() {
|
||||
@Override
|
||||
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
|
||||
|
||||
passListActivity.getMenuInflater().inflate(R.menu.activity_pass_action_mode, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
|
||||
if (new PassMenuOptions(passListActivity, viewHolder.pass).process(menuItem)) {
|
||||
actionMode.finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyActionMode(ActionMode _actionMode) {
|
||||
root.setCardElevation(root.getContext().getResources().getDimension(R.dimen.cardview_default_elevation));
|
||||
actionMode = null;
|
||||
}
|
||||
});
|
||||
|
||||
actionMode.setTag(getList().get(viewHolder.getAdapterPosition()));
|
||||
|
||||
root.setCardElevation(v.getContext().getResources().getDimension(R.dimen.card_longclick_elevation));
|
||||
|
||||
Snackbar.make(root, R.string.please_use_the_swipe_feature, Snackbar.LENGTH_LONG).show();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:yourapp="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_delete"
|
||||
yourapp:showAsAction="ifRoom"
|
||||
android:title="@string/menu_delete"
|
||||
android:icon="@drawable/ic_action_delete" />
|
||||
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_share"
|
||||
yourapp:showAsAction="ifRoom"
|
||||
android:title="@string/menu_share"
|
||||
android:icon="@drawable/ic_social_share" />
|
||||
|
||||
</menu>
|
|
@ -152,6 +152,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
|
|||
<string name="new_topic_input_hint">Title for new topic</string>
|
||||
<string name="new_topic_suggestions">Suggestions:</string>
|
||||
<string name="cannot_be_empty">cannot be empty</string>
|
||||
<string name="please_use_the_swipe_feature">Please use the swipe feature</string>
|
||||
<string-array name="sort_orders">
|
||||
<item>Date Ascending</item>
|
||||
<item>Date Descending</item>
|
||||
|
|
Loading…
Reference in a new issue