From 01e23be6118d68d38a71d186296d440eadcaa197 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 07 六月 2021 18:23:41 +0800
Subject: [PATCH] 特价bug修复

---
 app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java |   92 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 64 insertions(+), 28 deletions(-)

diff --git a/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java b/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java
index 8999563..fab2a16 100644
--- a/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java
+++ b/app/src/main/java/com/tejia/lijin/app/ui/main/MainActivity.java
@@ -21,15 +21,25 @@
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewTreeObserver;
+import android.view.Window;
+import android.view.WindowManager;
 import android.widget.ImageView;
+import android.widget.LinearLayout;
 import android.widget.RadioButton;
 import android.widget.RadioGroup;
+import android.widget.TextView;
 import android.widget.Toast;
 
 import com.app.hubert.guide.util.ScreenUtils;
 import com.coloros.mcssdk.PushManager;
 import com.huawei.android.hms.agent.HMSAgent;
 import com.huawei.android.hms.agent.push.handler.GetTokenHandler;
+import com.tejia.lijin.app.entity.TrendsCategory;
+import com.tejia.lijin.app.ui.dialog.GoodsDetailJumpLoaingDialog;
+import com.tejia.lijin.app.ui.recommend.GoodsDetailActivity;
+import com.tejia.lijin.app.ui.trends.SendCircleFragmet;
+import com.tejia.lijin.app.util.Constant;
+import com.tejia.lijin.app.util.TopStatusSettings;
 import com.tejia.lijin.app.util.ui.HomeUIUtil;
 import com.umeng.analytics.MobclickAgent;
 import com.vivo.push.PushClient;
@@ -97,7 +107,8 @@
 
 
     private SharedPreferences spkefu;
-    private ImageView img, tv_msg_num2;
+    private ImageView img;
+    private TextView tv_msg_count;
     private DragFloatActionButton acbutton;
 
     String tag1 = "systemclient/getsystemclientparams";
@@ -144,7 +155,6 @@
         super.onCreate(savedInstanceState);
         getIntentParams();
 
-        findViewById(R.id.v_status_bar).setBackground(HomeUIUtil.getHomeTopBg("#FF227B", "#FF2A3E"));
 
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
             try {
@@ -155,14 +165,40 @@
             } catch (Exception e) {
             }
         }
+
         setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 閿佸畾绔栧睆
         setContentView(R.layout.activity_main);
+
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            Window window = getWindow();
+            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
+            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
+            window.setStatusBarColor(Color.TRANSPARENT);
+            int result = 0;
+            int resourceId = getResources().getIdentifier("status_bar_height",
+                    "dimen", "android");
+            if (resourceId > 0) {
+                result = getResources().getDimensionPixelSize(resourceId);
+            }
+            //璁剧疆鐘舵�佹爮鏂囧瓧棰滆壊鍙婂浘鏍囦负娣辫壊
+//            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
+            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
+                    result);
+            findViewById(R.id.v_status_bar).setLayoutParams(params);
+            findViewById(R.id.v_status_bar).setBackground(HomeUIUtil.getHomeTopBg(getApplicationContext()));
+        } else {
+            findViewById(R.id.v_status_bar).setVisibility(View.GONE);
+        }
+
+
         EventBus.getDefault().register(this);
         sp = getSharedPreferences("user", MODE_PRIVATE);
         mFragmentSwitchHelper = FragmentSwitchHelper.create(
                 R.id.fl_main_fragment_container, getSupportFragmentManager(),
-                new RecommendTopFragment(), new BrandFragment(), new MessageFragment(),
-                new TrendsTopFragment(), new MineFragment());
+                new RecommendTopFragment(), HotSalesFragment.newInstance(5, "鍏ㄩ儴", new TrendsCategory(0, "")), new MessageFragment(),
+                BetterGoodsFragment.newInstance(7 + "", "0"), new MineFragment());
 
         rg_nav = findViewById(R.id.rg_nav);
         rg_nav.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@@ -178,11 +214,11 @@
                     case R.id.rb_nav_hot_sale: {//鐑崠
                         MainCustomEvent.mainActivity(MainActivity.this);
                         mFragmentSwitchHelper
-                                .changeFragment(TrendsTopFragment.class);
+                                .changeFragment(HotSalesFragment.class);
                     }
                     break;
