Browse Source

ad for checkin

billyyoyo 5 years ago
parent
commit
77778dce5d

+ 2 - 0
app/src/main/java/com/sheep/gamegroup/greendao/download/SheepAd.java

@@ -24,6 +24,8 @@ public class SheepAd {
     public final static int FORM_NEWS = 7;
     //8:游戏悬浮球广告
     public final static int FORM_GAME_FLOAT = 8;
+    //13:游戏悬浮球广告
+    public final static int FORM_CHECKIN = 13;
 
     @Id(autoincrement = true)
     private Long id;

+ 32 - 0
app/src/main/java/com/sheep/gamegroup/util/ViewUtil.java

@@ -527,6 +527,38 @@ public class ViewUtil {
 
     }
 
+    public void showCheckinAdDialog(final Activity mActivity, SheepAd ad, @LayoutRes int layoutId, Action1<View> action1) {
+        View view = LayoutInflater.from(mActivity).inflate(layoutId, null, false);
+        final AlertDialog mAlertDialog = new AlertDialog.Builder(mActivity, R.style.MyDialogActivityTheme)
+                .setView(view)
+                .create();
+        if (action1 != null)
+            action1.call(view);
+
+        ImageView ivClose = view.findViewById(R.id.dialog_close);
+        final ImageView adPicView = view.findViewById(R.id.ad_iv);
+        if (ad != null) {
+            setImage(adPicView, ad.getAd_img());
+            adPicView.setOnClickListener(v -> AdHelper.goAdLink(mActivity, ad));
+            AdHelper.stat(ad.getAd_id(), 1);
+        }
+
+        ivClose.setOnClickListener(v -> mAlertDialog.dismiss());
+        mAlertDialog.setOnDismissListener(dialogInterface -> {
+            DataUtil.putAsInt(DataKey.KEY_ORDER, 1);
+            if (mActivity instanceof ActMain && DataUtil.getAsBoolean("tryShowHalfScreenAd", false)) {
+                DataUtil.putAsBoolean("tryShowHalfScreenAd", false);
+                Jump2View.getInstance().tryShowHalfScreenAd(mActivity, ((ActMain) mActivity).getContainer());
+            }
+        });
+        try {
+            mAlertDialog.show();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+    }
+
     public static final String BLOCK = "\u2588";//用特殊字符显示方块
 
     /**

+ 33 - 14
app/src/main/java/com/sheep/jiuyan/samllsheep/ui/activity/SignActivity.java

@@ -12,6 +12,7 @@ import android.widget.TextView;
 
 import com.kfzs.duanduan.utils.NumberFormatUtils;
 import com.sheep.gamegroup.absBase.BaseUMActivity;
+import com.sheep.gamegroup.greendao.download.SheepAd;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.Lp;
 import com.sheep.gamegroup.model.entity.PunchAndSign;
@@ -406,25 +407,43 @@ public class SignActivity extends BaseUMActivity {
         });
     }
 
-    private void tryShowSignResultAndTask(final String title, final double money) {
-        CommonUtil.getInstance().robTask(new Action1<CommendTask>() {
+    private void showSignResult(String title, double money, SheepAd ad) {
+        ViewUtil.newInstance().showCheckinAdDialog(this, ad, R.layout.dialog_sign_result_and_task, new Action1<View>() {
             @Override
-            public void call(CommendTask robTask) {
-                if (robTask != null) {
-                    DataUtil.putAsInt(DataKey.KEY_ORDER, robTask.getOrder());
-                    try {
-                        showSignResultAndTask(title, money, robTask);
-                    } catch (Exception e) {
-                        e.printStackTrace();
-                        G.showToast(e.getMessage());
-                    }
-                } else {
-                    G.showToast(R.string.task_sold_out_focus_publish);
-                }
+            public void call(View view) {
+                ViewUtil.setText((TextView) view.findViewById(R.id.sign_window_title), title);
+                ViewUtil.setText((TextView) view.findViewById(R.id.sign_money_number), String.format(Locale.CHINA, "+%s", NumberFormatUtils.retainMost2(money)));
             }
         });
     }
 
+    private void tryShowSignResultAndTask(final String title, final double money) {
+//        CommonUtil.getInstance().robTask(new Action1<CommendTask>() {
+//            @Override
+//            public void call(CommendTask robTask) {
+//                if (robTask != null) {
+//                    DataUtil.putAsInt(DataKey.KEY_ORDER, robTask.getOrder());
+//                    try {
+//                        showSignResultAndTask(title, money, robTask);
+//                    } catch (Exception e) {
+//                        e.printStackTrace();
+//                        G.showToast(e.getMessage());
+//                    }
+//                } else {
+//                    G.showToast(R.string.task_sold_out_focus_publish);
+//                }
+//            }
+//        });
+        CommonUtil.getInstance().refreshAds(SheepAd.FORM_CHECKIN, (ret, ads) -> {
+            if (!ret || ads.size() == 0) {
+                showSignResult(title, money, null);
+            } else {
+                showSignResult(title, money, ads.get(0));
+            }
+
+        });
+    }
+
     @OnClick(R.id.active_info)
     public void onActiveInfoClicked() {
         startActivity(new Intent(SignActivity.this, ActiveRuleActivity.class));

+ 16 - 0
app/src/main/res/layout/dialog_sign_result_and_task.xml

@@ -64,15 +64,29 @@
                     android:textSize="12sp" />
             </LinearLayout>
 
+            <ImageView
+                android:id="@+id/ad_iv"
+                android:adjustViewBounds="true"
+                android:scaleType="center"
+                android:layout_marginTop="60dp"
+                android:maxHeight="150dp"
+                android:minHeight="100dp"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content" />
+
             <TextView
+                android:id="@+id/money_title_view"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="60dp"
                 android:text="今日赚钱推荐"
                 android:textColor="#ff089dfa"
+                android:visibility="gone"
                 android:textSize="18sp" />
 
             <LinearLayout
+                android:id="@+id/money_task_view"
+                android:visibility="gone"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="25dp"
@@ -121,10 +135,12 @@
             </LinearLayout>
 
             <LinearLayout
+                android:id="@+id/money_button_view"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_marginTop="20dp"
                 android:gravity="center"
+                android:visibility="gone"
                 android:orientation="horizontal">
 
                 <TextView

+ 1 - 1
app/src/main/res/layout/x_real_name_auther_layout.xml

@@ -19,7 +19,7 @@
         <TextView
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="请完善个人信息,第一次实名认证免费,若提交错误,再次提交需要扣除05绵羊币/次!实名信息一旦认证成功不可更改!"
+            android:text="请完善个人信息,第一次实名认证免费,若提交错误,再次提交需要扣除0.5绵羊币/次!实名信息一旦认证成功不可更改!"
             android:textColor="#666666"
             android:textSize="13sp" />
     </LinearLayout>