|
@@ -1,20 +1,29 @@
|
|
|
package com.xunao.effectdemo.activity;
|
|
|
|
|
|
-import androidx.appcompat.app.AppCompatActivity;
|
|
|
+import static com.blankj.utilcode.util.ScreenUtils.getScreenHeight;
|
|
|
+import static com.blankj.utilcode.util.ScreenUtils.getScreenWidth;
|
|
|
|
|
|
import android.app.Activity;
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
-import android.util.Log;
|
|
|
-import android.view.View;
|
|
|
+import android.view.ViewGroup;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.HorizontalScrollView;
|
|
|
+import android.widget.ImageView;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.RelativeLayout;
|
|
|
|
|
|
+import com.bumptech.glide.Glide;
|
|
|
+import com.bumptech.glide.load.DecodeFormat;
|
|
|
import com.xunao.effectdemo.R;
|
|
|
+import com.xunao.effectdemo.bean.MapBean;
|
|
|
+import com.xunao.effectdemo.bean.MapBean.ResultBean.ListBean.StepsBean;
|
|
|
import com.xunao.effectdemo.net.ApiHttpClient;
|
|
|
import com.xunao.effectdemo.net.ApiUrl;
|
|
|
import com.xunao.effectdemo.net.CSMHttpCallback;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
@@ -32,15 +41,27 @@ public class MapChallengeActivity extends Activity {
|
|
|
private String maps_id = "185";
|
|
|
private String student_id = "180721";
|
|
|
|
|
|
+ private List<String> bkg_images;
|
|
|
+ private LinearLayout llMapBg;
|
|
|
+ private RelativeLayout rlMapBg;
|
|
|
+ private HorizontalScrollView scrollView;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.activity_map_challenge);
|
|
|
initView();
|
|
|
+ initData();
|
|
|
+ }
|
|
|
+
|
|
|
+ void initData(){
|
|
|
+ getMap();
|
|
|
}
|
|
|
|
|
|
void initView(){
|
|
|
+ llMapBg = findViewById(R.id.ll_map_bg);
|
|
|
+ rlMapBg = findViewById(R.id.rl_map_bg);
|
|
|
btnMap1 = findViewById(R.id.btn_map_1);
|
|
|
btnMap2 = findViewById(R.id.btn_map_2);
|
|
|
btnMap2.setOnClickListener(v -> {
|
|
@@ -87,6 +108,45 @@ public class MapChallengeActivity extends Activity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void addBigBg(String url){
|
|
|
+ ImageView child = new ImageView(this);
|
|
|
+// Glide.with(this).asBitmap().load(url).into(new BitmapImageViewTarget(child){
|
|
|
+// @Override
|
|
|
+// public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
|
|
+// child.setLayoutParams(new LinearLayout.LayoutParams(getScreenHeight()* resource.getWidth()/resource.getHeight(),getScreenHeight()));
|
|
|
+// child.setImageBitmap(resource);
|
|
|
+// }
|
|
|
+// });
|
|
|
+ Glide.with(this)
|
|
|
+ .load(url)
|
|
|
+ .format(DecodeFormat.PREFER_RGB_565)
|
|
|
+ .into(child);
|
|
|
+ child.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
|
+ child.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,getScreenHeight()));
|
|
|
+ llMapBg.addView(child);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void addSmallBg(String url, double x, double y){
|
|
|
+ ImageView child = new ImageView(this);
|
|
|
+// Glide.with(this).asBitmap().load(url).into(new BitmapImageViewTarget(child){
|
|
|
+// @Override
|
|
|
+// public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
|
|
|
+// child.setLayoutParams(new LinearLayout.LayoutParams(getScreenHeight()* resource.getWidth()/resource.getHeight(),getScreenHeight()));
|
|
|
+// child.setImageBitmap(resource);
|
|
|
+// }
|
|
|
+// });
|
|
|
+ Glide.with(this)
|
|
|
+ .load(url)
|
|
|
+ .format(DecodeFormat.PREFER_RGB_565)
|
|
|
+ .into(child);
|
|
|
+ child.setScaleType(ImageView.ScaleType.FIT_XY);
|
|
|
+ RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(360,300);
|
|
|
+ layoutParams.leftMargin = (int)(x * getScreenWidth()*11);
|
|
|
+ layoutParams.topMargin = (int)(y * getScreenHeight());
|
|
|
+ child.setLayoutParams(layoutParams);
|
|
|
+ rlMapBg.addView(child);
|
|
|
+ }
|
|
|
+
|
|
|
void getMap(){
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
params.put("member_id",member_id);
|
|
@@ -96,7 +156,15 @@ public class MapChallengeActivity extends Activity {
|
|
|
ApiHttpClient.get(ApiUrl.getMap,params, new CSMHttpCallback() {
|
|
|
@Override
|
|
|
protected void onSuccess(String jsonStr) {
|
|
|
-
|
|
|
+ MapBean mapBean = MapBean.parse(jsonStr);
|
|
|
+ bkg_images = mapBean.getResult().getList().getBkg_images();
|
|
|
+ for(String url : bkg_images){
|
|
|
+ addBigBg(url);
|
|
|
+ }
|
|
|
+ List<StepsBean> stepsBeans = mapBean.getResult().getList().getSteps();
|
|
|
+ for(StepsBean stepsBean : stepsBeans){
|
|
|
+ addSmallBg(stepsBean.getImage(), stepsBean.getCoordinate().getX(), stepsBean.getCoordinate().getY());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|