package com.ved.musicmapapp.adapters; import java.util.ArrayList; import android.app.Activity; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.TextView; import com.ved.musicmapapp.R; import com.ved.musicmapapp.Objects.Song; import com.ved.musicmapapp.Objects.User; import com.ved.musicmapapp.Objects.UserLikes; import com.ved.musicmapapp.providers.LikeSongTask; import com.ved.musicmapapp.utils.Statics; public class UserLikeAdapter extends BaseAdapter { private Activity cxt; private ArrayList<UserLikes> userLikes; private LayoutInflater inflat; private OnClickSong oCS; private OnBuySong oBS; private int curSelected = -1; private boolean loading = false, hasData = false; private boolean isPlayAll; private User user; // private int count = Statics.EXPAND_VIEW_COUNT; public boolean isPlayAll() { return isPlayAll; } public void setPlayAll(boolean isPlayAll) { this.isPlayAll = isPlayAll; } public UserLikeAdapter(Activity cxt, ArrayList<UserLikes> userLikes) { this.cxt = cxt; this.userLikes = userLikes; inflat = (LayoutInflater) cxt .getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @Override public int getCount() { // count = songs.size(); // count = (count > Statics.EXPAND_VIEW_COUNT) ? // Statics.EXPAND_VIEW_COUNT // : count; return /* count */userLikes.size(); } @Override public long getItemId(int position) { return -1; } // public void expandData() { // count += Statics.EXPAND_VIEW_COUNT; // count = (count > songs.size()) ? songs.size() : count; // notifyDataSetChanged(); // } @Override public View getView(final int pos, View v, ViewGroup parent) { final UserLikes s = getItem(pos); if (v == null) { v = inflat.inflate(R.layout.item_like, null); } ImageView imv_like = (ImageView) v.findViewById(R.id.imv_image); final TextView tv_name = (TextView) v.findViewById(R.id.tv_title); tv_name.setText(s.getTitle()); switch (s.getType()) { case 0: //Game imv_like.setImageResource(R.drawable.ic_game); break; case 1: //movie imv_like.setImageResource(R.drawable.ic_movie); break; case 2: //school imv_like.setImageResource(R.drawable.ic_school); break; case 3: //book imv_like.setImageResource(R.drawable.ic_book); break; case 4: //other imv_like.setImageResource(R.drawable.ic_other); break; default: break; } return v; } public void dismissLoading(boolean hasData) { this.hasData = hasData; loading = false; notifyDataSetChanged(); } public void setSelected(int pos) { loading = true; curSelected = pos; notifyDataSetChanged(); } @Override public UserLikes getItem(int arg0) { // TODO Auto-generated method stub return userLikes.get(arg0); } public void setOnClickSong(OnClickSong oCS) { this.oCS = oCS; } public void setOnClickBuySong(OnBuySong oBS) { this.oBS = oBS; } public interface OnClickSong { public void onClick(Song song, int position, boolean play); } public interface OnBuySong { public void onBuyClick(Song song); } }