Skip to content

Commit

Permalink
fix(android): support detail property in row click event
Browse files Browse the repository at this point in the history
  • Loading branch information
garymathews authored and ewanharris committed Aug 13, 2021
1 parent ec53cf4 commit a615c42
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ private Object handleEvent(String eventName, Object data)
}
payload.put(TiC.EVENT_PROPERTY_ROW, this);
payload.put(TiC.EVENT_PROPERTY_INDEX, index);
payload.put(TiC.EVENT_PROPERTY_DETAIL, false);

if (tableView != null) {
payload.put(TiC.EVENT_PROPERTY_SEARCH_MODE, tableView.isFiltered());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.appcelerator.titanium.view.TiCompositeLayout;
import org.appcelerator.titanium.view.TiUIView;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
Expand All @@ -29,6 +30,7 @@
import android.graphics.drawable.PaintDrawable;
import android.os.Build;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
Expand Down Expand Up @@ -121,6 +123,7 @@ private void reset()
this.leftImage.setVisibility(View.GONE);
this.title.setVisibility(View.GONE);
this.rightImage.setVisibility(View.GONE);
this.rightImage.setOnTouchListener(null);

this.border.reset();
}
Expand All @@ -130,6 +133,7 @@ private void reset()
* @param proxy TableViewRowProxy to bind.
* @param selected Is row selected.
*/
@SuppressLint("ClickableViewAccessibility")
public void bind(final TableViewRowProxy proxy, final boolean selected)
{
reset();
Expand Down Expand Up @@ -259,6 +263,24 @@ public void bind(final TableViewRowProxy proxy, final boolean selected)
} else if (hasDetail) {
this.rightImage.setImageDrawable(disclosureDrawable);
this.rightImage.setVisibility(View.VISIBLE);
this.rightImage.setOnTouchListener(new View.OnTouchListener()
{
@Override
public boolean onTouch(View v, MotionEvent e)
{
if (e.getAction() == MotionEvent.ACTION_UP) {
final TiUIView view = proxy.peekView();

if (view != null) {
final KrollDict data = view.getLastUpEvent();

data.put(TiC.EVENT_PROPERTY_DETAIL, true);
proxy.fireEvent(TiC.EVENT_CLICK, data);
}
}
return true;
}
});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,11 @@ protected void disableHWAcceleration()
}
}

public KrollDict getLastUpEvent()
{
return dictFromEvent(this.lastUpEvent);
}

/**
* Retrieve the saved animated scale values, which we store here since Android provides no property
* for looking them up.
Expand Down

0 comments on commit a615c42

Please sign in to comment.