/** *ʧ����������ݲ鿴���� *create by songdebin 2016-04-05 **/ package com.bdyjy.fragment; import java.util.ArrayList; import java.util.List; import com.bdyjy.R; import com.bdyjy.activity.MainActivity; import com.bdyjy.constants.Const; import com.bdyjy.custom.view.ImageCycleView; import com.bdyjy.custom.view.ImageShow; import com.bdyjy.custom.view.ImageCycleView.ImageCycleViewListener; import com.bdyjy.entity.attArryData; import com.bdyjy.entity.lostfind.LostFind; import com.bdyjy.fragment.base.CollectionTypeConst; import com.bdyjy.fragment.base.FragmentWithCollection; import com.loopj.android.image.SmartImageView; import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.Fragment; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.Window; import android.widget.TextView; import android.widget.Button; import android.widget.RelativeLayout; @SuppressLint("ValidFragment") public class MyLostFindContentFragment extends FragmentWithCollection { private MainActivity ctx; private TextView tv_back; private Button btn_my; private int source; private TextView title; private TextView name; private TextView contacts; private TextView tel; private TextView description; // ͼƬչʾ private SmartImageView sv1;// private SmartImageView sv2;// private SmartImageView sv3; private SmartImageView sv4; // ������ public MyLostFindContentFragment(MainActivity ctx, int source) { super(ctx, CollectionTypeConst.LOSTANDFOUND); this.ctx = ctx; this.source = source; } public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.my_lostfind_content_fragment, null); // ������һ���� tv_back = (TextView) view.findViewById(R.id.tv_back); tv_back.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ctx.jumpToMyLost(source); } }); title = (TextView) view.findViewById(R.id.tv_title_lostfind_content); contacts = (TextView) view .findViewById(R.id.tv_contacts_lostfind_content); tel = (TextView) view.findViewById(R.id.tv_tel_lostfind_content); description = (TextView) view .findViewById(R.id.tv_description_lostfind_content); final LostFind lf = MainActivity.lostfindcontent; title.setText(lf.getTitle()); contacts.setText(lf.getContacts()); tel.setText(lf.getTel()); description.setText(lf.getDescription()); if (lf.getAttArry().size() == 0) // ���Ϊ�� ͼƬ�Ͳ�չʾ�� { View hiddenView = (View) view.findViewById(R.id.rl_picture_show); // ��hidden_view.xml��hidden_layout��root // layout if (null != hiddenView) { ViewGroup parent = (ViewGroup) hiddenView.getParent(); parent.removeView(hiddenView); } } else { try { String filePath = lf.getAttArry().get(0).getFilePath() .toString().trim(); // ��Ϊͨ������Content ���ص�attArryΪ�յ� // ��������ʱʹ�� ͨ�������б��ȡ��ͼƬ��ַ������ String attachmentPrefix = lf.getAttachmentPrefix().toString() .trim(); String http = attachmentPrefix + filePath; sv1 = (SmartImageView) view.findViewById(R.id.iv_show1); sv1.setImageUrl(http, R.drawable.default_image); sv1.setOnClickListener(new OnClickListener() { public void onClick(View view) { ImageShow(0); } }); } catch (Exception e) { e.printStackTrace(); } try { String filePath = lf.getAttArry().get(1).getFilePath() .toString().trim(); // ��Ϊͨ������Content ���ص�attArryΪ�յ� // ��������ʱʹ�� ͨ�������б��ȡ��ͼƬ��ַ������ String attachmentPrefix = lf.getAttachmentPrefix().toString() .trim(); String http = attachmentPrefix + filePath; sv2 = (SmartImageView) view.findViewById(R.id.iv_show2); sv2.setImageUrl(http, R.drawable.default_image); sv2.setOnClickListener(new OnClickListener() { public void onClick(View view) { ImageShow(1); } }); } catch (Exception e) { e.printStackTrace(); } try { String filePath = lf.getAttArry().get(2).getFilePath() .toString().trim(); // ��Ϊͨ������Content ���ص�attArryΪ�յ� // ��������ʱʹ�� ͨ�������б��ȡ��ͼƬ��ַ������ String attachmentPrefix = lf.getAttachmentPrefix().toString() .trim(); String http = attachmentPrefix + filePath; sv3 = (SmartImageView) view.findViewById(R.id.iv_show3); sv3.setImageUrl(http, R.drawable.default_image); sv3.setOnClickListener(new OnClickListener() { public void onClick(View view) { ImageShow(2); } }); } catch (Exception e) { e.printStackTrace(); } try { String filePath = lf.getAttArry().get(3).getFilePath() .toString().trim(); // ��Ϊͨ������Content ���ص�attArryΪ�յ� // ��������ʱʹ�� ͨ�������б��ȡ��ͼƬ��ַ������ String attachmentPrefix = lf.getAttachmentPrefix().toString() .trim(); String http = attachmentPrefix + filePath; sv4 = (SmartImageView) view.findViewById(R.id.iv_show4); sv4.setImageUrl(http, R.drawable.default_image); sv4.setOnClickListener(new OnClickListener() { public void onClick(View view) { ImageShow(3); } }); } catch (Exception e) { e.printStackTrace(); } } // ���µ���β���ղ���صĴ��� super.setMainView(view); dealCollect(lf.getId(), lf.getIsCollect(), lf.getTitle()); return view; } /** * * * * ********************************************/ private ImageCycleView mAdView; private ArrayList<String> mImageUrl = null; private ArrayList<String> mImageTitle = null; private ImageCycleViewListener mAdCycleViewListener = new ImageCycleViewListener() { @Override public void onImageClick(int position, View imageView) { // Toast.makeText(ctx, mImageUrl.get(position) + position, // 1).show(); } }; private ImageShow mAdView1; private ImageShow.ImageCycleViewListener mAdCycleViewListener1 = new ImageShow.ImageCycleViewListener() { @Override public void onImageClick(int position, View imageView) { // Toast.makeText(ctx, mImageUrl.get(position) + position, // 1).show(); } }; public void ImageShow(int currentItem) { AlertDialog alertDialog = new AlertDialog.Builder(ctx).create(); alertDialog.show(); Window window = alertDialog.getWindow(); window.setContentView(R.layout.dialog_image1); // SmartImageView sv; // sv=(SmartImageView)alertDialog.getWindow().findViewById(R.id.iv_show); LostFind lf = MainActivity.lostfindcontent; String filePath = lf.getAttArry().get(0).getFilePath().toString() .trim(); // ��Ϊͨ������Content ���ص�attArryΪ�յ� ��������ʱʹ�� ͨ�������б��ȡ��ͼƬ��ַ������ String attachmentPrefix = lf.getAttachmentPrefix().toString().trim(); String http = attachmentPrefix + filePath; // sv.setImageUrl(http, R.drawable.list_default_image); List<attArryData> attArry = lf.getAttArry(); mImageTitle = new ArrayList<String>(); mImageUrl = new ArrayList<String>(); // ѭ�����ͼƬ for (int i = 0; i < attArry.size(); i++) { filePath = lf.getAttArry().get(i).getFilePath().toString().trim(); // ��Ϊͨ������Content // ���ص�attArryΪ�յ� // ��������ʱʹ�� // ͨ�������б��ȡ��ͼƬ��ַ������ attachmentPrefix = lf.getAttachmentPrefix().toString().trim(); http = attachmentPrefix + filePath; mImageUrl.add(http); mImageTitle.add(""); } mAdView1 = (ImageShow) alertDialog.getWindow().findViewById( R.id.iv_showx); // mAdView1.pushImageCycle(); mAdView1.setImageResources(mImageUrl, mImageTitle, mAdCycleViewListener1, 2, currentItem); } }