国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示

這篇具有很好參考價(jià)值的文章主要介紹了Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

}

public void setTmp_min(String tmp_min) {

this.tmp_min = tmp_min;

}

public String getUv_index() {

return uv_index;

}

public void setUv_index(String uv_index) {

this.uv_index = uv_index;

}

public String getVis() {

return vis;

}

public void setVis(String vis) {

this.vis = vis;

}

public String getWind_deg() {

return wind_deg;

}

public void setWind_deg(String wind_deg) {

this.wind_deg = wind_deg;

}

public String getWind_dir() {

return wind_dir;

}

public void setWind_dir(String wind_dir) {

this.wind_dir = wind_dir;

}

public String getWind_sc() {

return wind_sc;

}

public void setWind_sc(String wind_sc) {

this.wind_sc = wind_sc;

}

public String getWind_spd() {

return wind_spd;

}

public void setWind_spd(String wind_spd) {

this.wind_spd = wind_spd;

}

}

public static class HourlyBean {

/**

  • cloud : 11

  • cond_code : 101

  • cond_txt : 多云

  • dew : 22

  • hum : 73

  • pop : 7

  • pres : 998

  • time : 2020-05-16 13:00

  • tmp : 33

  • wind_deg : 174

  • wind_dir : 南風(fēng)

  • wind_sc : 1-2

  • wind_spd : 5

*/

private String cloud;

private String cond_code;

private String cond_txt;

private String dew;

private String hum;

private String pop;

private String pres;

private String time;

private String tmp;

private String wind_deg;

private String wind_dir;

private String wind_sc;

private String wind_spd;

public String getCloud() {

return cloud;

}

public void setCloud(String cloud) {

this.cloud = cloud;

}

public String getCond_code() {

return cond_code;

}

public void setCond_code(String cond_code) {

this.cond_code = cond_code;

}

public String getCond_txt() {

return cond_txt;

}

public void setCond_txt(String cond_txt) {

this.cond_txt = cond_txt;

}

public String getDew() {

return dew;

}

public void setDew(String dew) {

this.dew = dew;

}

public String getHum() {

return hum;

}

public void setHum(String hum) {

this.hum = hum;

}

public String getPop() {

return pop;

}

public void setPop(String pop) {

this.pop = pop;

}

public String getPres() {

return pres;

}

public void setPres(String pres) {

this.pres = pres;

}

public String getTime() {

return time;

}

public void setTime(String time) {

this.time = time;

}

public String getTmp() {

return tmp;

}

public void setTmp(String tmp) {

this.tmp = tmp;

}

public String getWind_deg() {

return wind_deg;

}

public void setWind_deg(String wind_deg) {

this.wind_deg = wind_deg;

}

public String getWind_dir() {

return wind_dir;

}

public void setWind_dir(String wind_dir) {

this.wind_dir = wind_dir;

}

public String getWind_sc() {

return wind_sc;

}

public void setWind_sc(String wind_sc) {

this.wind_sc = wind_sc;

}

public String getWind_spd() {

return wind_spd;

}

public void setWind_spd(String wind_spd) {

this.wind_spd = wind_spd;

}

}

public static class LifestyleBean {

/**

  • type : comf

  • brf : 較不舒適

  • txt : 白天天氣多云,并且空氣濕度偏大,在這種天氣條件下,您會感到有些悶熱,不很舒適。

*/

private String type;

private String brf;

private String txt;

public String getType() {

return type;

}

public void setType(String type) {

this.type = type;

}

public String getBrf() {

return brf;

}

public void setBrf(String brf) {

this.brf = brf;

}

public String getTxt() {

return txt;

}

public void setTxt(String txt) {

this.txt = txt;

}

}

}

}

在ApiService中增加

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

/**

  • 獲取所有天氣數(shù)據(jù),在返回值中再做處理

  • @param location

  • @return

*/

@GET(“/s6/weather?key=3086e91d66c04ce588a7f538f917c7f4”)

Call weatherData(@Query(“l(fā)ocation”) String location);

在WeatherContract中增加訂閱

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

/**

  • 天氣所有數(shù)據(jù)

  • @param context

  • @param location

*/

public void weatherData(final Context context,String location){

ApiService service = ServiceGenerator.createService(ApiService.class,0);

service.weatherData(location).enqueue(new NetCallBack() {

@Override

public void onSuccess(Call call, Response response) {

if(getView() != null){

getView().getWeatherDataResult(response);

}

}

@Override

public void onFailed() {

if(getView() != null){

getView().getWeatherDataFailed();

}

}

});

}

//查詢天氣所有數(shù)據(jù)

void getWeatherDataResult(Response response);

//天氣數(shù)據(jù)獲取錯(cuò)誤返回

void getWeatherDataFailed();

進(jìn)入MainActivity.java中

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

/**

  • 所有天氣數(shù)據(jù)返回

  • @param response

*/

@Override

public void getWeatherDataResult(Response response) {

dismissLoadingDialog();//關(guān)閉彈窗

if ((“ok”).equals(response.body().getHeWeather6().get(0).getStatus())) {

}else {

ToastUtils.showShortToast(context, CodeToStringUtils.WeatherCode(response.body().getHeWeather6().get(0).getStatus()));

}

}

首先改動適配器

七天天氣預(yù)報(bào)適配器WeatherForecastAdapter.java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

逐小時(shí)天氣預(yù)報(bào)適配器WeatherHourlyAdapter.java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

然后回到MainActivity.java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

紅框中為新增的,然后之前的注釋掉,當(dāng)所有的改動都完成之后,再刪除掉注釋的沒有用的代碼、

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

紅框中的就是你要改動的

然后修改切換城市之后的方法請求

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

定位后

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

