// Path: vector/src/main/java/im/vector/adapters/ImageSizesAdapter.java
// public class ImageSizesAdapter extends ArrayAdapter<ImageCompressionDescription> {
//     private final Context mContext;
//     private final LayoutInflater mLayoutInflater;
//     private final int mLayoutResourceId;
// 
//     /**
//      * Construct an adapter which will display a list of image size
//      *
//      * @param context          Activity context
//      * @param layoutResourceId The resource ID of the layout for each item.
//      */
//     public ImageSizesAdapter(Context context, int layoutResourceId) {
//         super(context, layoutResourceId);
//         mContext = context;
//         mLayoutResourceId = layoutResourceId;
//         mLayoutInflater = LayoutInflater.from(mContext);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         if (convertView == null) {
//             convertView = mLayoutInflater.inflate(mLayoutResourceId, parent, false);
//         }
// 
//         ImageCompressionDescription imageSizesDescription = getItem(position);
// 
//         TextView textView = convertView.findViewById(R.id.ImageSizesAdapter_format);
//         textView.setText(imageSizesDescription.mCompressionText);
// 
//         textView = convertView.findViewById(R.id.ImageSizesAdapter_info);
//         textView.setText(imageSizesDescription.mCompressionInfoText);
//         return convertView;
//     }
// }


import im.vector.R;
import im.vector.adapters.ImageCompressionDescription;
import im.vector.adapters.ImageSizesAdapter;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import androidx.fragment.app.DialogFragment;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {
        // Always call the superclass so it can save the view hierarchy state
        super.onSaveInstanceState(savedInstanceState);

        if (null != mEntries) {
            savedInstanceState.putSerializable(SELECTIONS_LIST, (ArrayList) mEntries);
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog d = super.onCreateDialog(savedInstanceState);

        if (null != savedInstanceState) {
            if (savedInstanceState.containsKey(SELECTIONS_LIST)) {
                mEntries = (ArrayList<ImageCompressionDescription>) savedInstanceState.getSerializable(SELECTIONS_LIST);
            }
        }

        d.setTitle(getString(R.string.compression_options));
        return d;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View v = inflater.inflate(R.layout.dialog_base_list_view, container, false);
        ListView listView = v.findViewById(R.id.list_view);

// Path: vector/src/main/java/im/vector/adapters/ImageSizesAdapter.java
// public class ImageSizesAdapter extends ArrayAdapter<ImageCompressionDescription> {
//     private final Context mContext;
//     private final LayoutInflater mLayoutInflater;
//     private final int mLayoutResourceId;
// 
//     /**
//      * Construct an adapter which will display a list of image size
//      *
//      * @param context          Activity context
//      * @param layoutResourceId The resource ID of the layout for each item.
//      */
//     public ImageSizesAdapter(Context context, int layoutResourceId) {
//         super(context, layoutResourceId);
//         mContext = context;
//         mLayoutResourceId = layoutResourceId;
//         mLayoutInflater = LayoutInflater.from(mContext);
//     }
// 
//     @Override
//     public View getView(int position, View convertView, ViewGroup parent) {
//         if (convertView == null) {
//             convertView = mLayoutInflater.inflate(mLayoutResourceId, parent, false);
//         }
// 
//         ImageCompressionDescription imageSizesDescription = getItem(position);
// 
//         TextView textView = convertView.findViewById(R.id.ImageSizesAdapter_format);
//         textView.setText(imageSizesDescription.mCompressionText);
// 
//         textView = convertView.findViewById(R.id.ImageSizesAdapter_info);
//         textView.setText(imageSizesDescription.mCompressionInfoText);
//         return convertView;
//     }
// }


// Path: vector/src/main/java/im/vector/fragments/ImageSizeSelectionDialogFragment.java
import im.vector.R;
import im.vector.adapters.ImageCompressionDescription;
import im.vector.adapters.ImageSizesAdapter;
import android.app.Dialog;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import androidx.fragment.app.DialogFragment;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

    @Override
    public void onSaveInstanceState(Bundle savedInstanceState) {
        // Always call the superclass so it can save the view hierarchy state
        super.onSaveInstanceState(savedInstanceState);

        if (null != mEntries) {
            savedInstanceState.putSerializable(SELECTIONS_LIST, (ArrayList) mEntries);
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Dialog d = super.onCreateDialog(savedInstanceState);

        if (null != savedInstanceState) {
            if (savedInstanceState.containsKey(SELECTIONS_LIST)) {
                mEntries = (ArrayList<ImageCompressionDescription>) savedInstanceState.getSerializable(SELECTIONS_LIST);
            }
        }

        d.setTitle(getString(R.string.compression_options));
        return d;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreateView(inflater, container, savedInstanceState);
        View v = inflater.inflate(R.layout.dialog_base_list_view, container, false);
        ListView listView = v.findViewById(R.id.list_view);

        ImageSizesAdapter adapter = new ImageSizesAdapter(getActivity(), R.layout.adapter_item_image_size);