|
|
@ -12,8 +12,10 @@ import android.os.AsyncTask;
|
|
12
|
12
|
import android.os.Handler;
|
|
13
|
13
|
import android.os.Message;
|
|
14
|
14
|
import android.os.Parcelable;
|
|
|
15
|
|
|
15
|
16
|
import androidx.viewpager.widget.PagerAdapter;
|
|
16
|
17
|
import androidx.viewpager.widget.ViewPager;
|
|
|
18
|
|
|
17
|
19
|
import android.util.AttributeSet;
|
|
18
|
20
|
import android.util.Log;
|
|
19
|
21
|
import android.view.LayoutInflater;
|
|
|
@ -107,7 +109,6 @@ public class SlideFindView extends FrameLayout {
|
|
107
|
109
|
|
|
108
|
110
|
@Override
|
|
109
|
111
|
public void handleMessage(Message msg) {
|
|
110
|
|
// TODO Auto-generated method stub
|
|
111
|
112
|
super.handleMessage(msg);
|
|
112
|
113
|
viewPager.setCurrentItem(currentItem);
|
|
113
|
114
|
}
|
|
|
@ -116,41 +117,27 @@ public class SlideFindView extends FrameLayout {
|
|
116
|
117
|
|
|
117
|
118
|
public SlideFindView(Context context) {
|
|
118
|
119
|
this(context, null);
|
|
119
|
|
// TODO Auto-generated constructor stub
|
|
120
|
120
|
}
|
|
121
|
121
|
|
|
122
|
122
|
public SlideFindView(Context context, AttributeSet attrs) {
|
|
123
|
123
|
this(context, attrs, 0);
|
|
124
|
|
// TODO Auto-generated constructor stub
|
|
125
|
124
|
}
|
|
126
|
125
|
|
|
127
|
126
|
public SlideFindView(Context context, AttributeSet attrs, int defStyle) {
|
|
128
|
127
|
super(context, attrs, defStyle);
|
|
129
|
128
|
this.context = context;
|
|
130
|
|
|
|
131
|
|
|
|
132
|
129
|
}
|
|
133
|
130
|
|
|
134
|
|
/**
|
|
135
|
|
* ????????л?
|
|
136
|
|
*/
|
|
137
|
131
|
private void startPlay() {
|
|
138
|
132
|
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
|
|
139
|
133
|
scheduledExecutorService.scheduleAtFixedRate(new SlideShowTask(), 2, 6, TimeUnit.SECONDS);
|
|
140
|
134
|
}
|
|
141
|
135
|
|
|
142
|
|
/**
|
|
143
|
|
* ???????л?12qwasZ
|
|
144
|
|
*/
|
|
145
|
136
|
private void stopPlay() {
|
|
146
|
137
|
scheduledExecutorService.shutdown();
|
|
147
|
138
|
}
|
|
148
|
139
|
|
|
149
|
|
/**
|
|
150
|
|
* ????????Data
|
|
151
|
|
*/
|
|
152
|
140
|
public void initData(List<Adin> listAdin) {
|
|
153
|
|
|
|
154
|
141
|
initImageLoader(context);
|
|
155
|
142
|
mlistAdin = listAdin;
|
|
156
|
143
|
|
|
|
@ -162,9 +149,6 @@ public class SlideFindView extends FrameLayout {
|
|
162
|
149
|
}
|
|
163
|
150
|
}
|
|
164
|
151
|
|
|
165
|
|
/**
|
|
166
|
|
* ?????Views??UI
|
|
167
|
|
*/
|
|
168
|
152
|
private void initUI(final Context context) {
|
|
169
|
153
|
if (imageUrls == null || imageUrls.length == 0)
|
|
170
|
154
|
return;
|
|
|
@ -176,25 +160,20 @@ public class SlideFindView extends FrameLayout {
|
|
176
|
160
|
dotLayout.removeAllViews();
|
|
177
|
161
|
|
|
178
|
162
|
|
|
179
|
|
// ?????????????????
|
|
180
|
163
|
for (int i = 0; i < imageUrls.length; i++) {
|
|
181
|
164
|
ImageView view = new ImageView(context);
|
|
182
|
165
|
view.setTag(imageUrls[i]);
|
|
183
|
|
// if(i==0)//?????????
|
|
184
|
|
// view.setBackgroundResource(R.drawable.bg_banner2_0);
|
|
185
|
166
|
view.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
186
|
167
|
final int finalI = i;
|
|
187
|
168
|
final int finalI1 = i;
|
|
188
|
169
|
view.setOnClickListener(new View.OnClickListener() {
|
|
189
|
170
|
@Override
|
|
190
|
171
|
public void onClick(View view) {
|
|
191
|
|
Log.i("@@@@@@@@@@@", "view--see1see");
|
|
192
|
172
|
ImageView imageView = new ImageView(context);
|
|
193
|
173
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
194
|
174
|
params.leftMargin = 4;
|
|
195
|
175
|
params.rightMargin = 4;
|
|
196
|
176
|
imageBrower(finalI, imageUrls);
|
|
197
|
|
|
|
198
|
177
|
}
|
|
199
|
178
|
});
|
|
200
|
179
|
imageViewsList.add(view);
|
|
|
@ -211,7 +190,7 @@ public class SlideFindView extends FrameLayout {
|
|
211
|
190
|
viewPager.setFocusable(true);
|
|
212
|
191
|
|
|
213
|
192
|
viewPager.setAdapter(new MyPagerAdapter());
|
|
214
|
|
viewPager.setOnPageChangeListener(new MyPageChangeListener());
|
|
|
193
|
viewPager.addOnPageChangeListener(new MyPageChangeListener());
|
|
215
|
194
|
}
|
|
216
|
195
|
|
|
217
|
196
|
private void imageBrower(int position, String[] urls) {
|
|
|
@ -281,19 +260,12 @@ public class SlideFindView extends FrameLayout {
|
|
281
|
260
|
*/
|
|
282
|
261
|
public void onShareClick(WebView webView, String shareUrl, String shareThumbnail, String shareTitle, String shareSubtitle) {
|
|
283
|
262
|
//当分享按钮被点击时,会调用此处代码。在这里处理分享的业务逻辑。
|
|
284
|
|
// new AlertDialog.Builder(webView.getContext())
|
|
285
|
|
// .setTitle("分享信息")
|
|
286
|
|
// .setItems(new String[] {"标题:"+shareTitle,"副标题:"+shareSubtitle,"缩略图地址:"+shareThumbnail,"链接:"+shareUrl}, null)
|
|
287
|
|
// .setNegativeButton("确定", null)
|
|
288
|
|
// .show();
|
|
289
|
263
|
ChargingShareBean chargingShareBean = new ChargingShareBean();
|
|
290
|
264
|
chargingShareBean.setIcon(shareThumbnail);
|
|
291
|
265
|
chargingShareBean.setTitle(shareTitle);
|
|
292
|
266
|
chargingShareBean.setUrl(shareUrl);
|
|
293
|
267
|
chargingShareBean.setText(shareSubtitle);
|
|
294
|
268
|
showSimpleBottomSheetGrid(chargingShareBean);
|
|
295
|
|
|
|
296
|
|
|
|
297
|
269
|
}
|
|
298
|
270
|
|
|
299
|
271
|
/**
|
|
|
@ -351,11 +323,7 @@ public class SlideFindView extends FrameLayout {
|
|
351
|
323
|
}
|
|
352
|
324
|
}
|
|
353
|
325
|
|
|
354
|
|
/**
|
|
355
|
|
* ???ViewPager???????????
|
|
356
|
|
*/
|
|
357
|
326
|
private class MyPagerAdapter extends PagerAdapter {
|
|
358
|
|
|
|
359
|
327
|
@Override
|
|
360
|
328
|
public void destroyItem(View container, int position, Object object) {
|
|
361
|
329
|
// TODO Auto-generated method stub
|
|
|
@ -368,86 +336,57 @@ public class SlideFindView extends FrameLayout {
|
|
368
|
336
|
ImageView imageView = imageViewsList.get(position);
|
|
369
|
337
|
Adin mAdin = mlistAdin.get(position);
|
|
370
|
338
|
|
|
371
|
|
// imageLoader.displayImage(imageView.getTag() + "", imageView);
|
|
372
|
339
|
Picasso.with(context).load(MainApplication.url + "/zhannew/uploadfile/" + mAdin.getImg()).into(imageView);
|
|
373
|
|
// Glide.with(MainApplication.context)
|
|
374
|
|
// .load(MainApplication.url+"/zhannew/uploadfile/"+mAdin.getImg())
|
|
375
|
|
// .error(R.drawable.bg_find_banner)
|
|
376
|
|
// .placeholder(R.drawable.bg_find_banner)
|
|
377
|
|
// .into(imageView);
|
|
378
|
|
|
|
379
|
|
// PicassoUtil.loadingNetImage(getContext(),
|
|
380
|
|
// imageViewsList.get(position)+ "", imageView);
|
|
381
|
|
|
|
382
|
|
|
|
383
|
340
|
((ViewPager) container).addView(imageViewsList.get(position));
|
|
384
|
|
// context.startActivity(new Intent(context.getApplicationContext(),ImageShowActivity.class));
|
|
385
|
|
// imageView.setImageDrawable(resizeImage2("/storage/emulated/0/alterandroidapp.jpg",200,100));
|
|
386
|
341
|
return imageViewsList.get(position);
|
|
387
|
342
|
}
|
|
388
|
343
|
|
|
389
|
344
|
@Override
|
|
390
|
345
|
public int getCount() {
|
|
391
|
|
// TODO Auto-generated method stub
|
|
392
|
346
|
return imageViewsList.size();
|
|
393
|
347
|
}
|
|
394
|
348
|
|
|
395
|
349
|
@Override
|
|
396
|
350
|
public boolean isViewFromObject(View arg0, Object arg1) {
|
|
397
|
|
// TODO Auto-generated method stub
|
|
398
|
351
|
return arg0 == arg1;
|
|
399
|
352
|
}
|
|
400
|
353
|
|
|
401
|
354
|
@Override
|
|
402
|
355
|
public void restoreState(Parcelable arg0, ClassLoader arg1) {
|
|
403
|
|
// TODO Auto-generated method stub
|
|
404
|
|
|
|
405
|
356
|
}
|
|
406
|
357
|
|
|
407
|
358
|
@Override
|
|
408
|
359
|
public Parcelable saveState() {
|
|
409
|
|
// TODO Auto-generated method stub
|
|
410
|
360
|
return null;
|
|
411
|
361
|
}
|
|
412
|
362
|
|
|
413
|
363
|
@Override
|
|
414
|
364
|
public void startUpdate(View arg0) {
|
|
415
|
|
// TODO Auto-generated method stub
|
|
416
|
365
|
|
|
417
|
366
|
}
|
|
418
|
367
|
|
|
419
|
368
|
@Override
|
|
420
|
369
|
public void finishUpdate(View arg0) {
|
|
421
|
|
// TODO Auto-generated method stub
|
|
422
|
370
|
|
|
423
|
371
|
}
|
|
424
|
372
|
|
|
425
|
373
|
}
|
|
426
|
374
|
|
|
427
|
|
/**
|
|
428
|
|
* ViewPager???????
|
|
429
|
|
* ??ViewPager????????????????????
|
|
430
|
|
*/
|
|
431
|
375
|
private class MyPageChangeListener implements ViewPager.OnPageChangeListener {
|
|
432
|
|
|
|
433
|
376
|
boolean isAutoPlay = false;
|
|
434
|
|
|
|
435
|
377
|
@Override
|
|
436
|
378
|
public void onPageScrollStateChanged(int arg0) {
|
|
437
|
|
// TODO Auto-generated method stub
|
|
438
|
379
|
switch (arg0) {
|
|
439
|
|
case 1:// ???????????????
|
|
|
380
|
case 1:
|
|
440
|
381
|
isAutoPlay = false;
|
|
441
|
382
|
break;
|
|
442
|
|
case 2:// ?????л???
|
|
|
383
|
case 2:
|
|
443
|
384
|
isAutoPlay = true;
|
|
444
|
385
|
break;
|
|
445
|
|
case 0:// ?????????????л?????????????
|
|
446
|
|
// ??????????????????????????л????????
|
|
|
386
|
case 0:
|
|
447
|
387
|
if (viewPager.getCurrentItem() == viewPager.getAdapter().getCount() - 1 && !isAutoPlay) {
|
|
448
|
388
|
viewPager.setCurrentItem(0);
|
|
449
|
389
|
}
|
|
450
|
|
// ???????????????????????????л?????????
|
|
451
|
390
|
else if (viewPager.getCurrentItem() == 0 && !isAutoPlay) {
|
|
452
|
391
|
viewPager.setCurrentItem(viewPager.getAdapter().getCount() - 1);
|
|
453
|
392
|
}
|
|
|
@ -457,14 +396,10 @@ public class SlideFindView extends FrameLayout {
|
|
457
|
396
|
|
|
458
|
397
|
@Override
|
|
459
|
398
|
public void onPageScrolled(int arg0, float arg1, int arg2) {
|
|
460
|
|
// TODO Auto-generated method stub
|
|
461
|
|
|
|
462
|
399
|
}
|
|
463
|
400
|
|
|
464
|
401
|
@Override
|
|
465
|
402
|
public void onPageSelected(int pos) {
|
|
466
|
|
// TODO Auto-generated method stub
|
|
467
|
|
|
|
468
|
403
|
currentItem = pos;
|
|
469
|
404
|
for (int i = 0; i < dotViewsList.size(); i++) {
|
|
470
|
405
|
if (i == pos) {
|
|
|
@ -477,11 +412,7 @@ public class SlideFindView extends FrameLayout {
|
|
477
|
412
|
|
|
478
|
413
|
}
|
|
479
|
414
|
|
|
480
|
|
/**
|
|
481
|
|
* ????????л?????
|
|
482
|
|
*/
|
|
483
|
415
|
private class SlideShowTask implements Runnable {
|
|
484
|
|
|
|
485
|
416
|
@Override
|
|
486
|
417
|
public void run() {
|
|
487
|
418
|
// TODO Auto-generated method stub
|
|
|
@ -490,14 +421,9 @@ public class SlideFindView extends FrameLayout {
|
|
490
|
421
|
handler.obtainMessage().sendToTarget();
|
|
491
|
422
|
}
|
|
492
|
423
|
}
|
|
493
|
|
|
|
494
|
424
|
}
|
|
495
|
425
|
|
|
496
|
|
/**
|
|
497
|
|
* ????ImageView????????????
|
|
498
|
|
*/
|
|
499
|
426
|
private void destoryBitmaps() {
|
|
500
|
|
|
|
501
|
427
|
for (int i = 0; i < IMAGE_COUNT; i++) {
|
|
502
|
428
|
ImageView imageView = imageViewsList.get(i);
|
|
503
|
429
|
Drawable drawable = imageView.getDrawable();
|
|
|
@ -509,9 +435,6 @@ public class SlideFindView extends FrameLayout {
|
|
509
|
435
|
}
|
|
510
|
436
|
|
|
511
|
437
|
|
|
512
|
|
/**
|
|
513
|
|
* ??????,???????
|
|
514
|
|
*/
|
|
515
|
438
|
class GetListTask extends AsyncTask<String, Integer, Boolean> {
|
|
516
|
439
|
|
|
517
|
440
|
@Override
|
|
|
@ -519,38 +442,11 @@ public class SlideFindView extends FrameLayout {
|
|
519
|
442
|
try {
|
|
520
|
443
|
// 这里一般调用服务端接口获取一组轮播图片,下面是从百度找的几个图片
|
|
521
|
444
|
// 这里就是你获取的那个图片;就是你zhan.getPic();你获取的也是一个图片数组
|
|
522
|
|
//imageUrls = new String[]{
|
|
523
|
|
// "http://image.zcool.com.cn/56/35/1303967876491.jpg",
|
|
524
|
|
// "http://image.zcool.com.cn/59/54/m_1303967870670.jpg",
|
|
525
|
|
// "http://image.zcool.com.cn/47/19/1280115949992.jpg"
|
|
526
|
|
//};
|
|
527
|
|
|
|
528
|
|
// String pic="http://123.56.88.79/zhan/uploadfile/2015/0629/20150629110624418.jpg|http://123.56.88.79/zhan/uploadfile/2015/0629/20150629110624243.jpg|http://123.56.88.79/zhan/uploadfile/2015/0629/20150629110625492.png";
|
|
529
|
|
// if(imageUrls.equals("")||imageUrls == null){
|
|
530
|
|
//
|
|
531
|
|
// }
|
|
532
|
|
// Log.e("imageUrls!",imageUrls);
|
|
533
|
|
|
|
534
|
|
// for (int i = 0; i < mlistAdin.size(); i++) {
|
|
535
|
|
// List<Adin> listAdin= JsonUtils.parseToObjectList(adin, Adin.class);
|
|
536
|
|
// for (int i = 0; i < listAdin.size(); i++) {
|
|
537
|
|
//
|
|
538
|
|
// imageUrls[i]=listAdin.get(i).getUrl();
|
|
539
|
|
// System.out.println(listAdin.get(i).getUrl());
|
|
540
|
|
//
|
|
541
|
|
// }
|
|
542
|
445
|
for (int i = 0; i < mlistAdin.size(); i++) {
|
|
543
|
446
|
imageUrls = new String[mlistAdin.size()];
|
|
544
|
447
|
imageUrls[i] = "http://cdz.d1ev.com/zhannew/uploadfile/" + mlistAdin.get(i).getImg();
|
|
545
|
448
|
System.out.println(imageUrls[i]);
|
|
546
|
|
// Log.d("qqqq",imageUrls[i]);
|
|
547
|
|
// Log.d("1111",imageUrls.length+"");
|
|
548
|
449
|
}
|
|
549
|
|
// imageUrls.add("http://cdz.d1ev.com/zhantest/uploadfile/"+listAdin.get(i).getUrl());
|
|
550
|
|
//System.out.println(listAdin.get(i).getContent());
|
|
551
|
|
|
|
552
|
|
// }
|
|
553
|
|
// imageUrls =params[0].split("\\|");
|
|
554
|
450
|
return true;
|
|
555
|
451
|
} catch (Exception e) {
|
|
556
|
452
|
e.printStackTrace();
|
|
|
@ -567,11 +463,6 @@ public class SlideFindView extends FrameLayout {
|
|
567
|
463
|
}
|
|
568
|
464
|
}
|
|
569
|
465
|
|
|
570
|
|
/**
|
|
571
|
|
* ImageLoader ??????????
|
|
572
|
|
*
|
|
573
|
|
* @param context
|
|
574
|
|
*/
|
|
575
|
466
|
public static void initImageLoader(Context context) {
|
|
576
|
467
|
// This configuration tuning is custom. You can tune every option, you
|
|
577
|
468
|
// may tune some of them,
|
|
|
@ -585,7 +476,6 @@ public class SlideFindView extends FrameLayout {
|
|
585
|
476
|
.build();
|
|
586
|
477
|
// Initialize ImageLoader with configuration.
|
|
587
|
478
|
ImageLoader.getInstance().init(config);
|
|
588
|
|
// PicassoUtil.loadingNetImage(context,);
|
|
589
|
479
|
}
|
|
590
|
480
|
|
|
591
|
481
|
//使用BitmapFactory.Options的inSampleSize参数来缩放
|
|
|
@ -669,10 +559,7 @@ public class SlideFindView extends FrameLayout {
|
|
669
|
559
|
Log.e(TAG, "onResponse: getShareIntegral=" + response);
|
|
670
|
560
|
String rtnCode = JsonUtils.getKeyResult(response, "rtnCode");
|
|
671
|
561
|
if (rtnCode.equals("01")) {
|
|
672
|
|
|
|
673
|
|
|
|
674
|
562
|
} else {
|
|
675
|
|
// ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT);
|
|
676
|
563
|
}
|
|
677
|
564
|
}
|
|
678
|
565
|
});
|
|
|
@ -704,7 +591,6 @@ public class SlideFindView extends FrameLayout {
|
|
704
|
591
|
}
|
|
705
|
592
|
}
|
|
706
|
593
|
}).build();
|
|
707
|
|
// build.
|
|
708
|
594
|
build.show();
|
|
709
|
595
|
}
|
|
710
|
596
|
|
|
|
@ -723,7 +609,6 @@ public class SlideFindView extends FrameLayout {
|
|
723
|
609
|
if (MainApplication.isLogin()) {
|
|
724
|
610
|
getShareIntegral();
|
|
725
|
611
|
}
|
|
726
|
|
// ToastUtil.showToast(getApplicationContext(),"分享成功",Toast.LENGTH_SHORT);
|
|
727
|
612
|
}
|
|
728
|
613
|
|
|
729
|
614
|
@Override
|