下拉刷新之后

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

onResume方法中

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

返回值里面的業(yè)務(wù)邏輯處理代碼先注釋掉,最后修改getWeatherDataResult。

修改代碼如下:

/**

  • 所有天氣數(shù)據(jù)返回

  • @param response

*/

@Override

public void getWeatherDataResult(Response response) {

refresh.finishRefresh();//關(guān)閉刷新

dismissLoadingDialog();//關(guān)閉彈窗

if (mLocationClient != null) {

mLocationClient.stop();//數(shù)據(jù)返回后關(guān)閉定位

}

if ((“ok”).equals(response.body().getHeWeather6().get(0).getStatus())) {

if (response.body().getHeWeather6().get(0).getBasic() != null) {//得到數(shù)據(jù)不為空則進(jìn)行數(shù)據(jù)顯示

/**

  • 當(dāng)天天氣

*/

tvTemperature.setText(response.body().getHeWeather6().get(0).getNow().getTmp());//溫度

if (flag) {

ivLocation.setVisibility(View.VISIBLE);//顯示定位圖標(biāo)

} else {

ivLocation.setVisibility(View.GONE);//顯示定位圖標(biāo)

}

tvCity.setText(response.body().getHeWeather6().get(0).getBasic().getLocation());//城市

tvInfo.setText(response.body().getHeWeather6().get(0).getNow().getCond_txt());//天氣狀況

//修改上次更新時(shí)間的結(jié)果顯示 -> 更加人性化

String datetime = response.body().getHeWeather6().get(0).getUpdate().getLoc();//賦值

String time = datetime.substring(11);//截去前面的字符,保留后面所有的字符,就剩下 22:00

tvOldTime.setText(“上次更新時(shí)間:” + WeatherUtil.showTimeInfo(time) + time);

tvWindDirection.setText("風(fēng)向 " + response.body().getHeWeather6().get(0).getNow().getWind_dir());//風(fēng)向

tvWindPower.setText("風(fēng)力 " + response.body().getHeWeather6().get(0).getNow().getWind_sc() + “級”);//風(fēng)力

wwBig.startRotate();//大風(fēng)車開始轉(zhuǎn)動

wwSmall.startRotate();//小風(fēng)車開始轉(zhuǎn)動

/**

  • 查詢7天天氣預(yù)報(bào)

*/

//最低溫和最高溫

tvLowHeight.setText(response.body().getHeWeather6().get(0).getDaily_forecast().get(0).getTmp_min() + " / " +

response.body().getHeWeather6().get(0).getDaily_forecast().get(0).getTmp_max() + “℃”);

if (response.body().getHeWeather6().get(0).getDaily_forecast() != null) {

List<WeatherResponse.HeWeather6Bean.DailyForecastBean> data

= response.body().getHeWeather6().get(0).getDaily_forecast();

mListDailyForecast.clear();//添加數(shù)據(jù)之前先清除

mListDailyForecast.addAll(data);//添加數(shù)據(jù)

mAdapter.notifyDataSetChanged();//刷新列表

} else {

ToastUtils.showShortToast(context, “天氣預(yù)報(bào)數(shù)據(jù)為空”);

}

/**

  • 查詢逐小時(shí)天氣數(shù)據(jù)

*/

if (response.body().getHeWeather6().get(0).getHourly() != null) {

List<WeatherResponse.HeWeather6Bean.HourlyBean> data

= response.body().getHeWeather6().get(0).getHourly();

mListHourlyBean.clear();//添加數(shù)據(jù)之前先清除

mListHourlyBean.addAll(data);//添加數(shù)據(jù)

mAdapterHourly.notifyDataSetChanged();//刷新列表

} else {

ToastUtils.showShortToast(context, “逐小時(shí)預(yù)報(bào)數(shù)據(jù)為空”);

}

/**

  • 生活指數(shù)

*/

List<WeatherResponse.HeWeather6Bean.LifestyleBean> data = response.body().getHeWeather6().get(0).getLifestyle();

if (!ObjectUtils.isEmpty(data)) {

for (int i = 0; i < data.size(); i++) {

switch (data.get(i).getType()){

case “uv”:

tvUv.setText(“紫外線:” + data.get(i).getTxt());

break;

case “comf”:

tvComf.setText(“舒適度:” + data.get(i).getTxt());

break;

case “drsg”:

tvDrsg.setText(“穿衣指數(shù):” + data.get(i).getTxt());

break;

case “flu”:

tvFlu.setText(“感冒指數(shù):” + data.get(i).getTxt());

break;

case “sport”:

tvSport.setText(“運(yùn)動指數(shù):” + data.get(i).getTxt());

break;

case “trav”:

tvTrav.setText(“旅游指數(shù):” + data.get(i).getTxt());

break;

case “cw”:

tvCw.setText(“洗車指數(shù):” + data.get(i).getTxt());

break;

case “air”:

tvAir.setText(“空氣指數(shù):” + data.get(i).getTxt());

break;

}

}

} else {

ToastUtils.showShortToast(context, “生活指數(shù)數(shù)據(jù)為空”);

}

}else {

ToastUtils.showShortToast(context,“天氣數(shù)據(jù)為空”);

}

}else {

ToastUtils.showShortToast(context, CodeToStringUtils.WeatherCode(response.body().getHeWeather6().get(0).getStatus()));

}

改到這里就是初步改完了,運(yùn)行一下:

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

很明顯,和之前什么變化都沒有,但是,里面的業(yè)務(wù)處理方式發(fā)生了改變,之前是一次性請求四次接口,現(xiàn)在是變成一個(gè)接口了,無疑在機(jī)制上有了優(yōu)化,現(xiàn)在就可以注釋掉其他的代碼了。

打開ApiService

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

這里將之前的四個(gè)API注釋掉。

再打開訂閱器

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

然后再回到MainActivity

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

將這四個(gè)報(bào)錯(cuò)的返回方法注釋掉,這是你的頁面是不會有報(bào)錯(cuò)的,然后再運(yùn)行一下,確保沒有問題。好了,已經(jīng)運(yùn)行過沒有問題了,那么最后就是刪除掉注釋的代碼了。

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

這四個(gè)實(shí)體bean也可以刪除了,刪除之后再運(yùn)行一下,OK,沒有問題。也算是為應(yīng)用做了一次瘦身了,下面就是優(yōu)化一下用戶的體驗(yàn)。

優(yōu)化UI


增加逐小時(shí)天氣預(yù)報(bào)詳情和七天天氣預(yù)報(bào)詳情,

這個(gè)我打算用彈窗來做,首先是逐小時(shí)天氣預(yù)報(bào)的詳情,創(chuàng)建一個(gè)彈窗的背景樣式

在項(xiàng)目的drawable下創(chuàng)建shape_white_5.xml文件

樣式代碼如下:

<?xml version="1.0" encoding="utf-8"?>

① 逐小時(shí)天氣預(yù)報(bào)的詳情UI

在項(xiàng)目的layout文件下創(chuàng)建window_hourly_detail.xml文件

布局代碼如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:orientation=“vertical”

android:background=“@drawable/shape_white_5”

android:padding=“@dimen/dp_12”

android:layout_width=“300dp”

android:layout_height=“400dp”>

<TextView

android:gravity=“center_vertical”

android:textColor=“@color/black”

android:textSize=“@dimen/sp_16”

android:textStyle=“bold”

android:id=“@+id/tv_time”

android:layout_width=“match_parent”

android:layout_height=“@dimen/dp_40”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“溫度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_tem”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“天氣狀況”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_cond_txt”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)向360角度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_deg”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)向”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_dir”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)力”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_sc”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)速”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_spd”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“相對濕度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_hum”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“大氣壓強(qiáng)”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_pres”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“降水概率”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_pop”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“露點(diǎn)溫度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_dew”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“云量”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_cloud”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

