private void notifyStock() { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) { return; } String str = StockUtils.getStockCode1(mContent); String real = StockNewSettingUtils.getStockExchange(mContent, str) + str; try { float ff = Float.parseFloat(StockUtils.getStockBuyPrice1(mContent)); float low = Float.parseFloat(StockUtils.getStockKuisun1(mContent)); float hight = Float.parseFloat(StockUtils.getStockYingli1(mContent)); pullWetherFromNet(real, ff, low, hight); } catch (Exception e) { e.printStackTrace(); } str = StockUtils.getStockCode2(mContent); real = StockNewSettingUtils.getStockExchange(mContent, str) + str; try { float ff = Float.parseFloat(StockUtils.getStockBuyPrice2(mContent)); float low = Float.parseFloat(StockUtils.getStockKuisun2(mContent)); float hight = Float.parseFloat(StockUtils.getStockYingli2(mContent)); pullWetherFromNet(real, ff, low, hight); } catch (Exception e) { e.printStackTrace(); } }
private void notifyTime() { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) { return; } int xx = calendar.get(Calendar.HOUR_OF_DAY); int xx2 = calendar.get(Calendar.MINUTE) + xx * 60; if (xx2 > (8 * 60 + 55) && xx2 < (8 * 60 + 59)) { if (StockNewSettingUtils.getTime_0900(mContent)) { String tip = null; tip = "开盘时间快到了"; Notification notification = NotificationUtils.creatNotify(mContent, tip, false); NotificationManager manager = (NotificationManager) mContent.getSystemService(mContent.NOTIFICATION_SERVICE); manager.notify(CommonUtils.notify_time_id, notification); } } else if (xx2 > (11 * 60 + 25) && xx2 < (11 * 60 + 29)) { if (StockNewSettingUtils.getTime_1130(mContent)) { String tip = null; tip = "上午结束时间快到了"; Notification notification = NotificationUtils.creatNotify(mContent, tip, false); NotificationManager manager = (NotificationManager) mContent.getSystemService(mContent.NOTIFICATION_SERVICE); manager.notify(CommonUtils.notify_time_id, notification); } } else if (xx2 > (12 * 60 + 55) && xx2 < (12 * 60 + 59)) { if (StockNewSettingUtils.getTime_1300(mContent)) { String tip = null; tip = "下午开盘时间快到了"; Notification notification = NotificationUtils.creatNotify(mContent, tip, false); NotificationManager manager = (NotificationManager) mContent.getSystemService(mContent.NOTIFICATION_SERVICE); manager.notify(CommonUtils.notify_time_id, notification); } } else if (xx2 > (14 * 60 + 55) && xx2 < (14 * 60 + 59)) { if (StockNewSettingUtils.getTime_1500(mContent)) { String tip = null; tip = "下午结束时间快到了"; Notification notification = NotificationUtils.creatNotify(mContent, tip, false); NotificationManager manager = (NotificationManager) mContent.getSystemService(mContent.NOTIFICATION_SERVICE); manager.notify(CommonUtils.notify_time_id, notification); } } else if (xx2 > (14 * 60 + 25) && xx2 < (14 * 60 + 29)) { if (StockNewSettingUtils.getTime_1430(mContent)) { String tip = null; tip = "神奇时间快到了"; Notification notification = NotificationUtils.creatNotify(mContent, tip, false); NotificationManager manager = (NotificationManager) mContent.getSystemService(mContent.NOTIFICATION_SERVICE); manager.notify(CommonUtils.notify_time_id, notification); } } }
@Override public void onReceive(Context context, Intent intent) { mContent = context; if (mLL == null) { mLL = new IResultListner() { @Override public void onStockResult( final String realCode, final float buyprice, final float low, final float high, String result) { stockYujing(realCode, buyprice, low, high, result); } @Override public void onWhetherResult(String res) { if (!TextUtils.isEmpty(res)) { String t = tianqiWhere + " " + res.substring( res.indexOf("<status1>") + "<status1>".length(), res.indexOf("</status1>")) + " " + res.substring( res.indexOf("<status2>") + "<status2>".length(), res.indexOf("</status2>")); Notification notification = NotificationUtils.creatNotify(mContent, t, false); NotificationManager manager = (NotificationManager) mContent.getSystemService(mContent.NOTIFICATION_SERVICE); manager.notify(CommonUtils.notify_whether_id, notification); } } }; } timeDis = StockNewSettingUtils.getTimeBetween(context); iTickCount++; if (iTickCount == 3600) { iTickCount = 0; } if (iTickCount % timeDis == 0) { notifyActivity(); notifyStock(); // 提醒时间 notifyTime(); pullWetherFromNet(tianqiWhere); // 提醒点餐了 notifyDingcan(); // 下班记得打卡 notifyDaka(); } } // 如果无网络连接activeInfo为null