Skip to content

Commit

Permalink
showMoonDialog
Browse files Browse the repository at this point in the history
fixes bug where the moon dialog shows today's information instead of the selected day (#858)
  • Loading branch information
forrestguice committed Jan 6, 2025
1 parent 32bba6a commit d44addd
Showing 1 changed file with 12 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1382,22 +1382,6 @@ public void onNoteChanged(NoteData note, int transition)
});
}

private View.OnClickListener onMoonriseClick = new ViewUtils.ThrottledClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
showMoonDialog();
}
});
private View.OnLongClickListener onMoonriseLongClick = new View.OnLongClickListener()
{
@Override
public boolean onLongClick(View v) {
showMoonDialog();
return true;
}
};

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
Expand Down Expand Up @@ -2186,21 +2170,14 @@ public boolean onNoonHeaderLongClick(CardAdapter adapter, int position) {

@Override
public void onMoonHeaderClick(CardAdapter adapter, int position) {
onMoonHeaderAction(adapter, position);
showMoonPositionAt(adapter, position);
}
@Override
public boolean onMoonHeaderLongClick(CardAdapter adapter, int position)
{
onMoonHeaderAction(adapter, position);
showMoonPositionAt(adapter, position);
return true;
}
protected void onMoonHeaderAction(CardAdapter adapter, int position)
{
Pair<SuntimesRiseSetDataset, SuntimesMoonData> cardData = adapter.initData(SuntimesActivity.this, position);
if (Math.abs(CardAdapter.TODAY_POSITION - position) > 1 && cardData != null) {
showMoonPositionAt(cardData.first.dataNoon.calendar().getTimeInMillis());
} else showMoonDialog();
}

@Override
public void onLightmapClick(CardAdapter adapter, int position) {
Expand Down Expand Up @@ -2638,6 +2615,16 @@ public void showMoonPositionAt(@Nullable Long dateTime)
dialog = showMoonDialog();
dialog.showPositionAt(dateTime);
}
protected void showMoonPositionAt(CardAdapter adapter, int position)
{
Pair<SuntimesRiseSetDataset, SuntimesMoonData> cardData = ((adapter != null) ? adapter.initData(SuntimesActivity.this, position) : null);
if (cardData != null) {
showMoonPositionAt(cardData.first.dataNoon.calendar().getTimeInMillis());
} else showMoonDialog();
}
protected void showMoonPositionAt() {
showMoonPositionAt(card_adapter, card_layout.findFirstVisibleItemPosition());
}

/**
* Show data source labels / ui.
Expand Down

0 comments on commit d44addd

Please sign in to comment.