由于這一次的彈窗是屏幕中間出現(xiàn),所以增加動畫效果和代碼,在mvplibrary模塊下的anim文件夾中增加出現(xiàn)和隱藏的動畫xml文件

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

window_hidden_anim.xml

<?xml version="1.0" encoding="utf-8"?>

<scale

android:duration=“300”

android:fromXScale=“1.0”

android:fromYScale=“1.0”

android:pivotX=“50%”

android:pivotY=“50%”

android:toXScale=“0.5”

android:toYScale=“0.5” />

<alpha

android:duration=“300”

android:fromAlpha=“1.0”

android:interpolator=“@android:anim/accelerate_interpolator”

android:toAlpha=“0.0” />

window_show_anim.xml

<?xml version="1.0" encoding="utf-8"?>

<scale

android:duration=“300”

android:fromXScale=“0.6”

android:fromYScale=“0.6”

android:pivotX=“50%”

android:pivotY=“50%”

android:toXScale=“1.0”

android:toYScale=“1.0” />

<alpha

android:duration=“300”

android:fromAlpha=“0.0”

android:interpolator=“@android:anim/decelerate_interpolator”

android:toAlpha=“1.0” />

然后在styles.xml文件中添加

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

這里還會用到一個(gè)測量的工具類SizeUtils.java

代碼如下:

package com.llw.mvplibrary.utils;

import android.content.Context;

import android.util.DisplayMetrics;

import android.util.TypedValue;

import android.view.View;

import android.view.ViewGroup;

/**

  • dp sp px 轉(zhuǎn)換 view 測量工個(gè)類

*/

