Quote:
Originally Posted by georgelaza
What I'm trying to do is to rewrite the note taking app. I tried a simple invalidation like this:
-------------------
public class MainActivity extends AppCompatActivity {
public View viewforinv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
protected void onStart() {
super.onStart();
viewforinv=findViewById(R.id.forinv);
viewforinv.invalidate();
}
}
|
It doesn't make sense to hook view invalidations in activity lifecycle callbacks. OnStart is called once in the majority of scenarios. You might want to create a method that receives a view as a parameter and just performs a invalidation of the given view. Then you can use that method on your listeners or any other action that needs a full screen refresh.
Remember that anything that touches visible elements of the screen need to be run on the UI thread.
Anyways, I cannot comment the code sample you gave because I don't know what's in the xml layout file. Asumming R.layout.activity_main.xml has a top linear layout called topView my suggestion would be:
1. use LinearLayout topView = findViewById(R.id.topView);
2. create a view that you want to invalidate using View.inflate
3. add the view to your layout using topView.addView(nameOfYourView)
4. set the content view to your linear layout.
If you're starting I would suggest using buttons and calling view invalidation on click instead
Quote:
Originally Posted by georgelaza
I would appreciate any help, paid projects are not excluded.
|
I'm not aware of any paid project that do that.
KOReader has REd support for full screen updates in
https://github.com/koreader/android-...DController.kt. It is needed because the program uses ANativeActivity framework and the window buffer isn't hooked to the view hierarchy.
Librera uses the "normal" view hierarchy and their approach is based on view invalidation, see
https://github.com/foobnix/LibreraRe...s.java#L47-L70