Android Open Source - soas Photos Adapter






From Project

Back to project page soas.

License

The source code is released under:

Apache License

If you think the Android project soas 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.meg7.soas.ui.adapter;
/*  w  w  w  .  jav  a2s.c om*/
import android.content.Context;
import android.content.res.Configuration;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.meg7.soas.R;
import com.meg7.soas.data.Photo;
import com.meg7.soas.ui.view.PhotoView;

import java.util.List;

public class PhotosAdapter extends BaseEndlessAdapter<Photo> {

    private final int mOrientation;

    private static class ViewHolder {
        public PhotoView photo;
        public TextView owner;
        public TextView uploadDate;
    }

    public PhotosAdapter(Context context, List<Photo> list, int serverListSize) {
        super(context, list, serverListSize);

        mOrientation = context.getResources().getConfiguration().orientation;
    }

    @Override
    public View getDataRow(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        // Reuse views.
        if (view == null) {
            view = mInflater.inflate(R.layout.list_item_photo, parent, false);

            // Configure view holder.
            ViewHolder viewHolder = new ViewHolder();
            viewHolder.photo = (PhotoView) view.findViewById(R.id.photo);
            viewHolder.photo.setDefaultImageResId(R.drawable.default_rounded_photo);
            viewHolder.owner = (TextView) view.findViewById(R.id.photoOwner);
            viewHolder.uploadDate = (TextView) view.findViewById(R.id.photoUploadDate);

            if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) {
                viewHolder.photo.hideName();
                view.findViewById(R.id.photoDetailsContainer).setVisibility(View.GONE);
            }

            view.setTag(viewHolder);
        }

        Photo item = getItem(position);

        // Fill data.
        ViewHolder holder = (ViewHolder) view.getTag();

        holder.photo.resetColors();
        holder.photo.setImageUrl(item.photoFileUrl, mImageLoader);
        holder.photo.setText(item.ownerName);

        if (holder.owner != null) {
            holder.owner.setText(Html.fromHtml("<a href=\"" + item.ownerUrl + "\">"
                    + item.ownerName + "</a> "));
            // Making url clickable.
            holder.owner.setMovementMethod(LinkMovementMethod.getInstance());
        }

        if (holder.uploadDate != null) { holder.uploadDate.setText(item.uploadDate); }

        return view;
    }

}




Java Source Code List

com.meg7.soas.ApplicationTest.java
com.meg7.soas.SoasApplication.java
com.meg7.soas.data.Location.java
com.meg7.soas.data.OfflineNote.java
com.meg7.soas.data.Photo.java
com.meg7.soas.data.Photos.java
com.meg7.soas.database.DatabaseHelper.java
com.meg7.soas.database.OfflineNotesDataSource.java
com.meg7.soas.database.provider.OfflineNotesProvider.java
com.meg7.soas.database.provider.ProviderConstants.java
com.meg7.soas.database.provider.ProviderConstants.java
com.meg7.soas.espresso.LongListMatchers.java
com.meg7.soas.espresso.PhotosListActivityEspressoTest.java
com.meg7.soas.espresso.VolleyIdlingResource.java
com.meg7.soas.http.HttpConstants.java
com.meg7.soas.http.HttpHeaderParser.java
com.meg7.soas.http.request.GsonGetRequest.java
com.meg7.soas.http.util.UrlBuilder.java
com.meg7.soas.ui.BaseActivity.java
com.meg7.soas.ui.PhotoDetailActivity.java
com.meg7.soas.ui.PhotosListActivity.java
com.meg7.soas.ui.adapter.BaseEndlessAdapter.java
com.meg7.soas.ui.adapter.BaseEndlessScrollListener.java
com.meg7.soas.ui.adapter.PhotosAdapter.java
com.meg7.soas.ui.fragment.PhotoDetailFragment.java
com.meg7.soas.ui.fragment.PhotosListFragment.java
com.meg7.soas.ui.fragment.SwipeRefreshListFragment.java
com.meg7.soas.ui.fragment.retained.PhotosListTaskFragment.java
com.meg7.soas.ui.view.PhotoView.java
com.meg7.soas.ui.widget.BaseFadeInNetworkImageView.java
com.meg7.soas.ui.widget.RectangleFadeInNetworkImageView.java
com.meg7.soas.ui.widget.RoundedFadeInNetworkImageView.java
com.meg7.soas.unit.PhotosListActivityUnitTest.java
com.meg7.soas.util.BitmapLruCache.java
com.meg7.soas.util.SdkUtils.java
com.meg7.widget.RecyclingBitmapDrawable.java
com.meg7.widget.RecyclingImageView.java