• 大小: 6.66MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-11-02
  • 语言: Java
  • 标签: 天气应用  

资源简介

Android天气应用源码,里面界面功能很全,供大家学习。

资源截图

代码片段和文件信息

package tk.woppo.sunday;

import android.app.Application;
import android.content.Context;

import org.androidannotations.annotations.AfterInject;
import org.androidannotations.annotations.EApplication;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import tk.woppo.sunday.domain.CitySaxParseHandler;
import tk.woppo.sunday.model.WeatherModel;
import tk.woppo.sunday.model.city.AreaModel;
import tk.woppo.sunday.model.city.ProvicneModel;
import tk.woppo.sunday.util.FileUtil;
import tk.woppo.sunday.util.LogUtil;

/**
 * Created by Ho on 2014/6/25.
 */

@EApplication
public class App extends Application {

    protected final static String TAG = “App“;

    private static Context mContext;

    /** 城市列表 */
    private static List mProvicneModels;
    private static List mAreaModels;
    public static WeatherModel mCurWeatherModel;
    private static int mCurWeatherIndex;

    @AfterInject
    void init() {

        this.mContext = getApplicationContext();
        this.mAreaModels = new ArrayList();
        this.mCurWeatherIndex = 0;
        this.initMyArea();
        this.initProvicneModels();
    }

    public static Context getContext() {
        return mContext;
    }

    /**
     * 初始化城市列表
     */
    private void initProvicneModels() {
        try {
            InputStream in = getAssets().open(Const.FILE_CITY_NAME);
            mProvicneModels = CitySaxParseHandler.getProvicneModel(in);
            LogUtil.i(TAG mProvicneModels.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static List getProvicneModels() {
        return mProvicneModels;
    }

    /**
     * 初始化我的城市
     */
    private void initMyArea() {
        try {
            List models = (List) FileUtil.readObjsFromFile(Const.FILE_MY_AREA);
            if (models != null) {
                mAreaModels.addAll(models);
                LogUtil.i(TAG mAreaModels.get(0).getCityName());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void setCurCityIndex(int index) {
        mCurWeatherIndex = index;
    }

    public static int getCurCityIndex() {
        return mCurWeatherIndex;
    }

    /**
     * 添加我的城市
     * @param model
     * @return
     */
    public static String addMyArea(AreaModel model) {
        if (model == null) {
            LogUtil.i(TAG “null“);
            return null;
        }

        if (mAreaModels.size() >= 5) {
            return getContext().getString(R.string.city_exceed_num);
        } else {
            for (AreaModel areaModel : mAreaModels) {
                if (areaModel.getCityId().equals(model.getCityId())) {
                    return getContext().getString(R.string.city_already_exists);
                }
            }
            //添加到第一位
            mAreaModels.add(0 model);
            // 重新保存文件
            FileUtil.wri

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-09-16 01:25  SunDay-master\
     文件         310  2014-09-16 01:25  SunDay-master\.gitignore
     文件        4884  2014-09-16 01:25  SunDay-master\README.md
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\
     文件     1738065  2014-09-16 01:25  SunDay-master\Studio_v-1.0\SunDay-master.zip
     文件         679  2014-09-16 01:25  SunDay-master\Studio_v-1.0\SunDay.iml
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\
     文件           6  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\.gitignore
     文件        6088  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\app.iml
     文件        1113  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\build.gradle
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\libs\
     文件       87368  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\libs\androidannotations-api-3.0.1.jar
     文件      190418  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\libs\gson-2.2.4.jar
     文件      110746  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\libs\nineoldandroids-2.4.0.jar
     文件       31867  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\libs\rebound-v0.3.3.jar
     文件       85900  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\libs\volley.jar
     文件        2187  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\proguard-rules.txt
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\
     文件        4025  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\AndroidManifest.xml
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\assets\
     文件      207885  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\assets\city.xml
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\sunday\
     文件        4005  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\sunday\App.java
     文件        1291  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\sunday\Const.java
     目录           0  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\sunday\dao\
     文件        2407  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\sunday\dao\baseDataHelper.java
     文件         858  2014-09-16 01:25  SunDay-master\Studio_v-1.0\app\src\main\java\tk\woppo\sunday\dao\DBHelper.java
............此处省略620个文件信息

评论

共有 条评论