@ -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
|
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1 @@
|
||||
Simulate Positioning
|
@ -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,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/app/src/main/java/com/example/simulatepositioning/MainActivity.java" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="delegatedBuild" value="false" />
|
||||
<option name="testRunner" value="GRADLE" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="Embedded JDK" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,25 @@
|
||||
<?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="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="11" 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 @@
|
||||
Subproject commit db82b3668a6a8e8edbdb82638d55b99135ce7809
|
@ -0,0 +1 @@
|
||||
/build
|
@ -0,0 +1,49 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 33
|
||||
defaultConfig {
|
||||
applicationId "com.example.simulatepositioning"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 33
|
||||
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 'com.amap.api:3dmap:9.2.0'
|
||||
implementation 'com.amap.api:search:9.2.0'
|
||||
implementation 'com.amap.api:location:6.1.0'
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
implementation 'com.android.volley:volley:1.2.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
|
||||
implementation 'liji.library.dev:citypickerview:0.7.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
|
||||
implementation ('com.amap.api:location:6.3.0') {
|
||||
exclude group: 'com.amap.api', module: '3dmap'
|
||||
}
|
||||
configurations {
|
||||
all*.exclude group:'com.google.code.gson', module:'gson' //exclude排除某项库
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
|
||||
implementation 'com.android.support:support-annotations:28.0.0'
|
||||
//noinspection GradleCompatible
|
||||
implementation 'com.android.support:recyclerview-v7:28.0.0'
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
|
||||
}
|
@ -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.simulatepositioning;
|
||||
|
||||
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.simulatepositioning", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.example.simulatepositioning;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.SQLException;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class DatabaseHelper extends SQLiteOpenHelper {
|
||||
|
||||
public DatabaseHelper(@Nullable Context context) {//构造方法
|
||||
super(context, "citydb", null, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
String sql="create table citys(id INTEGER primary key autoincrement,city varchar(30) not null)";
|
||||
try {
|
||||
db.execSQL("drop table if exists citys");//执行数据库命令
|
||||
db.execSQL(sql);//执行数据库命令
|
||||
}catch (SQLException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion ) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.example.simulatepositioning;
|
||||
|
||||
public class ForeCast {
|
||||
private String date;
|
||||
private String week;
|
||||
private String dayweather;
|
||||
private String nightweather;
|
||||
private String daytemp;
|
||||
private String nighttemp;
|
||||
private String daywind;
|
||||
private String nightwind;
|
||||
private String daypower;
|
||||
private String nightpower;
|
||||
|
||||
public ForeCast() {
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public ForeCast(String date, String week, String dayweather, String nightweather, String daytemp, String nighttemp, String daywind, String nightwind, String daypower, String nightpower) {
|
||||
this.date = date;
|
||||
this.week = week;
|
||||
this.dayweather = dayweather;
|
||||
this.nightweather = nightweather;
|
||||
this.daytemp = daytemp;
|
||||
this.nighttemp = nighttemp;
|
||||
this.daywind = daywind;
|
||||
this.nightwind = nightwind;
|
||||
this.daypower = daypower;
|
||||
this.nightpower = nightpower;
|
||||
}
|
||||
|
||||
public void setDate(String date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public String getWeek() {
|
||||
return week;
|
||||
}
|
||||
|
||||
public void setWeek(String week) {
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public String getDayweather() {
|
||||
return dayweather;
|
||||
}
|
||||
|
||||
public void setDayweather(String dayweather) {
|
||||
this.dayweather = dayweather;
|
||||
}
|
||||
|
||||
public String getNightweather() {
|
||||
return nightweather;
|
||||
}
|
||||
|
||||
public void setNightweather(String nightweather) {
|
||||
this.nightweather = nightweather;
|
||||
}
|
||||
|
||||
public String getDaytemp() {
|
||||
return daytemp;
|
||||
}
|
||||
|
||||
public void setDaytemp(String daytemp) {
|
||||
this.daytemp = daytemp;
|
||||
}
|
||||
|
||||
public String getNighttemp() {
|
||||
return nighttemp;
|
||||
}
|
||||
|
||||
public void setNighttemp(String nighttemp) {
|
||||
this.nighttemp = nighttemp;
|
||||
}
|
||||
|
||||
public String getDaywind() {
|
||||
return daywind;
|
||||
}
|
||||
|
||||
public void setDaywind(String daywind) {
|
||||
this.daywind = daywind;
|
||||
}
|
||||
|
||||
public String getNightwind() {
|
||||
return nightwind;
|
||||
}
|
||||
|
||||
public void setNightwind(String nightwind) {
|
||||
this.nightwind = nightwind;
|
||||
}
|
||||
|
||||
public String getDaypower() {
|
||||
return daypower;
|
||||
}
|
||||
|
||||
public void setDaypower(String daypower) {
|
||||
this.daypower = daypower;
|
||||
}
|
||||
|
||||
public String getNightpower() {
|
||||
return nightpower;
|
||||
}
|
||||
|
||||
public void setNightpower(String nightpower) {
|
||||
this.nightpower = nightpower;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.example.simulatepositioning;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.*;
|
||||
|
||||
public class UserDao {
|
||||
private DatabaseHelper dbhelper;
|
||||
private SQLiteDatabase db;//增删改查的操作
|
||||
|
||||
UserDao(Context context){
|
||||
dbhelper=new DatabaseHelper(context);
|
||||
}
|
||||
|
||||
public void insert(String city){//添加数据
|
||||
ContentValues values =new ContentValues();
|
||||
values.put("city",city);
|
||||
db=dbhelper.getWritableDatabase();
|
||||
db.insert("citys",null,values);
|
||||
db.close();
|
||||
}
|
||||
|
||||
// 数据修改
|
||||
public void update(String city){
|
||||
db=dbhelper.getWritableDatabase();
|
||||
ContentValues values=new ContentValues();
|
||||
values.put("city",city);
|
||||
db.update("citys",values,"city=?",new String[]{String.valueOf(city)});
|
||||
db.close();
|
||||
}
|
||||
|
||||
// 数据删除
|
||||
public void delete(String city){
|
||||
db=dbhelper.getWritableDatabase();
|
||||
db.delete("citys","city=?",new String[]{city});
|
||||
// db.execSQL("delete from citys where city=" + city);
|
||||
db.close();
|
||||
}
|
||||
// 查询全部数据
|
||||
public List<String> getAll(){
|
||||
List<String> city=new ArrayList<>();
|
||||
db=dbhelper.getReadableDatabase();
|
||||
Cursor cursor = db.query("citys",new String[]{"id","city"},null,
|
||||
null,null,null,null);
|
||||
if (cursor.getCount()>0){
|
||||
while (cursor.moveToNext()){
|
||||
System.out.println("测试输出:"+cursor.getString(1));
|
||||
city.add(cursor.getString(1)+"");
|
||||
}
|
||||
}
|
||||
return city;
|
||||
}
|
||||
// 条件查询
|
||||
public List<String> query(String city){
|
||||
List<String> users=new ArrayList<>();
|
||||
db=dbhelper.getReadableDatabase();
|
||||
Cursor cursor = db.query("citys",new String[]{"city"},"city=?",
|
||||
new String[]{city},null,null,null);
|
||||
if (cursor.getCount()>0){
|
||||
while (cursor.moveToNext()){
|
||||
String c=cursor.getString(0);
|
||||
users.add(c);
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.example.simulatepositioning;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Util {
|
||||
static Map<String,String> city;
|
||||
static {
|
||||
city = new HashMap<>();
|
||||
city.put("杭州","330100");
|
||||
city.put("宁波","330200");
|
||||
city.put("温州","330300");
|
||||
city.put("嘉兴","330400");
|
||||
city.put("湖州","330500");
|
||||
city.put("绍兴","330400");
|
||||
}
|
||||
public static String getCodeByName(String name){
|
||||
return city.get(name);
|
||||
}
|
||||
static Map<String,Integer> pics;
|
||||
static {
|
||||
pics=new HashMap<>();
|
||||
pics.put("晴",R.drawable.a0);
|
||||
pics.put("多云",R.drawable.a4);
|
||||
pics.put("阴",R.drawable.a9);
|
||||
pics.put("大雪",R.drawable.a17);
|
||||
pics.put("雨",R.drawable.a14);
|
||||
pics.put("小雨",R.drawable.a13);
|
||||
pics.put("中雨",R.drawable.a14);
|
||||
pics.put("大雨",R.drawable.a15);
|
||||
pics.put("雨夹雪",R.drawable.a20);
|
||||
}
|
||||
|
||||
public static Integer getPicByWeather(String weather){
|
||||
return pics.get(weather);
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.example.simulatepositioning;
|
||||
|
||||
public class WeatherInfo {
|
||||
private String city;
|
||||
private String weather;
|
||||
private int temperature;
|
||||
private String winddirection;
|
||||
private String windpower;
|
||||
private int humidity;
|
||||
private String reporttime;
|
||||
|
||||
public WeatherInfo(String city, String weather, int temperature, String winddirection, String windpower, int humidity, String reporttime) {
|
||||
this.city = city;
|
||||
this.weather = weather;
|
||||
this.temperature = temperature;
|
||||
this.winddirection = winddirection;
|
||||
this.windpower = windpower;
|
||||
this.humidity = humidity;
|
||||
this.reporttime = reporttime;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getWeather() {
|
||||
return weather;
|
||||
}
|
||||
|
||||
public void setWeather(String weather) {
|
||||
this.weather = weather;
|
||||
}
|
||||
|
||||
public int getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
public void setTemperature(int temperature) {
|
||||
this.temperature = temperature;
|
||||
}
|
||||
|
||||
public String getWinddirection() {
|
||||
return winddirection;
|
||||
}
|
||||
|
||||
public void setWinddirection(String winddirection) {
|
||||
this.winddirection = winddirection;
|
||||
}
|
||||
|
||||
public String getWindpower() {
|
||||
return windpower;
|
||||
}
|
||||
|
||||
public void setWindpower(String windpower) {
|
||||
this.windpower = windpower;
|
||||
}
|
||||
|
||||
public int getHumidity() {
|
||||
return humidity;
|
||||
}
|
||||
|
||||
public void setHumidity(int humidity) {
|
||||
this.humidity = humidity;
|
||||
}
|
||||
|
||||
public String getReporttime() {
|
||||
return reporttime;
|
||||
}
|
||||
|
||||
public void setReporttime(String reporttime) {
|
||||
this.reporttime = reporttime;
|
||||
}
|
||||
}
|
@ -0,0 +1,190 @@
|
||||
package com.example.simulatepositioning;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.SimpleAdapter;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class likeCity extends AppCompatActivity {
|
||||
|
||||
UserDao dao;
|
||||
List<Map<String, Object>> list;
|
||||
List<String> city=new ArrayList<>();
|
||||
SimpleAdapter adapter;
|
||||
private ListView listView;
|
||||
Map<String, Object> map;
|
||||
private WeatherInfo weatherInfo;
|
||||
private TextView hint;
|
||||
// private String gethum;
|
||||
// private String getweather;
|
||||
// private int tqimage;
|
||||
// private int bgimage;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_like_city);
|
||||
|
||||
listView = findViewById(R.id.listView);
|
||||
hint=findViewById(R.id.hint);
|
||||
|
||||
dao = new UserDao(this);
|
||||
reFreshData();
|
||||
|
||||
listView.setAdapter(new MyBaseAdapter());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class MyBaseAdapter extends BaseAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return city.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return list.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {//组装数据
|
||||
View view=View.inflate(likeCity.this,R.layout.item,null);//在list_item中有两个id,现在要把他们拿过来
|
||||
TextView likeCity=(TextView) view.findViewById(R.id.likeCity);
|
||||
final TextView hum=(TextView) view.findViewById(R.id.hum);
|
||||
final TextView qw=(TextView) view.findViewById(R.id.qw);
|
||||
final ImageView tqImage=(ImageView)view.findViewById(R.id.tqImage);
|
||||
final LinearLayout bg=view.findViewById(R.id.bg);
|
||||
//组件一拿到,开始组装
|
||||
likeCity.setText(city.get(position));
|
||||
|
||||
String realUrl = "https://restapi.amap.com/v3/weather/weatherInfo?city=CITY&key=d72b046349b274bf3d90c1ba900407fc&extensions=base";
|
||||
realUrl = realUrl.replace("CITY", city.get(position));
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
final Request request = new Request.Builder().url(realUrl).build();
|
||||
Call call = client.newCall(request);
|
||||
call.enqueue(new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, final IOException e) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("错误信息:"+e);
|
||||
Toast.makeText(likeCity.this, "请求失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String json = response.body().string();
|
||||
try {
|
||||
JSONObject object = new JSONObject(json);
|
||||
String status = object.getString("status");
|
||||
if (status.equals("1")) {
|
||||
JSONArray array = object.getJSONArray("lives");
|
||||
JSONObject real_obj = (JSONObject) array.get(0);
|
||||
final String city = real_obj.getString("city");
|
||||
final String weather = real_obj.getString("weather");
|
||||
final int temp = real_obj.getInt("temperature");
|
||||
final String winddirection = real_obj.getString("winddirection");
|
||||
final String windpower = real_obj.getString("windpower");
|
||||
final int hunidity = real_obj.getInt("humidity");
|
||||
final String reporttime = real_obj.getString("reporttime");
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
weatherInfo = new WeatherInfo(city, weather, temp, winddirection, windpower, hunidity, reporttime);
|
||||
qw.setText(weatherInfo.getTemperature()+"°");
|
||||
hum.setText("湿度 "+weatherInfo.getHumidity());
|
||||
bg.setBackgroundResource(getBgImage(weatherInfo.getWeather()));
|
||||
tqImage.setImageResource(Util.getPicByWeather(weatherInfo.getWeather()));
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//组装玩开始返回
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getBgImage(String we) {
|
||||
if (we.indexOf("晴")!=-1){
|
||||
return R.drawable.qingmp;
|
||||
}else if (we.indexOf("多云")!=-1){
|
||||
return R.drawable.yump;
|
||||
}else if (we.indexOf("阴")!=-1){
|
||||
return R.drawable.yingmp;
|
||||
}else if (we.indexOf("雨")!=-1){
|
||||
return R.drawable.yump;
|
||||
}
|
||||
return R.drawable.qingmp;
|
||||
}
|
||||
|
||||
private void reFreshData() { //加载所有的数据,用于初始化,添加,删除,修改后的数据
|
||||
List<String> cityList = dao.getAll();
|
||||
city=new ArrayList<>();
|
||||
list = new ArrayList<>();
|
||||
if (cityList.size()==0){
|
||||
hint.setText("未查询到数据");
|
||||
}else{
|
||||
hint.setText("一共收藏了:"+cityList.size()+"个城市");
|
||||
}
|
||||
if (cityList != null && cityList.size() != 0) {
|
||||
for (String c : cityList) {
|
||||
// map = new HashMap<>();
|
||||
// map.put("city", c);
|
||||
// map.put("hum", c);
|
||||
// map.put("qw", c);
|
||||
city.add(c);
|
||||
|
||||
// map.put("username",user.getUsername());
|
||||
// map.put("password",user.getPassword());
|
||||
// map.put("phone",user.getPhone());
|
||||
// list.add(map);
|
||||
}
|
||||
|
||||
// adapter = new SimpleAdapter(this, list, R.layout.item, new String[]{"city"},
|
||||
// new int[]{R.id.likeCity});
|
||||
//ListView绑定适配器
|
||||
// listView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 9.8 KiB |
After Width: | Height: | Size: 464 KiB |
After Width: | Height: | Size: 501 KiB |
After Width: | Height: | Size: 246 KiB |
After Width: | Height: | Size: 526 KiB |
After Width: | Height: | Size: 358 KiB |
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 4.4 KiB |
@ -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>
|
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 52 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 66 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 49 KiB |
@ -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>
|
After Width: | Height: | Size: 57 KiB |
After Width: | Height: | Size: 7.8 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 7.9 KiB |
After Width: | Height: | Size: 15 KiB |
After Width: | Height: | Size: 218 KiB |
After Width: | Height: | Size: 55 KiB |
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<corners android:radius="5dip"/>
|
||||
<solid android:color="#ffffff"/>
|
||||
|
||||
</shape>
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval" >
|
||||
|
||||
<corners android:radius="60dip" />
|
||||
|
||||
<solid android:color="#ffffff" />
|
||||
|
||||
</shape>
|
||||
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/whileBg"/>
|
||||
<!-- 圆角 <corners android:radius="15dp"/>-->
|
||||
<corners
|
||||
android:topRightRadius="15dp"
|
||||
android:bottomRightRadius="15dp"
|
||||
android:bottomLeftRadius="15dp"
|
||||
android:topLeftRadius="15dp"/>
|
||||
<!-- <stroke android:width="1dp" android:color="#212121"/>-->
|
||||
</shape>
|
After Width: | Height: | Size: 8.2 KiB |
After Width: | Height: | Size: 4.7 KiB |
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
|
||||
<corners android:radius="50dip"/>
|
||||
|
||||
<stroke
|
||||
android:width="1dip"
|
||||
android:color="#ffffff" />
|
||||
|
||||
</shape>
|
||||
|
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 9.3 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 7.4 KiB |