public final class SizeUtils {

private SizeUtils() {

throw new UnsupportedOperationException(“u can’t instantiate me…”);

}

/**

  • Value of dp to value of px.

  • @param dpValue The value of dp.

  • @return value of px

*/

public static int dp2px(Context context, final float dpValue) {

final float scale = context.getApplicationContext().getResources().getDisplayMetrics().density;

return (int) (dpValue * scale + 0.5f);

}

/**

  • Value of px to value of dp.

  • @param pxValue The value of px.

  • @return value of dp

*/

public static int px2dp(Context context, final float pxValue) {

final float scale = context.getApplicationContext().getResources().getDisplayMetrics().density;

return (int) (pxValue / scale + 0.5f);

}

/**

  • Value of sp to value of px.

  • @param spValue The value of sp.

  • @return value of px

*/

public static int sp2px(Context context, final float spValue) {

final float fontScale = context.getApplicationContext().getResources().getDisplayMetrics().scaledDensity;

return (int) (spValue * fontScale + 0.5f);

}

/**

  • Value of px to value of sp.

  • @param pxValue The value of px.

  • @return value of sp

*/

public static int px2sp(Context context, final float pxValue) {

final float fontScale = context.getApplicationContext().getResources().getDisplayMetrics().scaledDensity;

return (int) (pxValue / fontScale + 0.5f);

}

/**

  • Converts an unpacked complex data value holding a dimension to its final floating

  • point value. The two parameters unit and value

  • are as in {@link TypedValue#TYPE_DIMENSION}.

  • @param value The value to apply the unit to.

  • @param unit The unit to convert from.

  • @return The complex floating point value multiplied by the appropriate

  • metrics depending on its unit.

*/

public static float applyDimension(Context context, final float value, final int unit) {

DisplayMetrics metrics = context.getApplicationContext().getResources().getDisplayMetrics();

switch (unit) {

case TypedValue.COMPLEX_UNIT_PX:

return value;

case TypedValue.COMPLEX_UNIT_DIP:

return value * metrics.density;

case TypedValue.COMPLEX_UNIT_SP:

return value * metrics.scaledDensity;

case TypedValue.COMPLEX_UNIT_PT:

return value * metrics.xdpi * (1.0f / 72);

case TypedValue.COMPLEX_UNIT_IN:

return value * metrics.xdpi;

case TypedValue.COMPLEX_UNIT_MM:

return value * metrics.xdpi * (1.0f / 25.4f);

}

return 0;

}

/**

  • Force get the size of view.

  • e.g.

  • 
    
  • SizeUtils.forceGetViewSize(view, new SizeUtils.onGetSizeListener() {

  • Override
    
  • public void onGetSize(final View view) {
    
  •     view.getWidth();
    
  • }
    
  • });

  • @param view The view.

  • @param listener The get size listener.

*/

public static void forceGetViewSize(final View view, final onGetSizeListener listener) {

view.post(new Runnable() {

@Override

public void run() {

if (listener != null) {

listener.onGetSize(view);

}

}

});

}

/**

  • Return the width of view.

  • @param view The view.

  • @return the width of view

*/

public static int getMeasuredWidth(final View view) {

return measureView(view)[0];

}

/**

  • Return the height of view.

  • @param view The view.

  • @return the height of view

*/

public static int getMeasuredHeight(final View view) {

return measureView(view)[1];

}

/**

  • Measure the view.

  • @param view The view.

  • @return arr[0]: view’s width, arr[1]: view’s height

*/

public static int[] measureView(final View view) {

ViewGroup.LayoutParams lp = view.getLayoutParams();

if (lp == null) {

lp = new ViewGroup.LayoutParams(

ViewGroup.LayoutParams.MATCH_PARENT,

ViewGroup.LayoutParams.WRAP_CONTENT

);

}

int widthSpec = ViewGroup.getChildMeasureSpec(0, 0, lp.width);

int lpHeight = lp.height;

int heightSpec;

if (lpHeight > 0) {

heightSpec = View.MeasureSpec.makeMeasureSpec(lpHeight, View.MeasureSpec.EXACTLY);

} else {

heightSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);

}

view.measure(widthSpec, heightSpec);

return new int[]{view.getMeasuredWidth(), view.getMeasuredHeight()};

}

///

// interface

///

public interface onGetSizeListener {

void onGetSize(View view);

}

}

現(xiàn)在去LiWindow.java中增加中間顯示的代碼.

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

增加的代碼我也貼一下:

/**

  • 中間顯示

  • @param mView

*/

public void showCenterPopupWindow(View mView,int width,int height) {

mPopupWindow = new PopupWindow(mView,

width, height, true);

mPopupWindow.setContentView(mView);

mPopupWindow.setAnimationStyle(R.style.AnimationCenterFade); //設(shè)置動畫

mPopupWindow.showAtLocation(mView, Gravity.CENTER, 0, 0);

mPopupWindow.update();

setBackgroundAlpha(0.5f,mContext);

WindowManager.LayoutParams nomal = ((Activity) mContext).getWindow().getAttributes();

nomal.alpha = 0.5f;

((Activity) mContext).getWindow().setAttributes(nomal);

mPopupWindow.setOnDismissListener(closeDismiss);

}

現(xiàn)在修改item_weather_hourly_list.xml,增加了一個(gè)id和點(diǎn)擊的水波紋效果,代碼如下,復(fù)制粘貼即可:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:orientation=“vertical”

android:gravity=“center_horizontal”

android:id=“@+id/item_hourly”

android:foreground=“@drawable/bg_white”

android:padding=“8dp”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”>

<TextView

android:id=“@+id/tv_time”

android:textColor=“#FFF”

android:text=“上午10:00”

android:textSize=“14sp”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”/>

<ImageView

android:layout_marginTop=“12dp”

android:layout_marginBottom=“8dp”

android:id=“@+id/iv_weather_state”

android:background=“@mipmap/icon_100”

android:layout_width=“30dp”

android:layout_height=“30dp”/>

<TextView

android:textSize=“20sp”

android:id=“@+id/tv_temperature”

android:textColor=“#FFF”

android:text=“25℃”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”/>

再修改WeatherHourlyAdapter.java適配器

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

添加點(diǎn)擊事件的id。

進(jìn)入MainActivity.java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

這個(gè)代碼就手寫一下吧,也不多,然后是這個(gè)彈窗的方法

//顯示逐三小時(shí)詳情天氣信息彈窗

