Left/right experiment

Refs #116
This commit is contained in:
M66B
2018-09-14 16:15:06 +00:00
parent 82023bd564
commit 790c09af9f
4 changed files with 145 additions and 4 deletions

View File

@@ -100,7 +100,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class FragmentMessage extends FragmentEx {
private ViewGroup view;
private ConstraintLayoutTouch view;
private View vwAnswerAnchor;
private ImageView ivFlagged;
private ImageView ivAvatar;
@@ -157,7 +157,7 @@ public class FragmentMessage extends FragmentEx {
@Override
@Nullable
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = (ViewGroup) inflater.inflate(R.layout.fragment_message, container, false);
view = (ConstraintLayoutTouch) inflater.inflate(R.layout.fragment_message, container, false);
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
debug = prefs.getBoolean("debug", false);
@@ -405,6 +405,38 @@ public class FragmentMessage extends FragmentEx {
}
});
view.setGestureListener(new ConstraintLayoutTouch.IGestureListener() {
@Override
public void onSwipe(ConstraintLayoutTouch.Direction direction) {
if (message == null)
return;
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("next",
direction == ConstraintLayoutTouch.Direction.Down ||
direction == ConstraintLayoutTouch.Direction.Right);
new SimpleTask<TupleMessageEx>() {
@Override
protected TupleMessageEx onLoad(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
boolean next = args.getBoolean("next");
return DB.getInstance(context).message().getMessage(id, next);
}
@Override
protected void onLoaded(Bundle args, TupleMessageEx message) {
if (message != null) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGE)
.putExtra("message", message));
}
}
}.load(FragmentMessage.this, args);
}
});
// Initialize
grpHeader.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE);