1
0
This commit is contained in:
田梓萱 2022-03-04 15:17:38 +08:00
parent fd6f6604d3
commit 2379ce45af
70 changed files with 593 additions and 179 deletions

View File

@ -1,7 +0,0 @@
\
,.idea/inspectionProfiles/Project_Default.xml,4\9\496a238a6afa168dbaf6efd37bb459331589579c
<
build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
v
Fentry/src/ohosTest/java/com/example/myapplication/ExampleOhosTest.java,6\a\6a6b1c750d19dd7877d9984c3de755233f64900b

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,11 +0,0 @@
package com.example.weather.data;
import java.util.ArrayList;
public class DataMo {
public ArrayList<CityMo> cityMos;
public DataMo(ArrayList<CityMo> cityMos){
this.cityMos = cityMos;
}
}

View File

@ -1,16 +0,0 @@
package com.example.weather.net;
import org.devio.hi.json.HiJson;
import java.util.Map;
import java.util.Map;
public interface IHiNet {
void get(String url, Map<String, String> params, NetListener listener);
interface NetListener{
void onSuccess(HiJson res);
void onFail(String message);
}
}

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid
ohos:color="#FFFFFF"/>
</shape>

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Text xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:id="$+id:city_item"
ohos:height="match_content"
ohos:width="match_content"
ohos:text_size="12vp"
ohos:text_color="#3fffff"
ohos:padding="6vp"
ohos:margin="2vp"
ohos:background_element="#70000000"/>

204
Weather/.idea/intellij-javadocs-4.0.1.xml generated Normal file
View File

@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaDocConfiguration">
<GENERAL>
<MODE>UPDATE</MODE>
<OVERRIDDEN_METHODS>false</OVERRIDDEN_METHODS>
<SPLITTED_CLASS_NAME>true</SPLITTED_CLASS_NAME>
<LEVELS>
<LEVEL>FIELD</LEVEL>
<LEVEL>TYPE</LEVEL>
<LEVEL>METHOD</LEVEL>
</LEVELS>
<VISIBILITIES>
<VISIBILITY>PUBLIC</VISIBILITY>
<VISIBILITY>PROTECTED</VISIBILITY>
<VISIBILITY>DEFAULT</VISIBILITY>
</VISIBILITIES>
</GENERAL>
<TEMPLATES>
<CLASSES>
<CLASS>
<KEY>^.*(public|protected|private)*.+interface\s+\w+.*</KEY>
<VALUE>/**\n
* The interface ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+enum\s+\w+.*</KEY>
<VALUE>/**\n
* The enum ${name}.\n
*/</VALUE>
</CLASS>
<CLASS>
<KEY>^.*(public|protected|private)*.+class\s+\w+.*</KEY>
<VALUE>/**\n
* The type ${name}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
*/</VALUE>
</CLASS>
<CLASS>
<KEY>.+</KEY>
<VALUE>/**\n
* The type ${name}.\n
*/</VALUE>
</CLASS>
</CLASSES>
<CONSTRUCTORS>
<CONSTRUCTOR>
<KEY>.+</KEY>
<VALUE>/**\n
* Instantiates a new ${name}.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</CONSTRUCTOR>
</CONSTRUCTORS>
<METHODS>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(\w(\s*&lt;.+&gt;)*)+\s+get\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Gets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*(public|protected|private)*\s*.*(void|\w(\s*&lt;.+&gt;)*)+\s+set\w+\s*\(.*\).+</KEY>
<VALUE>/**\n
* Sets ${partName}.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${partName}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>^.*((public\s+static)|(static\s+public))\s+void\s+main\s*\(\s*String\s*(\[\s*\]|\.\.\.)\s+\w+\s*\).+</KEY>
<VALUE>/**\n
* The entry point of application.\n
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
* @param ${element.parameterList.parameters[0].name} the input arguments\n
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
<METHOD>
<KEY>.+</KEY>
<VALUE>/**\n
* ${name}&lt;#if isNotVoid&gt; ${return}&lt;/#if&gt;.\n
&lt;#if element.typeParameters?has_content&gt; * \n
&lt;/#if&gt;
&lt;#list element.typeParameters as typeParameter&gt;
* @param &lt;${typeParameter.name}&gt; the type parameter\n
&lt;/#list&gt;
&lt;#if element.parameterList.parameters?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.parameterList.parameters as parameter&gt;
* @param ${parameter.name} the ${paramNames[parameter.name]}\n
&lt;/#list&gt;
&lt;#if isNotVoid&gt;
*\n
* @return the ${return}\n
&lt;/#if&gt;
&lt;#if element.throwsList.referenceElements?has_content&gt;
*\n
&lt;/#if&gt;
&lt;#list element.throwsList.referenceElements as exception&gt;
* @throws ${exception.referenceName} the ${exceptionNames[exception.referenceName]}\n
&lt;/#list&gt;
*/</VALUE>
</METHOD>
</METHODS>
<FIELDS>
<FIELD>
<KEY>^.*(public|protected|private)*.+static.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
* The constant ${element.getName()}.\n
*/</VALUE>
</FIELD>
<FIELD>
<KEY>^.*(public|protected|private)*.*(\w\s\w)+.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isInterface()&gt;
* The constant ${element.getName()}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt; */</VALUE>
</FIELD>
<FIELD>
<KEY>.+</KEY>
<VALUE>/**\n
&lt;#if element.parent.isEnum()&gt;
*${name} ${typeName}.\n
&lt;#else&gt;
* The ${name}.\n
&lt;/#if&gt;*/</VALUE>
</FIELD>
</FIELDS>
</TEMPLATES>
</component>
</project>

