title: LibGDX textures do not appear after reloading
body: <p>I'm working with an app which is using <code>OpenGL ES</code> through <code>libgdx</code>. There are undo/redo functions in my app. When the user clicks one of the buttons, the image in the app (which was created via OpenGL ES) is disposed. After that, in the OpenGL thread is loading a new image. Redo is doing the same function. Sometimes when I click undo/redo, the image in <code>ImageView</code> becomes black, sometimes text in <code>TextView</code> becomes black. I think the problem is in <code>dispose()</code> method, but I don't understand why the image and text becomes black. Maybe someone can help me.
  Code of dispose:</p>
  
  <pre><code>if(obj.getTexture() != null){
      obj.getTexture().dispose();
  }
  </code></pre>
  
  <p>Code of load texture:</p>
  
  <pre><code>texture = new Texture(Gdx.files.absolute(fileName));
  </code></pre>
  
  <p>Undo code:</p>
  
  <pre><code>int indexUndo = undoObjects.size() - 1;
  SpriteState ss = undoObjects.get(indexUndo);
  if(object instanceof PhotoSprite){
       PhotoSpriteState pState = (PhotoSpriteState)ss;
       if(pState.getTypeChanging() == TypeSpriteChanging.ChangeTexture){
          object.saveRedoState(TypeSpriteChanging.ChangeTexture);
          PhotoSprite photoObj = (PhotoSprite)object;
          photoObj.setFileName( pState.getFilename() );
          photoObj.setGeometry( pState.getGeometry() );
          photoObj.setTexture(null);
       }
  }
  </code></pre>
  
  <p>Redo code:</p>
  
  <pre><code>int indexRedo = redoObjects.size() - 1;
  SpriteState ss = redoObjects.get(indexRedo);
  if(object instanceof PhotoSprite){
       PhotoSpriteState pState = (PhotoSpriteState)ss;
       if(pState.getTypeChanging() == TypeSpriteChanging.ChangeTexture){
          object.saveRedoState(TypeSpriteChanging.ChangeTexture);
          PhotoSprite photoObj = (PhotoSprite)object;
          photoObj.setFileName( pState.getFilename() );
          photoObj.setGeometry( pState.getGeometry() );
          photoObj.setTexture(null);
       }
  }
  </code></pre>
  
  <p>Code laod texture:</p>
  
  <pre><code>public void render(PhotoSprite psObject, int zIndex) {
      ShaderProgram shader = psObject.getShader();
      if(!shader.isCompiled()){
          Log.i("ERROR", "SHERROR " + shader.getLog());
      }
      if(psObject.getTexture() == null){
          psObject.setTexture(loadTexture(FILE_PATH + psObject.getFileName()));
      }
      psObject.getTexture().bind(0);
  
      shader.begin();
      shader.setUniformMatrix("u_worldView", psObject.getMatrix(zIndex));
      shader.setUniformi("u_texture", 0);
      // psObject.getMesh()
      MeshUtil.MESH.render(shader, GL20.GL_TRIANGLES);
      shader.end();
  }
  </code></pre>
  
  <p>Initial state:</p>
  
  <p><img src="https://i.stack.imgur.com/MWV88.png" alt="enter image description here"></p>
  
  <p>After using undo/redo</p>
  
  <p><img src="https://i.stack.imgur.com/pVjjt.png" alt="enter image description here"></p>