iifast

MyApplication.java

Feb 2nd, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 KB | None | 0 0
  1. package com.mycompany.myapp;
  2.  
  3. //Android > Source Packages > package com.mycompany.myapp > MyApplication.java
  4. // full working android project + configured theme.res (mine)
  5. // android images parts link : https://imgur.com/a/T57SF32
  6.  
  7. import com.codename1.components.ImageViewer;
  8. import static com.codename1.ui.CN.*;
  9. import com.codename1.ui.Display;
  10. import com.codename1.ui.Form;
  11. import com.codename1.ui.Dialog;
  12. import com.codename1.ui.Label;
  13. import com.codename1.ui.plaf.UIManager;
  14. import com.codename1.ui.util.Resources;
  15. import com.codename1.io.Log;
  16. import com.codename1.ui.Toolbar;
  17. import java.io.IOException;
  18. import com.codename1.ui.layouts.BoxLayout;
  19. import com.codename1.io.NetworkEvent;
  20. import com.codename1.ui.Container;
  21. import com.codename1.ui.util.UIBuilder;
  22.  
  23. /**
  24.  * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
  25.  * of building native mobile applications using Java.
  26.  */
  27. public class MyApplication {
  28.  
  29.     private Form current;
  30.     private Resources theme;
  31.  
  32.     public void init(Object context) {
  33.         // use two network threads instead of one
  34.         updateNetworkThreadCount(2);
  35.  
  36.         theme = UIManager.initFirstTheme("/theme");
  37.  
  38.         // Enable Toolbar on all Forms by default
  39.         Toolbar.setGlobalToolbar(true);
  40.  
  41.         // Pro only feature
  42.         Log.bindCrashProtection(true);
  43.  
  44.         addNetworkErrorListener(err -> {
  45.             // prevent the event from propagating
  46.             err.consume();
  47.             if(err.getError() != null) {
  48.                 Log.e(err.getError());
  49.             }
  50.             Log.sendLogAsync();
  51.             Dialog.show("Connection Error", "There was a networking error in the connection to "
  52.                      + err.getConnectionRequest().getUrl(), "OK", null);
  53.         });        
  54.     }
  55.    
  56.     public void start() {
  57.         if(current != null){
  58.             current.show();
  59.             return;
  60.         }
  61.        
  62.      
  63.         UIBuilder UIB = new UIBuilder () ;
  64.         UIBuilder.registerCustomComponent("ImageViewer",ImageViewer.class);
  65.         Container ct = UIB.createContainer(theme, "GUI 1");
  66.         Form f=(Form) ct;
  67.        
  68.             f.show();
  69.        }
  70.  
  71.     public void stop() {
  72.         current = getCurrentForm();
  73.         if(current instanceof Dialog) {
  74.             ((Dialog)current).dispose();
  75.             current = getCurrentForm();
  76.         }
  77.     }
  78.    
  79.     public void destroy() {}
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment