Skip to content

Commit

Permalink
Adding back Java methods called from native code.
Browse files Browse the repository at this point in the history
Change-Id: I3f0b594b439a3787e166515ab8fc650c13730f4a
  • Loading branch information
claywilkinson committed Jan 11, 2018
1 parent 7b648f2 commit f6bf9e6
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,58 @@ void setImmersiveSticky() {
PopupWindow _popupWindow;
TextView _label;

public void showUI()
{
if( _popupWindow != null )
return;

_activity = this;

this.runOnUiThread(new Runnable() {
@Override
public void run() {
LayoutInflater layoutInflater
= (LayoutInflater)getBaseContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
if (layoutInflater != null) {
View popupView = layoutInflater.inflate(R.layout.widgets, null);
_popupWindow = new PopupWindow(
popupView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);

LinearLayout mainLayout = new LinearLayout(_activity);
MarginLayoutParams params = new MarginLayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
params.setMargins(0, 0, 0, 0);
_activity.setContentView(mainLayout, params);

// Show our UI over NativeActivity window
_popupWindow.showAtLocation(mainLayout, Gravity.TOP | Gravity.START, 10, 10);
_popupWindow.update();

_label = popupView.findViewById(R.id.textViewFPS);
} else {
throw new IllegalStateException("Cannot get layout service!");
}

}});
}

public void updateFPS(final float fFPS)
{
if( _label == null )
return;

_activity = this;
this.runOnUiThread(new Runnable() {
@Override
public void run() {
_label.setText(String.format(Locale.getDefault(),"%2.2f FPS", fFPS));

}});
}

protected void onPause() {
super.onPause();
if (_popupWindow != null) {
Expand Down

0 comments on commit f6bf9e6

Please sign in to comment.