View File

@ -31,5 +31,10 @@
<option name="name" value="BintrayJCenter" /> <option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" /> <option name="url" value="https://jcenter.bintray.com/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="MavenRepo" />
<option name="name" value="MavenRepo" />
<option name="url" value="https://repo.maven.apache.org/maven2/" />
</remote-repository>
</component> </component>
</project> </project>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project> </project>

View File

@ -0,0 +1,6 @@
j
java:S1104
"TMake cityName a static final constant or non-public and provide accessors if needed.(¹ÆŸŸ
o
java:S1104"TMake cityCode a static final constant or non-public and provide accessors if needed.(‘ê¨Íùÿÿÿÿ

View File

@ -0,0 +1,9 @@
E
java:S20933"*Change this "try" to a try-with-resources.(¡»¢üùÿÿÿÿ
C
java:S1604&"(Make this anonymous inner class a lambda(”Ì<C38C>þÿÿÿÿ
>
java:S1604E"(Make this anonymous inner class a lambda(<28>³Å»
]
java:S22599"HA "NullPointerException" could be thrown; "connection" is nullable here.(”—üH

View File

@ -0,0 +1,6 @@
P
java:S1118
":Add a private constructor to hide the implicit public one.(ã¶ÒÒ
J
java:S2864"4Iterate over the "entrySet" instead of the "keySet".(«ñá¬

View File

@ -0,0 +1,4 @@
C
java:S1185
"(Remove this method to simply inherit it.(Þ×Ίÿÿÿÿÿ

View File

@ -0,0 +1,3 @@
P
java:S1118 ":Add a private constructor to hide the implicit public one.(<28>Àð†

View File

