Преглед изворни кода

newbie guide small tune up

billyyoyo пре 6 година
родитељ
комит
0f9f30a6c6

+ 30 - 1
app/src/main/java/com/sheep/gamegroup/module/guide/NewbieGuideHelper.java

@@ -14,11 +14,13 @@ import com.app.hubert.guide.NewbieGuide;
 import com.app.hubert.guide.core.Builder;
 import com.app.hubert.guide.core.Controller;
 import com.app.hubert.guide.listener.OnGuideChangedListener;
+import com.app.hubert.guide.listener.OnLayoutInflatedListener;
 import com.app.hubert.guide.listener.OnPageChangedListener;
 import com.app.hubert.guide.model.GuidePage;
 import com.app.hubert.guide.model.HighLight;
 import com.app.hubert.guide.model.HighlightOptions;
 import com.app.hubert.guide.model.RelativeGuide;
+import com.app.hubert.guide.core.Controller;
 import com.kfzs.duanduan.cardview.ScreenUtil;
 import com.sheep.gamegroup.event.BigEvent;
 import com.sheep.gamegroup.module.game.fragment.FgtGameCenter;
@@ -55,6 +57,8 @@ public class NewbieGuideHelper {
     private Animation enterAnimation;
     private Animation exitAnimation;
 
+    private boolean goon = true;
+
     public NewbieGuideHelper(Activity mActivity) {
         this.mActivity = mActivity;
         enterAnimation = new AlphaAnimation(0f, 1f);
@@ -84,7 +88,7 @@ public class NewbieGuideHelper {
             return;
         }
         Builder builder = NewbieGuide.with(mActivity)
-                .setLabel("page_"+type)//设置引导层标示区分不同引导层,必传!否则报错
+                .setLabel("page_" + type)//设置引导层标示区分不同引导层,必传!否则报错
                 .setOnGuideChangedListener(new OnGuideChangedListener() {
                     @Override
                     public void onShowed(Controller controller) {
@@ -94,6 +98,7 @@ public class NewbieGuideHelper {
 
                     @Override
                     public void onRemoved(Controller controller) {
+                        if (!goon) return;
                         Log.e(TAG, "NewbieGuide  onRemoved: ");
                         if (type == GUIDE_HOME) {
                             Jump2View.getInstance().goPersonnalCenterView(mActivity, "newbie");
@@ -197,6 +202,8 @@ public class NewbieGuideHelper {
         return GuidePage.newInstance()//创建一个实例
                 .addHighLightWithOptions(ActMain.tabBtn1.get(), HighLight.Shape.CIRCLE, new HighlightOptions.Builder().useMaxSize(false).build())
                 .addHighLightWithOptions(FgtHome.meetRef.get(), HighLight.Shape.ROUND_RECTANGLE, round, 0, new HighlightOptions.Builder().setRelativeGuide(relativeGuide).build())
+                .setLayoutRes(R.layout.newbie_guide_cancel)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
@@ -209,6 +216,8 @@ public class NewbieGuideHelper {
         };
         return GuidePage.newInstance()//创建一个实例
                 .addHighLightWithOptions(FgtPersonalCenter.myMoneyRef.get(), HighLight.Shape.RECTANGLE, new HighlightOptions.Builder().setRelativeGuide(relativeGuide).build())
+                .setLayoutRes(R.layout.newbie_guide_cancel)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
@@ -222,6 +231,8 @@ public class NewbieGuideHelper {
         };
         return GuidePage.newInstance()//创建一个实例
                 .addHighLightWithOptions(FgtPersonalCenter.accountDetailRef.get(), HighLight.Shape.RECTANGLE, new HighlightOptions.Builder().setRelativeGuide(relativeGuide).build())
+                .setLayoutRes(R.layout.newbie_guide_cancel)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
@@ -230,6 +241,8 @@ public class NewbieGuideHelper {
         RelativeGuide relativeGuide = new RelativeGuide(R.layout.newbie_guide_7, Gravity.TOP, 0);
         return GuidePage.newInstance()//创建一个实例
                 .addHighLightWithOptions(FgtPersonalCenter.fagRef.get(), HighLight.Shape.RECTANGLE, new HighlightOptions.Builder().setRelativeGuide(relativeGuide).build())
+                .setLayoutRes(R.layout.newbie_guide_cancel)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
@@ -253,6 +266,7 @@ public class NewbieGuideHelper {
                 .addHighLightWithOptions(FgtMainHeader.downloadRef.get(), HighLight.Shape.CIRCLE, new HighlightOptions.Builder().setRelativeGuide(relativeGuide2).build())
                 .addHighLightWithOptions(FgtGameCenter.getTab(0), HighLight.Shape.OVAL, new HighlightOptions.Builder().setRelativeGuide(relativeGuide1).build())
                 .setLayoutRes(R.layout.newbie_guide_8_3)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
@@ -268,6 +282,8 @@ public class NewbieGuideHelper {
         return GuidePage.newInstance()//创建一个实例
                 .addHighLightWithOptions(ActMain.tabBtn2.get(), HighLight.Shape.CIRCLE, new HighlightOptions.Builder().useMaxSize(false).build())
                 .addHighLightWithOptions(FgtGameCenter.getTab(1), HighLight.Shape.OVAL, new HighlightOptions.Builder().setRelativeGuide(relativeGuide).build())
+                .setLayoutRes(R.layout.newbie_guide_cancel)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
@@ -283,8 +299,21 @@ public class NewbieGuideHelper {
         return GuidePage.newInstance()//创建一个实例
                 .addHighLightWithOptions(ActMain.tabBtn2.get(), HighLight.Shape.CIRCLE, new HighlightOptions.Builder().useMaxSize(false).build())
                 .addHighLightWithOptions(FgtGameCenter.getTab(3), HighLight.Shape.OVAL, new HighlightOptions.Builder().setRelativeGuide(relativeGuide).build())
+                .setLayoutRes(R.layout.newbie_guide_cancel)
+                .setOnLayoutInflatedListener(new OnBackgroundListener())
                 .setEnterAnimation(enterAnimation)//进入动画
                 .setExitAnimation(exitAnimation);//退出动画
     }
 
+    private class OnBackgroundListener implements OnLayoutInflatedListener {
+
+        @Override
+        public void onLayoutInflated(View view, Controller controller) {
+            view.findViewById(R.id.cancel_guide_btn).setOnClickListener(v -> {
+                goon = false;
+                controller.remove();
+            });
+        }
+    }
+
 }

+ 7 - 13
app/src/main/java/com/sheep/gamegroup/view/fragment/FgtPersonalCenter.java

@@ -210,27 +210,21 @@ public class FgtPersonalCenter extends BaseFragment {
         fagRef = new WeakReference<>(faq_layout);
         scrollRef = new WeakReference<>(scroll_view);
         if (isNewbie) {
-            new NewbieGuideHelper(getActivity()).show(NewbieGuideHelper.GUIDE_USER);
+            new Handler() {
+                public void handleMessage(Message msg) {
+                    new NewbieGuideHelper(getActivity()).show(NewbieGuideHelper.GUIDE_USER);
+                }
+            }.sendEmptyMessageDelayed(0, 500);
         }
     }
 
     @Override
     public void initViewOnVisibleToUser() {
-        ibtn_baseactivity_right.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View view) {
-                Jump2View.getInstance().goSetting(activity, null);
-            }
-        });
+        ibtn_baseactivity_right.setOnClickListener((v) -> Jump2View.getInstance().goSetting(activity, null));
 
         if (activity instanceof PersonalCenterAct) {
             img_baseactivity_title.setVisibility(View.VISIBLE);
-            img_baseactivity_title.setOnClickListener(new View.OnClickListener() {
-                @Override
-                public void onClick(View view) {
-                    activity.finish();
-                }
-            });
+            img_baseactivity_title.setOnClickListener((v) -> activity.finish());
         } else {
             img_baseactivity_title.setVisibility(View.INVISIBLE);
         }

+ 6 - 0
app/src/main/res/drawable/shape_white_stroke_20.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+    android:shape="rectangle">
+    <corners android:radius="20dp" />
+    <stroke android:color="#ffffff" android:width="1dp" />
+</shape>

+ 6 - 4
app/src/main/res/layout/newbie_guide_8_3.xml

@@ -3,13 +3,15 @@
     android:layout_width="match_parent"
     android:layout_height="wrap_content">
 
+    <include layout="@layout/newbie_guide_cancel" />
+
     <ImageView
         android:id="@+id/i1"
-        android:src="@mipmap/guide_8_3"
-        android:adjustViewBounds="true"
+        android:layout_width="127dp"
+        android:layout_height="wrap_content"
         android:layout_centerHorizontal="true"
         android:layout_marginTop="247dp"
-        android:layout_width="127dp"
-        android:layout_height="wrap_content" />
+        android:adjustViewBounds="true"
+        android:src="@mipmap/guide_8_3" />
 
 </RelativeLayout>

+ 18 - 0
app/src/main/res/layout/newbie_guide_cancel.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content">
+
+    <TextView
+        android:id="@+id/cancel_guide_btn"
+        android:text="跳过"
+        android:textSize="15sp"
+        android:textColor="@color/white"
+        android:background="@drawable/shape_white_stroke_20"
+        android:layout_marginTop="30dp"
+        android:layout_marginLeft="20dp"
+        android:gravity="center"
+        android:layout_width="60dp"
+        android:layout_height="31dp" />
+
+</RelativeLayout>