Commit b003da8e authored by fallenstardust's avatar fallenstardust

完善首页引导

parent 8f4966b2
...@@ -2,7 +2,11 @@ package cn.garymb.ygomobile.ui.home; ...@@ -2,7 +2,11 @@ package cn.garymb.ygomobile.ui.home;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Intent; import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.RectF;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
...@@ -20,6 +24,7 @@ import android.widget.Button; ...@@ -20,6 +24,7 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
...@@ -28,8 +33,12 @@ import androidx.recyclerview.widget.DividerItemDecoration; ...@@ -28,8 +33,12 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.app.hubert.guide.NewbieGuide; import com.app.hubert.guide.NewbieGuide;
import com.app.hubert.guide.core.Controller;
import com.app.hubert.guide.listener.OnHighlightDrewListener;
import com.app.hubert.guide.listener.OnLayoutInflatedListener;
import com.app.hubert.guide.model.GuidePage; import com.app.hubert.guide.model.GuidePage;
import com.app.hubert.guide.model.HighLight; import com.app.hubert.guide.model.HighLight;
import com.app.hubert.guide.model.HighlightOptions;
import com.google.android.material.navigation.NavigationView; import com.google.android.material.navigation.NavigationView;
import com.nightonke.boommenu.BoomButtons.BoomButton; import com.nightonke.boommenu.BoomButtons.BoomButton;
import com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton; import com.nightonke.boommenu.BoomButtons.TextOutsideCircleButton;
...@@ -109,18 +118,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -109,18 +118,8 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
setContentView(R.layout.activity_home); setContentView(R.layout.activity_home);
setExitAnimEnable(false); setExitAnimEnable(false);
mCardManager = new CardManager(AppsSettings.get().getDataBaseFile().getAbsolutePath(), null); mCardManager = new CardManager(AppsSettings.get().getDataBaseFile().getAbsolutePath(), null);
mServerList = $(R.id.list_server);
mServerListAdapter = new ServerListAdapter(this);
//server list //server list
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); initServerlist();
mServerList.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
mServerList.addItemDecoration(dividerItemDecoration);
mServerList.setAdapter(mServerListAdapter);
mServerListManager = new ServerListManager(this, mServerListAdapter);
mServerListManager.bind(mServerList);
mServerListManager.syncLoadData();
//event //event
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
initBoomMenuButton($(R.id.bmb)); initBoomMenuButton($(R.id.bmb));
...@@ -672,15 +671,98 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie ...@@ -672,15 +671,98 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
Toast.makeText(this, tips, Toast.LENGTH_LONG).show(); Toast.makeText(this, tips, Toast.LENGTH_LONG).show();
} }
} }
public void initServerlist() {
mServerList = $(R.id.list_server);
mServerListAdapter = new ServerListAdapter(this);
//server list
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
mServerList.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration =
new DividerItemDecoration(this, DividerItemDecoration.VERTICAL);
mServerList.addItemDecoration(dividerItemDecoration);
mServerList.setAdapter(mServerListAdapter);
mServerListManager = new ServerListManager(this, mServerListAdapter);
mServerListManager.bind(mServerList);
mServerListManager.syncLoadData();
}
//https://www.jianshu.com/p/99649af3b191 //https://www.jianshu.com/p/99649af3b191
public void showNewbieGuide() { public void showNewbieGuide() {
HighlightOptions options = new HighlightOptions.Builder()//绘制一个高亮虚线圈
.setOnHighlightDrewListener(new OnHighlightDrewListener() {
@Override
public void onHighlightDrew(Canvas canvas, RectF rectF) {
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(20);
paint.setPathEffect(new DashPathEffect(new float[]{20, 20}, 0));
canvas.drawCircle(rectF.centerX(), rectF.centerY(), rectF.width() / 2 + 10, paint);
}
}).build();
NewbieGuide.with(this)//with方法可以传入Activity或者Fragment,获取引导页的依附者 NewbieGuide.with(this)//with方法可以传入Activity或者Fragment,获取引导页的依附者
.setLabel("homeguide") .setLabel("homeguide")
.addGuidePage( .addGuidePage(
GuidePage.newInstance().setEverywhereCancelable(true) GuidePage.newInstance().setEverywhereCancelable(true)
.setBackgroundColor(0xcc000000) .setBackgroundColor(0xbc000000)
.addHighLight(findViewById(R.id.menu), HighLight.Shape.CIRCLE) .addHighLightWithOptions(findViewById(R.id.menu), HighLight.Shape.CIRCLE, options)
.setLayoutRes(R.layout.view_guide_home)) .setLayoutRes(R.layout.view_guide_home)
.setOnLayoutInflatedListener(new OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(View view, Controller controller) {
//可对同一个layout布局使用不同的文字图案和布局更改,不必重复创建许多类似的布局
TextView tv = view.findViewById(R.id.text_about);
tv.setText("软件主要功能在这里\n如教程,单人游戏,卡组编辑,设置等");
}
})
)
.addGuidePage(
GuidePage.newInstance().setEverywhereCancelable(true)
.setBackgroundColor(0xbc000000)
.addHighLightWithOptions(findViewById(R.id.mycard), HighLight.Shape.CIRCLE, options)
.setLayoutRes(R.layout.view_guide_home)
.setOnLayoutInflatedListener(new OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(View view, Controller controller) {
//可对同一个layout布局使用不同的文字图案和布局更改,不必重复创建许多类似的布局
TextView tv = view.findViewById(R.id.text_about);
tv.setText("萌卡平台,有排位天梯,战绩,断线重连,卡组云端备份等功能\n以及观战、新闻活动、决斗数据与交友聊天室等");
}
})
)
.addGuidePage(
GuidePage.newInstance().setEverywhereCancelable(true)
.setBackgroundColor(0xbc000000)
.addHighLight(findViewById(R.id.list_server), HighLight.Shape.ROUND_RECTANGLE)
.setLayoutRes(R.layout.view_guide_home)
.setOnLayoutInflatedListener(new OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(View view, Controller controller) {
TextView tv = view.findViewById(R.id.text_about);
tv.setText("点击一个服务器模块\n即可加入相应的在线游戏");
}
})
)
.addGuidePage(
GuidePage.newInstance().setEverywhereCancelable(true)
.setBackgroundColor(0xbc000000)
.setLayoutRes(R.layout.view_guide_home)
.setOnLayoutInflatedListener(new OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(View view, Controller controller) {
ImageView iv = view.findViewById(R.id.abt_rename);
iv.setVisibility(View.VISIBLE);
TextView tv = view.findViewById(R.id.text_about);
tv.setText("点击编辑按钮即可编辑相应的服务器信息\n比如改昵称等");
}
})
)
.alwaysShow(true)//总是显示,调试时可以打开 .alwaysShow(true)//总是显示,调试时可以打开
.show(); .show();
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<com.tubb.smrv.SwipeMenuRecyclerView <com.tubb.smrv.SwipeMenuRecyclerView
android:id="@+id/list_server" android:id="@+id/list_server"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:scrollbars="none" /> android:scrollbars="none" />
<RelativeLayout <RelativeLayout
......
...@@ -4,10 +4,23 @@ ...@@ -4,10 +4,23 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView <TextView
android:id="@+id/text_about"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="20dp" android:layout_margin="20dp"
android:text="软件主要功能在这里\n如教程,单人游戏,卡组编辑,设置等" android:text="about"
android:textColor="@color/white"
android:shadowColor="#000000"
android:shadowDy="2"
android:shadowRadius="2"
android:textSize="20sp" /> android:textSize="20sp" />
<ImageView
android:id="@+id/abt_rename"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:layout_margin="20dp"
android:src="@drawable/rename"
android:visibility="gone" />
</FrameLayout> </FrameLayout>
\ No newline at end of file
<?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="match_parent">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="20dp"
android:text="点击一个服务器模块\n即可加入相应的在线游戏"
android:textSize="20sp" />
<LinearLayout
android:id="@+id/abt_rename"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView">
<ImageView
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:layout_margin="20dp"
android:src="@drawable/rename" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="点击编辑按钮即可编辑相应的服务器信息\n比如改昵称等"
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment