Buggy code:
public class PhotoPickerActivity extends BaseFragment implements NotificationCenter . NotificationCenterDelegate , PhotoCropActivity . PhotoEditActivityDelegate , PhotoViewer . PhotoViewerProvider { public static interface PhotoPickerActivityDelegate { public abstract void selectedPhotosChanged ( ) { } public abstract void actionButtonPressed ( boolean canceled ) { } } private RequestQueue requestQueue ; private int type ; private HashMap < String , MediaController . SearchImage > selectedWebPhotos ; private HashMap < Integer , MediaController . PhotoEntry > selectedPhotos ; private ArrayList < MediaController . SearchImage > recentImages ; private ArrayList < MediaController . SearchImage > searchResult = new ArrayList < > ( ) ; private HashMap < String , MediaController . SearchImage > searchResultKeys = new HashMap < > ( ) ; private HashMap < String , MediaController . SearchImage > searchResultUrls = new HashMap < > ( ) ; private boolean searching ; private String nextSearchBingString ; private boolean giphySearchEndReached = true ; private String lastSearchString ; private boolean loadingRecent ; private AlbumEntry selectedAlbum ; private GridView listView ; private PhotoPickerActivity . ListAdapter listAdapter ; private PhotoPickerBottomLayout photoPickerBottomLayout ; private FrameLayout progressView ; private TextView emptyView ; private ActionBarMenuItem searchItem ; private int itemWidth = 100 ; private boolean sendPressed ; private PhotoPickerActivity . PhotoPickerActivityDelegate delegate ; public PhotoPickerActivity ( int type , MediaController . AlbumEntry selectedAlbum , HashMap < Integer , MediaController . PhotoEntry > selectedPhotos , HashMap < String , MediaController . SearchImage > selectedWebPhotos , ArrayList < MediaController . SearchImage > recentImages ) { } @ Override public boolean onFragmentCreate ( ) { } @ Override public void onFragmentDestroy ( ) { } @ SuppressWarnings ( "unchecked" ) @ Override public View createView ( LayoutInflater inflater , ViewGroup container ) { } @ Override public void onResume ( ) { } @ Override public void onConfigurationChanged ( Configuration newConfig ) { } @ SuppressWarnings ( "unchecked" ) @ Override public void didReceivedNotification ( int id , Object ... args ) { } private PhotoPickerPhotoCell getCellForIndex ( int index ) { } @ Override public PlaceProviderObject getPlaceForPhoto ( MessageObject messageObject , TLRPC . FileLocation fileLocation , int index ) { } @ Override public Bitmap getThumbForPhoto ( MessageObject messageObject , TLRPC . FileLocation fileLocation , int index ) { } @ Override public void willSwitchFromPhoto ( MessageObject messageObject , TLRPC . FileLocation fileLocation , int index ) { } @ Override public void willHidePhotoViewer ( ) { } @ Override public boolean isPhotoChecked ( int index ) { } @ Override public void setPhotoChecked ( int index ) { } @ Override public void cancelButtonPressed ( ) { } @ Override public void sendButtonPressed ( int index ) { } @ Override public int getSelectedCount ( ) { } @ Override public void onOpenAnimationEnd ( ) { } @ Override public void didFinishEdit ( Bitmap bitmap , Bundle args ) { } private void updateSearchInterface ( ) { } private void searchGiphyImages ( String query , int offset , final int count ) { if ( searching ) { searching = false ; requestQueue . cancelAll ( "search" ) ; } try { searching = true ; <START_BUG> String url = String . format ( "https:////api.giphy.com//v1//gifs//search?q=%s&offset=%d&limit=%d&api_key=141Wa2KDAfNfxu" , URLEncoder . encode ( query , "UTF-8" ) , offset , count ) ; <END_BUG> JsonObjectRequest jsonObjReq = new JsonObjectRequest ( Method . GET , url , null , new Response . Listener < JSONObject > ( ) { @ Override public void onResponse ( JSONObject response ) { try { JSONArray result = response . getJSONArray ( "data" ) ; try { JSONObject pagination = response . getJSONObject ( "pagination" ) ; int total_count = pagination . getInt ( "total_count" ) ; giphySearchEndReached = ( ( searchResult . size ( ) ) + ( result . length ( ) ) ) >= total_count ; } catch ( e ) { FileLog . e ( "tmessages" , e ) ; } boolean added = false ; for ( int a = 0 ; a < ( result . length ( ) ) ; a ++ ) { try { JSONObject object = result . getJSONObject ( a ) ; String id = object . getString ( "id" ) ; if ( searchResultKeys . containsKey ( id ) ) { continue ; } added = true ; JSONObject images = object . getJSONObject ( "images" ) ; JSONObject thumb = images . getJSONObject ( "downsized_still" ) ; JSONObject original = images . getJSONObject ( "original" ) ; MediaController . SearchImage bingImage = new MediaController . SearchImage ( ) ; bingImage . id = id ; bingImage . width = original . getInt ( "width" ) ; bingImage . height = original . getInt ( "height" ) ; bingImage . size = original . getInt ( "size" ) ; bingImage . imageUrl = original . getString ( "url" ) ; bingImage . thumbUrl = thumb . getString ( "url" ) ; bingImage . type = 1 ; searchResult . add ( bingImage ) ; searchResultKeys . put ( id , bingImage ) ; } catch ( e ) { FileLog . e ( "tmessages" , e ) ; } } if ( ! added ) { giphySearchEndReached = true ; } } catch ( e ) { FileLog . e ( "tmessages" , e ) ; } searching = false ; updateSearchInterface ( ) ; } } , new Response . ErrorListener ( ) { @ Override public void onErrorResponse ( VolleyError error ) { FileLog . e ( "tmessages" , ( "Error:<seq2seq4repair_space>" + ( error . getMessage ( ) ) ) ) ; giphySearchEndReached = true ; searching = false ; updateSearchInterface ( ) ; } } ) ; jsonObjReq . setTag ( "search" ) ; requestQueue . add ( jsonObjReq ) ; } catch ( Exception e ) { FileLog . e ( "tmessages" , e ) ; } } private void searchBingImages ( String query , int offset , int count ) { } public void setDelegate ( PhotoPickerActivity . PhotoPickerActivityDelegate delegate ) { }

Fix:
String url = String . format ( Locale . US , "https:////api.giphy.com//v1//gifs//search?q=%s&offset=%d&limit=%d&api_key=141Wa2KDAfNfxu" , URLEncoder . encode ( query , "UTF-8" ) , offset , count ) ;