Ejemplo n.º 1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO 两种模式,如果在列表界面,则加载user_load_item.xml
    // 如果在播放界面,则加载透明的user_load_item2.xml
    if (isAtPlaylist) {
      ViewHolder2 viewHolder2;
      if (convertView == null) {

        convertView = mLayoutInflater.inflate(R.layout.user_load_item2, null);
        viewHolder2 = new ViewHolder2();

        viewHolder2.text = (TextView) convertView.findViewById(R.id.channel_name);
        viewHolder2.textIndex = (TextView) convertView.findViewById(R.id.channel_index);
        convertView.setTag(viewHolder2);
      } else {
        viewHolder2 = (ViewHolder2) convertView.getTag();
      }

      viewHolder2.textIndex.setText(Integer.toString(position + 1));
      viewHolder2.text.setText(infos.get(position).getName());

      return convertView;
    } else {
      ViewHolder viewHolder;
      if (convertView == null) {

        convertView = mLayoutInflater.inflate(R.layout.user_load_item, null);

        viewHolder = new ViewHolder();
        viewHolder.text = (TextView) convertView.findViewById(R.id.channel_name);
        convertView.setTag(viewHolder);
      } else {
        viewHolder = (ViewHolder) convertView.getTag();
      }
      // ImageView imageView = (ImageView)
      // view.findViewById(R.id.channel_icon);
      viewHolder.text.setText(infos.get(position).getName());

      return convertView;
    }
  }
