/******************************************************************************
* Class : ActivityWeatherSetting.java *
* Main Weather activity, in this demo apps i use API from yahoo, you can *
* use other weather web service which you prefer *
* *
* Version : v1.0 *
* Date : May 06, 2011 *
* Copyright (c)-2011 DatNQ some right reserved *
* You can distribute, modify or what ever you want but WITHOUT ANY WARRANTY *
* Be honest by keep credit of this file *
* *
* If you have any concern, feel free to contact with me via email, i will *
* check email in free time *
* Email: nguyendatnq@gmail.com *
* ---------------------------------------------------------------------------*
* Modification Logs: *
* KEYCHANGE DATE AUTHOR DESCRIPTION *
* ---------------------------------------------------------------------------*
* ------- May 06, 2011 DatNQ Create new *
******************************************************************************/
package com.exoplatform.weather.controller;
import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.exoplatform.weather.R;
import com.exoplatform.weather.model.WeatherDataModel;
import com.exoplatform.weather.model.WeatherInfo;
import com.exoplatform.weather.model.WeatherPreferences;
import com.exoplatform.weather.model.YahooWeatherHelper;
import com.exoplatform.weather.view.ContextMenuAdapter;
import com.exoplatform.weather.view.ContextMenuItem;
/*******************************************************************************
* Purpose of this class for Activity setting yahoo weather service
* First of all with this requirement i think Widget is better (From user view)
* but currently i have a litter free time, so i create only Activity version
*
* I hope we will have widget version in near future when i have enough free time
* @author DatNQ
*
******************************************************************************/
public class ActivityWeatherSetting extends Activity {
/** TAG, for debugging */
private static final String TAG = "ActivityYahoo";
/** Dialog type */
private static final int DIALOG_TYPE_USER_AGREEMENT = 1;
/** Change location */
private static final int REG_CHANGELOCATION = 1;
/** Request get location */
private static final int REG_GET_WEATHER_START = 100;
/** Request get location finish */
private static final int REG_GET_WEATHER_FINISH = 101;
/** Frequency update */
private static final int ONE_MINUTE = 60*1000;
/** Context menu */
private static final int MENU_CONTEXT_0 = 0;
/** Context menu */
private static final int MENU_CONTEXT_1 = 1;
/** Context menu */
private static final int MENU_CONTEXT_2 = 2;
/** Item 1 */
private static final int SELECT_ITEM_1 = 0;
/** Item 2 */
private static final int SELECT_ITEM_2 = 1;
/** Item 3 */
private static final int SELECT_ITEM_3 = 2;
/** Weather infomation */
private WeatherInfo m_WeatherInfo;
/** Weather setting */
private WeatherPreferences m_Preferneces;
/** Model data */
private WeatherDataModel m_DataModel;
/** Location */
private TextView m_TextLocation;
/** Temperature */
private TextView m_Temperature;
/** Humimidy */
private TextView m_Humimidy;
/** State */
private TextView m_Visibility;
/** Time */
private TextView m_Date;
/** Icon */
private ImageView m_WeatherIcon;
/** week day*/
private TextView m_WeekDay;
/** temperater range*/
private TextView m_TemperatureRange;
/**Weather text*/
private TextView m_WeatherText;
/** tomorrow temperater range*/
private TextView m_TTemperatureRange;
/**tomorrow date*/
private TextView m_TDate;
/**tomorrow week day*/
private TextView m_TWeekDay;
/**tomorrow Weather text*/
private TextView m_TWeatherText;
/** tomorrow weather Icon */
private ImageView m_TWeatherIcon;
/** Handle request */
Handler m_HandleRequest;
/** Dialog */
//ProgressDialog m_ProgressDialog;
/** Dialog */
AlertDialog m_Dialog;
/** Runable */
Runnable m_Runnable;
/** For adapter of dialog */
private ContextMenuAdapter m_contextAdapter;
/** Dialog */
AlertDialog m_Alert;
/***************************************************************************
* On create called when start weather setting activity
* @see android.app.Activity#onCreate(android.os.Bundle)
* @date May 7, 2011
* @time 5:17:48 PM
* @author DatNQ
**************************************************************************/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_weather_setting);
/* Initialize data */
boolean bResult = initializeData();
if (bResult != false ){
/* Initialize view */
bResult = initializeView();
}
if (bResult == false){
Log.e(TAG,"Init data failed");
/* Add notify here and quit app */
finish();
return;
}
if (m_Preferneces.getAcceptAgreement() == false){
showDialog(DIALOG_TYPE_USER_AGREEMENT);
} else {
/* Draw screen */
drawWeatherScreen();
selectWeatherSetting();
}
}
/***************************************************************************
* Create Dialog
* @see android.app.Activity#onCreateDialog(int)
* @date May 7, 2011
* @time 5:18:50 PM
* @author DatNQ
**************************************************************************/
@Override
protected Dialog onCreateDialog(int id){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.str_user_agreement);
builder.setCancelable(false);
builder.setPositiveButton(R.string.str_agree, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
m_Preferneces.setAccpetAgreement(true);
/* Draw screen */
drawWeatherScreen();
}
});
builder.setNegativeButton(R.string.str_disagree, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
System.exit(0);
}
});
AlertDialog alert = builder.create();
return alert;
}
/***************************************************************************
* Create option menu
* @see android.app.Activity#onCreateOptionsMenu(android.view.Menu)
* @date May 7, 2011
* @time 8:58:39 PM
* @author DatNQ
**************************************************************************/
没有合适的资源?快使用搜索试试~ 我知道了~
雅虎天气预报WIDGET
共86个文件
png:53个
xml:14个
java:13个
4星 · 超过85%的资源 需积分: 17 84 下载量 159 浏览量
2012-12-26
17:51:05
上传
评论 2
收藏 723KB RAR 举报
温馨提示
雅虎天气预报WIDGET代码,可搜索世界各大城市,用于android 手机,整体可以运行,还有问题,高手们多指教指教啊。
资源推荐
资源详情
资源评论
收起资源包目录
WeatherForecast.rar (86个子文件)
WeatherForecast
.project 860B
project.properties 562B
proguard.cfg 1KB
src
com
exoplatform
weather
view
ContextMenuItem.java 4KB
ContextMenuSearch.java 2KB
ContextMenuAdapter.java 3KB
model
YahooWeatherHelper.java 10KB
HttpConnectHelper.java 6KB
WeatherPreferences.java 10KB
YahooLocationHelper.java 5KB
WeatherInfo.java 13KB
WeatherDataModel.java 7KB
controller
WidgetWeather.java 9KB
ActivityWeatherSetting.java 26KB
ActivityScreenLocation.java 9KB
WeatherCustomDialog.java 8KB
AndroidManifest.xml 3KB
res
drawable-ldpi
icon.png 2KB
xml
weather_provider.xml 331B
drawable-hdpi
icon.png 4KB
menu
option_weather_screen.xml 2KB
drawable
top_bar.png 900B
a45.png 7KB
a28.png 8KB
weather_background.png 69KB
icon_option_about.png 6KB
item_top.png 425B
a8.png 9KB
a30.png 8KB
weather_hot_ic.png 17KB
brew_nativec_ic.png 7KB
item_ic.png 3KB
a27.png 7KB
ic_context_menu.png 2KB
flashlite_j2me_ic.png 9KB
a9.png 7KB
android_ic.png 7KB
temperature_ic.png 4KB
a34.png 9KB
otherweather_ic.png 3KB
weathericon_condition_02.png 81KB
app_bg02.jpg 91KB
a36..png 8KB
suggest_icon.png 9KB
location_ic.png 4KB
background.png 104KB
a41.png 9KB
a29.png 7KB
a33.png 7KB
a31.png 6KB
a24.png 7KB
a19.png 8KB
custom_ic.png 4KB
a2.png 9KB
dat_hero_avatar.png 28KB
a44.png 7KB
default_menu_item.png 4KB
a32.png 8KB
a5.png 7KB
item_foot.png 888B
a46.png 9KB
update_time.png 4KB
a13.png 9KB
a35.png 7KB
a0.png 8KB
a17.png 7KB
a3200.png 5KB
icon_option_setting.png 2KB
a26.png 7KB
item_bg.png 327B
app_icon.png 8KB
a25.png 8KB
drawable-mdpi
icon.png 3KB
layout
customdialog_layout.xml 10KB
activity_weather_setting.xml 10KB
activity_setting_location.xml 3KB
personal_information.xml 3KB
boder.xml 309B
weather_widget_layout.xml 5KB
weather_selector.xml 2KB
context_menu_layout.xml 705B
drawable-xhdpi
values
color.xml 2KB
strings.xml 7KB
dimens.xml 2KB
Android.mk 230B
.classpath 356B
共 86 条
- 1
easonchueng
- 粉丝: 0
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页