示例#1
0
  @Override
  public void onResume() {
    super.onResume();
    DebugLog.d(TAG, "onResume");
    String str = BaseUtil.paste(mContext);
    if (str != null && str.matches(Patterns.NUMBER_PATTERN) && !str.equals(mPasteNumberString)) {
      mSearchView.setText(str);
      mPasteNumberString = str;
    }

    searchWeather();

    searchNongli();
  }
示例#2
0
 /** 查农历 */
 private void searchNongli() {
   if (System.currentTimeMillis() - mLastNongliUpdateTime < CustomConstant.QUARTER_HOUR) {
     DebugLog.d(TAG, "searchNongli: the time is too short");
     return;
   }
   BaseUtil.excute(
       new Runnable() {
         @Override
         public void run() {
           String nongli = RequestUtil.getInstance().searchNongli();
           if (!StringUtil.isEmpty(nongli)) {
             mLastNongliUpdateTime = System.currentTimeMillis();
             myHandler.sendMessage(
                 myHandler.obtainMessage(MessageWhat.NET_REQUEST_NONGLI, nongli));
           }
         }
       });
 }
示例#3
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));
            }
          }
        });
  }
示例#4
0
文件: Util.java 项目: or0fun/zhihaoma
 /** 删除确认 */
 public static void deleteConfirm(
     Context context,
     final WindowManager windowManager,
     final int id,
     final int position,
     final IDeleteConfirmListener deleteConfirm) {
   final View confirmView = LayoutInflater.from(context).inflate(R.layout.delete_confirm, null);
   confirmView
       .findViewById(R.id.todelete)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View arg0) {
               BaseUtil.removeView(windowManager, confirmView);
               BaseUtil.excute(
                   new Runnable() {
                     @Override
                     public void run() {
                       if (null != deleteConfirm) {
                         deleteConfirm.delete(id, position);
                       }
                     }
                   });
             }
           });
   confirmView
       .findViewById(R.id.cancel)
       .setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View arg0) {
               windowManager.removeView(confirmView);
             }
           });
   BaseUtil.addView(windowManager, confirmView);
 }
示例#5
0
 /** 复制号码 */
 protected void copyNumber() {
   BaseUtil.copy(mContext, mNumberString);
 }
示例#6
0
 /** 关闭弹窗 */
 public void remove() {
   if (mIsShowing) {
     mIsShowing = false;
     BaseUtil.removeView(mWindowManager, mView);
   }
 }
示例#7
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);
 }