-
获取必应每日一图返回
-
@param response BiYingImgResponse
*/
void getBiYingResult(Response response);
增加位置如下:
然后进入SplashActivity,重写getBiYingResult方法,代码如下:
/**
-
必应壁纸数据返回
-
@param response BiYingImgResponse
*/
@Override
public void getBiYingResult(Response response) {
if (response.body().getImages() != null) {
//得到的图片地址是没有前缀的,所以加上前缀否则显示不出来
String biyingUrl = “http://cn.bing.com” + response.body().getImages().get(0).getUrl();
SPUtils.putString(Constant.EVERYDAY_TIP_IMG,biyingUrl,context);
} else {
ToastUtils.showShortToast(context, “未获取到必应的图片”);
}
}
这里你会发现Constant.EVERYDAY_TIP_IMG,没有这个属性值,那么就到Constant中去创建。
/**
- 每日提示弹窗的背景图
*/
public static final String EVERYDAY_TIP_IMG = “everydayTipImg”;
/**
- 每日提示弹窗是否弹出
*/
public static final String EVERYDAY_POP_BOOLEAN = “everydayPopBoolean”;
在Constant里面增加这两个系统变量,注释已经说明了这两个变量的用途了。
下面在layout中新建一个dialog_everyday_tip.xml。里面的代码如下:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
android:layout_width=“@dimen/dp_270”
android:layout_height=“wrap_content”
android:orientation=“vertical”>
<com.google.android.material.imageview.ShapeableImageView
android:id=“@+id/iv_dialog_bg”
android:layout_width=“match_parent”
android:layout_height=“420dp”
android:foreground=“@drawable/shape_dialog_foreground_bg_12”
android:scaleType=“fitXY”
android:src=“@drawable/img_5”
app:shapeAppearanceOverlay=“@style/roundedImageStyle” />
<RelativeLayout
android:layout_width=“match_parent”
android:layout_height=“420dp”
android:padding=“@dimen/dp_12”>
<TextView
android:id=“@+id/tv_week”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:text=“星期四”
android:textColor=“@color/white”
android:textSize=“@dimen/sp_20”
android:textStyle=“bold” />
<TextView
android:id=“@+id/tv_temperature”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_below=“@+id/tv_week”
android:text=“温度”
android:textColor=“@color/white”
android:textSize=“@dimen/sp_48” />
<TextView
android:id=“@+id/tv_weather_state”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_below=“@+id/tv_temperature”
android:text=“天气”
android:textColor=“@color/white”
android:textSize=“@dimen/sp_20”
android:typeface=“monospace” />
<ImageView
android:id=“@+id/iv_weather_state”
android:layout_width=“@dimen/dp_80”
android:layout_height=“@dimen/dp_80”
android:layout_alignParentRight=“true”
android:src=“@mipmap/icon_100” />
<TextView
android:id=“@+id/tv_precipitation”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_below=“@+id/iv_weather_state”
android:layout_alignParentRight=“true”
android:layout_marginTop=“@dimen/dp_10”
android:drawableLeft=“@mipmap/icon_weather_prec”
android:drawablePadding=“4dp”
android:text=“降水预告”
android:textColor=“@color/white”
android:textSize=“@dimen/sp_12” />
<TextView
android:id=“@+id/tv_temp_difference”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_below=“@+id/tv_weather_state”
android:layout_marginTop=“@dimen/dp_100”
android:text=“温差提示”
android:textColor=“@color/white”
android:textSize=“@dimen/sp_18”
android:typeface=“monospace” />
<com.google.android.material.checkbox.MaterialCheckBox
android:id=“@+id/cb_no_pop_up”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_alignParentBottom=“true”
android:layout_centerHorizontal=“true”
android:text=“不再弹出”
android:textSize=“@dimen/sp_16”
app:useMaterialThemeColors=“true”
app:buttonTint=“@color/gray”
android:textColor=“@color/gray” />
<View
android:layout_centerHorizontal=“true”
android:layout_below=“@+id/iv_dialog_bg”
android:background=“@color/white”
android:layout_width=“@dimen/dp_1”
android:layout_height=“@dimen/dp_12”/>
<ImageView
android:id=“@+id/iv_close”
android:layout_width=“@dimen/dp_24”
android:layout_height=“@dimen/dp_24”
android:layout_below=“@+id/iv_dialog_bg”
android:layout_centerHorizontal=“true”
android:layout_marginTop=“@dimen/dp_12”
android:src=“@mipmap/icon_close_dialog” />
预览图如下所示(里面的图标没有的话可以去我的源码里面下载,或者自行下载一个,因为是白色的所示我贴了也看不见,CSDN中,不开会员的人无法修改文章的主题颜色,免费的主题,改不了博文的颜色,这一点我觉得很坑,非要你开个会员,吃相太难看了)
这里面用到了一个style,在app的styles.xml中增加如下代码:
在drawable下新建一个shape_dialog_foreground_bg_12.xml文件,代码如下:
<?xml version="1.0" encoding="utf-8"?>在app的colors.xml中新增一个颜色
#20000000
布局有了,那么就是先改变背景,再增加数据。
下面进入到MainActivity中,将检查版本更新的方法移动一个位置
因为自动更新的弹窗也是在每日第一次才弹出,所以公用,不过也要修改一下checkAppVersion里面的逻辑才行。修改后代码如下:
/**
- 检查APP版本
*/
private void checkAppVersion() {
AppVersion appVersion = LitePal.find(AppVersion.class, 1);//读取第一条数据
Log.d(“appVersion”, new Gson().toJson(appVersion.getVersionShort()));
if (AppStartUpUtils.isTodayFirstStartApp(context)) {//今天第一次打开APP
if (!appVersion.getVersionShort().equals(APKVersionInfoUtils.getVerName(context))) {//提示更新
//更新提示弹窗
showUpdateAppDialog(appVersion.getInstall_url(), appVersion.getChangelog());
}
//设置每日提示弹窗
setTipDialog();
}
}
之前是判断可不可以更新,再判断是否为第一次,现在判断是否为第一次打开。
然后下面的重点就是这个setTipDialog方法了
/**
- 设置每日弹窗
*/
private void setTipDialog() {
boolean isShow = SPUtils.getBoolean(Constant.EVERYDAY_POP_BOOLEAN, true, context);
if (isShow) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//当所有数据加载完成之后显示弹窗
if (everyDayTipDialog != null) {
return;
}
//弹出每日提醒弹窗
showEveryDayTipDialog();
}
},1000);
}
}
这里用到那么那个系统变量,判断是否可以弹窗这个弹窗,然后延时弹出。
/**
- 每日提示弹窗
*/
private void showEveryDayTipDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.addDefaultAnimation()//默认弹窗动画
.setCancelable(false)
.setText(R.id.tv_week, DateUtils.getWeekOfDate(new Date()))//星期
.setText(R.id.tv_weather_state, dialogWeatherState)//天气状态
.setText(R.id.tv_precipitation, dialogPrecipitation)//降水预告
.setText(R.id.tv_temp_difference,
WeatherUtil.differenceTempTip(dialogTempHeight, dialogTempLow))//温差提示信息
.setContentView(R.layout.dialog_everyday_tip)//载入布局文件
.setWidthAndHeight(SizeUtils.dp2px(context, 270), ViewGroup.LayoutParams.WRAP_CONTENT)//设置弹窗宽高
.setOnClickListener(R.id.iv_close, v -> {//关闭
everyDayTipDialog.dismiss();
});
everyDayTipDialog = builder.create();
String imgUrl = SPUtils.getString(Constant.EVERYDAY_TIP_IMG, “”, context);
ShapeableImageView bg = everyDayTipDialog.getView(R.id.iv_dialog_bg);
Glide.with(context).load(imgUrl).into(bg);
//温度
Typeface typeface = Typeface.createFromAsset(getAssets(), “fonts/Roboto-Light.ttf”);
TextView temp = everyDayTipDialog.getView(R.id.tv_temperature);
temp.setTypeface(typeface);
temp.setText(dialogTemp + “℃”);
//设置天气状态图标
ImageView weatherStateIcon = everyDayTipDialog.getView(R.id.iv_weather_state);
WeatherUtil.changeIcon(weatherStateIcon, dialogWeatherStateCode);
//不再弹出
MaterialCheckBox cb = everyDayTipDialog.getView(R.id.cb_no_pop_up);
cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
SPUtils.putBoolean(Constant.EVERYDAY_POP_BOOLEAN, false, context);
} else {
SPUtils.putBoolean(Constant.EVERYDAY_POP_BOOLEAN, true, context);
}
}
});
everyDayTipDialog.show();
}
这里面的代码就是先显示一些要的数据,通过缓存拿到必应的url设置背景,然后在弹窗的底部有一个选中框,选中后再关闭这个弹窗,那么这个弹窗以后都不会再弹出了,除非你再应用设置中进行打开。
到这一步,弹窗就出现了。
既然是增加用户的体验,那么自然要让用户可以自行控制,于是,我在新增了一个应用设置页面。在ui包下新建一个Empty Activity。命名为SettingActivity。它的xml布局如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”
xmlns:app=“http://schemas.android.com/apk/res-auto”
xmlns:tools=“http://schemas.android.com/tools”
android:orientation=“vertical”
android:fitsSystemWindows=“true”
android:background=“@color/gray_white”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
tools:context=“.ui.SettingActivity”>
<androidx.appcompat.widget.Toolbar
android:id=“@+id/toolbar”
android:layout_width=“match_parent”
android:layout_height=“?attr/actionBarSize”
android:background=“@color/white”
app:contentInsetLeft=“@dimen/dp_16”
android:elevation=“@dimen/dp_10”
app:layout_constraintEnd_toEndOf=“parent”
app:layout_scrollFlags=“scroll|enterAlways”
app:navigationIcon=“@mipmap/icon_return”
app:popupTheme=“@style/ThemeOverlay.AppCompat.Light”>
<TextView
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_gravity=“center”
android:text=“应用设置”
android:textColor=“@color/black”
android:textSize=“@dimen/sp_18” />
</androidx.appcompat.widget.Toolbar>
<LinearLayout
android:layout_marginTop=“@dimen/dp_12”
android:background=“@color/white”
android:paddingLeft=“@dimen/dp_16”
android:paddingRight=“@dimen/dp_16”
android:paddingTop=“@dimen/dp_8”
android:paddingBottom=“@dimen/dp_8”
android:gravity=“center_vertical”
android:orientation=“horizontal”
android:layout_width=“match_parent”
android:layout_height=“wrap_content”>
<TextView
android:text=“每日弹窗”
android:textColor=“@color/black”
android:textSize=“@dimen/sp_16”
android:layout_width=“0dp”
android:layout_weight=“1”
android:layout_height=“wrap_content”/>
<com.llw.mvplibrary.view.SwitchButton
android:id=“@+id/wb_everyday”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”/>
文末
初级工程师拿到需求会直接开始做,然后做着做着发现有问题了,要么技术实现不了,要么逻辑有问题。
而高级工程师拿到需求会考虑很多,技术的可行性?对现有业务有没有帮助?对现有技术架构的影响?扩展性如何?等等…之后才会再进行设计编码阶段。
而现在随着跨平台开发,混合式开发,前端开发之类的热门,Android开发者需要学习和掌握的技术也在不断的增加。
通过和一些行业里的朋友交流讨论,以及参考现在大厂面试的要求。我们花了差不多一个月时间整理出了这份Android高级工程师需要掌握的所有知识体系。你可以看下掌握了多少。
混合式开发,微信小程序。都是得学会并且熟练的
这些是Android相关技术的内核,还有Java进阶
高级进阶必备的一些技术。像移动开发架构项目实战等
Android前沿技术;包括了组件化,热升级和热修复,以及各种架构跟框架的详细技术体系
以上即是我们整理的Android高级工程师需要掌握的技术体系了。可能很多朋友觉得很多技术自己都会了,只是一些新的技术不清楚而已。应该没什么太大的问题。
而这恰恰是问题所在!为什么别人高级工程师能年限突破30万,而你只有十几万呢?
就因为你只需补充你自己认为需要的,但并不知道企业需要的。这个就特别容易造成差距。因为你的技术体系并不系统,是零碎的,散乱的。那么你凭什么突破30万年薪呢?
我这些话比较直接,可能会戳到一些人的玻璃心,但是我知道肯定会对一些人起到点醒的效果的。而但凡只要有人因为我的这份高级系统大纲以及这些话找到了方向,并且付出行动去提升自我,为了成功变得更加努力。那么我做的这些就都有了意义。
喜欢的话请帮忙转发点赞一下能让更多有需要的人看到吧。谢谢!
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!
个月时间整理出了这份Android高级工程师需要掌握的所有知识体系。你可以看下掌握了多少。
混合式开发,微信小程序。都是得学会并且熟练的
[外链图片转存中…(img-T2pvzR0h-1714562113016)]
这些是Android相关技术的内核,还有Java进阶
[外链图片转存中…(img-mFQ9EHaH-1714562113017)]
高级进阶必备的一些技术。像移动开发架构项目实战等
[外链图片转存中…(img-NOWmqYQ0-1714562113018)]
Android前沿技术;包括了组件化,热升级和热修复,以及各种架构跟框架的详细技术体系
[外链图片转存中…(img-P3LX55dB-1714562113019)]
以上即是我们整理的Android高级工程师需要掌握的技术体系了。可能很多朋友觉得很多技术自己都会了,只是一些新的技术不清楚而已。应该没什么太大的问题。
而这恰恰是问题所在!为什么别人高级工程师能年限突破30万,而你只有十几万呢?
就因为你只需补充你自己认为需要的,但并不知道企业需要的。这个就特别容易造成差距。因为你的技术体系并不系统,是零碎的,散乱的。那么你凭什么突破30万年薪呢?
我这些话比较直接,可能会戳到一些人的玻璃心,但是我知道肯定会对一些人起到点醒的效果的。而但凡只要有人因为我的这份高级系统大纲以及这些话找到了方向,并且付出行动去提升自我,为了成功变得更加努力。那么我做的这些就都有了意义。
喜欢的话请帮忙转发点赞一下能让更多有需要的人看到吧。谢谢!
《Android学习笔记总结+移动架构视频+大厂面试真题+项目实战源码》,点击传送门,即可获取!