导航菜单

页面标题

页面副标题

爱心e站 v1.0.0 - IndoorAlbumView.java 源代码

正在查看: 爱心e站 v1.0.0 应用的 IndoorAlbumView.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.baidu.panosdk.plugin.indoor.view;

import android.R;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.StateListDrawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.baidu.lbsapi.panoramaview.PanoramaView;
import com.baidu.panosdk.plugin.indoor.model.PhotoInfo;
import com.baidu.panosdk.plugin.indoor.res.IndoorResGlobal;
import com.baidu.panosdk.plugin.indoor.util.ScreenUtils;
import java.util.ArrayList;

public class IndoorAlbumView extends HorizontalScrollView {
    private GradientDrawable bg_imageFrame_Check;
    private int imageTitleSize;
    private OnClickExitListner onClickExitListner;
    private OnScrollStopListner onScrollStopListner;
    private PanoramaView panoramaView;
    private ArrayList<PhotoInfo> photoInfoList;
    private LinearLayout.LayoutParams singlePhotoParams;
    private LinearLayout tabContainer;
    private View[] views;

    public interface OnClickExitListner {
        void onClickExit();
    }

    public interface OnScrollStopListner {
        void onScrollStoped();
    }

    public IndoorAlbumView(Context context) {
        this(context, null);
    }

    public IndoorAlbumView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public IndoorAlbumView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        this.imageTitleSize = 10;
        setFillViewport(true);
        setWillNotDraw(false);
        this.tabContainer = new LinearLayout(context);
        this.tabContainer.setOrientation(0);
        this.tabContainer.setBackgroundColor(-1072424654);
        this.tabContainer.setLayoutParams(new LinearLayout.LayoutParams(-1, -1));
        addView(this.tabContainer);
        this.singlePhotoParams = new LinearLayout.LayoutParams(ScreenUtils.dip2px(60, context), ScreenUtils.dip2px(60, context));
        this.singlePhotoParams.setMargins(ScreenUtils.dip2px(8, context), ScreenUtils.dip2px(8, context), ScreenUtils.dip2px(8, context), ScreenUtils.dip2px(8, context));
        this.bg_imageFrame_Check = new GradientDrawable();
        this.bg_imageFrame_Check.setColor(0);
        this.bg_imageFrame_Check.setShape(0);
        this.bg_imageFrame_Check.setStroke(ScreenUtils.dip2px(2, context), -13400577);
    }

    public StateListDrawable getImageFrameBDrawable() {
        StateListDrawable bg_imageFrame = new StateListDrawable();
        GradientDrawable bg_imageFrame_F = new GradientDrawable();
        bg_imageFrame_F.setColor(0);
        bg_imageFrame_F.setShape(0);
        bg_imageFrame_F.setStroke(1, -11642518);
        GradientDrawable bg_imageFrame_P = new GradientDrawable();
        bg_imageFrame_P.setColor(0);
        bg_imageFrame_P.setShape(0);
        bg_imageFrame_P.setStroke(1, -13400577);
        bg_imageFrame.addState(new int[]{R.attr.state_pressed}, bg_imageFrame_P);
        bg_imageFrame.addState(new int[]{R.attr.state_focused}, bg_imageFrame_P);
        bg_imageFrame.addState(new int[0], bg_imageFrame_F);
        return bg_imageFrame;
    }

    public void notifyDataSetChanged() {
        this.tabContainer.removeAllViews();
        this.views = new View[this.photoInfoList.size()];
        for (int i = 0; i < this.photoInfoList.size(); i++) {
            final PhotoInfo photoInfo = this.photoInfoList.get(i);
            FrameLayout singlePhotoLayout = new FrameLayout(getContext());
            singlePhotoLayout.setBackgroundColor(-13748926);
            AsyncImageView imageView = new AsyncImageView(getContext(), photoInfo.type);
            imageView.loadImage(fromPhotoUrl(photoInfo.photoURL));
            FrameLayout.LayoutParams imageViewParams = new FrameLayout.LayoutParams(-1, -1);
            imageViewParams.gravity = 17;
            singlePhotoLayout.addView(imageView, imageViewParams);
            if (photoInfo.type == 0) {
                TextView imageTitle = new TextView(getContext());
                int[] colors = {R.color.transparent, -14144458};
                GradientDrawable bg_imageTitle = new GradientDrawable(GradientDrawable.Orientation.TOP_BOTTOM, colors);
                imageTitle.setBackgroundDrawable(bg_imageTitle);
                imageTitle.setTextColor(-1315344);
                imageTitle.setGravity(1);
                imageTitle.setPadding(ScreenUtils.dip2px(2, getContext()), 0, ScreenUtils.dip2px(2, getContext()), ScreenUtils.dip2px(3, getContext()));
                imageTitle.setTextSize(this.imageTitleSize);
                imageTitle.setSingleLine(true);
                imageTitle.setEllipsize(TextUtils.TruncateAt.END);
                imageTitle.setText(photoInfo.photoName);
                FrameLayout.LayoutParams imageTitleParams = new FrameLayout.LayoutParams(-1, -2);
                imageTitleParams.gravity = 80;
                singlePhotoLayout.addView(imageTitle, imageTitleParams);
            } else if (photoInfo.type == 1) {
                ImageView exitImage = new ImageView(getContext());
                exitImage.setScaleType(ImageView.ScaleType.CENTER);
                exitImage.setBackgroundColor(-1072424654);
                exitImage.setImageBitmap(IndoorResGlobal.INDOOR_EXIT);
                singlePhotoLayout.addView(exitImage, imageViewParams);
            }
            TextView imageFrame = new TextView(getContext());
            if (photoInfo.isDefault) {
                this.panoramaView.setPanorama(photoInfo.pid);
                imageFrame.setBackgroundDrawable(this.bg_imageFrame_Check);
            } else {
                imageFrame.setBackgroundDrawable(getImageFrameBDrawable());
            }
            singlePhotoLayout.addView(imageFrame, imageViewParams);
            imageFrame.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    for (View view : IndoorAlbumView.this.views) {
                        if (view.equals(v)) {
                            view.setBackgroundDrawable(IndoorAlbumView.this.bg_imageFrame_Check);
                        } else {
                            view.setBackgroundDrawable(IndoorAlbumView.this.getImageFrameBDrawable());
                        }
                    }
                    if (photoInfo.type == 0) {
                        IndoorAlbumView.this.panoramaView.setPanorama(photoInfo.pid);
                    } else if (photoInfo.type == 1 && IndoorAlbumView.this.onClickExitListner != null) {
                        IndoorAlbumView.this.onClickExitListner.onClickExit();
                    }
                }
            });
            this.views[i] = imageFrame;
            this.tabContainer.addView(singlePhotoLayout, this.singlePhotoParams);
        }
    }

    public void setPhotos(PanoramaView panoramaView, ArrayList<PhotoInfo> photoInfoList) {
        this.panoramaView = panoramaView;
        this.photoInfoList = photoInfoList;
        notifyDataSetChanged();
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        if (this.onScrollStopListner != null) {
            this.onScrollStopListner.onScrollStoped();
        }
    }

    public void setOnScrollStopListner(OnScrollStopListner listner) {
        this.onScrollStopListner = listner;
    }

    public void setOnClickExitListner(OnClickExitListner listner) {
        this.onClickExitListner = listner;
    }

    private String fromPhotoUrl(String pid) {
        return "http://pcsv1.map.bdimg.com/scape/?qt=pdata&sid=" + pid + "&pos=0_0&z=0";
    }
}