Android Open Source - dropdroid Cover Image Dialog Fragment






From Project

Back to project page dropdroid.

License

The source code is released under:

GNU General Public License

If you think the Android project dropdroid 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.fjaviermo.dropdroid;
/*from w  w w.j  av a  2  s . co  m*/
import java.io.ByteArrayOutputStream;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public final class CoverImageDialogFragment extends DialogFragment {
    private Bitmap mImage;
    private static final String IMAGE="image";
    
    /**
     * Create a new instance of CoverImageDialogFragment, providing "image"
     * as an argument.
     */
    static CoverImageDialogFragment newInstance(Bitmap image) {
        CoverImageDialogFragment coverImageDialog = new CoverImageDialogFragment();

        Bundle args = new Bundle();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        image.compress(Bitmap.CompressFormat.PNG, 100, stream);
        byte[] byteArray = stream.toByteArray();
        args.putByteArray(IMAGE, byteArray);
        coverImageDialog.setArguments(args);
        coverImageDialog.setStyle(DialogFragment.STYLE_NO_TITLE, 0);        
        return coverImageDialog;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        byte[] byteArray = getArguments().getByteArray(IMAGE);
        mImage = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.image_dialog, container, false);
    ImageView imgView=(ImageView)view.findViewById(R.id.thumbnail_epub);
    imgView.setImageBitmap(mImage);
        return view;
    }
}




Java Source Code List

com.fjaviermo.Utils.DropDroidConfig.java
com.fjaviermo.Utils.Util.java
com.fjaviermo.adapter.EpubAdapter.java
com.fjaviermo.comparator.EpubDateComparator.java
com.fjaviermo.comparator.EpubNameComparator.java
com.fjaviermo.dropdroid.CoverImageDialogFragment.java
com.fjaviermo.dropdroid.EpubListFragment.java
com.fjaviermo.dropdroid.EpubLoader.java
com.fjaviermo.dropdroid.MainActivity.java