private void showHourlyWindow(WeatherResponse.HeWeather6Bean.HourlyBean data) {

liWindow = new LiWindow(context);

final View view = LayoutInflater.from(context).inflate(R.layout.window_hourly_detail, null);

TextView tv_time = view.findViewById(R.id.tv_time);//時(shí)間

TextView tv_tem = view.findViewById(R.id.tv_tem);//溫度

TextView tv_cond_txt = view.findViewById(R.id.tv_cond_txt);//天氣狀態(tài)描述

TextView tv_wind_deg = view.findViewById(R.id.tv_wind_deg);//風(fēng)向360角度

TextView tv_wind_dir = view.findViewById(R.id.tv_wind_dir);//風(fēng)向

TextView tv_wind_sc = view.findViewById(R.id.tv_wind_sc);//風(fēng)力

TextView tv_wind_spd = view.findViewById(R.id.tv_wind_spd);//風(fēng)速

TextView tv_hum = view.findViewById(R.id.tv_hum);//相對濕度

TextView tv_pres = view.findViewById(R.id.tv_pres);//大氣壓強(qiáng)

TextView tv_pop = view.findViewById(R.id.tv_pop);//降水概率

TextView tv_dew = view.findViewById(R.id.tv_dew);//露點(diǎn)溫度

TextView tv_cloud = view.findViewById(R.id.tv_cloud);//云量

String datetime = data.getTime();//賦值

String time = datetime.substring(11);//截去前面的字符,保留后面所有的字符,就剩下 22:00

tv_time.setText(WeatherUtil.showTimeInfo(time) + time);

tv_tem.setText(data.getTmp() + “℃”);

tv_cond_txt.setText(data.getCond_txt());

tv_wind_deg.setText(data.getWind_deg()+“°”);

tv_wind_dir.setText(data.getWind_dir());

tv_wind_sc.setText(data.getWind_sc()+“級”);

tv_wind_spd.setText(data.getWind_spd() + “公里/小時(shí)”);

tv_hum.setText(data.getHum());

tv_pres.setText(data.getPres());

tv_pop.setText(data.getPop() + “%”);

tv_dew.setText(data.getDew()+“℃”);

tv_cloud.setText(data.getCloud());

liWindow.showCenterPopupWindow(view, SizeUtils.dp2px(context, 300),SizeUtils.dp2px(context, 400));

}

OK,到目前為止,可以運(yùn)行一下了

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

OK,還是蠻簡單的吧(PS:由于沒有UI,大家這個(gè)都知道開發(fā)的審美,就先將就一下,如果有好的建議可以給我提)。

② 未來七天天氣的詳情UI

其實(shí)這個(gè)和逐小時(shí)的比較類似,不過要比逐小時(shí)的數(shù)據(jù)要多一些,

在項(xiàng)目的layout文件下創(chuàng)建window_forecast_detail.xml文件

布局代碼如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:orientation=“vertical”

android:background=“@drawable/shape_white_5”

android:padding=“@dimen/dp_12”

android:layout_width=“300dp”

android:layout_height=“500dp”>

<TextView

android:gravity=“center_vertical”

android:textColor=“@color/black”

android:textSize=“@dimen/sp_16”

android:textStyle=“bold”

android:id=“@+id/tv_datetime”

android:layout_width=“match_parent”

android:layout_height=“@dimen/dp_40”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“最高溫”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_tmp_max”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“最低溫”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_tmp_min”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“紫外線強(qiáng)度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_uv_index”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“白天天氣狀況”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_cond_txt_d”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“晚上天氣狀況”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_cond_txt_n”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)向360角度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_deg”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)向”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_dir”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)力”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_sc”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“風(fēng)速”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_wind_spd”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“相對濕度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_hum”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“大氣壓強(qiáng)”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_pres”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“降水量”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_pcpn”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“降水概率”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_pop”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<LinearLayout

android:gravity=“center_vertical”

android:layout_width=“match_parent”

android:layout_height=“0dp”

android:layout_weight=“1”>

<TextView

android:text=“能見度”

android:textColor=“@color/black”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

<TextView

android:textColor=“@color/black”

android:id=“@+id/tv_vis”

android:layout_width=“0dp”

android:layout_weight=“1”

android:layout_height=“wrap_content”/>

修改item_weather_forecast_list.xml增加ID和點(diǎn)擊效果

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

修改WeatherForecastAdapter.java,綁定點(diǎn)擊事件的id

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

這里先添加一個(gè)事件日期的工具類進(jìn)去,是我好久之前寫的,不過也能用的上DateUtils.java,代碼如下:

package com.llw.goodweather.utils;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

import java.util.GregorianCalendar;

import java.util.Locale;

public class DateUtils {

//獲取當(dāng)前完整的日期和時(shí)間

public static String getNowDateTime() {

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);

return sdf.format(new Date());

}

//獲取當(dāng)前日期

public static String getNowDate() {

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”);

return sdf.format(new Date());

}

//前一天

public static String getYesterday(Date date) {

String tomorrow = “”;

Calendar calendar = new GregorianCalendar();

calendar.setTime(date);

calendar.add(calendar.DATE, -1);

date = calendar.getTime();

SimpleDateFormat formatter = new SimpleDateFormat(“yyyy-MM-dd”);

tomorrow = formatter.format(date);

return tomorrow;

}

//后一天

public static String getTomorrow(Date date) {

String tomorrow = “”;

Calendar calendar = new GregorianCalendar();

calendar.setTime(date);

calendar.add(calendar.DATE, +1);

date = calendar.getTime();

SimpleDateFormat formatter = new SimpleDateFormat(“yyyy-MM-dd”);

tomorrow = formatter.format(date);

return tomorrow;

}

//獲取當(dāng)前時(shí)間

public static String getNowTime() {

SimpleDateFormat sdf = new SimpleDateFormat(“HH:mm:ss”);

return sdf.format(new Date());

}

//獲取當(dāng)前日期(精確到毫秒)

public static String getNowTimeDetail() {

SimpleDateFormat sdf = new SimpleDateFormat(“HH:mm:ss.SSS”);

return sdf.format(new Date());

}

//獲取今天是星期幾

public static String getWeekOfDate(Date date) {

String[] weekDays = {“星期日”, “星期一”, “星期二”, “星期三”, “星期四”, “星期五”, “星期六”};

Calendar cal = Calendar.getInstance();

cal.setTime(date);

int w = cal.get(Calendar.DAY_OF_WEEK) - 1;

if (w < 0)

w = 0;

return weekDays[w];

}

//計(jì)算星期幾

private static int getDayOfWeek(String dateTime) {

Calendar cal = Calendar.getInstance();

if (dateTime.equals(“”)) {

cal.setTime(new Date(System.currentTimeMillis()));

} else {

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”, Locale.getDefault());

Date date;

try {

date = sdf.parse(dateTime);

} catch (ParseException e) {

date = null;

e.printStackTrace();

}

if (date != null) {

cal.setTime(new Date(date.getTime()));

}

}