-                    case R.id.rb_nav_record://瓒宠抗
-                        mFragmentSwitchHelper.changeFragment(BrandFragment.class);
+                    case R.id.rb_nav_better_goods://濂界墿
+                        mFragmentSwitchHelper.changeFragment(BetterGoodsFragment.class);
                         break;
 
                     case R.id.rb_nav_mine: {//鎴戠殑
@@ -199,12 +235,12 @@
         getSystemParams();
         v_no_login = findViewById(R.id.v_no_login);
         acbutton = findViewById(R.id.actionButton);
-        tv_msg_num2 = findViewById(R.id.tv_msg_num2);//鎴戠殑绾㈢偣
+        tv_msg_count = findViewById(R.id.tv_msg_count);//娑堟伅鏁伴噺
         acbutton.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
                 //鐧婚檰
-                if (getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
+                if (UserUtil.isLogin(getApplicationContext())) {
                     LoginTaobao.getLoginTaobao(MainActivity.this, new LonginTaobaoCallback() {
                         @Override
                         public void onSuccess() {
@@ -270,7 +306,7 @@
                     ((RadioButton) findViewById(R.id.rb_nav_hot_sale)).setChecked(true);
                     break;
                 case 2:
-                    ((RadioButton) findViewById(R.id.rb_nav_record)).setChecked(true);
+                    ((RadioButton) findViewById(R.id.rb_nav_better_goods)).setChecked(true);
                     break;
                 case 3:
                     ((RadioButton) findViewById(R.id.rb_nav_mine)).setChecked(true);
@@ -322,16 +358,14 @@
      * 绯荤粺琛ュ厖鍙傛暟璇锋眰
      */
     private void getSystemParams() {
-        String uid = getSharedPreferences("user",
-                Context.MODE_PRIVATE).getString("uid", "");
-        ShoppingApi.getSystemParams(MainActivity.this, uid, new BasicTextHttpResponseHandler() {
+        ShoppingApi.getSystemParams(MainActivity.this, UserUtil.getUid(ShoppingApplication.application), new BasicTextHttpResponseHandler() {
             @Override
             public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                 if (jsonObject.optString("code").equalsIgnoreCase("0")) {
                     JSONArray array = jsonObject.optJSONObject("data").optJSONArray("systemClientParamsList");
                     SystemParamsUtil.saveParams(getApplicationContext(), array);
                     boolean input = sp.getBoolean("isFirstInput", true);
-                    boolean isLogin = sp.getBoolean("isLogin", false);
+                    boolean isLogin = UserUtil.isLogin(getApplicationContext());
                     //鏂颁汉濂界ぜ1鍏冪孩鍖�
                     if (input && !isLogin && sp.getString("newuser", "1").equalsIgnoreCase("0")) {
                         isFirstInput();
@@ -341,7 +375,7 @@
                     textVideo.isRecord(jsonObject);
                     //鏈嶅姟鍣ㄨ鏄剧ず 璐墿杞�&&鏈湴涔熻鏄剧ず
                     if (textVideo.getCart_float().equals("1") && textVideo.getLocalCart_float() != 1
-                            && getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
+                            && UserUtil.isLogin(getApplicationContext())) {
                         acbutton.setVisibility(View.VISIBLE);
                     } else {//闅愯棌璐墿杞�
                         acbutton.setVisibility(View.GONE);
@@ -376,9 +410,9 @@
             BuXinConstant.GO_SCAN = false;
             ((RadioButton) findViewById(R.id.rb_nav_recommend)).setChecked(true);
         }
-        boolean isLogin = sp.getBoolean("isLogin", false);
+        boolean isLogin = UserUtil.isLogin(getApplicationContext());
         v_no_login.setVisibility(isLogin ? View.INVISIBLE : View.VISIBLE);
-        getUnReadMsgCount(sp.getString("uid", "0"));//娑堟伅 鏈鏁伴噺
+        getUnReadMsgCount(UserUtil.getUid(ShoppingApplication.application));//娑堟伅 鏈鏁伴噺
 
         if (MiPushMessageReceiver.miPushMessage != null) {//鎵撳紑灏忕背鎺ㄩ��
             MiPushMessage message = MiPushMessageReceiver.miPushMessage;
@@ -404,7 +438,7 @@
             RecordImageTextVideo textVideo = new RecordImageTextVideo(MainActivity.this);
             //鏈嶅姟鍣ㄨ鏄剧ず 璐墿杞�&&鏈湴涔熻鏄剧ず涓嶄负1
             if (textVideo.getCart_float().equals("1") && textVideo.getLocalCart_float() != 1 &&
-                    getSharedPreferences("user", MODE_PRIVATE).getBoolean("isLogin", false)) {
+                    UserUtil.isLogin(getApplicationContext())) {
                 acbutton.setVisibility(View.VISIBLE);
                 //鐐瑰嚮杩� 鍐嶆樉绀猴紙璁╂寜閽浣嶏級
                 if (textVideo.getLocalCart_float() == 2) {
@@ -457,7 +491,7 @@
      *
      * @param uid
      */
-    private void getUnReadMsgCount(String uid) {
+    private void getUnReadMsgCount(Long uid) {
         ShoppingApi.getUnReadMsgCount(this, uid, new BasicTextHttpResponseHandler() {
             @Override
             public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
@@ -467,11 +501,15 @@
                     } else {
                         totalCount = 0;
                     }
-                    totalCount = 0;
                 } else {
                     totalCount = 0;
-                    tv_msg_num2.setVisibility(View.INVISIBLE);//闅愯棌鎴戠殑绾㈢偣
                 }
+
+                tv_msg_count.setVisibility(totalCount > 0 ? View.VISIBLE : View.INVISIBLE);
+                if (totalCount > 0) {
+                    tv_msg_count.setText(totalCount >= 100 ? "99+" : (totalCount + ""));
+                }
+
                 setUnReadMsgCount(jsonObject);
                 getgetHomeMsgList();//鑾峰彇鏈娑堟伅鏉℃暟
             }
@@ -499,7 +537,7 @@
             }
         }
         //灞曠ず鎴戠殑 绾㈢偣
-        tv_msg_num2.setVisibility(jsonObject.optJSONObject("data").optInt("mineCount") > 0 ? View.VISIBLE : View.INVISIBLE);
+//        int msgCount = jsonObject.optJSONObject("data").optInt("mineCount");
     }
 
     private void isFirstInput() {
@@ -570,7 +608,7 @@
      * @param entity
      */
     public void onEventMainThread(EventMessageEntity entity) {
-        getUnReadMsgCount(sp.getString("uid", "0"));
+        getUnReadMsgCount(UserUtil.getUid(ShoppingApplication.application));
         if (messagePush != null) {
             // 杩欓噷灏变細璋冪敤鎴戜滑Fragment涓殑MessagePush鏂规硶
             messagePush.MessagePush(true);//浼犲叆娑堟伅鎺ㄩ��
@@ -727,9 +765,8 @@
      * @param homeMsgListListener
      */
     private void getHomeMsgList(final getHomeMsgListListener homeMsgListListener) {
-        String uid = getSharedPreferences("user",
-                Context.MODE_PRIVATE).getString("uid", "");
-        ShoppingApi.getHomeMsgList(this, uid, mPage + "", new BasicTextHttpResponseHandler() {
+
+        ShoppingApi.getHomeMsgList(this, UserUtil.getUid(ShoppingApplication.application), mPage + "", new BasicTextHttpResponseHandler() {
             @Override
             public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                 homeMsgListListener.onSuccessPerfect(statusCode, headers, jsonObject);
@@ -838,13 +875,12 @@
             SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE);
             if (MobileUtil.getDeviceBrand().equalsIgnoreCase("HUAWEI")
                     || MobileUtil.getDeviceBrand().equalsIgnoreCase("HONOR")) {
-                String uid = sp.getString("uid", "0");
                 Log.e("eee", "HONOR: ");
                 //闃叉澶氭璇锋眰
                 if (System.currentTimeMillis() - lastBindHWTime > 1000 * 5) {//5s鍚庡啀璇锋眰
                     lastBindHWTime = System.currentTimeMillis();
                     Log.e("eee", "涓婁紶token");
-                    ShoppingApi.bindHMPush(MainActivity.this, token, uid, null);
+                    ShoppingApi.bindHMPush(MainActivity.this, token, UserUtil.getUid(ShoppingApplication.application), null);
                 }
             }
         }

--
Gitblit v1.8.0