Android Open Source - Wardrobe_app Grid View Photo Adapter






From Project

Back to project page Wardrobe_app.

License

The source code is released under:

Apache License

If you think the Android project Wardrobe_app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.android.busolo.apps.wardrobe.engine.adapter;
//from w  ww. j a  v  a 2  s .  c om
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.busolo.apps.wardrobe.engine.R;
import com.android.busolo.apps.wardrobe.engine.model.Stream;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by james on 9/06/14.
 */
public class GridViewPhotoAdapter extends BaseAdapter {
    private List<Stream> photosList = new ArrayList<Stream>();
    private LayoutInflater inflater;
    private Activity activity;

    public class ViewHolder{
        ImageView itemPic;
        TextView itemPrice;
    }

    public GridViewPhotoAdapter(Activity context, ArrayList<Stream> photosList) {
        inflater = LayoutInflater.from(context);
        this.photosList = photosList;
        this.activity = context;
    }

    @Override
    public int getCount() {
        return photosList.size();
    }

    @Override
    public Object getItem(int position) {
        return photosList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View rowView = convertView;

        if (rowView == null) {
            rowView = inflater.inflate(R.layout.photo_grid_item, parent, false);

            ViewHolder viewHolder = new ViewHolder();
            viewHolder.itemPic = (ImageView)rowView.findViewById(R.id.img_item_pic);
            viewHolder.itemPrice = (TextView)rowView.findViewById(R.id.txt_item_price);

            rowView.setTag(viewHolder);
        }

        ViewHolder viewHolder = (ViewHolder)rowView.getTag();
        viewHolder.itemPic = (ImageView)rowView.findViewById(R.id.img_item_pic);
        viewHolder.itemPrice = (TextView)rowView.findViewById(R.id.txt_item_price);

        //TODO set data

        viewHolder.itemPrice.setText("Price: 4,500");
        viewHolder.itemPic.setBackgroundResource(R.drawable.shoes_4);

        viewHolder.itemPic.setOnClickListener(new ImageClickListener(position));

        return rowView;
    }

    class ImageClickListener implements View.OnClickListener{
        int position;

        public ImageClickListener(int position){
            this.position = position;
        }

        @Override
        public void onClick(View v) {

            //TODO show image detail
            Toast.makeText(activity, "....", Toast.LENGTH_SHORT).show();
        }
    }
}




Java Source Code List

com.android.busolo.apps.wardrobe.Config.java
com.android.busolo.apps.wardrobe.engine.BaseActivity.java
com.android.busolo.apps.wardrobe.engine.ColorPickerFragment.java
com.android.busolo.apps.wardrobe.engine.CommentsFragment.java
com.android.busolo.apps.wardrobe.engine.FollowActivity.java
com.android.busolo.apps.wardrobe.engine.HomeActivity.java
com.android.busolo.apps.wardrobe.engine.ItemDetailsActivity.java
com.android.busolo.apps.wardrobe.engine.LoginFragment.java
com.android.busolo.apps.wardrobe.engine.MatchFragment.java
com.android.busolo.apps.wardrobe.engine.NewPostActivity.java
com.android.busolo.apps.wardrobe.engine.PrivateStreamFragment.java
com.android.busolo.apps.wardrobe.engine.ProfileFragment.java
com.android.busolo.apps.wardrobe.engine.PublicStreamActivity.java
com.android.busolo.apps.wardrobe.engine.PublicStreamFragment.java
com.android.busolo.apps.wardrobe.engine.SignupFragment.java
com.android.busolo.apps.wardrobe.engine.StepOneFragment.java
com.android.busolo.apps.wardrobe.engine.StepTwoFragment.java
com.android.busolo.apps.wardrobe.engine.UserAccountActivity.java
com.android.busolo.apps.wardrobe.engine.adapter.ColorListAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.ColorSpinnerAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.FeedsListAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.GridViewPhotoAdapter.java
com.android.busolo.apps.wardrobe.engine.adapter.ViewInflaterBaseAdapter.java
com.android.busolo.apps.wardrobe.engine.model.ColorPicker.java
com.android.busolo.apps.wardrobe.engine.model.FilterParam.java
com.android.busolo.apps.wardrobe.engine.model.Follow.java
com.android.busolo.apps.wardrobe.engine.model.Stream.java
com.android.busolo.apps.wardrobe.sync.SyncHelper.java
com.android.busolo.apps.wardrobe.sync.SyncService.java
com.android.busolo.apps.wardrobe.utils.AccountUtils.java
com.android.busolo.apps.wardrobe.utils.BitmapCache.java
com.android.busolo.apps.wardrobe.utils.ImageLoader.java
com.android.busolo.apps.wardrobe.utils.LogUtils.java
com.android.busolo.apps.wardrobe.utils.LruBitmapCache.java
com.android.busolo.apps.wardrobe.utils.NetUtils.java
com.android.busolo.apps.wardrobe.utils.ParserUtils.java
com.android.busolo.apps.wardrobe.utils.PrefUtils.java
com.android.busolo.apps.wardrobe.utils.ServerResponse.java
com.android.busolo.apps.wardrobe.utils.UIUtils.java
com.android.busolo.apps.wardrobe.utils.VolleyAppController.java
com.android.busolo.apps.wardrobe.utils.model.FeedResult.java
com.android.busolo.apps.wardrobe.widget.BezelImageView.java
com.android.busolo.apps.wardrobe.widget.CheckableFrameLayout.java
com.android.busolo.apps.wardrobe.widget.EllipsizedTextView.java
com.android.busolo.apps.wardrobe.widget.ObservableScrollView.java
com.android.busolo.apps.wardrobe.widget.SquareImageView.java