Browse Source

1.购买天数和次数,重新获取过期时间和剩余次数

Tony 5 years ago
parent
commit
ec3022827c

+ 10 - 4
app/src/main/java/com/sunzee/mvp/advertising/AdvertisingPresenter.java

@@ -64,6 +64,9 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
         }
         if (rightFileSize != 0) {
             mvpView.playLeft(playFileList);
+            for (File file : playFileList) {
+                Log.d(TAG, "play: " + file.getName());
+            }
         }
     }
 
@@ -84,7 +87,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
      * @return
      */
     private int rightVideoImageFile() {
-        showOut = Hawk.get("show_out", new HashMap<Integer, GetAdBean>());
+        showOut = Hawk.get("show_out", new HashMap<Integer, GetAdBean>());// 第一次为空。
         Log.d(TAG, "show_out rightVideoImageFile: " + showOut);
         this.allFiles = FileUtil.getAllFiles(Environment.getExternalStorageDirectory().getPath() + "/rightvideoimg/", "");
         //判断是否为空
@@ -138,7 +141,9 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
             LogUtil.d(TAG, "rightvideoimg showOUt initView: allPlayList为0");
             return 0;
         }
+        Log.d(TAG, "rightVideoImageFile: " + allPlayList.size());
         return setTimeRules();
+//        return allPlayList.size();
     }
 
     //真正要播放的文件
@@ -208,7 +213,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
             LogUtil.e(TAG, "playCorporationAd: 没有下载A屏文件");
             return 0;
         }
-        adBeans = Hawk.get("showAdA", new ArrayList<GetAdBean>());//为空
+        adBeans = Hawk.get("showAdA", new ArrayList<GetAdBean>());//todo 第一次为空,第一次为零。
         Log.d(TAG, "showAdA leftVideoImageFile: " + adBeans);
         if (adBeans == null || adBeans.size() <= 0) {
             LogUtil.e(TAG, "playCorporationAd: 没有下载A屏数据");
@@ -292,7 +297,7 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
         addSubscription(apiStores.getCleanTimeAndRemaining(params), new ApiCallback<HttpResult2<String>>() {
             @Override
             public void onSuccess(HttpResult2<String> model) {
-                Log.d(TAG, "onSuccess: " + model);
+                Log.d(TAG, "onSuccess11: " + model);
                 String overdueDate = model.getOverdueDate();
                 String remaining = model.getRemaining();
                 if (TextUtils.isEmpty(overdueDate)) {
@@ -405,13 +410,14 @@ public class AdvertisingPresenter extends BasePresenter<AdvertisingView> {
 
     /**
      * 上次局部清洗的蹲位有多少个
+     *
      * @param num 数量
      */
     public void sendPositionNum(int num) {
         Map<String, String> params = new HashMap<>();
         params.put("clientId", Heartbeat.deviceId + "");
         params.put("num", num + "");
-        Log.d(TAG, "sendPositionNum: "+num);
+        Log.d(TAG, "sendPositionNum: " + num);
         addSubscription(apiStores.sendPositionNum(params), new ApiCallback<HttpResult<String>>() {
 
             @Override

+ 50 - 5
app/src/main/java/com/sunzee/service/MyIntentService.java

@@ -26,6 +26,7 @@ import com.sunzee.base.BaseApplication;
 import com.sunzee.model.Global;
 import com.sunzee.model.Heartbeat;
 import com.sunzee.model.HttpResult;
+import com.sunzee.model.HttpResult2;
 import com.sunzee.model.domain.GeTuiBean;
 import com.sunzee.model.domain.GetAdBean;
 import com.sunzee.model.domain.Name;
@@ -42,7 +43,9 @@ import org.greenrobot.eventbus.EventBus;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -120,7 +123,7 @@ public class MyIntentService extends GTIntentService {
                 break;
             case "updateRule":
                 //更新定时清洗的任务
-                LogUtil.d(TAG, "onReceiveMessageData: updateRule");
+                LogUtil.d(TAG, "onReceiveMessageData: updateRule"+geTuiBean.getKind_data());
                 updataCleanRule(gson, geTuiBean, kind);
                 break;
             case "statusType":
@@ -139,7 +142,9 @@ public class MyIntentService extends GTIntentService {
                 break;
             case "paySuccess":
                 // todo 客户支付成功了,我们需要获取它的日期事件
-                Log.d(TAG, "onReceiveMessageData: " + gson + ":" + geTuiBean + ":" + kind);
+                Log.d(TAG, "getKind: " + geTuiBean.getKind() + ";getKind_data:" + geTuiBean.getKind_data() + ":" );
+                Log.d(TAG, "getKind: "+geTuiBean.getNetTime()+";getWebTime:"+geTuiBean.getWebTime());
+                requestCleanTimeAndRemaining();
                 break;
             case "cleanPositionNum":
                 //局部清洗
@@ -149,9 +154,50 @@ public class MyIntentService extends GTIntentService {
 
     }
 
+    public void requestCleanTimeAndRemaining() {
+        Map<String, String> params = new HashMap<>();
+        params.put("clientId", Heartbeat.deviceId);
+        addSubscription(apiStores.getCleanTimeAndRemaining(params), new ApiCallback<HttpResult2<String>>() {
+            @Override
+            public void onSuccess(HttpResult2<String> model) {
+                Log.d(TAG, "onSuccess11: " + model);
+                String overdueDate = model.getOverdueDate();
+                String remaining = model.getRemaining();
+                if (TextUtils.isEmpty(overdueDate)) {
+                    //如果为空
+                    Hawk.put(Name.OVERDUE_DATE, null);
+                } else {
+                    try {
+                        Calendar calendar = Calendar.getInstance();
+                        calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(overdueDate));
+                        Hawk.put(Name.OVERDUE_DATE, calendar.getTimeInMillis());
+                    } catch (Exception e) {
+                        e.printStackTrace();
+                        Hawk.put(Name.OVERDUE_DATE, null);
+                    }
+                }
+                if (TextUtils.isEmpty(remaining)) {
+                    Hawk.put(Name.REMAINING, null);
+                } else {
+                    Hawk.put(Name.REMAINING, remaining);
+                }
+
+            }
+
+            @Override
+            public void onFailure(String msg) {
+                Log.d(TAG, "onFailure: " + msg);
+                //失败了。
+            }
+
+            @Override
+            public void onFinish() {
+            }
+        });
+    }
+
     private void cleanPositionNum(Gson gson, GeTuiBean geTuiBean, String kind) {
         //todo
-
         EventBus.getDefault().post(new ApiMessageEvent("cleanPositionNum",geTuiBean.getKind_data()));
     }
 
@@ -262,7 +308,7 @@ public class MyIntentService extends GTIntentService {
                 Log.d(TAG, "onSuccess: ");
                 String data = rule.getData();
                 //广告数据
-                ArrayList<GetAdBean> adBeans = Hawk.get("showAd", new ArrayList<GetAdBean>());
+                ArrayList<GetAdBean> adBeans = Hawk.get("showAd", new ArrayList<GetAdBean>());  //数据为空
                 Gson gson = new Gson();
                 Log.d(TAG, "onSuccess: 1" + adBeans);
                 List<TimeRuleBean> list = gson.fromJson(data, new TypeToken<List<TimeRuleBean>>() {
@@ -291,7 +337,6 @@ public class MyIntentService extends GTIntentService {
                 Log.d(TAG, "onSuccess: 3" + adRulesMap);
                 //保存对应的id对应的广告规则
                 Hawk.put("ad_rules_map", adRulesMap);
-                EventBus.getDefault().post(new ApiMessageEvent("pushTimeRule", null));
                 //发送设备id
                 deviceIdPostApi();
             }

+ 2 - 1
app/src/main/java/com/sunzee/service/MyService.java

@@ -729,6 +729,7 @@ public class MyService extends Service {
             Log.d(TAG, "event: " + getAdBeans);
             Hawk.put("show_sugar", showSugar);
             Hawk.put("show_out", showOut);
+            EventBus.getDefault().post(new ApiMessageEvent("pushTimeRule", null));
             LogUtil.d(TAG, "synAdSuccess:保存完成广告数据3" + getAdBeans.size());
             SharedPreferencesUtils.setParam(Name.SYSTEM_ID, Heartbeat.managerId);
             SharedPreferencesUtils.setParam(Name.CONNECT_STATE, 2);
@@ -841,7 +842,7 @@ public class MyService extends Service {
                 }
                 //保存对应的id对应的广告规则
                 Hawk.put("ad_rules_map", adRulesMap);
-
+                EventBus.getDefault().post(new ApiMessageEvent("pushTimeRule", null));// todo
 //                if (syncDialog != null) {
 //                    syncDialog.setAdRuleState(R.string.sync_success);
 //                    syncDialog.dismiss();

+ 13 - 3
app/src/main/java/com/sunzee/ui/activity/HomeActivity.java

@@ -7,6 +7,7 @@ import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
+import android.os.Handler;
 import android.support.annotation.NonNull;
 import android.support.annotation.RequiresApi;
 import android.support.design.widget.NavigationView;
@@ -40,6 +41,7 @@ import com.sunzee.ui.dialog.CheckUpdatesDialog;
 import com.sunzee.ui.dialog.ShutdownDialog;
 import com.sunzee.utils.FileUtil;
 import com.sunzee.utils.HomePagerSimpleFactory;
+import com.sunzee.utils.LongClickUtils;
 import com.sunzee.utils.PreventSpeedClickUtil;
 import com.sunzee.utils.SharedPreferencesUtils;
 import com.sunzee.utils.ToastUtil;
@@ -71,6 +73,7 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
     private LinearLayout mLlBlack;
     private ImageView mIvShutownLogo;
     private PreventSpeedClickUtil mPreventSpeedClickUtil;
+    private TextView mTvVersion1;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -88,12 +91,12 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
 
     private void initView() {
         mNavigationView = findViewById(R.id.bnv_main_navigationbar);
+        mTvVersion1 = findViewById(R.id.tv_version);
         mTvVersion = findViewById(R.id.tv_version);
         mTvUpdataAPK = findViewById(R.id.tv_updatapk);
         mLlBlack = findViewById(R.id.ll_black);
         mIvShutownLogo = findViewById(R.id.iv_shutown_logo);
         mNavigationView.setItemIconTintList(null);
-        mIvShutownLogo.setOnClickListener(this);
         mFragmentManager = getSupportFragmentManager();
         mTvConnectionSystem = findViewById(R.id.connection_system);
         mTvSystemId = findViewById(R.id.tv_system_id);
@@ -106,7 +109,6 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
         mPreventSpeedClickUtil = new PreventSpeedClickUtil();
     }
 
-
     private void initEvent() {
         mNavigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
             @Override
@@ -122,7 +124,15 @@ public class HomeActivity extends MvpActivity<HomePresenter> implements HomeView
         mTvConnectionSystem.setOnClickListener(this);
         mTvUpdataAPK.setOnClickListener(this);
         mLlBlack.setOnClickListener(this);
-
+        mIvShutownLogo.setOnClickListener(this);
+        //长按退出程序。
+        LongClickUtils.setLongClick(new Handler(), mTvVersion1, 3000, new View.OnLongClickListener() {
+            @Override
+            public boolean onLongClick(View v) {
+                finish();
+                return false;
+            }
+        });
     }
 
     @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)

+ 0 - 1
app/src/main/java/com/sunzee/ui/dialog/WifiDialog.java

@@ -235,7 +235,6 @@ public class WifiDialog extends Dialog implements View.OnClickListener {
                     is_password_error = false;
                     connectType = 1;
                     wifiListSet(connectedWifiInfo.getSSID(), connectType);
-                    dismiss();
                 } else if (NetworkInfo.State.CONNECTING == info.getState()) {//正在连接
                     Log.i(TAG, "wifi正在连接");
                     WifiInfo connectedWifiInfo = mWifiHelper.getConnectionWifiInfo();

+ 10 - 0
app/src/main/java/com/sunzee/ui/fragment/HomepageFragment.java

@@ -67,12 +67,22 @@ public class HomepageFragment extends MvpFragment<HomePagePresenter> implements
                     return;
                 }
                 Map<String, List<Float>> location = Hawk.get("location", null);
+                Log.d(TAG, "onClick: "+location);
                 if (location != null) {
+                    //给控件新位置,替换之前的位置。
                     for (String s : location.keySet()) {
+                        Log.d(TAG, "onClick: "+s );
                         if (integerMap.containsKey(s)) {
                             location.put(s, integerMap.get(s));
                         }
                     }
+                    //没有变化过位置的也加进去。
+                    for (String s : integerMap.keySet()) {
+                        Log.d(TAG, "onClick: "+s );
+                        if (!location.containsKey(s)) {
+                            location.put(s, integerMap.get(s));
+                        }
+                    }
                     Hawk.put("location", location);
                 } else {
                     Hawk.put("location", integerMap);

+ 4 - 0
app/src/main/java/com/sunzee/ui/view/CustomViewGrounp.java

@@ -135,14 +135,18 @@ public class CustomViewGrounp extends ViewGroup implements CustomView.Informatio
     @Override
     public void setInformationLocationListener(View view, List<Float> list, boolean ismove) {
         this.ismove = ismove;
+        Log.d(TAG, "setInformationLocationListener: "+view.getId());
         switch (view.getId()) {
             case R.id.cv_0:
+                Log.d(TAG, "setInformationLocationListener: cv_0");
                 mIntegerMap1.put("0", list);
                 break;
             case R.id.cv_1:
+                Log.d(TAG, "setInformationLocationListener: cv_1");
                 mIntegerMap1.put("1", list);
                 break;
             case R.id.cv_2:
+                Log.d(TAG, "setInformationLocationListener: cv_2");
                 mIntegerMap1.put("2", list);
                 break;
             case R.id.cv_3:

+ 1 - 0
app/src/main/res/layout/navigation_layout.xml

@@ -13,6 +13,7 @@
         android:src="@drawable/login_logo" />
 
     <TextView
+        android:id="@+id/tv_restart"
         android:layout_width="@dimen/dp_50"
         android:layout_height="@dimen/dp_50"
         android:layout_marginTop="@dimen/dp_7"