Skip to content

Commit a4d255e

Browse files
committed
done
1 parent 10b247b commit a4d255e

File tree

4 files changed

+66
-60
lines changed

4 files changed

+66
-60
lines changed

app/src/main/java/home/smart/fly/animations/customview/ClockView.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ private void initAnim() {
9494
mAnimator.setDuration(time * 1000);
9595
mAnimator.setInterpolator(new LinearInterpolator());
9696
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
97+
9798
@Override
9899
public void onAnimationUpdate(ValueAnimator animation) {
99100
Log.e(TAG, "onAnimationUpdate: fraction=" + animation.getAnimatedFraction() * time);
@@ -124,18 +125,20 @@ public void start() {
124125

125126
public void pause() {
126127
if (mAnimator != null) {
127-
if (mAnimator.isRunning()) {
128-
mAnimator.pause();
129-
} else if (mAnimator.isPaused()) {
128+
if (mAnimator.isPaused()) {
129+
Log.i(TAG, "do resume");
130130
mAnimator.resume();
131+
} else {
132+
Log.i(TAG, "do pause");
133+
mAnimator.pause();
131134
}
132135
}
133136
}
134137

135138

136139
public void stop() {
137140
if (mAnimator != null) {
138-
mAnimator.cancel();
141+
mAnimator.end();
139142
}
140143
}
141144

app/src/main/java/home/smart/fly/animations/ui/activity/FullscreenADActivity.java

+27-24
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
package home.smart.fly.animations.ui.activity;
22

33
import android.annotation.SuppressLint;
4+
45
import androidx.appcompat.app.ActionBar;
56
import androidx.appcompat.app.AppCompatActivity;
7+
8+
import android.graphics.Color;
9+
import android.os.Build;
610
import android.os.Bundle;
711
import android.os.Handler;
12+
import android.util.Log;
813
import android.view.MotionEvent;
914
import android.view.View;
15+
import android.view.WindowManager;
1016
import android.widget.ImageView;
1117

1218
import home.smart.fly.animations.R;
@@ -17,6 +23,7 @@
1723
* status bar and navigation/system bar) with user interaction.
1824
*/
1925
public class FullscreenADActivity extends SimpleBaseActivity {
26+
private static final String TAG = "FullscreenADActivity";
2027
/**
2128
* Whether or not the system UI should be auto-hidden after
2229
* {@link #AUTO_HIDE_DELAY_MILLIS} milliseconds.
@@ -40,23 +47,26 @@ public class FullscreenADActivity extends SimpleBaseActivity {
4047
@SuppressLint("InlinedApi")
4148
@Override
4249
public void run() {
50+
Log.d(TAG, "mHidePart2Runnable run() called");
4351
// Delayed removal of status and navigation bar
4452

4553
// Note that some of these constants are new as of API 16 (Jelly Bean)
4654
// and API 19 (KitKat). It is safe to use them, as they are inlined
4755
// at compile-time and do nothing on earlier devices.
48-
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
49-
| View.SYSTEM_UI_FLAG_FULLSCREEN
50-
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
51-
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
52-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
53-
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
56+
mContentView.setSystemUiVisibility(
57+
View.SYSTEM_UI_FLAG_LOW_PROFILE
58+
| View.SYSTEM_UI_FLAG_FULLSCREEN
59+
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
60+
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
61+
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
62+
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
5463
}
5564
};
5665
private View mControlsView;
5766
private final Runnable mShowPart2Runnable = new Runnable() {
5867
@Override
5968
public void run() {
69+
Log.d(TAG, "mShowPart2Runnable run() called");
6070
// Delayed display of UI elements
6171
ActionBar actionBar = getSupportActionBar();
6272
if (actionBar != null) {
@@ -72,27 +82,13 @@ public void run() {
7282
hide();
7383
}
7484
};
75-
/**
76-
* Touch listener to use for in-layout UI controls to delay hiding the
77-
* system UI. This is to prevent the jarring behavior of controls going away
78-
* while interacting with activity UI.
79-
*/
80-
private final View.OnTouchListener mDelayHideTouchListener = new View.OnTouchListener() {
81-
@Override
82-
public boolean onTouch(View view, MotionEvent motionEvent) {
83-
if (AUTO_HIDE) {
84-
delayedHide(AUTO_HIDE_DELAY_MILLIS);
85-
}
86-
return false;
87-
}
88-
};
8985

9086
@Override
9187
protected void onCreate(Bundle savedInstanceState) {
9288
super.onCreate(savedInstanceState);
9389

9490
setContentView(R.layout.activity_fullscreen_ad);
95-
int resId = getIntent().getIntExtra("url",R.drawable.girl);
91+
int resId = getIntent().getIntExtra("url", R.drawable.girl);
9692
mVisible = true;
9793
mControlsView = findViewById(R.id.fullscreen_content_controls);
9894
mContentView = findViewById(R.id.fullscreen_content);
@@ -108,7 +104,13 @@ public void onClick(View view) {
108104
// Upon interacting with UI controls, delay any scheduled hide()
109105
// operations to prevent the jarring behavior of controls going away
110106
// while interacting with the UI.
111-
findViewById(R.id.dummy_button).setOnTouchListener(mDelayHideTouchListener);
107+
108+
getWindow().setStatusBarColor(Color.TRANSPARENT);
109+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
110+
WindowManager.LayoutParams params = getWindow().getAttributes();
111+
params.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
112+
getWindow().setAttributes(params);
113+
}
112114
}
113115

114116
@Override
@@ -130,6 +132,7 @@ private void toggle() {
130132
}
131133

132134
private void hide() {
135+
Log.d(TAG, "hide() called");
133136
// Hide UI first
134137
ActionBar actionBar = getSupportActionBar();
135138
if (actionBar != null) {
@@ -145,9 +148,9 @@ private void hide() {
145148

146149
@SuppressLint("InlinedApi")
147150
private void show() {
151+
Log.d(TAG, "show() called");
148152
// Show the system bar
149-
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
150-
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
153+
mContentView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
151154
mVisible = true;
152155

153156
// Schedule a runnable to display UI elements after a delay

app/src/main/res/layout/activity_clock_view.xml

+31-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<RelativeLayout
3-
xmlns:android="http://schemas.android.com/apk/res/android"
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
43
xmlns:app="http://schemas.android.com/apk/res-auto"
54
xmlns:tools="http://schemas.android.com/tools"
65
android:layout_width="match_parent"
@@ -9,67 +8,68 @@
98

109

1110
<LinearLayout
12-
android:orientation="horizontal"
1311
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
1413
android:gravity="center_vertical"
15-
android:layout_height="wrap_content">
14+
android:orientation="horizontal">
1615

1716
<EditText
18-
android:inputType="numberDecimal"
19-
android:hint="please input time"
2017
android:id="@+id/value"
21-
android:text="60"
22-
android:layout_margin="16dp"
2318
android:layout_width="0dp"
19+
android:layout_height="wrap_content"
20+
android:layout_margin="16dp"
2421
android:layout_weight="9"
25-
android:layout_height="wrap_content"/>
22+
android:hint="please input time"
23+
android:inputType="numberDecimal"
24+
android:text="60" />
2625

2726
<Button
2827
android:id="@+id/set"
29-
android:text="init"
30-
android:layout_marginEnd="16dp"
3128
android:layout_width="wrap_content"
32-
android:layout_height="wrap_content"/>
29+
android:layout_height="wrap_content"
30+
android:layout_marginEnd="16dp"
31+
android:text="init" />
3332

3433
</LinearLayout>
3534

3635

37-
3836
<home.smart.fly.animations.customview.ClockView
39-
android:layout_margin="16dp"
4037
android:id="@+id/clockView"
41-
android:layout_centerInParent="true"
4238
android:layout_width="match_parent"
43-
android:layout_height="match_parent"/>
39+
android:layout_height="match_parent"
40+
android:layout_centerInParent="true"
41+
android:layout_margin="16dp" />
4442

4543
<LinearLayout
46-
android:layout_below="@id/clockView"
4744
android:layout_width="match_parent"
45+
android:layout_height="wrap_content"
46+
android:layout_below="@id/clockView"
4847
android:orientation="horizontal"
49-
android:padding="16dp"
50-
android:layout_height="wrap_content">
48+
android:padding="16dp">
5149

5250
<Button
53-
android:text="start"
51+
android:id="@+id/start"
5452
android:layout_width="0dp"
55-
android:layout_weight="1"
53+
android:layout_height="wrap_content"
5654
android:layout_margin="10dp"
57-
android:id="@+id/start"
58-
android:layout_height="wrap_content"/>
55+
android:layout_weight="1"
56+
android:text="start" />
57+
5958
<Button
60-
android:text="pause"
61-
android:layout_width="0dp"
6259
android:id="@+id/pause"
63-
android:layout_weight="1"
60+
android:layout_width="0dp"
61+
android:layout_height="wrap_content"
6462
android:layout_margin="10dp"
65-
android:layout_height="wrap_content"/>
63+
android:layout_weight="1.5"
64+
android:text="pause" />
65+
6666
<Button
67-
android:text="stop"
68-
android:layout_width="0dp"
6967
android:id="@+id/stop"
70-
android:layout_weight="1"
68+
android:layout_width="0dp"
69+
android:layout_height="wrap_content"
7170
android:layout_margin="10dp"
72-
android:layout_height="wrap_content"/>
71+
android:layout_weight="1"
72+
android:text="stop" />
7373

7474
</LinearLayout>
7575

app/src/main/res/layout/activity_fullscreen_ad.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<FrameLayout
2424
android:layout_width="match_parent"
2525
android:layout_height="match_parent"
26-
android:fitsSystemWindows="true">
26+
android:fitsSystemWindows="false">
2727

2828
<LinearLayout
2929
android:id="@+id/fullscreen_content_controls"

0 commit comments

Comments
 (0)