Question: I have a `ListView` which displays images from my cloud.
There may be a delay between when my user open the `activity` with the `ListView` and when the `ListView` is populated with the images. 

For example if the user do not have the Internet connection on, the images won't be displayed.

I'd like to change several things on my `UI` (add a button, start an animation...) only when the `ListView` is filled. I guess I should use a listener to know when the L`istView` is not empty or when my `EmptyView` visibility is gone. Here are the two solutions I tried :

Solution 1:

```
       myListview.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int i) {
                if (myListview.getVisibility() == View.VISIBLE){
//UI changes here

```

Solution 2 :

```
if (listviewAdapter != null){
...UI changes here

```

None of these solutions work, and I cannot find another one. Any idea ?

Thank you !

Answer: 
If you're working with [pre-DSA OpenGL](https://www.khronos.org/opengl/wiki/Direct_State_Access), and you absolutely must wrap OpenGL calls this directly with your own API, then the user is probably going to have to know about the whole bind-to-edit thing. After all, if they've bound a texture for rendering purposes, then they try to modify one, it could damage the current binding.

As such, you should build the bind-to-edit notion directly into the API.

That is, a texture object (which, BTW, should *not* be limited to just 2D textures) shouldn't actually have functions for modifying it, since you cannot modify an OpenGL texture without binding it (or without DSA, which you really ought to learn). It shouldn't have `mirror_u` and so forth; those functions should be part of a binder object:

```
bound_texture bind(some_texture, tex_unit);
bind.mirror_u();
...

```

The constructor of `bound_texture` binds `some_texture` to `tex_unit`. Its member functions will modify that texture (note: they need to call `glActiveTexture` to make sure that nobody has changed the active texture unit).

The destructor of `bound_texture` should automatically unbind the texture. But you should have a `release` member function that manually unbinds it.
You're not going to be able to do this at a compilation level. Instead, if you're really worried about the time costs of these kinds of mistakes, a manager object might be the way to go:

```
class state_manager {
    GLuint current_texture;
    /*Maybe other stuff?*/
public:
    void bind_texture(gl_texture_2d const& tex) {
        if(tex.handle() != current_texture) {
            current_texture = tex.handle();
            glBindTexture(/*...*/, current_texture);
        }
    }
};

int main() {
    state_manager manager;
    /*...*/
    gl_texture_2d tex;
    manager.bind(tex);
    manager.bind(tex); //Won't execute the bind twice in a row!
    /*Do Stuff with tex bound*/

}

```