Selaa lähdekoodia

首页弹出广告布局调整

huyuguo 5 vuotta sitten
vanhempi
commit
61396b183a

+ 0 - 33
app/src/main/java/com/electric/chargingpile/view/SlideAdView.java

70
import okhttp3.Call;
70
import okhttp3.Call;
71
71
72
72
73
/**
74
 * ViewPager??????????????????????柳?????????????Ч????
75
 * ??????????????????????????л????
76
 */
77
78
public class SlideAdView extends FrameLayout {
73
public class SlideAdView extends FrameLayout {
79
    private static final String TAG = "SlideAdView";
74
    private static final String TAG = "SlideAdView";
80
75
81
    // ???universal-image-loader????????????????????????universal-image-loader-1.8.6-with-sources.jar
82
    private ImageLoader imageLoader = ImageLoader.getInstance();
76
    private ImageLoader imageLoader = ImageLoader.getInstance();
83
77
84
    //??????????
85
    private final static int IMAGE_COUNT = 5;
78
    private final static int IMAGE_COUNT = 5;
86
    //?????????????
87
    private final static int TIME_INTERVAL = 5;
79
    private final static int TIME_INTERVAL = 5;
88
    //?????????????
89
    private final static boolean isAutoPlay = false;
80
    private final static boolean isAutoPlay = false;
90
81
91
    //??????????????
92
    private String[] imageUrls;
82
    private String[] imageUrls;
93
    private String imageUrl;
83
    private String imageUrl;
94
    private String imageT;
84
    private String imageT;
95
    Adin adin;
85
    Adin adin;
96
    //?????????ImageView ??list
97
    private List<ImageView> imageViewsList;
86
    private List<ImageView> imageViewsList;
98
    //??????View??list
99
    private List<View> dotViewsList;
87
    private List<View> dotViewsList;
100
    private List<Adin> mlistAdin;
88
    private List<Adin> mlistAdin;
101
89
102
    private ViewPager viewPager;
90
    private ViewPager viewPager;
103
    //???????
104
    private int currentItem = 0;
91
    private int currentItem = 0;
105
    //???????
106
    private ScheduledExecutorService scheduledExecutorService;
92
    private ScheduledExecutorService scheduledExecutorService;
107
93
108
    private Context context;
94
    private Context context;
147
133
148
    }
134
    }
149
135
150
    /**
151
     * ????????л?
152
     */
153
    private void startPlay() {
136
    private void startPlay() {
154
        scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
137
        scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
155
        scheduledExecutorService.scheduleAtFixedRate(new SlideShowTask(), 2, 3, TimeUnit.SECONDS);
138
        scheduledExecutorService.scheduleAtFixedRate(new SlideShowTask(), 2, 3, TimeUnit.SECONDS);
156
    }
139
    }
157
140
158
    /**
159
     * ???????л?
160
     */
161
    private void stopPlay() {
141
    private void stopPlay() {
162
        scheduledExecutorService.shutdown();
142
        scheduledExecutorService.shutdown();
163
    }
143
    }
164
144
165
    /**
166
     * ????????Data
167
     */
168
    public void initData(List<Adin> listAdin) {
145
    public void initData(List<Adin> listAdin) {
169
146
170
        initImageLoader(context);
147
        initImageLoader(context);
178
        }
155
        }
179
    }
156
    }
180
157
181
    /**
182
     * ?????Views??UI
183
     */
184
    private void initUI(final Context context) {
158
    private void initUI(final Context context) {
185
        if (imageUrls == null || imageUrls.length == 0)
159
        if (imageUrls == null || imageUrls.length == 0)
186
            return;
160
            return;
191
        dotLayout.removeAllViews();
165
        dotLayout.removeAllViews();
192
166
193
167
194
        // ?????????????????
195
        for (int i = 0; i < imageUrls.length; i++) {
168
        for (int i = 0; i < imageUrls.length; i++) {
196
            ImageView view = new ImageView(context);
169
            ImageView view = new ImageView(context);
197
            view.setTag(imageUrls[i]);
170
            view.setTag(imageUrls[i]);
198
//            if(i==0)//?????????
199
//                view.setBackgroundResource(R.drawable.bg_banner2_0);
200
            view.setScaleType(ScaleType.FIT_XY);
171
            view.setScaleType(ScaleType.FIT_XY);
201
            final int finalI = i;
172
            final int finalI = i;
202
            final int finalI1 = i;
173
            final int finalI1 = i;
221
            dotLayout.addView(dotView, params);
192
            dotLayout.addView(dotView, params);
222
            dotViewsList.add(dotView);
193
            dotViewsList.add(dotView);
223
            Log.e("qwe", dotViewsList.size() + "");
194
            Log.e("qwe", dotViewsList.size() + "");
224
//            dotLayout.setVisibility(VISIBLE);
225
//            ((View)dotViewsList.get(0)).setBackgroundResource(R.drawable.dot_focus);
226
        }
195
        }
227
        if (dotViewsList.size() > 1) {
196
        if (dotViewsList.size() > 1) {
228
            if (dotViewsList.size() == 2) {
197
            if (dotViewsList.size() == 2) {
252
221
253
        Log.e("position===", position + "");
222
        Log.e("position===", position + "");
254
223
255
//////
256
//        Uri uri = Uri.parse(mAdin.getUrl());
257
        System.out.print("44:" + mAdin.getUrl());
224
        System.out.print("44:" + mAdin.getUrl());
258
225
259
        if (mAdin.getIs_dui() == 0) {
226
        if (mAdin.getIs_dui() == 0) {

+ 9 - 12
app/src/main/res/layout/activity_main_map.xml

1770
        android:layout_centerHorizontal="true"
1770
        android:layout_centerHorizontal="true"
1771
        android:layout_centerVertical="true"
1771
        android:layout_centerVertical="true"
1772
        android:background="@drawable/bg_black2_0"
1772
        android:background="@drawable/bg_black2_0"
1773
        android:visibility="gone">
1773
        android:visibility="gone"
1774
        tools:visibility="gone">
1775
1776
        <com.electric.chargingpile.view.SlideAdView
1777
            android:id="@+id/imageView8"
1778
            android:layout_width="297dp"
1779
            android:layout_height="396dp"
1780
            android:layout_centerInParent="true"
1781
            android:scaleType="fitXY" />
1774
1782
1775
        <ImageView
1783
        <ImageView
1776
            android:id="@+id/iv_clear"
1784
            android:id="@+id/iv_clear"
1780
            android:layout_centerHorizontal="true"
1788
            android:layout_centerHorizontal="true"
1781
            android:layout_marginTop="35dp"
1789
            android:layout_marginTop="35dp"
1782
            android:src="@drawable/icon_adbutton2_0" />
1790
            android:src="@drawable/icon_adbutton2_0" />
1783
1784
        <com.electric.chargingpile.view.SlideAdView
1785
            android:id="@+id/imageView8"
1786
            android:layout_width="297dp"
1787
            android:layout_height="396dp"
1788
            android:layout_alignParentTop="true"
1789
            android:layout_centerHorizontal="true"
1790
            android:layout_gravity="center"
1791
            android:layout_marginTop="105dp"
1792
            android:scaleType="fitXY" />
1793
1794
    </com.zhy.autolayout.AutoRelativeLayout>
1791
    </com.zhy.autolayout.AutoRelativeLayout>
1795
    <!-- 首页弹出广告布局 end -->
1792
    <!-- 首页弹出广告布局 end -->
1796
    <!-- 首页首次启动弹出隐私协议 start -->
1793
    <!-- 首页首次启动弹出隐私协议 start -->