@Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    ViewHolder viewHolder = null;
    RelativeLayout row = null;

    if (view == null) {
      LayoutInflater inflater = mActivity.getLayoutInflater();
      row = (RelativeLayout) inflater.inflate(LAYOUT_ID, null);
      viewHolder = new ViewHolder();
      viewHolder.mImageViewProfilePicture =
          (ImageView) row.findViewById(R.id.adapter_profile_picture);
      viewHolder.mRatingBar = (RatingBar) row.findViewById(R.id.adapter_rating);
      viewHolder.mTextViewChannelName = (TextView) row.findViewById(R.id.adapter_channel_name);
      viewHolder.mTextViewFollower = (TextView) row.findViewById(R.id.adapter_followers);
      viewHolder.mTextViewUserName = (TextView) row.findViewById(R.id.adapter_user_name);
      viewHolder.mImageViewCover = (ImageView) row.findViewById(R.id.adapter_live_cover_image);
      FontsUtil.setViewGroupTypeface((ViewGroup) row, mActivity);

      row.setTag(viewHolder);
    } else {
      row = (RelativeLayout) view;
      viewHolder = (ViewHolder) row.getTag();
    }

    ChannelPOJO channelPOJO = (ChannelPOJO) getItem(i);
    viewHolder.mTextViewChannelName.setText(channelPOJO.getName());
    viewHolder.mTextViewFollower.setText(
        String.valueOf(channelPOJO.getFollowersCount())
            .concat(" ")
            .concat(mActivity.getString(R.string.followers)));
    viewHolder.mTextViewUserName.setText(channelPOJO.getUserPOJO().getUserName());

    if (!TextUtils.isEmpty(channelPOJO.getUserPOJO().getProfilePicture())) {
      Picasso.with(mActivity)
          .load(channelPOJO.getUserPOJO().getProfilePicture())
          .transform(new PicassoCircleTransformation())
          .into(viewHolder.mImageViewProfilePicture);
    } else {
      Picasso.with(mActivity)
          .load(R.drawable.default_avatar)
          .transform(new PicassoCircleTransformation())
          .into(viewHolder.mImageViewProfilePicture);
    }

    if (!TextUtils.isEmpty(channelPOJO.getCoverImage())) {
      Picasso.with(mActivity).load(channelPOJO.getCoverImage()).into(viewHolder.mImageViewCover);
    }

    Log.d("CuongCuongCuong", "channelPOJO.getRating " + channelPOJO.getRating());
    viewHolder.mRatingBar.setRating((float) channelPOJO.getRating());

    return row;
  }
Beispiel #2
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.ibtn_back:
        onBackPressed();
        break;
      case R.id.btn_do:
        if (type == 1) {
          requestRoutePlan((MyPoiInfo) rl_info.getTag());
        } else {

        }

        break;
      default:
        break;
    }
  }
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    RelativeLayout todoView = null;
    final VideoModel video = getItem(position);
    ViewHolder holder = new ViewHolder();
    String tag = "" + position + "";

    for (int x = 0; x < views.size(); x++) {
      todoView = (RelativeLayout) views.get(x);
      if (todoView.getTag().equals(tag)) {
        return todoView;
      }
    }
    /*
     * if (convertView == null) { todoView = new
     * RelativeLayout(getContext()); String inflater =
     * Context.LAYOUT_INFLATER_SERVICE; LayoutInflater li =
     * (LayoutInflater) getContext().getSystemService( inflater);
     * li.inflate(resource, todoView, true); } else { todoView =
     * (RelativeLayout) convertView; }
     */
    todoView = new RelativeLayout(getContext());
    String inflater = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater li = (LayoutInflater) getContext().getSystemService(inflater);
    li.inflate(resource, todoView, true);
    // holder.btn = (Button) todoView.findViewById(R.id.video_item_btn);

    holder.title = (TextView) todoView.findViewById(R.id.video_item_title);
    holder.tv_duration = (TextView) todoView.findViewById(R.id.tv_duration);

    String duration = "";
    try {
      final NumberFormat formatter = NumberFormat.getNumberInstance(Locale.getDefault());

      formatter.setMaximumFractionDigits(2);
      int durationInt = Integer.parseInt(video.getDuration());
      Double minutes = Math.floor(durationInt / 60.0);
      Double seconds = Math.floor((durationInt) - (minutes * 60));

      String str_min = formatter.format(minutes);
      if (minutes <= 9) {
        str_min = "0" + formatter.format(minutes);
      }

      String str_sec = formatter.format(seconds);
      if (seconds <= 9) {
        str_sec = "0" + formatter.format(seconds);
      }

      duration = str_min + " : " + str_sec;
    } catch (Exception e) {
      duration = c.getResources().getString(R.string.not_set);
    }
    holder.tv_duration.setText(duration);
    /*
     * holder.btn.setOnClickListener(new OnClickListener() {
     *
     * @Override public void onClick(View v) { Intent n = new Intent(c,
     * Ac_Video.class); n.putExtra("video_id", video.getID());
     * c.startActivity(n);
     *
     * } }) ;
     */

    holder.img_favorited = (ImageView) todoView.findViewById(R.id.img_favorited);
    if (dba.checkFavoStatus(video)) {
      holder.img_favorited.setImageResource(R.drawable.btn_favhover);
    } else {
      holder.img_favorited.setImageResource(R.drawable.btn_fav);
    }

    holder.img = (UIImage) todoView.findViewById(R.id.video_item_image);
    // default.jpg height:90,width:120
    // mqdefault.jpg,height:180,width:320
    // hqdefault.jpg,height:360,width:480
    String imageUrl = "http://i.ytimg.com/vi/" + video.getID() + "/mqdefault.jpg";
    if (UIPlayList.isTablet(c)) {
      imageUrl = "http://i.ytimg.com/vi/" + video.getID() + "/hqdefault.jpg";
    }

    holder.img.onAttacheActoin = false;
    holder.img.setImage(new ImageFileModel(imageUrl, null, null), 0, 0);

    holder.title.setText(video.getTitle());

    todoView.setTag(tag);
    views.add(todoView);
    return todoView;
  }