return cal.get(Calendar.DAY_OF_WEEK);

}

//根據(jù)年月日計(jì)算是星期幾并與當(dāng)前日期判斷 非昨天、今天、明天 則以星期顯示

public static String Week(String dateTime) {

String week = “”;

String yesterday = “”;

String today = “”;

String tomorrow = “”;

yesterday = getYesterday(new Date());

today = getNowDate();

tomorrow = getTomorrow(new Date());

if (dateTime.equals(yesterday)) {

week = “昨天”;

} else if (dateTime.equals(today)) {

week = “今天”;

} else if (dateTime.equals(tomorrow)) {

week = “明天”;

} else {

switch (getDayOfWeek(dateTime)) {

case 1:

week = “星期日”;

break;

case 2:

week = “星期一”;

break;

case 3:

week = “星期二”;

break;

case 4:

week = “星期三”;

break;

case 5:

week = “星期四”;

break;

case 6:

week = “星期五”;

break;

case 7:

week = “星期六”;

break;

}

}

return week;

}

//將時(shí)間戳轉(zhuǎn)化為對應(yīng)的時(shí)間(10位或者13位都可以)

public static String formatTime(long time) {

String times = null;

if (String.valueOf(time).length() > 10) {// 10位的秒級別的時(shí)間戳

times = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(new Date(time * 1000));

} else {// 13位的秒級別的時(shí)間戳

times = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(time);

}

return times;

}

//將時(shí)間字符串轉(zhuǎn)為時(shí)間戳字符串

public static String getStringTimestamp(String time) {

String timestamp = null;

自我介紹一下,小編13年上海交大畢業(yè),曾經(jīng)在小公司待過,也去過華為、OPPO等大廠,18年進(jìn)入阿里一直到現(xiàn)在。

深知大多數(shù)初中級Android工程師,想要提升技能,往往是自己摸索成長或者是報(bào)班學(xué)習(xí),但對于培訓(xùn)機(jī)構(gòu)動則近萬的學(xué)費(fèi),著實(shí)壓力不小。自己不成體系的自學(xué)效果低效又漫長,而且極易碰到天花板技術(shù)停滯不前!

因此收集整理了一份《2024年Android移動開發(fā)全套學(xué)習(xí)資料》,初衷也很簡單,就是希望能夠幫助到想自學(xué)提升又不知道該從何學(xué)起的朋友,同時(shí)減輕大家的負(fù)擔(dān)。

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

既有適合小白學(xué)習(xí)的零基礎(chǔ)資料,也有適合3年以上經(jīng)驗(yàn)的小伙伴深入學(xué)習(xí)提升的進(jìn)階課程,基本涵蓋了95%以上Android開發(fā)知識點(diǎn),真正體系化!

由于文件比較大,這里只是將部分目錄截圖出來,每個(gè)節(jié)點(diǎn)里面都包含大廠面經(jīng)、學(xué)習(xí)筆記、源碼講義、實(shí)戰(zhàn)項(xiàng)目、講解視頻,并且會持續(xù)更新!

如果你覺得這些內(nèi)容對你有幫助,可以掃碼獲?。。。▊渥ⅲ篈ndroid)

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

最后

這里我希望可以幫助到大家提升進(jìn)階。

內(nèi)容包含:Android學(xué)習(xí)PDF+架構(gòu)視頻+面試文檔+源碼筆記,高級架構(gòu)技術(shù)進(jìn)階腦圖、Android開發(fā)面試專題資料,高級進(jìn)階架構(gòu)資料 這幾塊的內(nèi)容。非常適合近期有面試和想在技術(shù)道路上繼續(xù)精進(jìn)的朋友。

喜歡本文的話,不妨給我點(diǎn)個(gè)小贊、評論區(qū)留言或者轉(zhuǎn)發(fā)支持一下唄~

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

《互聯(lián)網(wǎng)大廠面試真題解析、進(jìn)階開發(fā)核心學(xué)習(xí)筆記、全套講解視頻、實(shí)戰(zhàn)項(xiàng)目源碼講義》點(diǎn)擊傳送門即可獲取!文章來源地址http://www.zghlxwxcb.cn/news/detail-857815.html

  • 1;

if (w < 0)

w = 0;

return weekDays[w];

}

//計(jì)算星期幾

private static int getDayOfWeek(String dateTime) {

Calendar cal = Calendar.getInstance();

if (dateTime.equals(“”)) {

cal.setTime(new Date(System.currentTimeMillis()));

} else {

SimpleDateFormat sdf = new SimpleDateFormat(“yyyy-MM-dd”, Locale.getDefault());

Date date;

try {

date = sdf.parse(dateTime);

} catch (ParseException e) {

date = null;

e.printStackTrace();

}

if (date != null) {

cal.setTime(new Date(date.getTime()));

}

}

return cal.get(Calendar.DAY_OF_WEEK);

}

//根據(jù)年月日計(jì)算是星期幾并與當(dāng)前日期判斷 非昨天、今天、明天 則以星期顯示

public static String Week(String dateTime) {

String week = “”;

String yesterday = “”;

String today = “”;

String tomorrow = “”;

yesterday = getYesterday(new Date());

today = getNowDate();

tomorrow = getTomorrow(new Date());

if (dateTime.equals(yesterday)) {

week = “昨天”;

} else if (dateTime.equals(today)) {

week = “今天”;

} else if (dateTime.equals(tomorrow)) {

week = “明天”;

} else {

switch (getDayOfWeek(dateTime)) {

case 1:

week = “星期日”;

break;

case 2:

week = “星期一”;

break;

case 3:

week = “星期二”;

break;

case 4:

week = “星期三”;

break;

case 5:

week = “星期四”;

break;

case 6:

week = “星期五”;

break;

case 7:

week = “星期六”;

break;

}

}

return week;

}