@ -0,0 +1,17 @@
q java:S116"\Rename this field "temperature_1Text" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(å­ÿ•
m java:S116"XRename this field "weather_1Text" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(å­ÿ•
j java:S116"URename this field "tips_1Text" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(å­ÿ•
s java:S116 "YRename this field "weatherImage_1" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(£ŠÖúþÿÿÿÿ
^
java:S1659"HDeclare "weatherText" and all following declarations on a separate line.(å­ÿ•
G
java:S1659 ",Declare "weatherImage_1" on a separate line.(£ŠÖúþÿÿÿÿ
V java:S125`"<This block of commented-out lines of code should be removed.(Š×¯ûúÿÿÿÿ
Q java:S125g"<This block of commented-out lines of code should be removed.(øáå‚
V java:S125u"<This block of commented-out lines of code should be removed.(Š×¯ûúÿÿÿÿ
Q java:S125|"<This block of commented-out lines of code should be removed.(øáå‚
F
java:S1068"+Remove this unused "mLayout" private field.(¸·§Ïüÿÿÿÿ
f
java:S1192_"KDefine a constant instead of duplicating this literal "WeatherApp" 4 times.(êȇÊûÿÿÿÿ

View File

@ -0,0 +1,9 @@
Q
java:S1874 ";Remove this use of "RecycleItemProvider"; it is deprecated.(ø<C3B8>¿
c java:S100a"NRename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(Þĉš

java:S1319!"gThe type of "cityMos" should be an interface such as "List" rather than the implementation "ArrayList".(­É¯íûÿÿÿÿ
k java:S117C"QRename this local variable to match the regular expression '^[a-z][a-zA-Z0-9]*$'.(·ô€ðÿÿÿÿÿ
C
java:S1604M"(Make this anonymous inner class a lambda(ëÏ“éÿÿÿÿÿ

View File

@ -0,0 +1,7 @@

java:S1319 "gThe type of "cityMos" should be an interface such as "List" rather than the implementation "ArrayList".(É£Ýóøÿÿÿÿ

java:S1319"gThe type of "cityMos" should be an interface such as "List" rather than the implementation "ArrayList".(ÀΰÊýÿÿÿÿ
n
java:S1104 "SMake cityMos a static final constant or non-public and provide accessors if needed.(É£Ýóøÿÿÿÿ

View File

@ -0,0 +1,33 @@
\
,.idea/inspectionProfiles/Project_Default.xml,4\9\496a238a6afa168dbaf6efd37bb459331589579c
<
build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35
v
Fentry/src/ohosTest/java/com/example/myapplication/ExampleOhosTest.java,6\a\6a6b1c750d19dd7877d9984c3de755233f64900b
j
:entry/src/main/java/com/example/weather/MyApplication.java,7\5\750f76477761fe96654f7734d0ff1b7bb1be5876
f
6entry/src/main/java/com/example/weather/net/HiNet.java,0\9\0967d9173abdcb01da65265c8e154e9a37034a67
j
:entry/src/main/java/com/example/weather/net/HiNetUtil.java,4\2\42a85d72c6c5bb50c094790894e8cef757c01d01
g
7entry/src/main/java/com/example/weather/net/IHiNet.java,2\d\2de47c4a3a933c03f3a50b5cca0f22761d46d3d4
h
8entry/src/main/java/com/example/weather/data/CityMo.java,0\7\0774814162e422c76bce232de8fbe7aa73482fb1
h
8entry/src/main/java/com/example/weather/data/DataMo.java,d\b\dbba308765e22bdac0f7ce0d766cd240fae5658f
r
Bentry/src/main/java/com/example/weather/data/ListItemProvider.java,d\5\d515ec7324135962f492b6cd82deaeda948f45d6
9
Readme.md,0\c\0c1945d7443c2e154bd3e421c0d438bd4086d8c3
B
entry/build.gradle,a\d\ad38b2dea33752cac233aa09d7dfbe582e9dded6
l
<entry/src/main/java/com/example/weather/util/HiExecutor.java,8\f\8f423886990ce6638a830fe4e6a70e23f267f22a
h
8entry/src/main/java/com/example/weather/MainAbility.java,c\4\c4d7c06613adb8c5404d09c42a94f8ad8bcc9664
s
Centry/src/main/java/com/example/weather/slice/MainAbilitySlice.java,a\b\aba7d9f4dd5aeef95a00381e20cef7a825179e38
J
entry/src/main/config.json,1\0\10f965cf51fe14a5ef0ca2ebefb1bd7e4607eeb2

5
Weather/Readme.md Normal file
View File

@ -0,0 +1,5 @@
# 天气应用
这是一个简单的鸿蒙天气应用,支持鸿蒙手机以及鸿蒙手表; 采用org.devio.hi.json:hijson来解析网络请求数据 使用时请自行替换和风天气的API密钥已适配SDK6.0
2022.03.04更新

View File

@ -27,8 +27,8 @@ buildscript {
} }
} }
dependencies { dependencies {
classpath 'com.huawei.ohos:hap:3.0.3.4' classpath 'com.huawei.ohos:hap:3.0.5.2'
classpath 'com.huawei.ohos:decctest:1.2.6.0' classpath 'com.huawei.ohos:decctest:1.2.7.2'
} }
} }

View File

@ -6,7 +6,6 @@ ohos {
defaultConfig { defaultConfig {
compatibleSdkVersion 6 compatibleSdkVersion 6
} }
showInServiceCenter true
buildTypes { buildTypes {
release { release {
proguardOpt { proguardOpt {
@ -24,7 +23,7 @@ dependencies {
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200' ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
} }
decc { decc {
supportType = ['html','xml'] supportType = ['html', 'xml']
} }
buildscript { buildscript {
repositories { repositories {
@ -34,11 +33,11 @@ buildscript {
maven { maven {
url 'https://developer.huawei.com/repo/' url 'https://developer.huawei.com/repo/'
} }
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.huawei.ohos:hap:3.0.3.2' classpath 'com.huawei.ohos:hap:3.0.3.2'
classpath 'com.huawei.ohos:decctest:1.2.6.0' classpath 'com.huawei.ohos:decctest:1.2.7.2'
} }
} }
@ -50,6 +49,6 @@ allprojects {
maven { maven {
url 'https://developer.huawei.com/repo/' url 'https://developer.huawei.com/repo/'
} }
jcenter() mavenCentral()
} }
} }

View File

@ -1,7 +1,7 @@
{ {
"app": { "app": {
"bundleName": "com.example.test.weather", "bundleName": "com.example.test.weather",
"vendor": "example", "vendor": "xcl",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
@ -14,8 +14,7 @@
"mainAbility": "com.example.weather.MainAbility", "mainAbility": "com.example.weather.MainAbility",
"deviceType": [ "deviceType": [
"phone", "phone",
"tablet", "tablet"
"wearable"
], ],
"reqPermissions": [ "reqPermissions": [
{ {
@ -54,22 +53,6 @@
"formsEnabled": true, "formsEnabled": true,
"label": "$string:entry_MainAbility", "label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"forms": [
{
"isDefault": true,
"scheduledUpdateTime": "10:30",
"defaultDimension": "2*2",
"name": "widget",
"description": "This is a service widget",
"colorMode": "auto",
"type": "JS",
"supportDimensions": [
"2*2"
],
"updateEnabled": true,
"updateDuration": 1
}
],
"launchType": "standard" "launchType": "standard"
} }
] ]

View File

@ -4,6 +4,9 @@ import com.example.weather.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability; import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent; import ohos.aafwk.content.Intent;
/**
* The type Main ability.
*/
public class MainAbility extends Ability { public class MainAbility extends Ability {
@Override @Override
public void onStart(Intent intent) { public void onStart(Intent intent) {

View File

@ -2,6 +2,9 @@ package com.example.weather;
import ohos.aafwk.ability.AbilityPackage; import ohos.aafwk.ability.AbilityPackage;
/**
* The type My application.
*/
public class MyApplication extends AbilityPackage { public class MyApplication extends AbilityPackage {
@Override @Override
public void onInitialize() { public void onInitialize() {

View File

@ -1,9 +1,24 @@
package com.example.weather.data; package com.example.weather.data;
/**
* The type City mo.
*/
public class CityMo { public class CityMo {
/**
* The City name.
*/
public String cityName; public String cityName;
/**
* The City code.
*/
public String cityCode; public String cityCode;
/**
* Instantiates a new City mo.
*
* @param cityName the city name
* @param cityCode the city code
*/
public CityMo(String cityName, String cityCode) { public CityMo(String cityName, String cityCode) {
this.cityName = cityName; this.cityName = cityName;
this.cityCode = cityCode; this.cityCode = cityCode;

View File

@ -0,0 +1,22 @@
package com.example.weather.data;
import java.util.ArrayList;
/**
* The type Data mo.
*/
public class DataMo {
/**
* The City mos.
*/
public ArrayList<CityMo> cityMos;
/**
* Instantiates a new Data mo.
*
* @param cityMos the city mos
*/
public DataMo(ArrayList<CityMo> cityMos) {
this.cityMos = cityMos;
}
}

View File

@ -1,27 +1,41 @@
package com.example.weather.data; package com.example.weather.data;
import com.example.weather.ResourceTable;
import ohos.aafwk.ability.AbilitySlice; import ohos.aafwk.ability.AbilitySlice;
import ohos.agp.components.*; import ohos.agp.components.*;
import com.example.weather.ResourceTable;
import java.util.ArrayList; import java.util.ArrayList;
/**
* The type List item provider.
*/
public class ListItemProvider extends RecycleItemProvider { public class ListItemProvider extends RecycleItemProvider {
private AbilitySlice mSlice; private AbilitySlice mSlice;
private OnItemClickListener listener; private OnItemClickListener listener;
private ArrayList<DataMo> dataMos = new ArrayList<>(); private ArrayList<DataMo> dataMos = new ArrayList<>();
public ListItemProvider(AbilitySlice abilitySlice, OnItemClickListener listener){ /**
* Instantiates a new List item provider.
*
* @param abilitySlice the ability slice
* @param listener the listener
*/
public ListItemProvider(AbilitySlice abilitySlice, OnItemClickListener listener) {
this.mSlice = abilitySlice; this.mSlice = abilitySlice;
this.listener = listener; this.listener = listener;
} }
public void setData(ArrayList<CityMo> cityMos){ /**
* Set data.
*
* @param cityMos the city mos
*/
public void setData(ArrayList<CityMo> cityMos) {
this.dataMos.clear(); this.dataMos.clear();
int i = 0; int i = 0;
ArrayList<CityMo> tempList = new ArrayList<>(); ArrayList<CityMo> tempList = new ArrayList<>();
for (CityMo mo:cityMos){ for (CityMo mo : cityMos) {
if (i == 3){ if (i == 3) {
i = 0; i = 0;
dataMos.add(new DataMo(tempList)); dataMos.add(new DataMo(tempList));
tempList = new ArrayList<>(); tempList = new ArrayList<>();
@ -32,6 +46,7 @@ public class ListItemProvider extends RecycleItemProvider {
dataMos.add(new DataMo(tempList)); dataMos.add(new DataMo(tempList));
this.notifyDataChanged(); this.notifyDataChanged();
} }
@Override @Override
public int getCount() { public int getCount() {
return dataMos.size(); return dataMos.size();
@ -50,12 +65,12 @@ public class ListItemProvider extends RecycleItemProvider {
@Override @Override
public Component getComponent(int i, Component component, ComponentContainer componentContainer) { public Component getComponent(int i, Component component, ComponentContainer componentContainer) {
Component component_item = LayoutScatter.getInstance(mSlice).parse(ResourceTable.Layout_list_item, null, false); Component component_item = LayoutScatter.getInstance(mSlice).parse(ResourceTable.Layout_list_item, null, false);
if ( !(component_item instanceof ComponentContainer)){ if (!(component_item instanceof ComponentContainer)) {
return null; return null;
} }
ComponentContainer rootLayout = (ComponentContainer)component_item; ComponentContainer rootLayout = (ComponentContainer) component_item;
DataMo dataMo = dataMos.get(i); DataMo dataMo = dataMos.get(i);
for (CityMo mo:dataMo.cityMos){ for (CityMo mo : dataMo.cityMos) {
Text titleItem = (Text) LayoutScatter.getInstance(mSlice).parse(ResourceTable.Layout_item_title, null, false); Text titleItem = (Text) LayoutScatter.getInstance(mSlice).parse(ResourceTable.Layout_item_title, null, false);
titleItem.setText(mo.cityName); titleItem.setText(mo.cityName);
rootLayout.addComponent(titleItem); rootLayout.addComponent(titleItem);
@ -69,7 +84,16 @@ public class ListItemProvider extends RecycleItemProvider {
return component_item; return component_item;
} }
public interface OnItemClickListener{ /**
* The interface On item click listener.
*/
public interface OnItemClickListener {
/**
* On item click.
*
* @param cityMo the city mo
* @param position the position
*/
void OnItemClick(CityMo cityMo, int position); void OnItemClick(CityMo cityMo, int position);
} }
} }

View File

@ -1,5 +1,6 @@
package com.example.weather.net; package com.example.weather.net;
import com.example.weather.util.HiExecutor;
import ohos.hiviewdfx.HiLog; import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel; import ohos.hiviewdfx.HiLogLabel;
import ohos.net.NetHandle; import ohos.net.NetHandle;
@ -7,7 +8,6 @@ import ohos.net.NetManager;
import org.devio.hi.json.HiJson; import org.devio.hi.json.HiJson;
import org.devio.hi.json.JSONException; import org.devio.hi.json.JSONException;
import org.devio.hi.json.JSONObject; import org.devio.hi.json.JSONObject;
import com.example.weather.util.HiExecutor;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.InputStream; import java.io.InputStream;
@ -17,11 +17,17 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Map; import java.util.Map;
public class HiNet implements IHiNet{ /**
* The type Hi net.
*/
public class HiNet implements IHiNet {
private NetManager netManager; private NetManager netManager;
private HiLogLabel logLabel = new HiLogLabel(0,0, HiNet.class.getSimpleName()); private HiLogLabel logLabel = new HiLogLabel(0, 0, HiNet.class.getSimpleName());
public HiNet(){ /**
* Instantiates a new Hi net.
*/
public HiNet() {
netManager = NetManager.getInstance(null); netManager = NetManager.getInstance(null);
} }
@ -45,25 +51,25 @@ public class HiNet implements IHiNet{
try { try {
URL url = new URL(finalUrl); URL url = new URL(finalUrl);
URLConnection urlConnection = netHandle.openConnection(url, Proxy.NO_PROXY); URLConnection urlConnection = netHandle.openConnection(url, Proxy.NO_PROXY);
if (urlConnection instanceof HttpURLConnection){ if (urlConnection instanceof HttpURLConnection) {
connection = (HttpURLConnection)urlConnection; connection = (HttpURLConnection) urlConnection;
} }
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
connection.connect(); connection.connect();
HiLog.debug(logLabel, "connect..."); HiLog.debug(logLabel, "connect...");
if (connection.getResponseCode() == 200){ if (connection.getResponseCode() == 200) {
inputStream = connection.getInputStream(); inputStream = connection.getInputStream();
baos = new ByteArrayOutputStream(); baos = new ByteArrayOutputStream();
int readLen; int readLen;
byte[] bytes = new byte[1024]; byte[] bytes = new byte[1024];
while((readLen = inputStream.read(bytes)) != -1){ while ((readLen = inputStream.read(bytes)) != -1) {
baos.write(bytes, 0, readLen); baos.write(bytes, 0, readLen);
} }
String result = baos.toString(); String result = baos.toString();
HiExecutor.runUI(new Runnable() { HiExecutor.runUI(new Runnable() {
@Override @Override
public void run() { public void run() {
try{ try {
HiJson res = new HiJson(new JSONObject(result)); HiJson res = new HiJson(new JSONObject(result));
listener.onSuccess(res); listener.onSuccess(res);
HiLog.debug(logLabel, "success."); HiLog.debug(logLabel, "success.");
@ -77,11 +83,11 @@ public class HiNet implements IHiNet{
HiLog.debug(logLabel, "Request fail, code:" + connection.getResponseCode()); HiLog.debug(logLabel, "Request fail, code:" + connection.getResponseCode());
listener.onFail("Request fail, code:" + connection.getResponseCode()); listener.onFail("Request fail, code:" + connection.getResponseCode());
} }
} catch (Exception e){ } catch (Exception e) {
HiLog.debug(logLabel, "Request fail, msg:" + e.toString()); HiLog.debug(logLabel, "Request fail, msg:" + e.toString());
listener.onFail("Request fail, msg:" + e.toString()); listener.onFail("Request fail, msg:" + e.toString());
} finally { } finally {
if (connection != null){ if (connection != null) {
connection.disconnect(); connection.disconnect();
} }
HiNetUtil.close(inputStream); HiNetUtil.close(inputStream);

View File

@ -4,16 +4,26 @@ import java.io.Closeable;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
/**
* The type Hi net util.
*/
public class HiNetUtil { public class HiNetUtil {
public static String buildParams(String url, Map<String, String> params){ /**
* Build params string.
*
* @param url the url
* @param params the params
* @return the string
*/
public static String buildParams(String url, Map<String, String> params) {
if (params == null) return null; if (params == null) return null;
StringBuilder builder = new StringBuilder(url); StringBuilder builder = new StringBuilder(url);
boolean isFirst = true; boolean isFirst = true;
for (String key : params.keySet()){ for (String key : params.keySet()) {
String value = params.get(key); String value = params.get(key);
if (key != null && value != null){ if (key != null && value != null) {
if (isFirst){ if (isFirst) {
isFirst = false; isFirst = false;
builder.append("?"); builder.append("?");
} else { } else {
@ -27,8 +37,13 @@ public class HiNetUtil {
return builder.toString(); return builder.toString();
} }
public static void close(Closeable closeable){ /**
if (closeable != null){ * Close.
*
* @param closeable the closeable
*/
public static void close(Closeable closeable) {
if (closeable != null) {
try { try {
closeable.close(); closeable.close();
} catch (IOException e) { } catch (IOException e) {

View File

@ -0,0 +1,38 @@
package com.example.weather.net;
import org.devio.hi.json.HiJson;
import java.util.Map;
/**
* The interface Hi net.
*/
public interface IHiNet {
/**
* Get.
*
* @param url the url
* @param params the params
* @param listener the listener
*/
void get(String url, Map<String, String> params, NetListener listener);
/**
* The interface Net listener.
*/
interface NetListener {
/**
* On success.
*
* @param res the res
*/
void onSuccess(HiJson res);
/**
* On fail.
*
* @param message the message
*/
void onFail(String message);
}
}

View File

@ -1,32 +1,35 @@
package com.example.weather.slice; package com.example.weather.slice;
import com.example.weather.ResourceTable;
import com.example.weather.data.CityMo;
import com.example.weather.data.ListItemProvider;
import com.example.weather.net.HiNet;
import com.example.weather.net.IHiNet;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.DirectionalLayout; import ohos.agp.components.DirectionalLayout;
import ohos.agp.components.Image; import ohos.agp.components.Image;
import ohos.agp.components.ListContainer; import ohos.agp.components.ListContainer;
import ohos.agp.components.Text; import ohos.agp.components.Text;
import ohos.hiviewdfx.HiLog; import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel; import ohos.hiviewdfx.HiLogLabel;
import org.devio.hi.json.HiJson; import org.devio.hi.json.HiJson;
import com.example.weather.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import com.example.weather.data.CityMo;
import com.example.weather.data.ListItemProvider;
import com.example.weather.net.HiNet;
import com.example.weather.net.IHiNet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.OnItemClickListener{ /**
* The type Main ability slice.
*/
public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.OnItemClickListener {
private DirectionalLayout mLayout = new DirectionalLayout(this); private DirectionalLayout mLayout = new DirectionalLayout(this);
private ListContainer listContainer; private ListContainer listContainer;
private ListItemProvider listItemProvider; private ListItemProvider listItemProvider;
private ArrayList<CityMo> cities = new ArrayList<>(); private ArrayList<CityMo> cities = new ArrayList<>();
private HiNet hiNet; private HiNet hiNet;
private Text temperatureText,weatherText,tipsText,temperature_1Text,weather_1Text,tips_1Text; private Text temperatureText, weatherText, tipsText, temperature_1Text, weather_1Text, tips_1Text;
private Image weatherImage,weatherImage_1; private Image weatherImage, weatherImage_1;
@Override @Override
public void onStart(Intent intent) { public void onStart(Intent intent) {
@ -41,12 +44,12 @@ public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.O
} }
private void initLayout1() { private void initLayout1() {
listContainer = (ListContainer)findComponentById(ResourceTable.Id_list); listContainer = (ListContainer) findComponentById(ResourceTable.Id_list);
listItemProvider = new ListItemProvider(this, this); listItemProvider = new ListItemProvider(this, this);
listContainer.setItemProvider(listItemProvider); listContainer.setItemProvider(listItemProvider);
temperatureText = (Text)findComponentById(ResourceTable.Id_temperature_1); temperatureText = (Text) findComponentById(ResourceTable.Id_temperature_1);
weatherText = (Text)findComponentById(ResourceTable.Id_weather_1); weatherText = (Text) findComponentById(ResourceTable.Id_weather_1);
tipsText = (Text)findComponentById(ResourceTable.Id_tips_1); tipsText = (Text) findComponentById(ResourceTable.Id_tips_1);
weatherImage = (Image) findComponentById(ResourceTable.Id_weather_icon_1); weatherImage = (Image) findComponentById(ResourceTable.Id_weather_icon_1);
} }
@ -55,13 +58,13 @@ public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.O
} }
private void initLayout(){ private void initLayout() {
listContainer = (ListContainer)findComponentById(ResourceTable.Id_list); listContainer = (ListContainer) findComponentById(ResourceTable.Id_list);
listItemProvider = new ListItemProvider(this, this); listItemProvider = new ListItemProvider(this, this);
listContainer.setItemProvider(listItemProvider); listContainer.setItemProvider(listItemProvider);
temperature_1Text = (Text)findComponentById(ResourceTable.Id_temperature); temperature_1Text = (Text) findComponentById(ResourceTable.Id_temperature);
weather_1Text = (Text)findComponentById(ResourceTable.Id_weather); weather_1Text = (Text) findComponentById(ResourceTable.Id_weather);
tips_1Text = (Text)findComponentById(ResourceTable.Id_tips); tips_1Text = (Text) findComponentById(ResourceTable.Id_tips);
weatherImage_1 = (Image) findComponentById(ResourceTable.Id_weather_icon); weatherImage_1 = (Image) findComponentById(ResourceTable.Id_weather_icon);
} }
@ -80,40 +83,44 @@ public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.O
loadData(cityMo); loadData(cityMo);
} }
private void loadData(CityMo mo){
private void loadData(CityMo mo) {
//https://devapi.qweather.com/v7/weather/now?location=114.03,22.32&key=<用户key:18418bf60e874597abf85b7906d03e48> //https://devapi.qweather.com/v7/weather/now?location=114.03,22.32&key=<用户key:18418bf60e874597abf85b7906d03e48>
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("location", mo.cityCode); params.put("location", mo.cityCode);
params.put("key", "18418bf60e874597abf85b7906d03e48"); params.put("key", "你的和风天气API密钥");
hiNet.get("https://devapi.qweather.com/v7/weather/now", params, new IHiNet.NetListener() { hiNet.get("https://devapi.qweather.com/v7/weather/now", params, new IHiNet.NetListener() {
@Override @Override
public void onSuccess(HiJson res) { public void onSuccess(HiJson res) {
HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get success:" + res.toString()); HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get success:" + res.toString());
//System.out.println("WeatherApp onSuccess:"+ res); //System.out.println("WeatherApp onSuccess:"+ res);
bindData(res, mo); bindData(res, mo);
} }
@Override @Override
public void onFail(String message) { public void onFail(String message) {
HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get fail:" + message); HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get fail:" + message);
//System.out.println("WeatherApp onSuccess:"+ message); //System.out.println("WeatherApp onSuccess:"+ message);
} }
}); });
} }
private void loadData1(CityMo mo){
private void loadData1(CityMo mo) {
//https://devapi.qweather.com/v7/weather/now?location=114.03,22.32&key=<用户key:18418bf60e874597abf85b7906d03e48> //https://devapi.qweather.com/v7/weather/now?location=114.03,22.32&key=<用户key:18418bf60e874597abf85b7906d03e48>
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("location", mo.cityCode); params.put("location", mo.cityCode);
params.put("key", "18418bf60e874597abf85b7906d03e48"); params.put("key", "你的和风天气API密钥");
hiNet.get("https://devapi.qweather.com/v7/weather/now", params, new IHiNet.NetListener() { hiNet.get("https://devapi.qweather.com/v7/weather/now", params, new IHiNet.NetListener() {
@Override @Override
public void onSuccess(HiJson res) { public void onSuccess(HiJson res) {
HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get success:" + res.toString()); HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get success:" + res.toString());
//System.out.println("WeatherApp onSuccess:"+ res); //System.out.println("WeatherApp onSuccess:"+ res);
bindData1(res, mo); bindData1(res, mo);
} }
@Override @Override
public void onFail(String message) { public void onFail(String message) {
HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get fail:" + message); HiLog.info(new HiLogLabel(HiLog.LOG_APP, 0x00201, "WeatherApp"), "Get fail:" + message);
//System.out.println("WeatherApp onSuccess:"+ message); //System.out.println("WeatherApp onSuccess:"+ message);
} }
}); });
@ -126,26 +133,27 @@ public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.O
String winddirection = hiJson.value("windDir"); String winddirection = hiJson.value("windDir");
String windpower = hiJson.value("windScale"); String windpower = hiJson.value("windScale");
String humidity = hiJson.value("humidity"); String humidity = hiJson.value("humidity");
/* /*
*上方为对于获取到的JSON数据的读取处理可加异常抛出 *上方为对于获取到的JSON数据的读取处理可加异常抛出
*/ */
temperatureText.setText(temperature + ""); temperatureText.setText(temperature + "");
weatherText.setText(weather); weatherText.setText(weather);
tipsText.setText(mo.cityName + ":" + winddirection +" 最大风力:"+ windpower + "" + " 空气湿度" + humidity + "%"); tipsText.setText(mo.cityName + ":" + winddirection + " 最大风力:" + windpower + "" + " 空气湿度" + humidity + "%");
int id = ResourceTable.Media_sunshine; int id = ResourceTable.Media_sunshine;
if (weather.contains("")){ if (weather.contains("")) {
id = ResourceTable.Media_overcast; id = ResourceTable.Media_overcast;
} else if (weather.contains("")){ } else if (weather.contains("")) {
id = ResourceTable.Media_rain; id = ResourceTable.Media_rain;
} else if (weather.contains("")){ } else if (weather.contains("")) {
id = ResourceTable.Media_snow; id = ResourceTable.Media_snow;
} else if (weather.contains("雷电")){ } else if (weather.contains("雷电")) {
id = ResourceTable.Media_thunder; id = ResourceTable.Media_thunder;
} else if (weather.contains("多云")){ } else if (weather.contains("多云")) {
id = ResourceTable.Media_cloudy; id = ResourceTable.Media_cloudy;
}/*此处的天气详情待完善*/ }/*此处的天气详情待完善*/
weatherImage.setImageAndDecodeBounds(id); weatherImage.setImageAndDecodeBounds(id);
} }
private void bindData1(HiJson res, CityMo mo) { private void bindData1(HiJson res, CityMo mo) {
HiJson hiJson = res.get("now"); HiJson hiJson = res.get("now");
String temperature = hiJson.value("temp"); String temperature = hiJson.value("temp");
@ -158,17 +166,17 @@ public class MainAbilitySlice extends AbilitySlice implements ListItemProvider.O
*/ */
temperature_1Text.setText(temperature + ""); temperature_1Text.setText(temperature + "");
weather_1Text.setText(weather); weather_1Text.setText(weather);
tips_1Text.setText(mo.cityName + ":" + winddirection +" 最大风力:"+ windpower + "" + " 空气湿度" + humidity + "%"); tips_1Text.setText(mo.cityName + ":" + winddirection + " 最大风力:" + windpower + "" + " 空气湿度" + humidity + "%");
int id = ResourceTable.Media_sunshine; int id = ResourceTable.Media_sunshine;
if (weather.contains("")){ if (weather.contains("")) {
id = ResourceTable.Media_overcast; id = ResourceTable.Media_overcast;
} else if (weather.contains("")){ } else if (weather.contains("")) {
id = ResourceTable.Media_rain; id = ResourceTable.Media_rain;
} else if (weather.contains("")){ } else if (weather.contains("")) {
id = ResourceTable.Media_snow; id = ResourceTable.Media_snow;
} else if (weather.contains("雷电")){ } else if (weather.contains("雷电")) {
id = ResourceTable.Media_thunder; id = ResourceTable.Media_thunder;
} else if (weather.contains("多云")){ } else if (weather.contains("多云")) {
id = ResourceTable.Media_cloudy; id = ResourceTable.Media_cloudy;
}/*此处的天气详情待完善*/ }/*此处的天气详情待完善*/
weatherImage_1.setImageAndDecodeBounds(id); weatherImage_1.setImageAndDecodeBounds(id);

View File

@ -3,12 +3,20 @@ package com.example.weather.util;
import ohos.eventhandler.EventHandler; import ohos.eventhandler.EventHandler;
import ohos.eventhandler.EventRunner; import ohos.eventhandler.EventRunner;
/**
* The type Hi executor.
*/
public class HiExecutor { public class HiExecutor {
/**
* Run ui.
*
* @param runnable the runnable
*/
/* /*
* 切换任务到主线程执行 * 切换任务到主线程执行
* @param runnable * @param runnable
* */ * */
public static void runUI(Runnable runnable){ public static void runUI(Runnable runnable) {
// 切换到主线程 // 切换到主线程
EventRunner runner = EventRunner.getMainEventRunner(); EventRunner runner = EventRunner.getMainEventRunner();
EventHandler eventHandler = new EventHandler(runner); EventHandler eventHandler = new EventHandler(runner);
@ -16,11 +24,16 @@ public class HiExecutor {
eventHandler.postSyncTask(runnable); eventHandler.postSyncTask(runnable);
} }
/**
* Run bg.
*
* @param runnable the runnable
*/
/* /*
* 在子线程执行任务 * 在子线程执行任务
* @param runnable * @param runnable
* */ * */
public static void runBG(Runnable runnable){ public static void runBG(Runnable runnable) {
//开启一个线程 //开启一个线程
EventRunner runner = EventRunner.create(true); EventRunner runner = EventRunner.create(true);
EventHandler eventHandler = new EventHandler(runner); EventHandler eventHandler = new EventHandler(runner);

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<shape
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid
ohos:color="#FFFFFF"/>
</shape>

View File

@ -1,98 +1,106 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout <DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos" xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:id="$+id:root"
ohos:height="match_parent" ohos:height="match_parent"
ohos:width="match_parent" ohos:width="match_parent"
ohos:id="$+id:root"
ohos:alignment="horizontal_center" ohos:alignment="horizontal_center"
ohos:padding="32" ohos:orientation="vertical"
ohos:orientation="vertical"> ohos:padding="32">
<DirectionalLayout <DirectionalLayout
ohos:orientation="horizontal"
ohos:width="match_parent"
ohos:height="match_content" ohos:height="match_content"
ohos:alignment="horizontal_center"> ohos:width="match_parent"
ohos:alignment="horizontal_center"
ohos:orientation="horizontal">
<Image <Image
ohos:id="$+id:weather_icon" ohos:id="$+id:weather_icon"
ohos:height="60vp" ohos:height="60vp"
ohos:width="60vp" ohos:width="60vp"
ohos:scale_mode="inside"
ohos:padding="5vp"
ohos:image_src="$media:sunshine" ohos:image_src="$media:sunshine"
ohos:padding="5vp"
ohos:scale_mode="inside"
/> />
<Text <Text
ohos:id="$+id:weather" ohos:id="$+id:weather"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_content" ohos:width="match_content"
ohos:right_margin="10vp"
ohos:text="1保留" ohos:text="1保留"
ohos:text_color="#FF000000" ohos:text_color="#FF000000"
ohos:right_margin="10vp"
ohos:text_size="12fp" ohos:text_size="12fp"
/> />
<Text <Text
ohos:id="$+id:temperature" ohos:id="$+id:temperature"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_content" ohos:width="match_content"
ohos:text="1保留" ohos:text="1保留"
ohos:top_padding="8vp"
ohos:text_color="#FF000000" ohos:text_color="#FF000000"
ohos:text_size="20fp" ohos:text_size="20fp"
ohos:top_padding="8vp"
/> />
</DirectionalLayout> </DirectionalLayout>
<Text <Text
ohos:id="$+id:tips" ohos:id="$+id:tips"
ohos:width="match_content"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="horizontal_center" ohos:layout_alignment="horizontal_center"
ohos:text="1保留"
ohos:text_color="#FF3A6B53"
ohos:left_margin="10vp" ohos:left_margin="10vp"
ohos:right_margin="10vp" ohos:right_margin="10vp"
ohos:text="1保留"
ohos:text_color="#FF3A6B53"
ohos:text_size="12vp" ohos:text_size="12vp"
/> />
<DirectionalLayout <DirectionalLayout
ohos:orientation="horizontal"
ohos:width="match_parent"
ohos:height="match_content" ohos:height="match_content"
ohos:alignment="horizontal_center"> ohos:width="match_parent"
ohos:alignment="horizontal_center"
ohos:orientation="horizontal">
<Image <Image
ohos:id="$+id:weather_icon_1" ohos:id="$+id:weather_icon_1"
ohos:height="60vp" ohos:height="60vp"
ohos:width="60vp" ohos:width="60vp"
ohos:scale_mode="inside"
ohos:padding="5vp"
ohos:image_src="$media:sunshine" ohos:image_src="$media:sunshine"
ohos:padding="5vp"
ohos:scale_mode="inside"
/> />
<Text <Text
ohos:id="$+id:weather_1" ohos:id="$+id:weather_1"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_content" ohos:width="match_content"
ohos:right_margin="10vp"
ohos:text="2保留" ohos:text="2保留"
ohos:text_color="#FF000000" ohos:text_color="#FF000000"
ohos:right_margin="10vp"
ohos:text_size="12fp" ohos:text_size="12fp"
/> />
<Text <Text
ohos:id="$+id:temperature_1" ohos:id="$+id:temperature_1"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_content" ohos:width="match_content"
ohos:text="2保留" ohos:text="2保留"
ohos:top_padding="8vp"
ohos:text_color="#FF000000" ohos:text_color="#FF000000"
ohos:text_size="20fp" ohos:text_size="20fp"
ohos:top_padding="8vp"
/> />
</DirectionalLayout> </DirectionalLayout>
<Text <Text
ohos:id="$+id:tips_1" ohos:id="$+id:tips_1"
ohos:width="match_content"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="horizontal_center" ohos:layout_alignment="horizontal_center"
ohos:text="2保留"
ohos:text_color="#FF3A6B53"
ohos:left_margin="10vp" ohos:left_margin="10vp"
ohos:right_margin="10vp" ohos:right_margin="10vp"
ohos:text="2保留"
ohos:text_color="#FF3A6B53"
ohos:text_size="12vp" ohos:text_size="12vp"
/> />

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Text
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:id="$+id:city_item"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="#70000000"
ohos:margin="2vp"
ohos:padding="6vp"
ohos:text_color="#3fffff"
ohos:text_size="12vp"/>

View File

@ -3,5 +3,5 @@
xmlns:ohos="http://schemas.huawei.com/res/ohos" xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_content" ohos:height="match_content"
ohos:width="match_parent" ohos:width="match_parent"
ohos:orientation="horizontal" ohos:alignment="horizontal_center"
ohos:alignment="horizontal_center"/> ohos:orientation="horizontal"/>

View File

Before

Width:  |  Height:  |  Size: 368 KiB

After

Width:  |  Height:  |  Size: 368 KiB

View File

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists