master
2982339571 2 years ago
commit d9af88d707

14
.gitignore vendored

@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx

3
.idea/.gitignore vendored

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

@ -0,0 +1 @@
My Application

@ -0,0 +1,116 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>
</component>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="corretto-11" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://maven.aliyun.com/repository/google/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://maven.aliyun.com/repository/jcenter/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Embedded JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RenderSettings">
<option name="showDecorations" value="true" />
</component>
</project>

1
app/.gitignore vendored

@ -0,0 +1 @@
/build

@ -0,0 +1,35 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'org.xutils:xutils:3.7.6'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.code.gson:gson:2.2.4'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.3.0-alpha02'
}

@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

@ -0,0 +1,27 @@
package com.example.myapplication;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("com.example.myapplication", appContext.getPackageName());
}
}

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".base.UniteApp"
android:allowBackup="true"
android:icon="@mipmap/bj"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".city_manager.CityManagerActivity" />
<activity android:name=".city_manager.SearchCityActivity" />
<activity android:name=".city_manager.DeleteCityActivity" />
<activity android:name=".MoreActivity"></activity>
</application>
</manifest>

@ -0,0 +1,44 @@
package com.example.myapplication;
import java.util.List;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
public class CityFragmentPagerAdapter extends FragmentStatePagerAdapter {
List<Fragment>fragmentList;
public CityFragmentPagerAdapter(FragmentManager fm, List<Fragment>fragmentLis) {
super(fm);
this.fragmentList = fragmentLis;
}
@Override
public Fragment getItem(int position) {
return fragmentList.get(position);
}
@Override
public int getCount() {
return fragmentList.size();
}
int childCount = 0; //表示ViewPager包含的页数
// 当ViewPager的页数发生改变时必须要重写两个函数
@Override
public void notifyDataSetChanged() {
this.childCount = getCount();
super.notifyDataSetChanged();
}
@Override
public int getItemPosition(@NonNull Object object) {
if (childCount>0) {
childCount--;
return POSITION_NONE;
}
return super.getItemPosition(object);
}
}

@ -0,0 +1,324 @@
package com.example.myapplication;
import android.app.AlertDialog;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import com.example.myapplication.base.BaseFragment;
import com.example.myapplication.bean.WeatherBean;
import com.example.myapplication.db.DBManager;
import com.google.gson.Gson;
import com.squareup.picasso.Picasso;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import androidx.fragment.app.Fragment;
import static android.content.Context.MODE_PRIVATE;
/**
* A simple {@link Fragment} subclass.
*/
public class CityWeatherFragment extends BaseFragment implements View.OnClickListener{
TextView tempTv,cityTv,conditionTv,windTv,tempRangeTv,dateTv,clothIndexTv,carIndexTv,coldIndexTv,sportIndexTv,raysIndexTv,tipTv,umbrellaTv;
ImageView dayIv;
LinearLayout futureLayout;
ScrollView outLayout;
String url1 = "https://wis.qq.com/weather/common?source=pc&weather_type=observe|index|rise|alarm|air|tips|forecast_24h&province=";
String url2 = "&city=";
String city;
String provice;
private WeatherBean.DataBean.IndexBean index;
private SharedPreferences pref;
private int bgNum;
// 换壁纸的函数
public void exchangeBg(){
pref = getActivity().getSharedPreferences("bg_pref", MODE_PRIVATE);
bgNum = pref.getInt("bg", 2);
switch (bgNum) {
case 0:
outLayout.setBackgroundResource(R.mipmap.bg);
break;
case 1:
outLayout.setBackgroundResource(R.mipmap.bg2);
break;
case 2:
outLayout.setBackgroundResource(R.mipmap.bg3);
break;
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_city_weather, container, false);
initView(view);
exchangeBg();
// 可以通过activity传值获取到当前fragment加载的是那个地方的省份和天气情况
Bundle bundle = getArguments();
String provice_city = bundle.getString("city");
// 获取省份
if(provice_city.split(" ").length>1)
{ provice =provice_city.split(" ")[0];
city = provice_city.split(" ")[1];
}
else
{
city = provice_city.split(" ")[0];
provice = provice_city.split(" ")[0];
}
String url = url1+provice+url2+city;
// 调用父类获取数据的方法
loadData(url);
return view;
}
@Override
public void onSuccess(String result) {
// 解析并展示数据
try {
parseShowData(result);
} catch (ParseException e) {
e.printStackTrace();
}
// 更新数据
int i = DBManager.updateInfoByCity(city, result);
if (i<=0) {
// 更新数据库失败,说明没有这条城市信息,增加这个城市记录
DBManager.addCityInfo(city,result);
}
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
// 数据库当中查找上一次信息显示在Fragment当中
String s = DBManager.queryInfoByCity(city);
if (!TextUtils.isEmpty(s)) {
try {
parseShowData(s);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
private void parseShowData(String result) throws ParseException {
// 使用gson解析数据
WeatherBean weatherBean = new Gson().fromJson(result, WeatherBean.class);
WeatherBean.DataBean resultsBean = weatherBean.getData();
index = resultsBean.getIndex();
// 设置TextView
cityTv.setText(city);
tipTv.setText(resultsBean.getTips().getObserve().get_$0());
// 获取今日天气情况
WeatherBean.DataBean.ObserveBean todayDataBean = resultsBean.getObserve();
String time = changeTime(todayDataBean.getUpdate_time());
dateTv.setText(time);
windTv.setText("湿度 "+todayDataBean.getHumidity()+"%");
tempRangeTv.setText("气压 "+todayDataBean.getPressure()+"hPa");
conditionTv.setText(todayDataBean.getWeather_short());
// 获取实时天气温度情况,需要处理字符串
tempTv.setText(todayDataBean.getDegree()+"°C");
//设置天气情况图片
// Picasso.with(getActivity()).load(todayDataBean.getWeather()).into(dayIv);
// 获取近七天的天气情况加载到layout当中
WeatherBean.DataBean.Forecast24hBean futureList = resultsBean.getForecast_24h();
View itemView = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center, null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView);
TextView idateTv = itemView.findViewById(R.id.item_center_tv_date);
TextView iconTv = itemView.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv = itemView.findViewById(R.id.item_center_tv_temp);
TextView wind = itemView.findViewById(R.id.item_center_tv_winddirection);
// 获取明天对应的位置的天气情况
idateTv.setText(futureList.get_$1().getTime());
iconTv.setText(futureList.get_$1().getDay_weather());
wind.setText(futureList.get_$1().getDay_wind_direction());
itemprangeTv.setText(futureList.get_$1().getMin_degree()+"~"+futureList.get_$1().getMax_degree()+"°C");
View itemView3 = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center, null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView3);
TextView idateTv3 = itemView3.findViewById(R.id.item_center_tv_date);
TextView iconTv3 = itemView3.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv3 = itemView3.findViewById(R.id.item_center_tv_temp);
TextView wind3 = itemView3.findViewById(R.id.item_center_tv_winddirection);
// 获取后天对应的位置的天气情况
idateTv3.setText(futureList.get_$2().getTime());
iconTv3.setText(futureList.get_$2().getDay_weather());
wind3.setText(futureList.get_$2().getDay_wind_direction());
itemprangeTv3.setText(futureList.get_$2().getMin_degree()+"~"+futureList.get_$2().getMax_degree()+"°C");
View itemView2 = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center, null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView2);
TextView idateTv2 = itemView2.findViewById(R.id.item_center_tv_date);
TextView iconTv2 = itemView2.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv2 = itemView2.findViewById(R.id.item_center_tv_temp);
TextView wind2 = itemView2.findViewById(R.id.item_center_tv_winddirection);
// 获取大后天对应的位置的天气情况
idateTv2.setText(futureList.get_$3().getTime());
iconTv2.setText(futureList.get_$3().getDay_weather());
wind2.setText(futureList.get_$3().getDay_wind_direction());
itemprangeTv2.setText(futureList.get_$3().getMin_degree()+"~"+futureList.get_$3().getMax_degree()+"°C");
View itemView4 = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center,null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView4);
TextView idateTv4 = itemView4.findViewById(R.id.item_center_tv_date);
TextView iconTv4 = itemView4.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv4 = itemView4.findViewById(R.id.item_center_tv_temp);
TextView wind4 = itemView4.findViewById(R.id.item_center_tv_winddirection);
// 获取第四天对应的位置的天气情况
idateTv4.setText(futureList.get_$4().getTime());
iconTv4.setText(futureList.get_$4().getDay_weather());
wind4.setText(futureList.get_$4().getDay_wind_direction());
itemprangeTv4.setText(futureList.get_$4().getMin_degree()+"~"+futureList.get_$4().getMax_degree()+"°C");
View itemView5 = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center,null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView5);
TextView idateTv5 = itemView5.findViewById(R.id.item_center_tv_date);
TextView iconTv5 = itemView5.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv5 = itemView5.findViewById(R.id.item_center_tv_temp);
TextView wind5 = itemView5.findViewById(R.id.item_center_tv_winddirection);
// 获取第五天对应的位置的天气情况
idateTv5.setText(futureList.get_$5().getTime());
iconTv5.setText(futureList.get_$5().getDay_weather());
wind5.setText(futureList.get_$5().getDay_wind_direction());
itemprangeTv5.setText(futureList.get_$5().getMin_degree()+"~"+futureList.get_$5().getMax_degree()+"°C");
View itemView6 = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center,null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView6);
TextView idateTv6 = itemView6.findViewById(R.id.item_center_tv_date);
TextView iconTv6 = itemView6.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv6 = itemView6.findViewById(R.id.item_center_tv_temp);
TextView wind6 = itemView6.findViewById(R.id.item_center_tv_winddirection);
// 获取第六天对应的位置的天气情况
idateTv6.setText(futureList.get_$6().getTime());
iconTv6.setText(futureList.get_$6().getDay_weather());
wind6.setText(futureList.get_$6().getDay_wind_direction());
itemprangeTv6.setText(futureList.get_$6().getMin_degree()+"~"+futureList.get_$6().getMax_degree()+"°C");
View itemView7 = LayoutInflater.from(getActivity()).inflate(R.layout.item_main_center,null);
itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
futureLayout.addView(itemView7);
TextView idateTv7 = itemView7.findViewById(R.id.item_center_tv_date);
TextView iconTv7 = itemView7.findViewById(R.id.item_center_tv_con);
TextView itemprangeTv7 = itemView7.findViewById(R.id.item_center_tv_temp);
TextView wind7 = itemView7.findViewById(R.id.item_center_tv_winddirection);
// 获取第七天对应的位置的天气情况
idateTv7.setText(futureList.get_$7().getTime());
iconTv7.setText(futureList.get_$7().getDay_weather());
wind7.setText(futureList.get_$7().getDay_wind_direction());
itemprangeTv7.setText(futureList.get_$7().getMin_degree()+"~"+futureList.get_$7().getMax_degree()+"°C");
}
// 时间格式化
private String changeTime(String update_time) throws ParseException {
SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMddHHmm");
SimpleDateFormat sf2 =new SimpleDateFormat("yyyy-MM-dd HH:mm");
String sfstr = "";
sfstr = sf2.format(sf1.parse(update_time));
return sfstr;
}
private void initView(View view) {
// 用于初始化控件操作
tipTv = view.findViewById(R.id.frag_tv_tips);
tempTv = view.findViewById(R.id.frag_tv_currenttemp);
cityTv = view.findViewById(R.id.frag_tv_city);
conditionTv = view.findViewById(R.id.frag_tv_condition);
windTv = view.findViewById(R.id.frag_tv_wind);
tempRangeTv = view.findViewById(R.id.frag_tv_temprange);
dateTv = view.findViewById(R.id.frag_tv_date);
clothIndexTv = view.findViewById(R.id.frag_index_tv_dress);
carIndexTv = view.findViewById(R.id.frag_index_tv_washcar);
coldIndexTv = view.findViewById(R.id.frag_index_tv_cold);
sportIndexTv = view.findViewById(R.id.frag_index_tv_sport);
raysIndexTv = view.findViewById(R.id.frag_index_tv_rays);
dayIv = view.findViewById(R.id.frag_iv_today);
futureLayout = view.findViewById(R.id.frag_center_layout);
outLayout = view.findViewById(R.id.out_layout);
umbrellaTv = view.findViewById(R.id.frag_index_tv_umbrella);
// 设置点击事件的监听
clothIndexTv.setOnClickListener(this);
carIndexTv.setOnClickListener(this);
coldIndexTv.setOnClickListener(this);
sportIndexTv.setOnClickListener(this);
raysIndexTv.setOnClickListener(this);
umbrellaTv.setOnClickListener(this);
}
//点击监听事件
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
switch (v.getId()) {
case R.id.frag_index_tv_dress:
builder.setTitle("穿衣指数");
WeatherBean.DataBean.IndexBean.ClothesBean cloth = index.getClothes();
String msg = cloth.getInfo()+"\n"+cloth.getDetail();
builder.setMessage(msg);
builder.setPositiveButton("确定",null);
break;
case R.id.frag_index_tv_washcar:
builder.setTitle("洗车指数");
WeatherBean.DataBean.IndexBean.CarwashBean car = index.getCarwash();
msg = car.getInfo()+"\n"+car.getDetail();
builder.setMessage(msg);
builder.setPositiveButton("确定",null);
break;
case R.id.frag_index_tv_cold:
builder.setTitle("感冒指数");
WeatherBean.DataBean.IndexBean.ColdBean cold = index.getCold();
msg = cold.getInfo()+"\n"+cold.getDetail();
builder.setMessage(msg);
builder.setPositiveButton("确定",null);
break;
case R.id.frag_index_tv_sport:
builder.setTitle("运动指数");
WeatherBean.DataBean.IndexBean.SportsBean sport = index.getSports();
msg = sport.getInfo()+"\n"+sport.getDetail();
builder.setMessage(msg);
builder.setPositiveButton("确定",null);
break;
case R.id.frag_index_tv_rays:
builder.setTitle("紫外线指数");
WeatherBean.DataBean.IndexBean.UltravioletBean ultraviolet = index.getUltraviolet();
msg = ultraviolet.getInfo()+"\n"+ultraviolet.getDetail();
builder.setMessage(msg);
builder.setPositiveButton("确定",null);
break;
case R.id.frag_index_tv_umbrella:
builder.setTitle("雨伞指数");
WeatherBean.DataBean.IndexBean.UmbrellaBean umbrella = index.getUmbrella();
msg = umbrella.getInfo()+"\n"+umbrella.getDetail();
builder.setMessage(msg);
builder.setPositiveButton("确定",null);
break;
}
builder.create().show();
}
}

@ -0,0 +1,184 @@
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import com.example.myapplication.city_manager.CityManagerActivity;
import com.example.myapplication.db.DBManager;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener{
ImageView addCityIv,moreIv;
LinearLayout pointLayout;
RelativeLayout outLayout;
ViewPager mainVp;
// ViewPager的数据源
List<Fragment>fragmentList;
// 表示需要显示的城市的集合
List<String>cityList;
// 表示ViewPager的页数指数器显示集合
List<ImageView>imgList;
private CityFragmentPagerAdapter adapter;
private SharedPreferences pref;
private int bgNum;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
addCityIv = findViewById(R.id.main_iv_add);
moreIv = findViewById(R.id.main_iv_more);
pointLayout = findViewById(R.id.main_layout_point);
outLayout = findViewById(R.id.main_out_layout);
exchangeBg();
mainVp = findViewById(R.id.main_vp);
// 添加点击事件
addCityIv.setOnClickListener(this);
moreIv.setOnClickListener(this);
fragmentList = new ArrayList<>();
// cityList = new ArrayList<>();
cityList = DBManager.queryAllCityName(); //获取数据库包含的城市信息列表
imgList = new ArrayList<>();
if (cityList.size()==0) {
cityList.add("北京");
// cityList.add("上海");
// cityList.add("广东省 广州");
// cityList.add("广东省 深圳");
// cityList.add("福建省 厦门");
}
/* 因为可能搜索界面点击跳转此界面,会传值,所以此处获取一下*/
try {
Intent intent = getIntent();
String city = intent.getStringExtra("city");
if (!cityList.contains(city)&&!TextUtils.isEmpty(city)) {
cityList.add(city);
}
}catch (Exception e){
Log.i("animee","程序出现问题了!!");
}//输出提示性信息,日志
// 初始化ViewPager页面的方法
initPager();
adapter = new CityFragmentPagerAdapter(getSupportFragmentManager(), fragmentList);
mainVp.setAdapter(adapter);
// 创建小圆点指示器
initPoint();
// 设置最后一个城市信息
mainVp.setCurrentItem(fragmentList.size()-1);
// 设置ViewPager页面监听(页面变动小圆点也随之改变)
setPagerListener();
}
// 换壁纸的函数
public void exchangeBg(){
pref = getSharedPreferences("bg_pref", MODE_PRIVATE);
bgNum = pref.getInt("bg", 2);
switch (bgNum) {
case 0:
outLayout.setBackgroundResource(R.mipmap.bg);
break;
case 1:
outLayout.setBackgroundResource(R.mipmap.bg2);
break;
case 2:
outLayout.setBackgroundResource(R.mipmap.bg3);
break;
}
}
private void setPagerListener() {
/* 设置监听事件*/
mainVp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
for (int i = 0; i < imgList.size(); i++) {
imgList.get(i).setImageResource(R.mipmap.a1);
}
imgList.get(position).setImageResource(R.mipmap.a2);
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
}
private void initPoint() {
// 创建小圆点 ViewPager页面指示器的函数
for (int i = 0; i < fragmentList.size(); i++) {
ImageView pIv = new ImageView(this);
pIv.setImageResource(R.mipmap.a1);
pIv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) pIv.getLayoutParams();
lp.setMargins(0,0,20,0);
imgList.add(pIv);
pointLayout.addView(pIv);
}
imgList.get(imgList.size()-1).setImageResource(R.mipmap.a2);
}
private void initPager() {
/* 创建Fragment对象添加到ViewPager数据源当中*/
for (int i = 0; i < cityList.size(); i++) {
CityWeatherFragment cwFrag = new CityWeatherFragment();
Bundle bundle = new Bundle();
bundle.putString("city",cityList.get(i));
//传值
cwFrag.setArguments(bundle);
fragmentList.add(cwFrag);
}
}
@Override
public void onClick(View v) {
Intent intent = new Intent();
switch (v.getId()) {
case R.id.main_iv_add:
intent.setClass(this, CityManagerActivity.class);
break;
case R.id.main_iv_more:
intent.setClass(this,MoreActivity.class);
break;
}
startActivity(intent);
}
/* 当页面重写加载时会调用的函数这个函数在页面获取焦点之前进行调用此处完成ViewPager页数的更新*/
@Override
protected void onRestart() {
super.onRestart();
// 获取数据库当中还剩下的城市集合
List<String> list = DBManager.queryAllCityName();
if (list.size()==0) {
list.add("北京");
}
cityList.clear(); //重写加载之前,清空原本数据源
cityList.addAll(list);
// 剩余城市也要创建对应的fragment页面
fragmentList.clear();
initPager();
adapter.notifyDataSetChanged();
// 页面数量发生改变,指示器的数量也会发生变化,重写设置添加指示器
imgList.clear();
pointLayout.removeAllViews(); //将布局当中所有元素全部移除
initPoint();
mainVp.setCurrentItem(fragmentList.size()-1);
}
}

@ -0,0 +1,171 @@
package com.example.myapplication;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import com.example.myapplication.db.DBManager;
import androidx.appcompat.app.AppCompatActivity;
public class MoreActivity extends AppCompatActivity implements View.OnClickListener{
TextView bgTv,cacheTv,versionTv,shareTv,musicTV,aiTV;
RadioGroup exbgRg;
ImageView backIv;
private SharedPreferences pref;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_more);
bgTv = findViewById(R.id.more_tv_exchangebg);
cacheTv = findViewById(R.id.more_tv_cache);
versionTv = findViewById(R.id.more_tv_version);
shareTv = findViewById(R.id.more_tv_share);
musicTV = findViewById(R.id.more_music);
aiTV = findViewById(R.id.more_tv_ai);
backIv = findViewById(R.id.more_iv_back);
exbgRg = findViewById(R.id.more_rg);
bgTv.setOnClickListener(this);
cacheTv.setOnClickListener(this);
shareTv.setOnClickListener(this);
backIv.setOnClickListener(this);
musicTV.setOnClickListener(this);
aiTV.setOnClickListener(this);
pref = getSharedPreferences("bg_pref", MODE_PRIVATE);
String versionName = getVersionName();
versionTv.setText("当前版本: v"+"2.0");
setRGListener();
}
private void setRGListener() {
/* 设置改变背景图片的单选按钮的监听*/
exbgRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// 获取目前的默认壁纸
int bg = pref.getInt("bg", 0);
SharedPreferences.Editor editor = pref.edit();
Intent intent = new Intent(MoreActivity.this,MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
switch (checkedId) {
case R.id.more_rb_green:
if (bg==0) {
Toast.makeText(MoreActivity.this,"您选择的为当前背景,无需改变!",Toast.LENGTH_SHORT).show();
return;
}
editor.putInt("bg",0);
editor.commit();
break;
case R.id.more_rb_pink:
if (bg==1) {
Toast.makeText(MoreActivity.this,"您选择的为当前背景,无需改变!",Toast.LENGTH_SHORT).show();
return;
}
editor.putInt("bg",1);
editor.commit();
break;
case R.id.more_rb_blue:
if (bg==2) {
Toast.makeText(MoreActivity.this,"您选择的为当前背景,无需改变!",Toast.LENGTH_SHORT).show();
return;
}
editor.putInt("bg",2);
editor.commit();
break;
}
startActivity(intent);
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.more_iv_back:
finish();
break;
case R.id.more_tv_cache:
clearCache();
break;
case R.id.more_tv_share:
shareSoftwareMsg("天气预报app是一款超萌超可爱的天气预报软件画面简约播报天气情况非常精准快来下载吧");
break;
case R.id.more_tv_exchangebg:
if (exbgRg.getVisibility() == View.VISIBLE) {
exbgRg.setVisibility(View.GONE);
}else{
exbgRg.setVisibility(View.VISIBLE);
}
break;
case R.id.more_music:
startAi();
break;
case R.id.more_tv_ai:
startBgm();
break;
}
}
private void shareSoftwareMsg(String s) {
/* 分享软件的函数*/
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,s);
startActivity(Intent.createChooser(intent,"天气预报"));
}
private void clearCache() {
/* 清除缓存的函数*/
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("提示信息").setMessage("确定要删除所有缓存么?");
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
DBManager.deleteAllInfo();
Toast.makeText(MoreActivity.this,"已清除全部缓存!",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MoreActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}).setNegativeButton("取消",null);
builder.create().show();
}
private void startBgm(){
Intent intent = new Intent();
}
private void startAi(){
}
public String getVersionName() {
/* 获取应用的版本名称*/
PackageManager manager = getPackageManager();
String versionName = null;
try {
PackageInfo info = manager.getPackageInfo(getPackageName(), 0);
versionName = info.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return versionName;
}
}

@ -0,0 +1,16 @@
package com.example.myapplication;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class Test {
public static void main(String arg[]) throws ParseException {
String str="202009222245";
SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMddHHmm");
SimpleDateFormat sf2 =new SimpleDateFormat("yyyy-MM-dd HH:mm");
String sfstr = "";
sfstr = sf2.format(sf1.parse(str));
System.out.println(sfstr);
}
}

@ -0,0 +1,35 @@
package com.example.myapplication.base;
import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;
import androidx.appcompat.app.AppCompatActivity;
public class BaseActivity extends AppCompatActivity implements Callback.CommonCallback<String>{
public void loadData(String url){
RequestParams params = new RequestParams(url);
x.http().get(params,this);
}
@Override
public void onSuccess(String result) {
}
@Override
public void onError(Throwable ex, boolean isOnCallback) {
}
@Override
public void onCancelled(CancelledException cex) {
}
@Override
public void onFinished() {
}
}

@ -0,0 +1,39 @@
package com.example.myapplication.base;
import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;
import androidx.fragment.app.Fragment;
/*xutils
* 1.
* 2.
* */
public class BaseFragment extends Fragment implements Callback.CommonCallback<String>{
public void loadData(String path){
RequestParams params = new RequestParams(path);
x.http().get(params,this);
}
// 获取数据成功时,会回调的接口
@Override
public void onSuccess(String result) {
}
// 获取数据失败时,会调用的接口
@Override
public void onError(Throwable ex, boolean isOnCallback) {
}
// 取消请求时,会调用的接口
@Override
public void onCancelled(CancelledException cex) {
}
// 请求完成后,会回调的接口
@Override
public void onFinished() {
}
}

@ -0,0 +1,15 @@
package com.example.myapplication.base;
import android.app.Application;
import com.example.myapplication.db.DBManager;
import org.xutils.x;
public class UniteApp extends Application {
@Override
public void onCreate() {
super.onCreate();
x.Ext.init(this);
DBManager.initDB(this);
}
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,69 @@
package com.example.myapplication.city_manager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;
import com.example.myapplication.R;
import com.example.myapplication.db.DBManager;
import com.example.myapplication.db.DatabaseBean;
import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;
public class CityManagerActivity extends AppCompatActivity implements View.OnClickListener{
ImageView addIv,backIv,deleteIv;
ListView cityLv;
List<DatabaseBean> mDatas; //显示列表数据源
private CityManagerAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_city_manager);
addIv = findViewById(R.id.city_iv_add);
backIv = findViewById(R.id.city_iv_back);
deleteIv = findViewById(R.id.city_iv_delete);
cityLv = findViewById(R.id.city_lv);
mDatas = new ArrayList<>();
// 添加点击监听事件
addIv.setOnClickListener(this);
deleteIv.setOnClickListener(this);
backIv.setOnClickListener(this);
// 设置适配器
adapter = new CityManagerAdapter(this, mDatas);
cityLv.setAdapter(adapter);
}
/* 获取数据库当中真实数据源,添加到原有数据源当中,提示适配器更新*/
@Override
protected void onResume() {
super.onResume();
List<DatabaseBean> list = DBManager.queryAllInfo();
mDatas.clear();
mDatas.addAll(list);
adapter.notifyDataSetChanged();
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.city_iv_add:
int cityCount = DBManager.getCityCount();
if (cityCount<5) {
Intent intent = new Intent(this, SearchCityActivity.class);
startActivity(intent);
}else {
Toast.makeText(this,"存储城市数量已达上限,请删除后再增加",Toast.LENGTH_SHORT).show();
}
break;
case R.id.city_iv_back:
finish();
break;
case R.id.city_iv_delete:
Intent intent1 = new Intent(this, DeleteCityActivity.class);
startActivity(intent1);
break;
}
}
}

@ -0,0 +1,89 @@
package com.example.myapplication.city_manager;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.myapplication.R;
import com.example.myapplication.bean.WeatherBean;
import com.example.myapplication.db.DatabaseBean;
import com.google.gson.Gson;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
public class CityManagerAdapter extends BaseAdapter{
Context context;
List<DatabaseBean>mDatas;
public CityManagerAdapter(Context context, List<DatabaseBean> mDatas) {
this.context = context;
this.mDatas = mDatas;
}
@Override
public int getCount() {
return mDatas.size();
}
@Override
public Object getItem(int position) {
return mDatas.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_city_manager,null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
DatabaseBean bean = mDatas.get(position);
holder.cityTv.setText(bean.getCity());
WeatherBean weatherBean = new Gson().fromJson(bean.getContent(), WeatherBean.class);
// 获取今日天气情况
WeatherBean.DataBean.ObserveBean dataBean = weatherBean.getData().getObserve();
holder.conTv.setText("天气 : "+dataBean.getWeather_short());
holder.currentTempTv.setText(dataBean.getDegree()+"°C");
holder.windTv.setText("湿度 "+dataBean.getHumidity()+"% ");
try {
holder.tempRangeTv.setText(changeTime(dataBean.getUpdate_time()));
} catch (ParseException e) {
e.printStackTrace();
}
return convertView;
}
// 时间格式化
private String changeTime(String update_time) throws ParseException {
SimpleDateFormat sf1 = new SimpleDateFormat("yyyyMMddHHmm");
SimpleDateFormat sf2 =new SimpleDateFormat("yyyy-MM-dd HH:mm");
String sfstr = "";
sfstr = sf2.format(sf1.parse(update_time));
return sfstr;
}
class ViewHolder{
TextView cityTv,conTv,currentTempTv,windTv,tempRangeTv;
public ViewHolder(View itemView){
cityTv = itemView.findViewById(R.id.item_city_tv_city);
conTv = itemView.findViewById(R.id.item_city_tv_condition);
currentTempTv = itemView.findViewById(R.id.item_city_tv_temp);
windTv = itemView.findViewById(R.id.item_city_wind);
tempRangeTv = itemView.findViewById(R.id.item_city_temprange);
}
}
}

@ -0,0 +1,67 @@
package com.example.myapplication.city_manager;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import com.example.myapplication.R;
import com.example.myapplication.db.DBManager;
import java.util.ArrayList;
import java.util.List;
import androidx.appcompat.app.AppCompatActivity;
public class DeleteCityActivity extends AppCompatActivity implements View.OnClickListener{
ImageView errorIv,rightIv;
ListView deleteLv;
List<String>mDatas; //listview的数据源
List<String>deleteCitys; //表示存储了删除的城市信息
private DeleteCityAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_delete_city);
errorIv = findViewById(R.id.delete_iv_error);
rightIv = findViewById(R.id.delete_iv_right);
deleteLv = findViewById(R.id.delete_lv);
mDatas = DBManager.queryAllCityName();
deleteCitys = new ArrayList<>();
// 设置点击监听事件
errorIv.setOnClickListener(this);
rightIv.setOnClickListener(this);
// 适配器的设置
adapter = new DeleteCityAdapter(this, mDatas, deleteCitys);
deleteLv.setAdapter(adapter);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.delete_iv_error:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("提示信息").setMessage("您确定要舍弃更改么?")
.setPositiveButton("舍弃更改", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish(); //关闭当前的activity
}
});
builder.setNegativeButton("取消",null);
builder.create().show();
break;
case R.id.delete_iv_right:
for (int i = 0; i < deleteCitys.size(); i++) {
String city = deleteCitys.get(i);
// 调用删除城市的函数
int i1 = DBManager.deleteInfoByCity(city);
}
// 删除成功返回上一级页面
finish();
break;
}
}
}

@ -0,0 +1,70 @@
package com.example.myapplication.city_manager;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.myapplication.R;
import java.util.List;
public class DeleteCityAdapter extends BaseAdapter{
Context context;
List<String>mDatas;
List<String>deleteCitys;
public DeleteCityAdapter(Context context, List<String> mDatas,List<String>deleteCitys) {
this.context = context;
this.mDatas = mDatas;
this.deleteCitys = deleteCitys;
}
@Override
public int getCount() {
return mDatas.size();
}
@Override
public Object getItem(int position) {
return mDatas.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.item_deletecity,null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
}else{
holder = (ViewHolder) convertView.getTag();
}
final String city = mDatas.get(position);
holder.tv.setText(city);
holder.iv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDatas.remove(city);
deleteCitys.add(city);
notifyDataSetChanged(); //删除了提示适配器更新
}
});
return convertView;
}
class ViewHolder{
TextView tv;
ImageView iv;
public ViewHolder(View itemView){
tv = itemView.findViewById(R.id.item_delete_tv);
iv = itemView.findViewById(R.id.item_delete_iv);
}
}
}

@ -0,0 +1,109 @@
package com.example.myapplication.city_manager;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.Toast;
import com.example.myapplication.MainActivity;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseActivity;
import com.example.myapplication.bean.WeatherBean;
import com.google.gson.Gson;
public class SearchCityActivity extends BaseActivity implements View.OnClickListener{
EditText searchEt;
ImageView submitIv;
GridView searchGv;
String[]hotCitys = {"北京","上海","广州","深圳","珠海","佛山","南京","苏州","厦门",
"长沙","成都","福州","杭州","武汉","青岛","西安","太原","沈阳","重庆","天津","南宁","运城","郑州","北海"};
private ArrayAdapter<String> adapter;
//腾讯api
String url1 = "https://wis.qq.com/weather/common?source=pc&weather_type=observe|index|rise|alarm|air|tips|forecast_24h&province=";
String url2 = "&city=";
String city;
String provice;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_city);
searchEt = findViewById(R.id.search_et);
submitIv = findViewById(R.id.search_iv_submit);
searchGv = findViewById(R.id.search_gv);
submitIv.setOnClickListener(this);
// 设置适配器
adapter = new ArrayAdapter<>(this, R.layout.item_hotcity, hotCitys);
searchGv.setAdapter(adapter);
setListener();
}
/* 设置监听事件*/
private void setListener() {
searchGv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
city = hotCitys[position];
// 获取省份
provice=GetProvice(city);
String url = url1+provice+url2+city;
loadData(url);
}
});
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.search_iv_submit:
city = searchEt.getText().toString();
if (!TextUtils.isEmpty(city)) {
// 判断是否能够找到这个城市
provice=GetProvice(city);
String url = url1+provice+url2+city;
loadData(url);
}else {
Toast.makeText(this,"输入内容不能为空!",Toast.LENGTH_SHORT).show();
}
break;
}
}
@Override
public void onSuccess(String result) {
WeatherBean weatherBean = new Gson().fromJson(result, WeatherBean.class);
if (weatherBean.getData().getIndex().getClothes()!=null) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_NEW_TASK);
city=provice+" "+city;
intent.putExtra("city",city);
startActivity(intent);
}else{
Toast.makeText(this,"暂时未收入此城市天气信息...",Toast.LENGTH_SHORT).show();
}
}
private String GetProvice(String city) {
String[]Citys = {"北京","上海","广东省 广州","广东省 深圳","广东省 珠海","广东省 佛山",
"江苏省 南京","江苏省 苏州","福建省 厦门","湖南省 长沙","四川省 成都","福建省 福州","浙江省 杭州",
"湖北省 武汉","山东省 青岛","陕西省 西安","山西省 太原","辽宁省 沈阳","重庆","天津","广西省 南宁","广西省 北海"};
for(int i=0;i<Citys.length;i++){
if(Citys[i].contains(city)){
if(Citys[i].split(" ").length>1)
{ provice =Citys[i].split(" ")[0];
}
else
{
provice = Citys[i].split(" ")[0];
}
break;
}
}
return provice;
}
}

@ -0,0 +1,23 @@
package com.example.myapplication.db;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHelper extends SQLiteOpenHelper{
public DBHelper(Context context){
super(context,"forecast.db",null,1);
}
@Override
public void onCreate(SQLiteDatabase db) {
// 创建表的操作
String sql = "create table info(_id integer primary key autoincrement,city varchar(20) unique not null,content text not null)";
db.execSQL(sql);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}

@ -0,0 +1,83 @@
package com.example.myapplication.db;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import java.util.ArrayList;
import java.util.List;
public class DBManager {
public static SQLiteDatabase database;
/* 初始化数据库信息*/
public static void initDB(Context context){
DBHelper dbHelper = new DBHelper(context);
database = dbHelper.getWritableDatabase();
}
/* 查找数据库当中城市列表*/
public static List<String>queryAllCityName(){
Cursor cursor = database.query("info", null, null, null, null, null,null);
List<String>cityList = new ArrayList<>();
while (cursor.moveToNext()) {
String city = cursor.getString(cursor.getColumnIndex("city"));
cityList.add(city);
}
return cityList;
}
/* 根据城市名称,替换信息内容*/
public static int updateInfoByCity(String city,String content){
ContentValues values = new ContentValues();
values.put("content",content);
return database.update("info",values,"city=?",new String[]{city});
}
/* 新增一条城市记录*/
public static long addCityInfo(String city,String content){
ContentValues values = new ContentValues();
values.put("city",city);
values.put("content",content);
return database.insert("info",null,values);
}
/* 根据城市名,查询数据库当中的内容*/
public static String queryInfoByCity(String city){
Cursor cursor = database.query("info", null, "city=?", new String[]{city}, null, null, null);
if (cursor.getCount()>0) {
cursor.moveToFirst();
String content = cursor.getString(cursor.getColumnIndex("content"));
return content;
}
return null;
}
/* 存储城市天气要求最多存储5个城市的信息一旦超过5个城市就不能存储了获取目前已经存储的数量*/
public static int getCityCount(){
Cursor cursor = database.query("info", null, null, null, null, null, null);
int count = cursor.getCount();
return count;
}
/* 查询数据库当中的全部信息*/
public static List<DatabaseBean>queryAllInfo(){
Cursor cursor = database.query("info", null, null, null, null, null, null);
List<DatabaseBean>list = new ArrayList<>();
while (cursor.moveToNext()) {
int id = cursor.getInt(cursor.getColumnIndex("_id"));
String city = cursor.getString(cursor.getColumnIndex("city"));
String content = cursor.getString(cursor.getColumnIndex("content"));
DatabaseBean bean = new DatabaseBean(id, city, content);
list.add(bean);
}
return list;
}
/* 根据城市名称,删除这个城市在数据库当中的数据*/
public static int deleteInfoByCity(String city){
return database.delete("info","city=?",new String[]{city});
}
/* 删除表当中所有的数据信息*/
public static void deleteAllInfo(){
String sql = "delete from info";
database.execSQL(sql);
}
}

@ -0,0 +1,40 @@
package com.example.myapplication.db;
public class DatabaseBean {
private int _id;
private String city;
private String content;
public DatabaseBean() {
}
public DatabaseBean(int _id, String city, String content) {
this._id = _id;
this.city = city;
this.content = content;
}
public int get_id() {
return _id;
}
public void set_id(int _id) {
this._id = _id;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeWidth="1"
android:strokeColor="#00000000">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

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

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp"></corners>
<solid android:color="#83D3F8"></solid>
</shape>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="3dp"></corners>
<solid android:color="#FAFFF0"/>
</shape>

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#008577"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

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

@ -0,0 +1,56 @@
<?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="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bigcitysky">
<RelativeLayout
android:id="@+id/city_top_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#F5F5F5">
<ImageView
android:id="@+id/city_iv_back"
android:layout_marginLeft="10dp"
android:src="@mipmap/icon_back"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<ImageView
android:id="@+id/city_iv_delete"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/icon_write"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"/>
<TextView
android:id="@+id/city_tv_title"
android:text="城市管理"
android:textSize="18sp"
android:textStyle="bold"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<ImageView
android:id="@+id/city_line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DCDCDC"
android:layout_below="@id/city_top_layout"/>
<ListView
android:id="@+id/city_lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/city_line"
android:divider="@null"></ListView>
<ImageView
android:id="@+id/city_iv_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/icon_add"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_margin="30dp"
android:background="#FFF0F0"
android:padding="3dp" />
</RelativeLayout>

@ -0,0 +1,46 @@
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg6"
android:orientation="vertical"
tools:context=".city_manager.DeleteCityActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#F5F5F5"
android:id="@+id/delete_top_layout">
<ImageView
android:id="@+id/delete_iv_error"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/icon_error"
android:layout_marginLeft="5dp"/>
<ImageView
android:id="@+id/delete_iv_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/icon_right"
android:layout_alignParentRight="true"
android:layout_marginRight="5dp"/>
<TextView
android:id="@+id/delete_tv_title"
android:text="城市管理"
android:layout_centerInParent="true"
android:textSize="18sp"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#DCDCDC"/>
<ListView
android:id="@+id/delete_lv"
android:divider="@null"
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</LinearLayout>

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_out_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg">
<RelativeLayout
android:id="@+id/main_bottom_layout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/main_iv_add"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/icon_add"/>
<ImageView
android:id="@+id/main_iv_more"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/icon_more"
android:layout_alignParentRight="true"/>
<LinearLayout
android:id="@+id/main_layout_point"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerInParent="true">
</LinearLayout>
</RelativeLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/main_vp"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_above="@id/main_bottom_layout">
</androidx.viewpager.widget.ViewPager>
</RelativeLayout>

@ -0,0 +1,170 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/snow"
tools:context=".MoreActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#F5F5F5"
android:id="@+id/more_top_layout">
<ImageView
android:id="@+id/more_iv_back"
android:layout_width="wrap_content"
android:src="@mipmap/icon_back"
android:layout_marginLeft="10dp"
android:layout_height="match_parent" />
<TextView
android:id="@+id/more_tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="更多设置"
android:textStyle="bold"
android:textSize="18sp"
android:layout_centerInParent="true"/>
</RelativeLayout>
<ImageView
android:id="@+id/more_line1"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/more_top_layout"
android:background="#dcdcdc"
/>
<TextView
android:id="@+id/more_tv_exchangebg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="改变壁纸"
android:textSize="18sp"
android:drawableLeft="@mipmap/more_bg"
android:layout_below="@id/more_line1"
android:drawablePadding="20dp"
android:padding="10dp"/>
<ImageView
android:id="@+id/more_line2"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/more_tv_exchangebg"
android:background="#DCDCDC"/>
<RadioGroup
android:id="@+id/more_rg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/more_line2"
android:visibility="gone"
android:orientation="horizontal">
<RadioButton
android:id="@+id/more_rb_green"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="#C5EDD1"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:text="青瓦白墙"
android:textStyle="bold"/>
<RadioButton
android:id="@+id/more_rb_pink"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="#FCAFAE"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:text="粉状玉砌"
android:textStyle="bold"/>
<RadioButton
android:id="@+id/more_rb_blue"
android:layout_width="0dp"
android:layout_height="40dp"
android:background="#87CEEB"
android:layout_weight="1"
android:button="@null"
android:gravity="center"
android:text="蓝色梦想"
android:textStyle="bold"/>
</RadioGroup>
<TextView
android:id="@+id/more_tv_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="当前版本"
android:textSize="18sp"
android:drawableLeft="@mipmap/more_version"
android:layout_below="@id/more_rg"
android:drawablePadding="20dp"
android:padding="10dp"/>
<ImageView
android:id="@+id/more_line3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/more_tv_version"
android:background="#DCDCDC"/>
<TextView
android:id="@+id/more_tv_cache"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="清除缓存"
android:textSize="18sp"
android:drawableLeft="@mipmap/more_cache"
android:layout_below="@id/more_line3"
android:drawablePadding="20dp"
android:padding="10dp"/>
<ImageView
android:id="@+id/more_line4"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/more_tv_cache"
android:background="#DCDCDC"/>
<TextView
android:id="@+id/more_tv_share"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="分享软件"
android:textSize="18sp"
android:drawableLeft="@mipmap/more_share"
android:layout_below="@id/more_line4"
android:drawablePadding="20dp"
android:padding="10dp"/>
<ImageView
android:id="@+id/more_line5"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/more_tv_share"
android:background="#dcdcdc" />
<TextView
android:id="@+id/more_tv_ai"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/more_line5"
android:drawableLeft="@mipmap/more_music"
android:drawablePadding="20dp"
android:padding="10dp"
android:text="音乐播放器"
android:textSize="18sp" />
<ImageView
android:id="@+id/more_line6"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@id/more_tv_ai"
android:background="#dcdcdc" />
<TextView
android:id="@+id/more_music"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="@+id/more_line6"
android:drawableLeft="@mipmap/more_ai1"
android:drawablePadding="20dp"
android:padding="10dp"
android:text="Siri同学(人工智障)"
android:textSize="18sp" />
</RelativeLayout>

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg6"
android:padding="10dp">
<ImageView
android:id="@+id/search_iv_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginLeft="5dp"
android:src="@mipmap/icon_search"/>
<EditText
android:id="@+id/search_et"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp"
android:layout_toLeftOf="@id/search_iv_submit"
android:hint="搜索国内城市:"
android:background="@drawable/searchbg"/>
<TextView
android:id="@+id/search_tv"
android:layout_below="@id/search_et"
android:layout_marginTop="20dp"
android:textSize="16sp"
android:textStyle="bold"
android:text="热门城市"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<GridView
android:id="@+id/search_gv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/search_tv"
android:numColumns="3"
></GridView>
</RelativeLayout>

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg"
android:id="@+id/out_layout">
<LinearLayout
android:id="@+id/frag_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/frag_tv_tips"
style="@style/todaytext"
android:text="✌待到初雪落,故人应当归✌"
android:layout_marginTop="8dp"
android:layout_marginLeft="85dp"
android:textSize="20sp"
android:typeface="serif"
/>
<TextView
android:id="@+id/frag_tv_city"
style="@style/todaytext"
android:text="广西省 南宁"
android:layout_marginLeft="168dp"
android:textSize="25sp"
android:layout_below="@+id/frag_tv_tips"
/>
<TextView
android:id="@+id/frag_tv_currenttemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="30℃"
android:textSize="70sp"
android:textStyle="bold"
android:layout_below="@id/frag_tv_condition"
android:layout_marginLeft="120dp"
/>
<TextView
android:id="@+id/frag_tv_condition"
style="@style/todaytext"
android:text="晴天"
android:layout_below="@id/frag_tv_city"
android:layout_marginLeft="176dp"/>
<TextView
android:id="@+id/frag_tv_date"
android:text="2021-05-01"
android:layout_marginTop="10dp"
style="@style/todaytext"
android:layout_below="@+id/frag_tv_temprange"
android:layout_marginLeft="125dp"
/>
<TextView
android:id="@+id/frag_tv_wind"
style="@style/todaytext"
android:layout_below="@id/frag_tv_currenttemp"
android:layout_marginTop="5dp"
android:text="湿度 83%"
android:layout_marginLeft="90dp"
/>
<TextView
android:id="@+id/frag_tv_line1"
android:layout_width="2dp"
android:layout_height="25dp"
android:layout_toRightOf="@id/frag_tv_wind"
android:background="#2E8B40"
android:layout_alignBottom="@id/frag_tv_wind"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"/>
<TextView
android:id="@+id/frag_tv_temprange"
style="@style/todaytext"
android:text="气压 1003hPa"
android:layout_toRightOf="@id/frag_tv_line1"
android:layout_alignBottom="@id/frag_tv_wind"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:layout_margin="10dp"
android:background="@drawable/frag_bg1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="👇今日外出游玩指南👇"
style="@style/indextext"
android:layout_gravity="center"></TextView>
</LinearLayout>
<!-- 用于表示指数信息的线性布局-->
<LinearLayout
android:id="@+id/frag_index_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@drawable/frag_bg"
android:padding="10dp"
android:layout_marginTop="-11dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/frag_index_tv_dress"
style="@style/indextext"
android:text="穿衣指数"
android:drawableBottom="@mipmap/icon_cloth"/>
<ImageView
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#E0E0E0"/>
<TextView
android:id="@+id/frag_index_tv_washcar"
style="@style/indextext"
android:text="洗车指数"
android:drawableBottom="@mipmap/icon_car"/>
<ImageView
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#E0E0E0"/>
<TextView
android:id="@+id/frag_index_tv_cold"
style="@style/indextext"
android:text="感冒指数"
android:drawableBottom="@mipmap/icon_ganmao"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#E0E0E0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/frag_index_tv_sport"
style="@style/indextext"
android:text="运动指数"
android:drawableBottom="@mipmap/icon_sport"/>
<ImageView
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#E0E0E0"/>
<TextView
android:id="@+id/frag_index_tv_rays"
style="@style/indextext"
android:text="紫外线指数"
android:drawableBottom="@mipmap/icon_light"/>
<ImageView
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#E0E0E0"/>
<TextView
android:id="@+id/frag_index_tv_umbrella"
style="@style/indextext"
android:text="雨伞指数"
android:drawableBottom="@mipmap/icon_umbrella"/>
</LinearLayout>
</LinearLayout>
<pl.droidsonroids.gif.GifImageView
android:layout_width="120dp"
android:layout_height="120dp"
android:id="@+id/frag_iv_today"
android:scaleType="centerCrop"
android:layout_alignParentRight="true"
android:src="@mipmap/gificon"
android:layout_gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
android:layout_marginTop="15dp"
android:background="@drawable/frag_bg1"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="👇近七天的天气情况👇"
style="@style/indextext"
android:layout_gravity="center"></TextView>
</LinearLayout>
<!-- 用于显示未来七天的天气情况-->
<LinearLayout
android:id="@+id/frag_center_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp"
android:background="@drawable/frag_bg"
android:layout_marginTop="0dp"
></LinearLayout>
</LinearLayout>
</ScrollView>

@ -0,0 +1,79 @@
<?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"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<androidx.cardview.widget.CardView
android:id="@+id/item_city_cv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="3dp"
app:cardCornerRadius="10dp"
app:cardElevation="5dp"
app:contentPadding="10dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/bg4">
<TextView
android:id="@+id/item_city_tv_city"
android:layout_marginTop="12dp"
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="30sp"
android:text="北京"/>
<TextView
android:id="@+id/item_city_tv_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:text="12℃"/>
<ImageView
android:id="@+id/item_city_line1"
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_below="@id/item_city_tv_temp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="#2E8B57"/>
<TextView
android:id="@+id/item_city_tv_condition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_below="@id/item_city_line1"
android:text="天气:晴"/>
<TextView
android:id="@+id/item_city_line2"
android:layout_width="2dp"
android:layout_height="20dp"
android:layout_toRightOf="@id/item_city_tv_condition"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#2E8B57"
android:layout_below="@id/item_city_line1"/>
<TextView
android:id="@+id/item_city_wind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_toRightOf="@id/item_city_line2"
android:layout_below="@id/item_city_line1"
android:text="西南风2级"/>
<TextView
android:id="@+id/item_city_temprange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/item_city_line1"
android:textSize="16sp"
android:layout_alignParentRight="true"
android:text="16~9℃"
android:layout_marginRight="20dp"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

@ -0,0 +1,40 @@
<?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"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="5dp">
<androidx.cardview.widget.CardView
android:id="@+id/item_delete_cv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:cardElevation="5dp"
app:cardCornerRadius="10dp"
app:contentPadding="20dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:id="@+id/item_delete_iv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/icon_laji"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
/>
<TextView
android:id="@+id/item_delete_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="北京"
android:textSize="20sp"
android:layout_toRightOf="@id/item_delete_iv"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textStyle="bold"/>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:gravity="center"
android:text="北京"
android:background="@drawable/hotbg">
</TextView>

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:padding="5dp">
<TextView
android:id="@+id/item_center_tv_date"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:text="周六"
android:textSize="16sp"/>
<TextView
android:id="@+id/item_center_tv_con"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="晴"
android:textSize="16sp"
android:layout_toRightOf="@id/item_center_tv_date"
android:layout_marginLeft="10dp"/>
<TextView
android:id="@+id/item_center_tv_winddirection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="微风"
android:textSize="16sp"
android:layout_toRightOf="@+id/item_center_tv_con"
android:layout_marginLeft="2dp"/>
<TextView
android:id="@+id/item_center_tv_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:layout_alignParentRight="true"
android:text="9~-1℃"/>
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="@+id/item_center_iv"
android:layout_toLeftOf="@id/item_center_tv_temp"
android:layout_marginRight="10dp"
android:src="@mipmap/icon_add"/>
<TextView
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#E0E0E0"
android:layout_below="@id/item_center_tv_date"
android:layout_marginTop="5dp"/>
</RelativeLayout>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 466 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save