|
@@ -3,17 +3,25 @@ package com.itant.shibei.ui.home.tool.weather;
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
|
+import android.widget.EditText;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.itant.shibei.BuildConfig;
|
|
|
import com.itant.shibei.R;
|
|
import com.itant.shibei.R;
|
|
|
import com.itant.shibei.base.BaseBeiActivity;
|
|
import com.itant.shibei.base.BaseBeiActivity;
|
|
|
import com.itant.shibei.bean.BeiUser;
|
|
import com.itant.shibei.bean.BeiUser;
|
|
|
import com.itant.shibei.manager.UserInfoManager;
|
|
import com.itant.shibei.manager.UserInfoManager;
|
|
|
|
|
+import com.itant.shibei.tool.SystemTool;
|
|
|
|
|
+import com.miekir.common.utils.ToastTool;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 天气界面
|
|
* 天气界面
|
|
|
*/
|
|
*/
|
|
|
public class WeatherActivity extends BaseBeiActivity implements View.OnClickListener {
|
|
public class WeatherActivity extends BaseBeiActivity implements View.OnClickListener {
|
|
|
|
|
+ private static final String FORMAT_URL = "%s/shibei/weather";
|
|
|
|
|
+ private static final String FORMAT_EMAIL = "\"email\":\"%s\"";
|
|
|
|
|
+ private static final String FORMAT_TOKEN = "\"token\":\"%s\"";
|
|
|
|
|
+
|
|
|
private BeiUser mUser;
|
|
private BeiUser mUser;
|
|
|
|
|
|
|
|
private TextView tv_weather_url;
|
|
private TextView tv_weather_url;
|
|
@@ -31,26 +39,54 @@ public class WeatherActivity extends BaseBeiActivity implements View.OnClickList
|
|
|
setTitle("日期天气API");
|
|
setTitle("日期天气API");
|
|
|
|
|
|
|
|
tv_weather_url = findViewById(R.id.tv_weather_url);
|
|
tv_weather_url = findViewById(R.id.tv_weather_url);
|
|
|
|
|
+ tv_weather_url.setText(String.format(FORMAT_URL, BuildConfig.BASE_URL));
|
|
|
tv_header_email = findViewById(R.id.tv_header_email);
|
|
tv_header_email = findViewById(R.id.tv_header_email);
|
|
|
|
|
+ tv_header_email.setText(String.format(FORMAT_EMAIL, mUser.email));
|
|
|
tv_header_token = findViewById(R.id.tv_header_token);
|
|
tv_header_token = findViewById(R.id.tv_header_token);
|
|
|
|
|
+ tv_header_token.setText(String.format(FORMAT_TOKEN, mUser.token));
|
|
|
|
|
|
|
|
findViewById(R.id.fl_weather_url).setOnClickListener(this);
|
|
findViewById(R.id.fl_weather_url).setOnClickListener(this);
|
|
|
findViewById(R.id.fl_header_email).setOnClickListener(this);
|
|
findViewById(R.id.fl_header_email).setOnClickListener(this);
|
|
|
findViewById(R.id.fl_header_token).setOnClickListener(this);
|
|
findViewById(R.id.fl_header_token).setOnClickListener(this);
|
|
|
|
|
+
|
|
|
|
|
+ EditText et_weather = findViewById(R.id.et_weather);
|
|
|
|
|
+ et_weather.setText("{\n" +
|
|
|
|
|
+ " \"temperatureLow\": 28.5,\n" +
|
|
|
|
|
+ " \"temperatureHigh\": 30.5,\n" +
|
|
|
|
|
+ " \"temperatureNow\": 29.2,\n" +
|
|
|
|
|
+ " \"wind\": \"无持续风,微风\",\n" +
|
|
|
|
|
+ " \"air\": \"优\",\n" +
|
|
|
|
|
+ " \"desc\": \"阵雨转多云\"\n" +
|
|
|
|
|
+ "}");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
switch (v.getId()) {
|
|
switch (v.getId()) {
|
|
|
case R.id.fl_weather_url:
|
|
case R.id.fl_weather_url:
|
|
|
- // todo 复制GET链接URL
|
|
|
|
|
|
|
+ // 复制GET链接URL
|
|
|
|
|
+ if (SystemTool.copyText(getApplicationContext(), tv_weather_url.getText().toString())) {
|
|
|
|
|
+ ToastTool.showShort("复制成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastTool.showShort("复制失败");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case R.id.fl_header_email:
|
|
case R.id.fl_header_email:
|
|
|
- // todo 复制header参数email
|
|
|
|
|
|
|
+ // 复制header参数email
|
|
|
|
|
+ if (SystemTool.copyText(getApplicationContext(), tv_header_email.getText().toString())) {
|
|
|
|
|
+ ToastTool.showShort("复制成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastTool.showShort("复制失败");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
case R.id.fl_header_token:
|
|
case R.id.fl_header_token:
|
|
|
- // todo 复制header参数token
|
|
|
|
|
|
|
+ // 复制header参数token
|
|
|
|
|
+ if (SystemTool.copyText(getApplicationContext(), tv_header_token.getText().toString())) {
|
|
|
|
|
+ ToastTool.showShort("复制成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ToastTool.showShort("复制失败");
|
|
|
|
|
+ }
|
|
|
break;
|
|
break;
|
|
|
default:
|
|
default:
|
|
|
break;
|
|
break;
|