@Override
 public void onDestroy() {
   if (!NetworkView.Instance().isInitialized() && NetworkInitializer.Instance != null) {
     NetworkInitializer.Instance.setActivity(null);
   }
   super.onDestroy();
 }
 @Override
 public void onResume() {
   super.onResume();
   if (!NetworkView.Instance().isInitialized()) {
     if (NetworkInitializer.Instance == null) {
       new NetworkInitializer(this);
       NetworkInitializer.Instance.start();
     } else {
       NetworkInitializer.Instance.setActivity(this);
     }
   } else {
     prepareView();
     if (myIntent != null) {
       processIntent(myIntent);
       myIntent = null;
     }
   }
 }
  private void refreshCatalogsList() {
    final NetworkView view = NetworkView.Instance();

    final Handler handler =
        new Handler() {
          @Override
          public void handleMessage(Message msg) {
            if (msg.obj == null) {
              view.finishBackgroundUpdate();
            } else {
              final ZLResource dialogResource = ZLResource.resource("dialog");
              final ZLResource boxResource = dialogResource.getResource("networkError");
              final ZLResource buttonResource = dialogResource.getResource("button");
              new AlertDialog.Builder(NetworkLibraryActivity.this)
                  .setTitle(boxResource.getResource("title").getValue())
                  .setMessage((String) msg.obj)
                  .setIcon(0)
                  .setPositiveButton(buttonResource.getResource("ok").getValue(), null)
                  .create()
                  .show();
            }
          }
        };

    UIUtil.wait(
        "updatingCatalogsList",
        new Runnable() {
          public void run() {
            String error = null;
            try {
              view.runBackgroundUpdate(true);
            } catch (ZLNetworkException e) {
              error = e.getMessage();
            }
            handler.sendMessage(handler.obtainMessage(0, error));
          }
        },
        this);
  }
 public final int getCount() {
   if (!NetworkView.Instance().isInitialized()) {
     return 0;
   }
   return myTree.subTrees().size();
 }