Beispiel #4
0
  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.my_topics_rl:
        String user_id = String.valueOf(CurrentUser.getId());
        Intent intent = new Intent(this, UserTopicsActivity.class);
        intent.putExtra("user_id", Integer.parseInt(user_id));
        intent.putExtra("uname", "");
        startActivity(intent);
        break;
      case R.id.my_favorite_rl:
        break;
      case R.id.my_related_rl:
        Intent intentAt = new Intent(this, UserTopicsActivity.class);
        intentAt.putExtra(Constant.RELATED_TOPIC_TYPE, UserRelatedTopicType.at.getCode());
        startActivity(intentAt);
        break;
      case R.id.my_comment_rl:
        Intent intentComment = new Intent(this, UserTopicsActivity.class);
        intentComment.putExtra(Constant.RELATED_TOPIC_TYPE, UserRelatedTopicType.comment.getCode());
        startActivity(intentComment);
        break;
      case R.id.my_follow_points:
        Intent intentPoints = new Intent(MyDashboardActivity.this, SearchPointsActivity.class);
        intentPoints.putExtra("user_follow", true);
        Bundle bundlePoints = new Bundle();
        bundlePoints.putSerializable("desUser", CurrentUser);
        intentPoints.putExtras(bundlePoints);
        intentPoints.putExtra("search_type", PointSearchType.User_Follow.getCode());
        startActivity(intentPoints);
        break;
      case R.id.my_home_rl:
        if (myHome.getTag() != null) {
          Building building = (Building) myHome.getTag();
          // Intent intentHome = new Intent(MyDashboardActivity.this,BuildingHomeActivity.class);
          Intent intentHome = new Intent(MyDashboardActivity.this, BuildingCardActivity.class);
          Bundle bundle = new Bundle();
          bundle.putSerializable("building", building);
          Log.v(TAG, "Home:" + building.getHome());
          intentHome.putExtras(bundle);
          startActivity(intentHome);
        }
        break;

      case R.id.my_work_rl:
        if (myWork.getTag() != null) {
          Building building = (Building) myWork.getTag();
          // Intent intentWork = new Intent(MyDashboardActivity.this,BuildingHomeActivity.class);
          Intent intentWork = new Intent(MyDashboardActivity.this, BuildingCardActivity.class);
          Bundle bundle = new Bundle();
          bundle.putSerializable("building", building);
          intentWork.putExtras(bundle);
          startActivity(intentWork);
        }
        break;
      case R.id.my_personal_rl:
        Intent intentSetting = new Intent(this, UserSettingsActivity.class);
        startActivity(intentSetting);
        break;
      case R.id.my_setting_rl:
        Intent appSetting = new Intent(this, AppSettingActivity.class);
        startActivity(appSetting);
        break;
      case R.id.my_quit_rl:
        DBManager dbManager = new DBManager(this);
        dbManager.Logout(BaseActivity.CurrentUser.getId());
        dbManager.closeDB();
        // dbManager.deleteAllAccounts();
        // finish();
        System.exit(0);
        break;
      default:
        break;
    }
  }