fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10.  
  11. public static class Glide
  12. {
  13. public static class Loader {
  14. final public byte[] arr;
  15. public Loader(byte[] arr) {
  16. this.arr = arr;
  17. }
  18.  
  19. public Target asBitmap() {
  20. return new Target(this);
  21. }
  22. }
  23.  
  24. public static class Target {
  25. final Loader loader;
  26. public Target(Loader loader) {
  27. this.loader = loader;
  28. }
  29.  
  30. public void into(Object image){
  31. new Thread() {
  32. public void run() {
  33. try{
  34. Thread.sleep(450);
  35. } catch (Exception ex) {}
  36. System.out.println(loader.arr[0] + "");
  37. }
  38. }.start();
  39. }
  40. }
  41.  
  42. public static Glide with(Object ctx) {
  43. return new Glide();
  44. }
  45. public Loader load(byte[] arr) {
  46. return new Loader(arr);
  47. }
  48. }
  49.  
  50. static byte[] img = new byte[10];
  51.  
  52. public static byte[] getArrayFromWebApi(int i) throws Exception {
  53. Thread.sleep(100);
  54. for(int j = 0; j < img.length; j++)
  55. img[j] = (byte)i;
  56. return img;
  57. }
  58.  
  59. public static void main (String[] args) throws java.lang.Exception
  60. {
  61. Object context = null;
  62. Object rowImageView = null;
  63. System.out.println("--Without Glide--");
  64. for(int i = 0; i < 10; i++){
  65. byte[] imageByteArray = getArrayFromWebApi(i);
  66. System.out.println(imageByteArray[0] + "");
  67. }
  68. System.out.println("++With Glide++");
  69. for(int i = 0; i < 10; i++){
  70. byte[] imageByteArray = getArrayFromWebApi(i);
  71. Glide.with(context).load(imageByteArray).asBitmap().into(rowImageView);
  72. }
  73. Thread.sleep(10000);
  74.  
  75. }
  76. }
Time limit exceeded #stdin #stdout 5s 323200KB
stdin
Standard input is empty
stdout
--Without Glide--
0
1
2
3
4
5
6
7
8
9
++With    Glide++
4
5
6
7
8
9
9
9
9
9