Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HorizntallMediaList extends
- ArrayAdapter<ItemsMediaSuggestion> {
- String ImageURL;
- Context context;
- int table = 0;
- List<ItemsMediaSuggestion> objects;
- ItemsMediaSuggestion related;
- public HorizntallMediaList(Context context, int textViewResourceId,
- List<ItemsMediaSuggestion> objects,
- int table) {
- super(context, textViewResourceId, objects);
- this.context = context;
- this.objects = objects;
- this.table = table;
- }
- viewHolder holder = new viewHolder();
- private class viewHolder {
- private RelativeLayout relativeLayout;
- private ImageView userImage, addImage;
- private TextView userName;
- }
- @Override
- public long getItemId(int position) {
- return super.getItemId(position);
- }
- @Override
- public int getCount() {
- return super.getCount();
- }
- @Override
- public ItemsMediaSuggestion getItem(int position) {
- return super.getItem(position);
- }
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- try{
- related = getItem(position);
- } catch (IndexOutOfBoundsException e) {
- }
- LayoutInflater inflater = (LayoutInflater) context
- .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
- if (convertView == null) {
- convertView = inflater.inflate(R.layout.items_wall_horizntal,
- parent, false);
- holder = new viewHolder();
- holder.relativeLayout = (RelativeLayout) convertView
- .findViewById(R.id.horRelative);
- holder.userImage = (ImageView) convertView
- .findViewById(R.id.HorUserImage);
- holder.userName = (TextView) convertView.findViewById(R.id.HorName);
- holder.addImage = (ImageView) convertView.findViewById(R.id.HorAdd);
- holder.addImage.setVisibility(View.GONE);
- convertView.setTag(holder);
- } else {
- holder = (viewHolder) convertView.getTag();
- }
- holder.relativeLayout
- .setBackgroundColor(GlobalConstants.ColorPicker_int);
- if (table == 5) {
- ImageURL = GlobalConstants.server_file
- + table
- + "/m/"
- + related.getStorage()
- + "."
- + related.getStorageRand() + ".jpg";
- holder.userName.setText(PublicMethods.readable(related
- .getDescribtion()));
- } else if (table == 6) {
- if (related.getStorage().equals("0")) {
- holder.userName.setText(PublicMethods.readable(related
- .getTitle()));
- ImageURL = "https://img.youtube.com/vi/"
- + related.getStorageRand() + "/1" + ".jpg";
- } else {
- ImageURL = GlobalConstants.server_file
- + table
- + "/m/"
- + related.getStorage()
- + "."
- + related.getStorageRand() + ".jpg";
- holder.userName.setText(PublicMethods.readable(related
- .getTitle()));
- }
- } else {
- ImageURL = GlobalConstants.server_file
- + 5
- + "/m/"
- + related.getStorage()
- + "."
- + related.getStorageRand() + ".jpg";
- holder.userName.setText(PublicMethods.readable(related.getTitle()));
- }
- Picasso.with(context).load(ImageURL).fit().into(holder.userImage);
- return convertView;
- }
- }
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/background_with_shadow"
- android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="200dp"
- android:layout_height="200dp" >
- <ImageView
- android:id="@+id/HorUserImage"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true"
- android:layout_alignParentRight="true"
- android:layout_alignParentTop="true"
- />
- <RelativeLayout
- android:id="@+id/horRelative"
- android:layout_width="match_parent"
- android:layout_height="40dp"
- android:layout_alignParentBottom="true"
- android:layout_alignParentLeft="true" >
- <TextView
- android:id="@+id/HorName"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_centerVertical="true"
- android:layout_marginLeft="20dp"
- android:layout_marginRight="5dp"
- android:layout_toLeftOf="@+id/HorAdd"
- android:gravity="right"
- android:maxLines="1"
- android:text="Name"
- android:textColor="@color/WhiteColor"
- android:textSize="18sp" />
- <ImageView
- android:id="@+id/HorAdd"
- android:layout_width="40dp"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:src="@drawable/plus" />
- </RelativeLayout>
- </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement