Buggy code:
ArrayAdapter < String > spinadapter2 ; Context curcontext ; Button button ; Activity activity ; boolean draftscoming = false ; public static AddTab newInstance ( ) { } public AddTab ( ) { } @ Override public void onCreate ( Bundle savedInstanceState ) { } @ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { mainActivity = ( ( MainActivity ) ( getActivity ( ) ) ) ; rv = inflater . inflate ( fragment_add_tab , container , false ) ; curcontext = rv . getContext ( ) ; pref = mainActivity . getPref ( ) ; categoryArray = mainActivity . categories ; iv = ( ( ImageView ) ( rv . findViewById ( add_ok_title ) ) ) ; iv . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { iv = ( ( ImageView ) ( rv . findViewById ( add_ok_title ) ) ) ; et = ( ( EditText ) ( rv . findViewById ( add_edit_title ) ) ) ; try { add_title = et . getText ( ) . toString ( ) ; if ( ( ! ( Pattern . matches ( "(?i)^([^\"\\[:\\]\\|=\\+\\*\\?<>\\\\\\//\\r\\n]+)$" , add_title ) ) ) || ( ( add_title ) == null ) ) { et . setText ( null ) ; iv . setImageResource ( ic_red_x ) ; add_title = null ; } else { iv . setImageResource ( ic_green_check ) ; } } catch ( Exception e ) { add_title = null ; iv . setImageResource ( ic_red_x ) ; et . setText ( null ) ; } try { if ( ( add_title . length ( ) ) > 35 ) { iv . setImageResource ( ic_red_x ) ; } } catch ( NullPointerException e ) { iv . setImageResource ( ic_red_x ) ; hideSoftKeyboard ( ) ; } hideSoftKeyboard ( ) ; } } ) ; iv = ( ( ImageView ) ( rv . findViewById ( add_ok_description ) ) ) ; iv . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { iv = ( ( ImageView ) ( rv . findViewById ( add_ok_description ) ) ) ; et = ( ( EditText ) ( rv . findViewById ( add_edit_description ) ) ) ; try { add_description = et . getText ( ) . toString ( ) ; if ( ( ! ( Pattern . matches ( "(?i)^([^\"\\[:\\]\\|=\\+\\*\\?<>\\\\\\//]+)$" , add_description ) ) ) || ( ( add_description ) == null ) ) { et . setText ( null ) ; iv . setImageResource ( ic_red_x ) ; add_description = null ; } else { iv . setImageResource ( ic_green_check ) ; } } catch ( Exception e ) { add_description = null ; iv . setImageResource ( ic_red_x ) ; } try { if ( ( add_description . length ( ) ) > 700 ) { iv . setImageResource ( ic_red_x ) ; } } catch ( NullPointerException e ) { iv . setImageResource ( ic_red_x ) ; hideSoftKeyboard ( ) ; } hideSoftKeyboard ( ) ; } } ) ; spin1 = ( ( Spinner ) ( rv . findViewById ( add_spin_category ) ) ) ; spinadapter1 = new ArrayAdapter ( curcontext , layout . simple_spinner_dropdown_item , category ) ; spin1 . setAdapter ( spinadapter1 ) ; spin1 . setOnItemSelectedListener ( new AdapterView . OnItemSelectedListener ( ) { @ Override public void onItemSelected ( AdapterView < ? > parent , View view , int position , long id ) { if ( draftscoming ) { spin2 . setSelection ( add_subcategory ) ; draftscoming = false ; } else { if ( position != 0 ) { add_category = position ; add_subcategory = 0 ; <START_BUG> int q = categoryArray [ 0 ] . length ; <END_BUG> subcategory = new String [ q ] ; System . arraycopy ( categoryArray [ ( position - 1 ) ] , 0 , subcategory , 0 , q ) ; subcategory [ 0 ] = "Select<seq2seq4repair_space>a<seq2seq4repair_space>Subcategory" ; iv = ( ( ImageView ) ( rv . findViewById ( add_ok_spinner ) ) ) ; iv . setImageResource ( ic_red_x ) ; spin2 = ( ( Spinner ) ( rv . findViewById ( add_spin_subcategory ) ) ) ; spinadapter2 = new ArrayAdapter ( curcontext , layout . simple_spinner_dropdown_item , subcategory ) ; spin2 . setAdapter ( spinadapter2 ) ; spin2 . setOnItemSelectedListener ( new AdapterView . OnItemSelectedListener ( ) { @ Override public void onItemSelected ( AdapterView < ? > parent , View view , int position , long id ) { if ( position != 0 ) { add_subcategory = position ; iv = ( ( ImageView ) ( rv . findViewById ( add_ok_spinner ) ) ) ; iv . setImageResource ( ic_green_check ) ; } else { add_subcategory = 0 ; iv = ( ( ImageView ) ( rv . findViewById ( add_ok_spinner ) ) ) ; iv . setImageResource ( ic_red_x ) ; } } @ Override public void onNothingSelected ( AdapterView < ? > parent ) { } } ) ; } else if ( ( add_subcategory ) != 0 ) { add_subcategory = 0 ; subcategory [ 0 ] = "Select<seq2seq4repair_space>a<seq2seq4repair_space>Subcategory" ; iv = ( ( ImageView ) ( rv . findViewById ( add_ok_spinner ) ) ) ; iv . setImageResource ( ic_red_x ) ; spin2 = ( ( Spinner ) ( rv . findViewById ( add_spin_subcategory ) ) ) ; spin2 . setSelection ( 0 ) ; } } } @ Override public void onNothingSelected ( AdapterView < ? > parent ) { } } ) ; button = ( ( Button ) ( rv . findViewById ( add_draft ) ) ) ; button . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { t = ( ( TextView ) ( rv . findViewById ( add_submission_status ) ) ) ;

Fix:
int q = categoryArray [ ( position - 1 ) ] . length ;