Ejemplo n.º 1
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (isViewCreated()) {
      return mView;
    }

    View rootView = inflater.inflate(R.layout.number_layout, container, false);
    mResultTextView = (TextView) rootView.findViewById(R.id.result);
    MySpan.formatTextView(mContext, mResultTextView, mNumberInfoString, false);

    mSearchView = new SearchView(mContext, rootView.findViewById(R.id.search_view));

    mFoodListLayout = (LinearLayout) rootView.findViewById(R.id.foodlistBtn);
    mFoodListLayout.setOnClickListener(this);
    mHouseListLayout = (LinearLayout) rootView.findViewById(R.id.houselistBtn);
    mHouseListLayout.setOnClickListener(this);
    mExpressListLayout = (LinearLayout) rootView.findViewById(R.id.expresslistBtn);
    mExpressListLayout.setOnClickListener(this);
    mServiceListLayout = (LinearLayout) rootView.findViewById(R.id.servicelistBtn);
    mServiceListLayout.setOnClickListener(this);

    mSearchExpressBtn = (Button) rootView.findViewById(R.id.searchExpressBtn);
    mSearchExpressBtn.setOnClickListener(this);

    mWeatherList = (LinearLayout) rootView.findViewById(R.id.weatherList);
    mWeatherCity = (TextView) rootView.findViewById(R.id.weather_city);

    mToday = (TextView) rootView.findViewById(R.id.today);

    rootView.findViewById(R.id.history).setOnClickListener(this);
    rootView.findViewById(R.id.news).setOnClickListener(this);
    rootView.findViewById(R.id.qiushi).setOnClickListener(this);
    rootView.findViewById(R.id.yisi).setOnClickListener(this);
    rootView.findViewById(R.id.zhihu).setOnClickListener(this);

    rootView.findViewById(R.id.scan).setOnClickListener(this);

    rootView.findViewById(R.id.mylove).setOnClickListener(this);

    // 显示农历和天气
    handlerNongli(SharedPreferencesHelper.getInstance().getString(SharedPreferencesHelper.NONGLI));
    handlerWeather(
        SharedPreferencesHelper.getInstance().getString(SharedPreferencesHelper.WEATHER));
    handlerAir(SharedPreferencesHelper.getInstance().getString(SharedPreferencesHelper.AIR));

    return rootView;
  }
Ejemplo n.º 2
0
  /**
   * 处理获取到的农历信息
   *
   * @param nongli
   */
  private void handlerNongli(final String nongli) {
    if (!StringUtil.isEmpty(nongli)) {
      StringBuilder today = new StringBuilder();
      today.append("今天是");
      if (nongli.trim().length() > 0) {
        today.append(nongli.replace("\n", "<br/>"));
        mToday.setText(Html.fromHtml(today.toString()));

        SharedPreferencesHelper.getInstance().setString(SharedPreferencesHelper.NONGLI, nongli);
      }
    }
  }
Ejemplo n.º 3
0
  /**
   * 处理获取到的天气信息
   *
   * @param weather
   */
  private void handlerWeather(String weather) {
    if (!StringUtil.isEmpty(weather)) {
      SharedPreferencesHelper.getInstance().setString(SharedPreferencesHelper.WEATHER, weather);
      int index = weather.indexOf(" ");
      if (index > 0) {
        String city = weather.substring(0, index);
        weather = weather.substring(index + 1);
        mWeatherCity.setText(city + " " + mContext.getString(R.string.number_weather));
        String[] str = weather.split("\\|");

        mWeatherList.removeAllViews();
        for (int i = 0; i < str.length; i++) {
          mWeatherList.addView(WeatherHelper.createWeatherItem(mContext, str[i], i));
        }
      }
    }
  }
Ejemplo n.º 4
0
  private void searchWeather() {
    if (SharedPreferencesHelper.getInstance()
            .getString(SharedPreferencesHelper.WEATHER, "")
            .length()
        > 0) {
      if (System.currentTimeMillis() - mLastWeatherUpdateTime < CustomConstant.ONE_HOUR) {
        DebugLog.d(TAG, "searchWeather: the time is too short");
        return;
      }
    }
    if (null == BDMapListener.getInstance().getBdLocation()) {
      MapUtil.getInstance().getLocationClient().requestLocation();
      return;
    }

    BaseUtil.excute(
        new Runnable() {
          @Override
          public void run() {
            // 最多7天
            String weather =
                RequestUtil.getInstance()
                    .searchWeather(
                        7,
                        BDMapListener.getInstance().getBdLocation().getCity(),
                        ServerUtil.getInstance(mContext).getUserID());
            if (!StringUtil.isEmpty(weather)) {
              mLastWeatherUpdateTime = System.currentTimeMillis();
              myHandler.sendMessage(
                  myHandler.obtainMessage(MessageWhat.NET_REQUEST_WEATHER, weather));
            }
            // 获取空气质量
            String air =
                RequestUtil.getInstance()
                    .searchAir(BDMapListener.getInstance().getBdLocation().getCity());
            if (!StringUtil.isEmpty(air)) {
              myHandler.sendMessage(myHandler.obtainMessage(MessageWhat.NET_REQUEST_AIR, air));
            }
          }
        });
  }
Ejemplo n.º 5
0
 @Override
 public void handleMessage(Message msg) {
   switch (msg.what) {
     case MessageWhat.NET_REQUEST_NUMBER:
       if (null == msg.obj) {
         break;
       }
       mInfoString = (String) msg.obj;
       mInfoTextView.setText(mInfoString);
       if (mType == PhoneReceiver.INCOMING_CALL_MSG) {
         // 来电播报
         if (BaseUtil.isWiredHeadsetOn(mContext)) {
           if (SharedPreferencesHelper.getInstance()
               .getBoolean(
                   SharedPreferencesHelper.SETTING_BROADCAST_WHEN_WIREDHEADSETON, true)) {
             broadcastContent(createCallBroadcastContent());
             // 日志
             LogOperate.updateLog(mContext, LogCode.CALL_BROADCAST);
           }
         }
       }
       String[] infosStrings = mInfoString.split(" ");
       String city = "";
       if (infosStrings.length == 1) {
         if (infosStrings[0].length() < 5) {
           city = infosStrings[0];
         }
       } else if (infosStrings.length == 2) {
         if (infosStrings[1].contains("中国")) {
           city = infosStrings[0];
         } else {
           city = infosStrings[1];
         }
       } else {
         city = infosStrings[1];
       }
       if (!StringUtil.isEmpty(city)) {
         BusinessHelper.getWeatherInfo(mContext, city, myHandler);
       }
       break;
     case MessageWhat.NET_REQUEST_WEATHER:
       if (null != msg.obj) {
         mWeatherTextView.setText((String) msg.obj);
         mWeatherTextView.setVisibility(View.VISIBLE);
       }
       break;
     case MessageWhat.CALL_RECORDS:
       if (null != msg.obj) {
         mRecordsTextView.setText((String) msg.obj);
       }
       break;
     case MessageWhat.MSG_SHOW_COMMENTS:
       if (null != msg.obj) {
         mCommentsArray = null;
         try {
           mCommentsArray = new JSONArray((String) msg.obj);
           if (mCommentsArray.length() > 0) {
             mFlashingIndex = -1;
             mCommentLayout.setVisibility(View.VISIBLE);
             showFlashComment();
           }
         } catch (JSONException e) {
           DebugLog.d(TAG, e.toString());
         }
       }
       break;
     case MSG_SHOW_ONE_COMMENT:
       if (null != msg.obj) {
         mCommentTextView.setText((String) msg.obj);
         mFlashingAnimation.reset();
         mCommentTextView.startAnimation(mFlashingAnimation);
       }
       break;
     case MSG_REMOVE:
       remove();
       break;
     case MessageWhat.MSG_LAST_RECORD_DATE:
       if (null != msg.obj) {
         mLastRecordTextView.setText((String) msg.obj);
         mLastRecordTextView.setVisibility(View.VISIBLE);
       }
       break;
     default:
       break;
   }
   super.handleMessage(msg);
 }
Ejemplo n.º 6
0
 /**
  * 处理获取到的空气信息
  *
  * @param air
  */
 private void handlerAir(String air) {
   if (!StringUtil.isEmpty(air)) {
     SharedPreferencesHelper.getInstance().setString(SharedPreferencesHelper.AIR, air);
     mWeatherCity.setText(air);
   }
 }