Ejemplo n.º 2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder2 viewHolder2 = null;
    if (convertView == null) {
      viewHolder2 = new ViewHolder2();
      convertView = LayoutInflater.from(context).inflate(R.layout.item_system_news, null);
      viewHolder2.time2 = (TextView) convertView.findViewById(R.id.tv_ptimes);
      viewHolder2.title = (TextView) convertView.findViewById(R.id.tv_titles);
      viewHolder2.desc = (TextView) convertView.findViewById(R.id.tv_desc);
      viewHolder2.image = (ImageView) convertView.findViewById(R.id.iv_imgs);
      viewHolder2.rl_tt = (RelativeLayout) convertView.findViewById(R.id.rl_yuanw);
      convertView.setTag(viewHolder2);
    } else {
      viewHolder2 = (ViewHolder2) convertView.getTag();
    }
    final SystemNewsEntity entity = list.get(position);
    viewHolder2.time2.setText(entity.getAdd_time());
    viewHolder2.title.setText(entity.getTitle());
    viewHolder2.desc.setText(entity.getContent());
    String imgs = entity.getPicture();
    final String url = entity.getLinkurl();
    /** 图片要经过处理的 */
    ImageLoader imageLoader = null;

    // 图片
    if (imageLoader == null) {
      imageLoader = MyApplication.getInstance().getImageLoader();
    }

    DisplayImageOptions options =
        new DisplayImageOptions.Builder()
            .showImageOnLoading(R.mipmap.logo)
            .showImageForEmptyUri(R.mipmap.logo)
            .showImageOnFail(R.mipmap.logo)
            .cacheInMemory(true)
            .cacheOnDisk(true)
            .considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(200))
            .build();
    imageLoader.displayImage(imgs, viewHolder2.image, options);
    viewHolder2.rl_tt.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            T.ss("查看原文");
            //  Uri uri = Uri.parse(url);
            Intent intent = new Intent(context, WebActivity.class);
            intent.putExtra("url", entity.getLinkurl());
            intent.putExtra("title", "系统消息");
            context.startActivity(intent);
          }
        });
    return convertView;
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder1 viewHolder1 = null;
    ViewHolder2 viewHolder2 = null;
    ViewHolder3 viewHolder3 = null;
    int type = getItemViewType(position);
    if (convertView == null) {
      switch (type) {
        case TYPE_ONE:
          viewHolder1 = new ViewHolder1();
          convertView = inflater.inflate(R.layout.item_topic1, null);
          viewHolder1.tv_tipic_flag = (TextView) convertView.findViewById(R.id.tv_tipic_flag);
          viewHolder1.iv_topic = (ImageView) convertView.findViewById(R.id.iv_topic);
          viewHolder1.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
          viewHolder1.tv_people = (TextView) convertView.findViewById(R.id.tv_people);
          viewHolder1.btn_join = (Button) convertView.findViewById(R.id.btn_join);
          convertView.setTag(viewHolder1);
          break;
        case TYPE_TWO:
          viewHolder2 = new ViewHolder2();
          convertView = inflater.inflate(R.layout.item_topic2, null);
          viewHolder2.tv_history = (TextView) convertView.findViewById(R.id.tv_history);
          viewHolder2.tv1 = (TextView) convertView.findViewById(R.id.tv1);
          viewHolder2.tv2 = (TextView) convertView.findViewById(R.id.tv2);
          viewHolder2.tv3 = (TextView) convertView.findViewById(R.id.tv3);
          viewHolder2.iv1 = (ImageView) convertView.findViewById(R.id.iv1);
          viewHolder2.iv2 = (ImageView) convertView.findViewById(R.id.iv2);
          viewHolder2.iv3 = (ImageView) convertView.findViewById(R.id.iv3);
          convertView.setTag(viewHolder2);
          break;
        case TYPE_THREE:
          viewHolder3 = new ViewHolder3();
          convertView = inflater.inflate(R.layout.item_topic3, null);
          viewHolder3.iv_cover = (ImageView) convertView.findViewById(R.id.iv_cover);
          viewHolder3.iv_user = (CircleImageView) convertView.findViewById(R.id.iv_user);
          viewHolder3.tv_user_name = (TextView) convertView.findViewById(R.id.tv_user_name);
          viewHolder3.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
          convertView.setTag(viewHolder3);
          break;
      }
    } else {
      switch (type) {
        case TYPE_ONE:
          viewHolder1 = (ViewHolder1) convertView.getTag();
          break;
        case TYPE_TWO:
          viewHolder2 = (ViewHolder2) convertView.getTag();
          break;
        case TYPE_THREE:
          viewHolder3 = (ViewHolder3) convertView.getTag();
          break;
      }
    }
    // data
    switch (type) {
      case TYPE_ONE:
        viewHolder1.tv_tipic_flag.setText(activityEntities.get(position).getTitle());
        viewHolder1.tv_time.setText("时间01.08-02.06");
        viewHolder1.tv_people.setText(
            "参与人数" + activityEntities.get(position).getActivityStats().getParticipator() + "人");
        ImageUtils.getInstance()
            .loadWebImage(
                mContext, viewHolder1.iv_topic, activityEntities.get(position).getImage());
        viewHolder1.btn_join.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {}
            });
        break;
      case TYPE_TWO:
        /*ImageUtils.getInstance().loadWebImage(mContext,viewHolder2.iv1,activityEntities.get(position).getImage());
        ImageUtils.getInstance().loadWebImage(mContext,viewHolder2.iv2,activityEntities.get(position+1).getImage());
        ImageUtils.getInstance().loadWebImage(mContext,viewHolder2.iv3,activityEntities.get(position+2).getImage());*/
        break;
      case TYPE_THREE:
        viewHolder3.tv_user_name.setText(
            userEntities.get(position - bundle.getInt("TYPE1_COUNT")).getLoginNickname());
        viewHolder3.tv_title.setText("#" + activityEntities.get(position).getTitle());
        ImageUtils.getInstance()
            .loadWebImage(
                mContext,
                viewHolder3.iv_user,
                userEntities.get(position - bundle.getInt("TYPE1_COUNT")).getLoginAvatar());
        if (postEntities.get(position - bundle.getInt("TYPE1_COUNT")).getMedia().size() > 1) {
          ImageUtils.getInstance()
              .loadWebImage(
                  mContext,
                  viewHolder3.iv_cover,
                  postEntities
                      .get(position - bundle.getInt("TYPE1_COUNT"))
                      .getMedia()
                      .get(1)
                      .getOriginalUrl());
        } else {
          ImageUtils.getInstance()
              .loadWebImage(
                  mContext,
                  viewHolder3.iv_cover,
                  activityEntities.get(position).getBackgroundImage());
        }
        break;
    }

    return convertView;
  }
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ViewHolder viewHolder;
      ViewHolder2 viewHolder2;
      ViewHolder3 viewHolder3;
      int type = getItemViewType(position);
      switch (type) {
        case TYPE_TIME:
          if (convertView == null) {
            convertView =
                LayoutInflater.from(getActivity())
                    .inflate(R.layout.item_homemode_appointment_list_1, null);
            viewHolder = new ViewHolder();
            viewHolder.beginTime =
                (TextView) convertView.findViewById(R.id.item_appointment_begin_time);
            viewHolder.endTime =
                (TextView) convertView.findViewById(R.id.item_appointment_end_time);
            viewHolder.beginDelete =
                (ImageView) convertView.findViewById(R.id.item_appointment_begin_delete);
            viewHolder.endDelete =
                (ImageView) convertView.findViewById(R.id.item_appointment_end_delete);
            convertView.setTag(viewHolder);
          } else {
            viewHolder = (ViewHolder) convertView.getTag();
          }
          AppointmentTime curretAppointmentTime = appointmentList.get(position);
          viewHolder.beginTime.setText(parseTime(curretAppointmentTime.beginTime));
          viewHolder.endTime.setText(parseTime(curretAppointmentTime.endTime));
          viewHolder.endDelete.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  // TODO Auto-generated method stub
                  appointmentList.remove(position);
                  if (appointmentList.size() == 0
                      || appointmentList.get(appointmentList.size() - 1).type == TYPE_TIME) {
                    AppointmentTime appointmentTime =
                        new AppointmentTimeBuilder(AppointmentTimeAdapter.TYPE_TIP).build();
                    appointmentList.add(appointmentTime);
                  }
                  adapter.notifyDataSetChanged();
                }
              });
          viewHolder.beginDelete.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  // TODO Auto-generated method stub
                  appointmentList.remove(position);
                  if (appointmentList.size() == 0
                      || appointmentList.get(appointmentList.size() - 1).type == TYPE_TIME) {
                    AppointmentTime appointmentTime =
                        new AppointmentTimeBuilder(AppointmentTimeAdapter.TYPE_TIP).build();
                    appointmentList.add(appointmentTime);
                  }
                  adapter.notifyDataSetChanged();
                }
              });
          break;
        case TYPE_TIP:
          if (convertView == null) {
            convertView =
                LayoutInflater.from(getActivity())
                    .inflate(R.layout.item_homemode_appointment_list_2, null);
            viewHolder2 = new ViewHolder2();
            viewHolder2.beginTip =
                (TextView) convertView.findViewById(R.id.item_appointment_begin_time_title);
            viewHolder2.endTip =
                (TextView) convertView.findViewById(R.id.item_appointment_end_time_title);
            convertView.setTag(viewHolder2);
          } else {
            viewHolder2 = (ViewHolder2) convertView.getTag();
          }
          viewHolder2.beginTip.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View view) {
                  MyDate lastDate = getLastDate();
                  SelectAppointmentTimeDialog dialog =
                      new SelectAppointmentTimeDialog(
                          getActivity(),
                          getBeginDay(),
                          lastDate.year,
                          lastDate.month,
                          lastDate.day,
                          lastDate.hour);
                  dialog.setOnSelectedListener(
                      new OnSelectedListener() {
                        @Override
                        public void onSelected(String selectedData) {
                          // TODO Auto-generated method stub
                          System.out.println("您选择的时间-->" + selectedData);
                          AppointmentTime curretAppointmentTime = appointmentList.get(position);
                          curretAppointmentTime.setBeginTime(selectedData);
                          curretAppointmentTime.setType(TYPE_TIME_TIP);
                          adapter.notifyDataSetChanged();
                        }
                      });
                  dialog.show(((HomeModeWindow) getActivity()).getParentView());
                }
              });
          viewHolder2.endTip.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View view) {
                  ToastUtil.show(getActivity(), "请先选择开始时间");
                }
              });
          break;
        case TYPE_TIME_TIP:
          if (convertView == null) {
            convertView =
                LayoutInflater.from(getActivity())
                    .inflate(R.layout.item_homemode_appointment_list_3, null);
            viewHolder3 = new ViewHolder3();
            viewHolder3.beginTime =
                (TextView) convertView.findViewById(R.id.item_appointment_begin_time);
            viewHolder3.endTip =
                (TextView) convertView.findViewById(R.id.item_appointment_end_time_title);
            viewHolder3.beginDelete =
                (ImageView) convertView.findViewById(R.id.item_appointment_begin_delete);
            convertView.setTag(viewHolder3);
          } else {
            viewHolder3 = (ViewHolder3) convertView.getTag();
          }
          AppointmentTime curretAppointmentTime3 = appointmentList.get(position);
          viewHolder3.beginTime.setText(parseTime(curretAppointmentTime3.beginTime));
          viewHolder3.beginDelete.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View v) {
                  // TODO Auto-generated method stub
                  appointmentList.remove(position);
                  if (appointmentList.size() < 5) {
                    AppointmentTime appointmentTime =
                        new AppointmentTimeBuilder(AppointmentTimeAdapter.TYPE_TIP).build();
                    appointmentList.add(appointmentTime);
                  }
                  adapter.notifyDataSetChanged();
                }
              });
          viewHolder3.endTip.setOnClickListener(
              new OnClickListener() {
                @Override
                public void onClick(View view) {
                  MyDate lastDate = getLastDate();
                  SelectAppointmentTimeDialog dialog =
                      new SelectAppointmentTimeDialog(
                          getActivity(),
                          getBeginDay(),
                          lastDate.year,
                          lastDate.month,
                          lastDate.day,
                          lastDate.hour);
                  dialog.setOnSelectedListener(
                      new OnSelectedListener() {
                        @Override
                        public void onSelected(String selectedData) {
                          // TODO Auto-generated method stub
                          System.out.println("您选择的时间-->" + selectedData);
                          AppointmentTime curretAppointmentTime = appointmentList.get(position);
                          curretAppointmentTime.setEndTime(selectedData);
                          curretAppointmentTime.setType(TYPE_TIME);
                          // 自动添加一个新的
                          if (appointmentList.size() < 5) {
                            AppointmentTime appointmentTime =
                                new AppointmentTimeBuilder(AppointmentTimeAdapter.TYPE_TIP).build();
                            appointmentList.add(appointmentTime);
                          }
                          adapter.notifyDataSetChanged();
                        }
                      });
                  dialog.show(((HomeModeWindow) getActivity()).getParentView());
                }
              });
          break;
        default:
          break;
      }

      return convertView;
    }