Android Open Source - soas Photo Detail Fragment






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.fragment;
/*from  w w  w .java  2s.c om*/
import android.app.Fragment;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.meg7.soas.R;
import com.meg7.soas.SoasApplication;
import com.meg7.soas.data.Photo;
import com.meg7.soas.database.OfflineNotesDataSource;

import org.parceler.Parcels;

/**
 * A fragment representing a single Photo detail screen.
 * This fragment is either contained in a {@link com.meg7.soas.ui.PhotosListActivity}
 * in two-pane mode (on tablets) or a {@link com.meg7.soas.ui.PhotoDetailActivity}
 * on handsets.
 */
public class PhotoDetailFragment extends Fragment {

    /**
     * The fragment argument representing the photo that this fragment represents.
     */
    public static final String ARG_PHOTO = "arg_photo";

    private Photo mPhoto;

    private OfflineNotesDataSource mOfflineNotesDataSource;

    public static PhotoDetailFragment newInstance(Parcelable photo) {
        PhotoDetailFragment fragment = new PhotoDetailFragment();

        Bundle arguments = new Bundle();
        arguments.putParcelable(PhotoDetailFragment.ARG_PHOTO, photo);
        fragment.setArguments(arguments);

        return fragment;
    }

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public PhotoDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Bundle args = getArguments();
        if (args.containsKey(ARG_PHOTO)) {
            mPhoto = Parcels.unwrap(args.getParcelable(ARG_PHOTO));

            if (mPhoto != null && !TextUtils.isEmpty(mPhoto.photoTitle)) {
                getActivity().setTitle(mPhoto.photoTitle);
            }
        }

        mOfflineNotesDataSource = new OfflineNotesDataSource(getActivity());
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_photo_detail, container, false);

        if (mPhoto != null) {
            NetworkImageView photo = (NetworkImageView) rootView.findViewById(R.id.photo);
            photo.setImageUrl(mPhoto.photoFileUrl, SoasApplication.getImageLoader(getActivity()));
            photo.setDefaultImageResId(R.drawable.default_photo);

            TextView photoName = (TextView) rootView.findViewById(R.id.photoName);
            photoName.setText(mPhoto.photoTitle);

            TextView photoOwner = (TextView) rootView.findViewById(R.id.photoOwner);
            photoOwner.setText(mPhoto.ownerName);
        }

        return rootView;
    }

    @Override
    public void onResume() {
        super.onResume();

        mOfflineNotesDataSource.open();
    }

    @Override
    public void onPause() {
        super.onPause();

        mOfflineNotesDataSource.close();
    }
}




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