Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/src/main/java/com/demo/aty/SimpleGuideViewActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ public void onClick(View view) {
});
ll_nearby = (LinearLayout) findViewById(R.id.ll_nearby);
ll_video = (LinearLayout) findViewById(R.id.ll_video);
header_imgbtn.post(new Runnable() {
@Override
public void run() {
showGuideView();
}
});
}

public void showGuideView() {
Expand Down
41 changes: 39 additions & 2 deletions guideview/src/main/java/com/binioter/guideview/Guide.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

Expand Down Expand Up @@ -55,8 +57,23 @@ public void setOnSlideListener(GuideBuilder.OnSlideListener onSlideListener) {
*
* @param activity 目标Activity
*/
public void show(Activity activity) {
show(activity, null);
public void show(final Activity activity) {
View target = mConfiguration.mTargetView;
if (target == null) {
target = activity.findViewById(mConfiguration.mTargetViewId);
}
if (target != null) {
if (mConfiguration.mTargetView.getMeasuredWidth() > 0 && mConfiguration.mTargetView.getMeasuredHeight() > 0) {
show(activity, null);
} else {
mConfiguration.mTargetView.post(new Runnable() {
@Override
public void run() {
show(activity, null);
}
});
}
}
}

/**
Expand All @@ -69,6 +86,26 @@ public void show(Activity activity, ViewGroup overlay) {
mMaskView = onCreateView(activity, overlay);
if (overlay == null) {
overlay = (ViewGroup) activity.getWindow().getDecorView();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
final ViewGroup finalOverlay = overlay;
final Activity finalActivity = activity;
overlay.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
private boolean executedBefore = false;

@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
if (insets.getSystemWindowInsetTop() > 0) {
if (!executedBefore && mMaskView.isAttachedToWindow()) { //如果状态栏由隐藏变为显示此时如果已经展示了,重新展示一遍
dismiss();
show(finalActivity, finalOverlay);
executedBefore = true;
}

}
return insets;
}
});
}
}
if (mMaskView.getParent() == null && mConfiguration.mTargetView != null) {
overlay.addView(mMaskView);
Expand Down