/*************************************************************************
Copyright 2014 MagicMod Project
This file is part of MagicMod Weather.
MagicMod Weather is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MagicMod Weather is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MagicMod Weather. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/
package com.magicmod.mmweather;
import android.location.Location;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import com.magicmod.mmweather.config.PreferenceUI;
import com.magicmod.mmweather.config.Preferences;
import com.magicmod.mmweather.engine.WeatherEngine;
import com.magicmod.mmweather.engine.WeatherInfo;
import com.magicmod.mmweather.engine.WeatherProvider;
import com.magicmod.mmweather.engine.WeatherResProvider;
import com.magicmod.mmweather.engine.WeatherInfo.DayForecast;
import com.magicmod.mmweather.engine.WeatherProvider.LocationResult;
import com.magicmod.mmweather.utils.Constants;
import com.magicmod.mmweather.utils.ImageUtils;
import com.magicmod.mmweather.utils.widget.RotateImageView;
import com.magicmod.mmweather.utils.widget.CirclePageIndicator;
import java.nio.MappedByteBuffer;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
public class MainActivity extends FragmentActivity implements OnClickListener {
private static final String TAG = "MainActivity";
private static final boolean DBG = Constants.DEBUG;
/*private static final int LOACTION_OK = 0;
private static final int UPDATE_EXISTS_CITY = 2;
public static final int GET_WEATHER_SCUESS = 3;
public static final int GET_WEATHER_FAIL = 4;*/
//Title
private ImageView mCityManagerBtn, mLocationBtn, mShareBtn;
private TextView mTitleCityName;
private RotateImageView mUpdateProgressBar;
//Today's view
private TextView mCountryTextView;
private TextView mCityTextView, mSyncTimeTextView, mWeatherSourceTextView, mPm25TextView, mAqiDataTextView;
private TextView mTodayWeekTextView, mTodayMonthTextView, mTempTextView, mHumidityTextView, mWeatherConditionTextView, mWindTextView;
private ImageView mWeatherImageView, mAqiImageView;
private View mAqiRootView;
private ViewPager mViewPager;
private List<Fragment> fragments;
private NextDaysWeatherPagerAdapter mWeatherPagerAdapter;
private WeatherEngine mWeatherEngine;
private Context mContext;
//private WeatherApplication mApplication;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mContext = getApplicationContext();
setContentView(R.layout.activity_main);
final WeatherApplication mApplication = (WeatherApplication) this.getApplication();
mWeatherEngine = mApplication.getWeatherEngine();
initViews();
initWeatherData();
initFragments();
/*Intent intent = new Intent(mContext, WeatherUpdateServices.class);
mContext.startService(intent);*/
}
@Override
protected void onResume() {
super.onResume();
//initWeatherData();
}
private void initViews() {
mCityManagerBtn = (ImageView) findViewById(R.id.title_city_manager);
mCityManagerBtn.setOnClickListener(this);
mLocationBtn = (ImageView) findViewById(R.id.title_location);
mLocationBtn.setOnClickListener(this);
mShareBtn = (ImageView) findViewById(R.id.title_share);
mShareBtn.setOnClickListener(this);
mUpdateProgressBar = (RotateImageView) findViewById(R.id.title_update_progress);
mUpdateProgressBar.setOnClickListener(this);
mTitleCityName = (TextView) findViewById(R.id.title_city_name);
mTitleCityName.setOnClickListener(this);
mCountryTextView = (TextView) findViewById(R.id.country);
mCityTextView = (TextView) findViewById(R.id.city);
mWeatherSourceTextView = (TextView) findViewById(R.id.weather_source_view);
mSyncTimeTextView = (TextView) findViewById(R.id.sync_time);
mPm25TextView = (TextView) findViewById(R.id.pm_data);
mAqiDataTextView = (TextView) findViewById(R.id.pm2_5_quality);
mTodayWeekTextView = (TextView) findViewById(R.id.week_today);
mTodayMonthTextView = (TextView) findViewById(R.id.month_today);
mTempTextView = (TextView) findViewById(R.id.temperature);
mHumidityTextView = (TextView) findViewById(R.id.humidity);
mWeatherConditionTextView = (TextView) findViewById(R.id.weather_condition);
mWindTextView = (TextView) findViewById(R.id.wind);
mWeatherImageView = (ImageView) findViewById(R.id.weather_img);
mAqiImageView = (ImageView) findViewById(R.id.pm2_5_img);
mAqiImageView.setOnClickListener(this);
}
/**
* First data adapter when app opened
* 2014年1月19日
*/
private void initWeatherData() {
if (DBG)
Log.d(TAG, "init weather data");
WeatherInfo info = mWeatherEngine.getCache(); //get weather info from cache
if (info == null) { //open a dialog to let user select their city
if (DBG)
Log.d(TAG, "get cache fail, start the city input dialog");
showCityInputDialog(true);
}
updateWeatherView(info,false);
}
private void initFragments() {
fragments = new ArrayList<Fragment>();
fragments.add(new NextDaysFirstWeatherFragment(mContext, mWeatherEngine.getCache(),
mWeatherEngine.getWeatherProvider().getWeatherResProvider()));
fragments.add(new NextDaysSecondWeatherFragment(mContext, mWeatherEngine.getCache(),
mWeatherEngine.getWeatherProvider().getWeatherResProvider()));
mViewPager = (ViewPager) findViewById(R.id.viewpager);
mWeatherPagerAdapter = new NextDaysWeatherPagerAdapter(getSupportFragmentManager(),
fragments);
mViewPager.setAdapter(mWeatherPagerAdapter);
((CirclePageIndicator) findViewById(R.id.indicator)).setViewPager(mViewPager);
}
private void updateWeatherView(WeatherInfo weatherInfo, boolean refreshFragment) {
if (weatherInfo == null) {
return;
}
WeatherProvider provider = mWeatherEngine.getWeatherProvider();
WeatherResProvider res = provider.getWeatherResProvider();
if (refreshFragment) {
if (fragments.size() > 0) {
((NextDaysFirstWeatherFragment) mWeatherPagerAdapter.getItem(0)).updateWeather(
weatherInfo, res, mContext);
((NextDaysSecondWeatherFragment) mWeatherPagerAdapter.getItem(1)).updateWeather(
没有合适的资源?快使用搜索试试~ 我知道了~
简洁天气项目源码.zip项目安卓应用源码下载
共325个文件
png:267个
xml:28个
java:25个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 25 浏览量
2022-03-09
07:48:34
上传
评论
收藏 2.29MB ZIP 举报
温馨提示
简洁天气项目源码.zip项目安卓应用源码下载简洁天气项目源码.zip项目安卓应用源码下载 1.适合学生毕业设计研究参考 2.适合个人学习研究参考 3.适合公司开发项目技术参考
资源推荐
资源详情
资源评论
收起资源包目录
简洁天气项目源码.zip项目安卓应用源码下载 (325个子文件)
COPYING 34KB
proguard.flags 44B
.gitignore 416B
MainActivity.java 22KB
WeatherUpdateService.java 17KB
YahooWeatherProvider.java 17KB
CirclePageIndicator.java 16KB
WeatherEngine.java 11KB
YahooWeatherResProvider.java 7KB
Lunar.java 7KB
WeatherInfo.java 7KB
NextDaysSecondWeatherFragment.java 7KB
NextDaysFirstWeatherFragment.java 7KB
PreferenceUI.java 5KB
WeatherWidget.java 4KB
Preferences.java 4KB
ImageUtils.java 3KB
TimeUtil.java 2KB
WeatherResProvider.java 2KB
WeatherProvider.java 2KB
RotateImageView.java 2KB
NetUtil.java 2KB
PageIndicator.java 2KB
WeatherApplication.java 2KB
HttpRetriever.java 2KB
Constants.java 1KB
NextDaysWeatherPagerAdapter.java 1KB
WeatherDataChangedListener.java 732B
Android.mk 967B
mm_plugin_weather_bg.png 647KB
bg.png 245KB
javaapk.com_0000.png 111KB
javaapk.com_0001.png 85KB
ic_launcher-web.png 50KB
widget_preview.png 41KB
weather_8.png 21KB
weather_8.png 21KB
weather_10.png 21KB
weather_10.png 21KB
weather_39.png 21KB
weather_37.png 21KB
weather_39.png 21KB
weather_37.png 21KB
weather_43.png 21KB
weather_43.png 21KB
weather_15.png 20KB
weather_15.png 20KB
weather_25.png 20KB
weather_25.png 20KB
weather_40.png 20KB
weather_40.png 20KB
weather_na.png 20KB
weather_na.png 20KB
weather_9.png 20KB
weather_9.png 20KB
weather_47.png 20KB
weather_38.png 20KB
weather_47.png 20KB
weather_38.png 20KB
weather_35.png 20KB
weather_35.png 20KB
weather_42.png 20KB
weather_42.png 20KB
weather_36.png 20KB
weather_36.png 20KB
weather_28.png 20KB
weather_30.png 20KB
weather_28.png 20KB
weather_30.png 20KB
weather_12.png 20KB
weather_11.png 20KB
weather_12.png 20KB
weather_11.png 20KB
weather_17.png 20KB
weather_17.png 20KB
weather_4.png 20KB
weather_45.png 20KB
weather_3.png 20KB
weather_4.png 20KB
weather_45.png 20KB
weather_3.png 20KB
weather_16.png 20KB
weather_41.png 20KB
weather_16.png 20KB
weather_41.png 20KB
weather_27.png 20KB
weather_29.png 20KB
weather_44.png 20KB
weather_27.png 20KB
weather_29.png 20KB
weather_44.png 20KB
weather_26.png 20KB
weather_26.png 20KB
weather_18.png 20KB
weather_6.png 20KB
weather_5.png 20KB
weather_7.png 20KB
weather_18.png 20KB
weather_6.png 20KB
weather_5.png 20KB
共 325 条
- 1
- 2
- 3
- 4
资源评论
yxkfw
- 粉丝: 77
- 资源: 2万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Java项目-电影院售票管理系统(java+Servlet+JSP+JDBC+Mysql)
- SSM整合开发-图书管理系统
- 计二202301020210蒋怡.zip
- 基于74LS160的70进制计数器仿真节线图
- 基于74LS160的30进制与70进制转化仿真节线图
- 【用360解压工具解压】springboot+vue实验室(预约)管理系统【www.java1234.com】.zip
- commodity.cpp
- WordPress主题JustNews v6.01自适应自媒体博客主题免授权
- C语言开发小游戏案例 - 弹跳球
- Delphi 12 控件之TMS VCL UI Pack v13.1.3.2.7z
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功