package net.somethingdreadful.MAL.dialog;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;

import net.somethingdreadful.MAL.DetailView;
import net.somethingdreadful.MAL.R;
import net.somethingdreadful.MAL.SearchActivity;
import net.somethingdreadful.MAL.api.MALApi;
import net.somethingdreadful.MAL.api.response.Anime;
import net.somethingdreadful.MAL.api.response.Manga;

import org.holoeverywhere.app.AlertDialog;
import org.holoeverywhere.app.DialogFragment;

public class SearchIdDialogFragment extends DialogFragment {

    @Override
    public AlertDialog onCreateDialog(Bundle savedInstanceState) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setTitle(R.string.dialog_title_id_search);
        builder.setMessage(R.string.dialog_message_id_search);

        final Integer query = Integer.parseInt(((SearchActivity) getActivity()).query);

        builder.setPositiveButton(R.string.dialog_label_anime, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Anime record = new Anime();
                record.setId(query);
                Intent startDetails = new Intent(getActivity(), DetailView.class);
                startDetails.putExtra("record", record);
                startDetails.putExtra("recordType", MALApi.ListType.ANIME);
                startActivity(startDetails);
                dismiss();
                getActivity().finish();
            }
        });
        builder.setNeutralButton(R.string.dialog_label_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dismiss();
                getActivity().finish();
            }
        });
        builder.setNegativeButton(R.string.dialog_label_manga, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Manga record = new Manga();
                record.setId(query);
                Intent startDetails = new Intent(getActivity(), DetailView.class);
                startDetails.putExtra("record", record);
                startDetails.putExtra("recordType", MALApi.ListType.MANGA);
                startActivity(startDetails);
                dismiss();
                getActivity().finish();
            }
        });

        return builder.create();
    }
}
@@ -313,114 +313,48 @@
 pi;%0A
+%0A
 import 
-net.somethingdreadful.MAL.api.response.Anime;%0Aimport net.somethingdreadful.MAL.api.response.Manga;%0A
+org.holoeverywhere.app.Activity;
 %0Aimp
@@ -500,16 +500,201 @@
 agment %7B
+%0A    int query;%0A%0A    @Override%0A    public void onAttach(Activity activity) %7B%0A        super.onAttach(activity);%0A        query = Integer.parseInt(((SearchActivity) activity).query);%0A    %7D
 %0A%0A    @O
@@ -973,97 +973,8 @@
 );%0A%0A
-        final Integer query = Integer.parseInt(((SearchActivity) getActivity()).query);%0A%0A
     
@@ -1167,89 +1167,8 @@
 ) %7B%0A
-                Anime record = new Anime();%0A                record.setId(query);%0A
     
@@ -1287,33 +1287,34 @@
 xtra(%22record
+ID
 %22, 
-record
+query
 );%0A         
@@ -2003,89 +2003,8 @@
 ) %7B%0A
-                Manga record = new Manga();%0A                record.setId(query);%0A
     
@@ -2131,17 +2131,18 @@
 cord
+ID
 %22, 
-record
+query
 );%0A 

Fix id search after rebase (Dialog)