mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Show animation status
This commit is contained in:
parent
296b76070c
commit
6aa653a46d
4 changed files with 37 additions and 0 deletions
|
@ -18,6 +18,7 @@ import android.webkit.URLUtil;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mozilla.servoview.ServoView;
|
||||
import com.mozilla.servoview.Servo;
|
||||
|
@ -35,6 +36,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
Button mStopButton;
|
||||
EditText mUrlField;
|
||||
ProgressBar mProgressBar;
|
||||
TextView mIdleText;
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -49,6 +51,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
mStopButton = findViewById(R.id.stopbutton);
|
||||
mUrlField = findViewById(R.id.urlfield);
|
||||
mProgressBar = findViewById(R.id.progressbar);
|
||||
mIdleText = findViewById(R.id.redrawing);
|
||||
|
||||
mBackButton.setEnabled(false);
|
||||
mFwdButton.setEnabled(false);
|
||||
|
@ -151,6 +154,14 @@ public class MainActivity extends Activity implements Servo.Client {
|
|||
mFwdButton.setEnabled(canGoForward);
|
||||
}
|
||||
|
||||
public void onRedrawing(boolean redrawing) {
|
||||
if (redrawing) {
|
||||
mIdleText.setText("LOOP");
|
||||
} else {
|
||||
mIdleText.setText("IDLE");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mServoView.onPause();
|
||||
|
|
|
@ -82,6 +82,17 @@
|
|||
android:text="Rld"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/redrawing"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="monospace"
|
||||
android:text="idle"
|
||||
android:textAlignment="center"
|
||||
android:textSize="10sp"
|
||||
android:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.mozilla.servoview.ServoView
|
||||
|
|
|
@ -116,6 +116,8 @@ public class Servo {
|
|||
void onUrlChanged(String url);
|
||||
|
||||
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
||||
|
||||
void onRedrawing(boolean redrawing);
|
||||
}
|
||||
|
||||
public interface RunCallback {
|
||||
|
@ -182,6 +184,10 @@ public class Servo {
|
|||
mRunCallback.inUIThread(() -> mClient.onHistoryChanged(canGoBack, canGoForward));
|
||||
}
|
||||
|
||||
public void onRedrawing(boolean redrawing) {
|
||||
mRunCallback.inUIThread(() -> mClient.onRedrawing(redrawing));
|
||||
}
|
||||
|
||||
public byte[] readfile(String file) {
|
||||
try {
|
||||
InputStream stream = mAssetMgr.open(file);
|
||||
|
|
|
@ -55,6 +55,8 @@ public class ServoView extends GLSurfaceView
|
|||
private boolean mZooming;
|
||||
private float mZoomFactor = 1;
|
||||
|
||||
private boolean mRedrawing;
|
||||
|
||||
public ServoView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mActivity = (Activity) context;
|
||||
|
@ -152,6 +154,10 @@ public class ServoView extends GLSurfaceView
|
|||
}
|
||||
|
||||
public void doFrame(long frameTimeNanos) {
|
||||
if (!mRedrawing) {
|
||||
mRedrawing = true;
|
||||
mClient.onRedrawing(mRedrawing);
|
||||
}
|
||||
|
||||
// 3 reasons to be here: animating or scrolling/flinging or pinching
|
||||
|
||||
|
@ -191,6 +197,9 @@ public class ServoView extends GLSurfaceView
|
|||
|
||||
if (mZooming || mScrolling || mAnimating) {
|
||||
Choreographer.getInstance().postFrameCallback(this);
|
||||
} else {
|
||||
mRedrawing = false;
|
||||
mClient.onRedrawing(mRedrawing);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue