Example #1
0
  // --------------------------------------------------------------------------------------------------------------------------
  private void showBeans() {
    // Read all the beans from the channel
    MobileBean[] beans = MobileBean.readAll("cloud_channel");
    if (MobileBean.isBooted("cloud_channel")) {
      // Populate the List View
      ListView view = (ListView) findViewById(R.id.list);

      // Prepare the data for the adapter. Data is read from the ticket bean instances
      ArrayList<HashMap<String, String>> mylist = new ArrayList<HashMap<String, String>>();
      if (beans != null && beans.length > 0) {
        for (MobileBean local : beans) {
          HashMap<String, String> map = new HashMap<String, String>();

          String name = local.getValue("name");
          String value = local.getValue("value");

          if (name.length() > 25) {
            name = name.substring(0, 22) + "...";
          }

          if (value.length() > 25) {
            value = value.substring(0, 22) + "...";
          }

          map.put("name", name);
          map.put("value", value);
          mylist.add(map);
        }
      }

      SimpleAdapter beanAdapter =
          new SimpleAdapter(
              this,
              mylist,
              R.layout.bean_row,
              new String[] {"name", "value"},
              new int[] {R.id.name, R.id.value});
      view.setAdapter(beanAdapter);

      // List Listener...used to respond to selecting a ticket instance
      OnItemClickListener clickListener = new ClickListener(beans);
      view.setOnItemClickListener(clickListener);
    } else {
      // Tickets not found...put up a Sync in progress message and wait for data to be downloaded
      // from the Backend
      if (!HomeScreen.syncInProgress && !HomeScreen.syncComplete) {
        HomeScreen.syncInProgress = true;
        SyncInProgressAsyncTask task = new SyncInProgressAsyncTask();
        task.execute();
      }
    }
  }
 public void doAction(CommandContext commandContext) {
   try {
     int counter = 5;
     while (!MobileBean.isBooted(Constants.channel)) {
       Thread.currentThread().sleep(1000);
       if (counter-- == 0) {
         throw new RuntimeException();
       }
     }
   } catch (Exception e) {
     throw new AppException();
   }
 }
Example #3
0
    @Override
    protected String doInBackground(Void... arg0) {
      try {
        // Check if the CRM Ticket channel has data to be read
        boolean isBooted = MobileBean.isBooted("cloud_channel");
        int counter = 20;
        while (!isBooted) {
          Thread.sleep(2000);

          if (counter > 0) {
            isBooted = MobileBean.isBooted("cloud_channel");
            counter--;
          } else {
            break;
          }
        }

        return "" + isBooted;
      } catch (Exception e) {
        return "failure";
      }
    }