//將時(shí)間戳轉(zhuǎn)化為對應(yīng)的時(shí)間(10位或者13位都可以)

public static String formatTime(long time) {

String times = null;

if (String.valueOf(time).length() > 10) {// 10位的秒級別的時(shí)間戳

times = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(new Date(time * 1000));

} else {// 13位的秒級別的時(shí)間戳

times = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”).format(time);

}

return times;

}

//將時(shí)間字符串轉(zhuǎn)為時(shí)間戳字符串

public static String getStringTimestamp(String time) {

String timestamp = null;

自我介紹一下,小編13年上海交大畢業(yè),曾經(jīng)在小公司待過,也去過華為、OPPO等大廠,18年進(jìn)入阿里一直到現(xiàn)在。

深知大多數(shù)初中級Android工程師,想要提升技能,往往是自己摸索成長或者是報(bào)班學(xué)習(xí),但對于培訓(xùn)機(jī)構(gòu)動則近萬的學(xué)費(fèi),著實(shí)壓力不小。自己不成體系的自學(xué)效果低效又漫長,而且極易碰到天花板技術(shù)停滯不前!

因此收集整理了一份《2024年Android移動開發(fā)全套學(xué)習(xí)資料》,初衷也很簡單,就是希望能夠幫助到想自學(xué)提升又不知道該從何學(xué)起的朋友,同時(shí)減輕大家的負(fù)擔(dān)。

[外鏈圖片轉(zhuǎn)存中…(img-pR9J0zJ8-1713113885069)]

[外鏈圖片轉(zhuǎn)存中…(img-CDByZMwm-1713113885070)]

[外鏈圖片轉(zhuǎn)存中…(img-gM4b6UTd-1713113885070)]

[外鏈圖片轉(zhuǎn)存中…(img-IIXvtiRq-1713113885070)]

[外鏈圖片轉(zhuǎn)存中…(img-uVTZEn1W-1713113885071)]

既有適合小白學(xué)習(xí)的零基礎(chǔ)資料,也有適合3年以上經(jīng)驗(yàn)的小伙伴深入學(xué)習(xí)提升的進(jìn)階課程,基本涵蓋了95%以上Android開發(fā)知識點(diǎn),真正體系化!

由于文件比較大,這里只是將部分目錄截圖出來,每個(gè)節(jié)點(diǎn)里面都包含大廠面經(jīng)、學(xué)習(xí)筆記、源碼講義、實(shí)戰(zhàn)項(xiàng)目、講解視頻,并且會持續(xù)更新!

如果你覺得這些內(nèi)容對你有幫助,可以掃碼獲?。。。▊渥ⅲ篈ndroid)

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

最后

這里我希望可以幫助到大家提升進(jìn)階。

內(nèi)容包含:Android學(xué)習(xí)PDF+架構(gòu)視頻+面試文檔+源碼筆記,高級架構(gòu)技術(shù)進(jìn)階腦圖、Android開發(fā)面試專題資料,高級進(jìn)階架構(gòu)資料 這幾塊的內(nèi)容。非常適合近期有面試和想在技術(shù)道路上繼續(xù)精進(jìn)的朋友。

喜歡本文的話,不妨給我點(diǎn)個(gè)小贊、評論區(qū)留言或者轉(zhuǎn)發(fā)支持一下唄~

Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示,程序員,android,ui,java

《互聯(lián)網(wǎng)大廠面試真題解析、進(jìn)階開發(fā)核心學(xué)習(xí)筆記、全套講解視頻、實(shí)戰(zhàn)項(xiàng)目源碼講義》點(diǎn)擊傳送門即可獲??!

到了這里,關(guān)于Android 天氣APP(十四)修復(fù)UI顯示異常、優(yōu)化業(yè)務(wù)代碼邏輯、增加詳情天氣顯示的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Android應(yīng)用優(yōu)化之最基本的UI層顯示優(yōu)化

    Android應(yīng)用優(yōu)化之最基本的UI層顯示優(yōu)化

    .Android Studio有自帶的視圖分析工具 Layout Inspector(布局檢查器),打開方式菜單欄Tools– Layout Inspector。 可以看到Layout Inspector最右側(cè)的屬性欄可以查看每一個(gè)View的所附帶的屬性及屬性值。 3.接下來我們主要分析以下三個(gè)問題: 【問題1】沒有用的父布局 通過工具和查看代碼,

    2024年04月28日
    瀏覽(20)
  • Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符

    Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符

    ??上一篇中了解了特性和屬性,同時(shí)顯示設(shè)備藍(lán)牙服務(wù)下的特性和屬性,本文中就需要來使用這些特性和屬性來完成一些功能。 Ble藍(lán)牙App(一)掃描 Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù) Ble藍(lán)牙App(三)特性和屬性 Ble藍(lán)牙App(四)UI優(yōu)化和描述符 Ble藍(lán)牙App(五)數(shù)據(jù)操作 ??

    2024年02月13日
    瀏覽(16)
  • Android Compose 新聞App(三)網(wǎng)絡(luò)數(shù)據(jù)Compose UI顯示加載、Room和DataStore使用

    Android Compose 新聞App(三)網(wǎng)絡(luò)數(shù)據(jù)Compose UI顯示加載、Room和DataStore使用

    正文 =============================================================== 后面的內(nèi)容涉及到樣式布局組件,內(nèi)容比較多。 一、樣式 在這里我們先進(jìn)行樣式的配置,打開ui.theme文件夾。 首先是修改Color.kt文件 val Blue200 = Color(0xFF979FF2) val Blue300 = Color(0xFF6D7DEA) val Blue700 = Color(0xFF0068C2) val Blue800 = Col

    2024年04月09日
    瀏覽(23)
  • Android——一個(gè)簡單的天氣APP

    Android——一個(gè)簡單的天氣APP

    EasyWeather演示效果視頻 此天氣數(shù)據(jù)源采用心知天氣API(試用版),免費(fèi)版獲取數(shù)據(jù)有限,只能獲取普通的溫度、濕度等,例如壓力、云量、可見度等均獲取不到,試用版相當(dāng)于正式版,可以獲取大部分?jǐn)?shù)據(jù),試用日期是14天。 首頁不同城市天氣頁面之間的滑動采用的是 ViewPager

    2023年04月26日
    瀏覽(20)
  • Android實(shí)現(xiàn)-心知天氣API接口開發(fā)(天氣預(yù)報(bào)app)

    Android實(shí)現(xiàn)-心知天氣API接口開發(fā)(天氣預(yù)報(bào)app)

    自己開發(fā)app之心知天氣APP程序代碼粘貼即可用。完整代碼附最后。 第一步:去知心天氣注冊開發(fā)者賬號查看自己的token。注冊好登錄進(jìn)去--控制臺---免費(fèi)版--秘鑰。這里的秘鑰就是自己的token。(有興趣的可以看開發(fā)文檔,這里就不多介紹了) ?第二步,下載素材包。點(diǎn)擊文檔

    2024年02月03日
    瀏覽(24)
  • 基于Android實(shí)現(xiàn)的天氣預(yù)測APP

    基于Android實(shí)現(xiàn)的天氣預(yù)測APP

    網(wǎng)絡(luò)數(shù)據(jù)源使用 Retrofit 庫訪問彩云 API 提供的 Webservice 接口來實(shí)現(xiàn)。 Retrofit 通過封裝絡(luò)請求和數(shù)據(jù)解析,極地提升了開發(fā)效率。并且持定義數(shù)據(jù)解析在封裝所有網(wǎng)絡(luò)請求的 API 時(shí),我使用了協(xié)程技術(shù)來簡化 Retrofit 回調(diào)的寫法。 1.1.1 數(shù)據(jù)存儲 本地?cái)?shù)據(jù)源使用 SharedPreferences 持久

    2024年02月01日
    瀏覽(24)
  • 卸載WPS后如何修復(fù)Office文檔圖標(biāo)顯示異常

    卸載WPS后如何修復(fù)Office文檔圖標(biāo)顯示異常

    卸載WPS后發(fā)現(xiàn)Office文件word、ppt、excel的圖標(biāo)變成空白圖標(biāo),該如何解決? 嘗試了很多方法后,終于篩選出兩種簡單且有效的方法。 (有文章說可以修改注冊表,但我建議慎用,如果一不小心修改注冊表錯(cuò)誤,后果可能會很麻煩) 方法一: 解鈴還需系鈴人,可以使用Office自帶

    2024年02月04日
    瀏覽(19)
  • kotlin 編寫一個(gè)簡單的天氣預(yù)報(bào)app(六)使用recyclerView顯示forecast內(nèi)容

    要使用RecyclerView顯示天氣預(yù)報(bào)的內(nèi)容 先在grandle里添加recyclerView的引用 創(chuàng)建一個(gè)RecyclerView控件:在布局文件中,添加一個(gè)RecyclerView控件,用于顯示天氣預(yù)報(bào)的列表。 這是一個(gè)包含三個(gè)TextView的LinearLayout布局,用于顯示天氣相關(guān)的數(shù)據(jù)。每個(gè)TextView都有一個(gè)唯一的id,可用于在代

    2024年02月13日
    瀏覽(22)
  • Android Studio 實(shí)現(xiàn)天氣預(yù)報(bào)App (簡單方便展示內(nèi)容超多)

    Android Studio 實(shí)現(xiàn)天氣預(yù)報(bào)App (簡單方便展示內(nèi)容超多)

    ?? 文章末尾有獲取完整項(xiàng)目源碼方式 ?? 目錄 前言 一、任務(wù)介紹 1.1 背景 1.2目的和意義 二、?實(shí)現(xiàn)介紹 視頻演示 2.1 啟動頁實(shí)現(xiàn) 2.2注冊頁面實(shí)現(xiàn) 2.3 登陸頁面實(shí)現(xiàn) 2.4 首頁實(shí)現(xiàn) 2.5 城市管理列表頁面實(shí)現(xiàn)??????????????? 三、獲取源碼 ????????在使用Android Studio開發(fā)

    2024年04月24日
    瀏覽(27)
  • 安卓大作業(yè):使用Android Studio開發(fā)天氣預(yù)報(bào)APP(使用sqlite數(shù)據(jù)庫)

    安卓大作業(yè):使用Android Studio開發(fā)天氣預(yù)報(bào)APP(使用sqlite數(shù)據(jù)庫)

    今天我來分享一下如何使用Android Studio開發(fā)一個(gè)天氣預(yù)報(bào)APP。在文中,我們將使用第三方接口獲取實(shí)時(shí)天氣數(shù)據(jù),并顯示在APP界面上。 首先,打開Android Studio并創(chuàng)建一個(gè)新的項(xiàng)目。在創(chuàng)建新項(xiàng)目時(shí),我們需要設(shè)置項(xiàng)目名稱、包名和支持的最低API級別。 為了獲取實(shí)時(shí)天氣數(shù)據(jù),

    2024年02月08日
    瀏覽(31)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包