Prechádzať zdrojové kódy

弹窗广告添加最小宽高的缓存

zengjiebin 7 rokov pred
rodič
commit
e3cc8cfc65

+ 13 - 1
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -47,9 +47,12 @@ import com.sheep.gamegroup.view.dialog.DialogPayAccount;
 import com.sheep.gamegroup.view.dialog.DialogPayGame;
 import com.sheep.gamegroup.view.dialog.DialogShare;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.ClassFileHelper;
 import com.sheep.jiuyan.samllsheep.utils.G;
 
+import org.afinal.simplecache.ACache;
+
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -564,10 +567,17 @@ public class ViewUtil {
                     .create();
             TextView dialog_title = dialog_parent.findViewById(R.id.dialog_title);
             final View dialog_close = dialog_parent.findViewById(R.id.dialog_close);
-            LinearLayout dialog_center_ll = dialog_parent.findViewById(R.id.dialog_center_ll);
+            final LinearLayout dialog_center_ll = dialog_parent.findViewById(R.id.dialog_center_ll);
             View view = LayoutInflater.from(activity).inflate(R.layout.dialog_half_screen_ad, dialog_center_ll, true);
             setText(dialog_title, advertising.getName());
 
+            ACache aCache = ACache.get(SheepApp.getInstance());
+            String wh = aCache.getAsString(advertising.getDisplay_src());
+            if(!TextUtils.isEmpty(wh) && wh.contains(";")) {
+                String[] items = wh.split(";");
+                dialog_center_ll.setMinimumWidth(Integer.parseInt(items[0]));
+                dialog_center_ll.setMinimumHeight(Integer.parseInt(items[1]));
+            }
             dialog_center_ll.setPadding(0,activity.getResources().getDimensionPixelSize(R.dimen.content_padding_54),0,activity.getResources().getDimensionPixelSize(R.dimen.content_padding_15));
 
             ImageView ad_iv = view.findViewById(R.id.ad_iv);
@@ -665,6 +675,8 @@ public class ViewUtil {
 //                    if (finalTimer != null) {
 //                        finalTimer.clear();
 //                    }
+                    ACache aCache = ACache.get(SheepApp.getInstance());
+                    aCache.put(advertising.getDisplay_src(), String.format(Locale.CHINA, "%d;%d", dialog_center_ll.getWidth(), dialog_center_ll.getHeight()));
                     Jump2View.getInstance().tryShowReservation(activity);
                 }
             });