mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +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.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.mozilla.servoview.ServoView;
|
import com.mozilla.servoview.ServoView;
|
||||||
import com.mozilla.servoview.Servo;
|
import com.mozilla.servoview.Servo;
|
||||||
|
@ -35,6 +36,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
||||||
Button mStopButton;
|
Button mStopButton;
|
||||||
EditText mUrlField;
|
EditText mUrlField;
|
||||||
ProgressBar mProgressBar;
|
ProgressBar mProgressBar;
|
||||||
|
TextView mIdleText;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -49,6 +51,7 @@ public class MainActivity extends Activity implements Servo.Client {
|
||||||
mStopButton = findViewById(R.id.stopbutton);
|
mStopButton = findViewById(R.id.stopbutton);
|
||||||
mUrlField = findViewById(R.id.urlfield);
|
mUrlField = findViewById(R.id.urlfield);
|
||||||
mProgressBar = findViewById(R.id.progressbar);
|
mProgressBar = findViewById(R.id.progressbar);
|
||||||
|
mIdleText = findViewById(R.id.redrawing);
|
||||||
|
|
||||||
mBackButton.setEnabled(false);
|
mBackButton.setEnabled(false);
|
||||||
mFwdButton.setEnabled(false);
|
mFwdButton.setEnabled(false);
|
||||||
|
@ -151,6 +154,14 @@ public class MainActivity extends Activity implements Servo.Client {
|
||||||
mFwdButton.setEnabled(canGoForward);
|
mFwdButton.setEnabled(canGoForward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onRedrawing(boolean redrawing) {
|
||||||
|
if (redrawing) {
|
||||||
|
mIdleText.setText("LOOP");
|
||||||
|
} else {
|
||||||
|
mIdleText.setText("IDLE");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
mServoView.onPause();
|
mServoView.onPause();
|
||||||
|
|
|
@ -82,6 +82,17 @@
|
||||||
android:text="Rld"
|
android:text="Rld"
|
||||||
android:textSize="10sp" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<com.mozilla.servoview.ServoView
|
<com.mozilla.servoview.ServoView
|
||||||
|
|
|
@ -116,6 +116,8 @@ public class Servo {
|
||||||
void onUrlChanged(String url);
|
void onUrlChanged(String url);
|
||||||
|
|
||||||
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
void onHistoryChanged(boolean canGoBack, boolean canGoForward);
|
||||||
|
|
||||||
|
void onRedrawing(boolean redrawing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RunCallback {
|
public interface RunCallback {
|
||||||
|
@ -182,6 +184,10 @@ public class Servo {
|
||||||
mRunCallback.inUIThread(() -> mClient.onHistoryChanged(canGoBack, canGoForward));
|
mRunCallback.inUIThread(() -> mClient.onHistoryChanged(canGoBack, canGoForward));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onRedrawing(boolean redrawing) {
|
||||||
|
mRunCallback.inUIThread(() -> mClient.onRedrawing(redrawing));
|
||||||
|
}
|
||||||
|
|
||||||
public byte[] readfile(String file) {
|
public byte[] readfile(String file) {
|
||||||
try {
|
try {
|
||||||
InputStream stream = mAssetMgr.open(file);
|
InputStream stream = mAssetMgr.open(file);
|
||||||
|
|
|
@ -55,6 +55,8 @@ public class ServoView extends GLSurfaceView
|
||||||
private boolean mZooming;
|
private boolean mZooming;
|
||||||
private float mZoomFactor = 1;
|
private float mZoomFactor = 1;
|
||||||
|
|
||||||
|
private boolean mRedrawing;
|
||||||
|
|
||||||
public ServoView(Context context, AttributeSet attrs) {
|
public ServoView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mActivity = (Activity) context;
|
mActivity = (Activity) context;
|
||||||
|
@ -152,6 +154,10 @@ public class ServoView extends GLSurfaceView
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doFrame(long frameTimeNanos) {
|
public void doFrame(long frameTimeNanos) {
|
||||||
|
if (!mRedrawing) {
|
||||||
|
mRedrawing = true;
|
||||||
|
mClient.onRedrawing(mRedrawing);
|
||||||
|
}
|
||||||
|
|
||||||
// 3 reasons to be here: animating or scrolling/flinging or pinching
|
// 3 reasons to be here: animating or scrolling/flinging or pinching
|
||||||
|
|
||||||
|
@ -191,6 +197,9 @@ public class ServoView extends GLSurfaceView
|
||||||
|
|
||||||
if (mZooming || mScrolling || mAnimating) {
|
if (mZooming || mScrolling || mAnimating) {
|
||||||
Choreographer.getInstance().postFrameCallback(this);
|
Choreographer.getInstance().postFrameCallback(this);
|
||||||
|
} else {
|
||||||
|
mRedrawing = false;
|
||||||
|
mClient.onRedrawing(mRedrawing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue