Пример #1
0
  public void initializeType2(OntologyBase base, ActionEnum type) {
    Action oua = new Action(type);

    ItemInfo it;
    for (int i = 0; i < base.itemInfoArrayList.size(); i++) {
      it = base.itemInfoArrayList.get(i);
      SubtypeInfo st;
      for (int j = 0; j < it.getChildArrayList().size(); j++) {
        st = (SubtypeInfo) it.getChildArrayList().get(j);
        Action cua = (Action) oua.clone();
        cua.setItem(st);
        setAction(cua);
      }
    }
    AtomInfo at;
    for (int i = 0; i < base.atomInfoArrayList.size(); i++) {
      at = base.atomInfoArrayList.get(i);
      DataInfo di;
      for (int j = 0; j < at.getChildArrayList().size(); j++) {
        di = (DataInfo) at.getChildArrayList().get(j);
        Action cua = (Action) oua.clone();
        cua.setItem(di);
        setAction(cua);
      }
    }
  }
Пример #2
0
  public void tick(double dt) {
    int max = 0;
    int[] lmax = new int[4];
    for (int i = 0; i < 4; i++) {
      lmax[i] = ui.sess.glob.cattr.get(Tempers.anm[i]).base;
      if (lmax[i] == 0) return;
      if (lmax[i] != this.lmax[i]) redraw();
      max = Math.max(max, lmax[i]);
    }
    this.lmax = lmax;
    this.max = max;

    GobbleInfo food = null;
    Alchemy ch = null;
    if (ui.lasttip instanceof WItem.ItemTip) {
      try {
        food = ItemInfo.find(GobbleInfo.class, ((WItem.ItemTip) ui.lasttip).item().info());
        ch = ItemInfo.find(Alchemy.class, ((WItem.ItemTip) ui.lasttip).item().info());
      } catch (Loading e) {
      }
    }
    if (lfood != food) {
      lfood = food;
      redraw();
    }
  }
Пример #3
0
 public static Tex rendertt(Resource res, boolean withpg, boolean hotkey) {
   Resource.AButton ad = res.layer(Resource.action);
   Resource.Pagina pg = res.layer(Resource.pagina);
   String tt = ad.name;
   BufferedImage xp = null, food = null;
   if (hotkey) {
     int pos = tt.toUpperCase().indexOf(Character.toUpperCase(ad.hk));
     if (pos >= 0)
       tt =
           tt.substring(0, pos)
               + "$col[255,255,0]{"
               + tt.charAt(pos)
               + "}"
               + tt.substring(pos + 1);
     else if (ad.hk != 0) tt += " [" + ad.hk + "]";
   }
   if (withpg) {
     if (pg != null) {
       tt += "\n\n" + pg.text;
     }
     xp = getXPgain(ad.name);
     food = getFood(ad.name);
   }
   BufferedImage img = ttfnd.render(tt, 300).img;
   if (xp != null) {
     img = ItemInfo.catimgs(3, img, xp);
   }
   if (food != null) {
     img = ItemInfo.catimgs(3, img, food);
   }
   return (new TexI(img));
 }
Пример #4
0
 public Object getValueAt(int row, int column) {
   Object value = null;
   ItemInfo ii = (ItemInfo) list.get(row);
   if (column == 0) {
     value = ii.getName();
   } else if (column == 1) {
     value = new Double(ii.getPrice());
   } else if (column == 2) {
     value = new Integer(ii.getQuantity());
   }
   return value;
 }
  @Override
  public void onAddToDatabase(ContentValues values) {
    super.onAddToDatabase(values);

    String titleStr = title != null ? title.toString() : null;
    values.put(LauncherSettings.BaseLauncherColumns.TITLE, titleStr);

    String uri = intent != null ? intent.toUri(0) : null;
    values.put(LauncherSettings.BaseLauncherColumns.INTENT, uri);

    if (customIcon) {
      values.put(
          LauncherSettings.BaseLauncherColumns.ICON_TYPE,
          LauncherSettings.BaseLauncherColumns.ICON_TYPE_BITMAP);
      writeBitmap(values, mIcon);
    } else {
      if (onExternalStorage && !usingFallbackIcon) {
        writeBitmap(values, mIcon);
      }
      values.put(
          LauncherSettings.BaseLauncherColumns.ICON_TYPE,
          LauncherSettings.BaseLauncherColumns.ICON_TYPE_RESOURCE);
      if (iconResource != null) {
        values.put(LauncherSettings.BaseLauncherColumns.ICON_PACKAGE, iconResource.packageName);
        values.put(LauncherSettings.BaseLauncherColumns.ICON_RESOURCE, iconResource.resourceName);
      }
    }
  }
Пример #6
0
 public static BufferedImage getFood(String name) {
   Item itm = Wiki.get(name);
   if (itm != null) {
     Map<String, Float[]> food = itm.food;
     if (food != null) {
       Float[] heal = food.get("Heals");
       Float[] salt = food.get("Salt");
       Float[] merc = food.get("Mercury");
       Float[] sulph = food.get("Sulphur");
       Float[] lead = food.get("Lead");
       int[] tempers = new int[4];
       int[][] evs = new int[4][4];
       for (int i = 0; i < 4; i++) {
         tempers[i] = (int) (1000 * heal[i]);
         evs[0][i] = (int) (1000 * salt[i]);
         evs[1][i] = (int) (1000 * merc[i]);
         evs[2][i] = (int) (1000 * sulph[i]);
         evs[3][i] = (int) (1000 * lead[i]);
       }
       FoodInfo fi = new FoodInfo(null, tempers);
       GobbleInfo gi = new GobbleInfo(null, evs, 0);
       return ItemInfo.catimgs(3, fi.longtip(), gi.longtip());
     }
   }
   return null;
 }
Пример #7
0
  public void weaponAddDamage() {
    Connection con = null;
    PreparedStatement pstm = null;
    ResultSet rs = null;

    try {
      con = L1DatabaseFactory.getInstance().getConnection();
      pstm =
          con.prepareStatement(
              "select item_id, name, bless, enchantlvl, attr_enchantlvl, price from autoshopbuyitemlist where price > 0");
      rs = pstm.executeQuery();

      int index = 0;
      ItemInfo itemInfo = null;
      while (rs.next()) {
        itemInfo = new ItemInfo();

        itemInfo.id = rs.getInt("item_id");
        itemInfo.name = rs.getString("name");
        itemInfo.bless = rs.getInt("bless");
        itemInfo.enchantlvl = rs.getInt("enchantlvl");
        itemInfo.attrEnchantlvl = rs.getInt("attr_enchantlvl");
        itemInfo.price = rs.getInt("price");

        _idlist.put(index++, itemInfo);
      }

    } catch (SQLException e) {
      _log.log(Level.SEVERE, "AutoShopBuyTable[]Error", e);
    } finally {
      SQLUtil.close(rs);
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    }
  }
Пример #8
0
    private void normalizeIcons(SQLiteDatabase db) {
      Log.d(TAG, "normalizing icons");

      db.beginTransaction();
      Cursor c = null;
      SQLiteStatement update = null;
      try {
        boolean logged = false;
        update = db.compileStatement("UPDATE favorites " + "SET icon=? WHERE _id=?");

        c =
            db.rawQuery(
                "SELECT _id, icon FROM favorites WHERE iconType=" + Favorites.ICON_TYPE_BITMAP,
                null);

        final int idIndex = c.getColumnIndexOrThrow(Favorites._ID);
        final int iconIndex = c.getColumnIndexOrThrow(Favorites.ICON);

        while (c.moveToNext()) {
          long id = c.getLong(idIndex);
          byte[] data = c.getBlob(iconIndex);
          try {
            Bitmap bitmap =
                Utilities.resampleIconBitmap(
                    BitmapFactory.decodeByteArray(data, 0, data.length), mContext);
            if (bitmap != null) {
              update.bindLong(1, id);
              data = ItemInfo.flattenBitmap(bitmap);
              if (data != null) {
                update.bindBlob(2, data);
                update.execute();
              }
              bitmap.recycle();
            }
          } catch (Exception e) {
            if (!logged) {
              Log.e(TAG, "Failed normalizing icon " + id, e);
            } else {
              Log.e(TAG, "Also failed normalizing icon " + id);
            }
            logged = true;
          }
        }
        db.setTransactionSuccessful();
      } catch (SQLException ex) {
        Log.w(TAG, "Problem while allocating appWidgetIds for existing widgets", ex);
      } finally {
        db.endTransaction();
        if (update != null) {
          update.close();
        }
        if (c != null) {
          c.close();
        }
      }
    }
Пример #9
0
  private void add_submitActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_add_submitActionPerformed

    try {
      if (!invalid(item_id.getText()) && !invalid(item_name.getText())) {
        ItemInfo item =
            new ItemInfo(item_id.getText(), item_name.getText(), Integer.parseInt(qty.getText()));

        if (Inventory.searchItem(item.getID())
            .toLowerCase()
            .contains(item_name.getText())) // //search if item already in database
        {
          if (Inventory.update(item.getID(), item.getQty())) {
            add_msg.setForeground(Color.blue);
            add_msg.setText("Item successfully added");
          } else {
            add_msg.setForeground(Color.red);
            add_msg.setText("Item failed to update");
          }

          System.out.println("item found");
        } else if (Inventory.UpdateInvent(item)) {
          add_msg.setForeground(Color.blue);
          add_msg.setText("Item successfully added");
          // add_dialog.dispose();
        } else {
          add_msg.setForeground(Color.red);
          add_msg.setText("internal database error occured");
        }
      } else {
        add_msg.setForeground(Color.red);
        add_msg.setText("invalid data entered");
      }

      // add_msg.setForeground(Color.green);
      // add_msg.setText("Item successfully added");
    } catch (NumberFormatException nfe) {
      add_msg.setForeground(Color.red);
      add_msg.setText("invalid quantity entered");
    }
  } // GEN-LAST:event_add_submitActionPerformed
  private void arrangeChildren(ArrayList<View> list) {
    int[] vacant = new int[2];
    if (list == null) {
      list = getItemsInReadingOrder();
    }
    mContent.removeAllViews();

    for (int i = 0; i < list.size(); i++) {
      View v = list.get(i);
      mContent.getVacantCell(vacant, 1, 1);
      CellLayout.LayoutParams lp = (CellLayout.LayoutParams) v.getLayoutParams();
      lp.cellX = vacant[0];
      lp.cellY = vacant[1];
      ItemInfo info = (ItemInfo) v.getTag();
      if (info.cellX != vacant[0] || info.cellY != vacant[1]) {
        info.cellX = vacant[0];
        info.cellY = vacant[1];
        LauncherModel.addOrMoveItemInDatabase(mLauncher, info, mInfo.id, 0, info.cellX, info.cellY);
      }
      boolean insert = false;
      mContent.addViewToCellLayout(v, insert ? 0 : -1, (int) info.id, lp, true);
    }
    mItemsInvalidated = true;
  }
 @Override
 void unbind() {
   super.unbind();
   hostView = null;
 }
Пример #12
0
  protected boolean generate(TrackerWebPageRequest request, TrackerWebPageResponse response)
      throws IOException {
    InetSocketAddress local_address = request.getLocalAddress();

    if (local_address == null) {

      return (false);
    }

    String host = local_address.getAddress().getHostAddress();

    String url = request.getURL();

    if (TRACE) {
      System.out.println("url: " + url);
    }

    if (!url.startsWith("/TiVoConnect?")) {

      return (false);
    }

    int pos = url.indexOf('?');

    if (pos == -1) {

      return (false);
    }

    String[] bits = url.substring(pos + 1).split("&");

    Map<String, String> args = new HashMap<String, String>();

    for (String bit : bits) {

      String[] x = bit.split("=");

      args.put(x[0], URLDecoder.decode(x[1], "UTF-8"));
    }

    if (TRACE) {
      System.out.println("args: " + args);
    }

    // root folder /TiVoConnect?Command=QueryContainer&Container=%2F

    String command = args.get("Command");

    if (command == null) {

      return (false);
    }

    String reply = null;

    if (command.equals("QueryContainer")) {

      String container = args.get("Container");

      if (container == null) {

        return (false);
      }

      if (container.equals("/")) {

        reply =
            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
                + NL
                + "<TiVoContainer>"
                + NL
                + "    <Details>"
                + NL
                + "        <Title>"
                + server_name
                + "</Title>"
                + NL
                + "        <ContentType>x-container/tivo-server</ContentType>"
                + NL
                + "        <SourceFormat>x-container/folder</SourceFormat>"
                + NL
                + "        <TotalItems>1</TotalItems>"
                + NL
                + "    </Details>"
                + NL
                + "    <Item>"
                + NL
                + "        <Details>"
                + NL
                + "            <Title>"
                + server_name
                + "</Title>"
                + NL
                + "            <ContentType>x-container/tivo-videos</ContentType>"
                + NL
                + "            <SourceFormat>x-container/folder</SourceFormat>"
                + NL
                + "        </Details>"
                + NL
                + "        <Links>"
                + NL
                + "            <Content>"
                + NL
                + "                <Url>/TiVoConnect?Command=QueryContainer&amp;Container="
                + urlencode("/Content")
                + "</Url>"
                + NL
                + "                <ContentType>x-container/tivo-videos</ContentType>"
                + NL
                + "            </Content>"
                + NL
                + "        </Links>"
                + NL
                + "    </Item>"
                + NL
                + "    <ItemStart>0</ItemStart>"
                + NL
                + "    <ItemCount>1</ItemCount>"
                + NL
                + "</TiVoContainer>";

      } else if (container.startsWith("/Content")) {

        boolean show_categories = getShowCategories();

        String recurse = args.get("Recurse");

        if (recurse != null && recurse.equals("Yes")) {

          show_categories = false;
        }

        TranscodeFileImpl[] tfs = getFiles();

        String category_or_tag = null;

        Map<String, ContainerInfo> categories_or_tags = null;

        if (show_categories) {

          if (container.startsWith("/Content/")) {

            category_or_tag = container.substring(container.lastIndexOf('/') + 1);

          } else {

            categories_or_tags = new HashMap<String, ContainerInfo>();
          }
        }

        // build list of applicable items

        List<ItemInfo> items = new ArrayList<ItemInfo>(tfs.length);

        for (TranscodeFileImpl file : tfs) {

          if (!file.isComplete()) {

            // see if we can set up a stream xcode for this but only if we
            // know the duration and the transcode is in progress (done in setup)

            if (!setupStreamXCode(file)) {

              continue;
            }
          }

          if (category_or_tag != null) {

            boolean hit = false;

            String[] cats = file.getCategories();
            String[] tags = file.getTags(true);

            for (String[] strs : new String[][] {cats, tags}) {

              for (String c : strs) {

                if (c.equals(category_or_tag)) {

                  hit = true;
                }
              }
            }

            if (!hit) {

              continue;
            }
          }

          FileInfo info = new FileInfo(file, host);

          if (info.isOK()) {

            boolean skip = false;

            if (categories_or_tags != null) {

              String[] cats = file.getCategories();
              String[] tags = file.getTags(true);

              if (cats.length > 0 || tags.length > 0) {

                skip = true;

                for (String[] strs : new String[][] {cats, tags}) {

                  for (String s : strs) {

                    ContainerInfo cont = categories_or_tags.get(s);

                    if (cont == null) {

                      items.add(cont = new ContainerInfo(s));

                      categories_or_tags.put(s, cont);
                    }

                    cont.addChild();
                  }
                }
              }
            }

            if (!skip) {

              items.add(info);
            }
          }
        }

        // sort

        String sort_order = args.get("SortOrder");

        if (sort_order != null) {

          String[] keys = Constants.PAT_SPLIT_COMMA.split(sort_order);

          final List<Comparator<ItemInfo>> comparators = new ArrayList<Comparator<ItemInfo>>();
          final List<Boolean> reverses = new ArrayList<Boolean>();

          for (String key : keys) {

            boolean reverse = false;

            if (key.startsWith("!")) {

              reverse = true;

              key = key.substring(1);
            }

            Comparator<ItemInfo> comp = sort_comparators.get(key);

            if (comp != null) {

              comparators.add(comp);
              reverses.add(reverse);
            }
          }

          if (comparators.size() > 0) {

            Collections.sort(
                items,
                new Comparator<ItemInfo>() {
                  public int compare(ItemInfo i1, ItemInfo i2) {
                    for (int i = 0; i < comparators.size(); i++) {

                      Comparator<ItemInfo> comp = comparators.get(i);

                      int res = comp.compare(i1, i2);

                      if (res != 0) {

                        if (reverses.get(i)) {

                          if (res < 0) {

                            res = 1;

                          } else {

                            res = -1;
                          }
                        }

                        return (res);
                      }
                    }

                    return (0);
                  }
                });
          }
        }

        // select items to return

        String item_count = args.get("ItemCount");
        String anchor_offset = args.get("AnchorOffset");
        String anchor = args.get("AnchorItem");

        int num_items;

        if (item_count == null) {

          num_items = items.size();

        } else {

          // can be negative if X items from end

          num_items = Integer.parseInt(item_count);
        }

        int
            anchor_index; // either one before or one after item to be returned depending on count
                          // +ve/-ve

        if (num_items < 0) {

          anchor_index = items.size();

        } else {

          anchor_index = -1;
        }

        if (anchor != null) {

          for (int i = 0; i < items.size(); i++) {

            ItemInfo info = items.get(i);

            if (anchor.equals(info.getLinkURL())) {

              anchor_index = i;
            }
          }
        }

        if (anchor_offset != null) {

          anchor_index += Integer.parseInt(anchor_offset);

          if (anchor_index < -1) {

            anchor_index = -1;

          } else if (anchor_index > items.size()) {

            anchor_index = items.size();
          }
        }

        int start_index;
        int end_index;

        if (num_items > 0) {

          start_index = anchor_index + 1;

          end_index = anchor_index + num_items;

        } else {

          start_index = anchor_index + num_items;

          end_index = anchor_index - 1;
        }

        if (start_index < 0) {

          start_index = 0;
        }

        if (end_index >= items.size()) {

          end_index = items.size() - 1;
        }

        int num_to_return = end_index - start_index + 1;

        if (num_to_return < 0) {

          num_to_return = 0;
        }

        String machine = getMachineName();

        if (machine == null) {

          // default until we find out what it is - can't see any way to get it apart from wait for
          // broadcast

          machine = "TivoHDDVR";
        }

        String header =
            "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
                + NL
                + "<TiVoContainer>"
                + NL
                + "    <Tivos>"
                + NL
                + "      <Tivo>"
                + machine
                + "</Tivo>"
                + NL
                + "    </Tivos>"
                + NL
                + "    <ItemStart>"
                + start_index
                + "</ItemStart>"
                + NL
                + "    <ItemCount>"
                + num_to_return
                + "</ItemCount>"
                + NL
                + "    <Details>"
                + NL
                + "        <Title>"
                + escape(container)
                + "</Title>"
                + NL
                + "        <ContentType>x-container/tivo-videos</ContentType>"
                + NL
                + "        <SourceFormat>x-container/folder</SourceFormat>"
                + NL
                + "        <TotalItems>"
                + items.size()
                + "</TotalItems>"
                + NL
                + "    </Details>"
                + NL;

        reply = header;

        for (int i = start_index; i <= end_index; i++) {

          ItemInfo item = items.get(i);

          if (item instanceof FileInfo) {

            FileInfo file = (FileInfo) item;

            long file_size = file.getTargetSize();

            String title = escape(file.getName());
            String desc = title;

            int MAX_TITLE_LENGTH = 30;

            if (title.length() > MAX_TITLE_LENGTH) {

              // TiVo has problems displaying a truncated title if it has
              // no spaces in it

              String temp = "";

              for (int j = 0; j < title.length(); j++) {

                char c = title.charAt(j);

                if (Character.isLetterOrDigit(c)) {

                  temp += c;
                } else {

                  temp += ' ';
                }
              }

              int space_pos = temp.indexOf(' ');

              if (space_pos == -1 || space_pos > MAX_TITLE_LENGTH) {

                temp = temp.substring(0, 30) + "...";
              }

              title = temp;
            }

            reply +=
                "    <Item>"
                    + NL
                    + "        <Details>"
                    + NL
                    + "            <Title>"
                    + title
                    + "</Title>"
                    + NL
                    + "            <ContentType>video/x-tivo-mpeg</ContentType>"
                    + NL
                    + "            <SourceFormat>video/x-ms-wmv</SourceFormat>"
                    + NL;

            if (file_size > 0) {
              reply += "            <SourceSize>" + file_size + "</SourceSize>" + NL;
            } else {
              long est_size = file.getEstimatedTargetSize();

              if (est_size > 0) {
                reply += "            <SourceSize>" + est_size + "</SourceSize>" + NL;
              }
            }

            reply +=
                "            <Duration>"
                    + file.getDurationMillis()
                    + "</Duration>"
                    + NL
                    + "            <Description>"
                    + desc
                    + "</Description>"
                    + NL
                    + "            <SourceChannel>0</SourceChannel>"
                    + NL
                    + "            <SourceStation></SourceStation>"
                    + NL
                    + "            <SeriesId></SeriesId>"
                    + NL
                    + "            <CaptureDate>"
                    + file.getCaptureDate()
                    + "</CaptureDate>"
                    + NL
                    + "        </Details>"
                    + NL
                    + "        <Links>"
                    + NL
                    + "            <Content>"
                    + NL
                    + "                <ContentType>video/x-tivo-mpeg</ContentType>"
                    + NL
                    + "                    <AcceptsParams>No</AcceptsParams>"
                    + NL
                    + "                    <Url>"
                    + file.getLinkURL()
                    + "</Url>"
                    + NL
                    + "                </Content>"
                    + NL
                    + "                <CustomIcon>"
                    + NL
                    + "                    <ContentType>video/*</ContentType>"
                    + NL
                    + "                    <AcceptsParams>No</AcceptsParams>"
                    + NL
                    + "                    <Url>urn:tivo:image:save-until-i-delete-recording</Url>"
                    + NL
                    + "                </CustomIcon>"
                    + NL
                    + "        </Links>"
                    + NL
                    + "    </Item>"
                    + NL;

          } else {

            ContainerInfo cont = (ContainerInfo) item;

            reply +=
                "    <Item>"
                    + NL
                    + "        <Details>"
                    + NL
                    + "            <Title>"
                    + cont.getName()
                    + "</Title>"
                    + NL
                    + "            <ContentType>x-container/tivo-videos</ContentType>"
                    + NL
                    + "            <SourceFormat>x-container/folder</SourceFormat>"
                    + NL
                    + "            <TotalItems>"
                    + cont.getChildCount()
                    + "</TotalItems>"
                    + NL
                    + "        </Details>"
                    + NL
                    + "        <Links>"
                    + NL
                    + "            <Content>"
                    + NL
                    + "                <Url>"
                    + cont.getLinkURL()
                    + "</Url>"
                    + NL
                    + "                <ContentType>x-container/tivo-videos</ContentType>"
                    + NL
                    + "            </Content>"
                    + NL
                    + "        </Links>"
                    + NL
                    + "    </Item>"
                    + NL;
          }
        }

        String footer = "</TiVoContainer>";

        reply += footer;
      }

    } else if (command.equals("QueryFormats")) {

      String source_format = args.get("SourceFormat");

      if (source_format != null && source_format.startsWith("video")) {

        // /TiVoConnect?Command=QueryFormats&SourceFormat=video%2Fx-tivo-mpeg

        reply =
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                + NL
                + "<TiVoFormats><Format>"
                + NL
                + "<ContentType>video/x-tivo-mpeg</ContentType><Description/>"
                + NL
                + "</Format></TiVoFormats>";
      }
    }

    if (reply == null) {

      return (false);
    }

    if (TRACE) {
      System.out.println("->" + reply);
    }

    response.setContentType("text/xml");

    response.getOutputStream().write(reply.getBytes("UTF-8"));

    return (true);
  }
Пример #13
0
 ////////////////////////////////////////////////////////////////////////////
 //
 // Refresh
 //
 ////////////////////////////////////////////////////////////////////////////
 @Override
 protected void refresh_fetch() throws Exception {
   ReflectionUtils.invokeMethod(getObject(), "expandMenu()");
   super.refresh_fetch();
   ReflectionUtils.invokeMethod(getObject(), "deactivate()");
 }
 @Override
 void onAddToDatabase(ContentValues values) {
   super.onAddToDatabase(values);
   values.put(LauncherSettings.Favorites.APPWIDGET_ID, appWidgetId);
 }
 @Override
 public void unbind() {
   super.unbind();
 }
Пример #16
0
 @Override
 public void run() {
   String url = SERVER_URL_TEST;
   String params = getParams(ACTION_LIST, true);
   boolean isSucceed = false;
   if (params != null) {
     CustomerHttpClient client = new CustomerHttpClient(mContext);
     String[] res = client.post(url, params);
     if (isExit) {
       synchronized (syncObject) {
         downListThread = null;
         return;
       }
     }
     if (res != null) {
       String content = res[0];
       Log.v("downloadlist", "content = " + content);
       //					Tools.writelogTosd( content );
       JSONObject json = null;
       try {
         json = new JSONObject(content);
         int retCode = json.getInt("retcode");
         if (retCode == 0) {
           String configUrl = json.getString("reslist");
           json = new JSONObject(configUrl);
           for (Iterator iter = json.keys(); iter.hasNext(); ) {
             String key = (String) iter.next();
             JSONObject tmJson = (JSONObject) json.get(key);
             ListInfo listInfo = new ListInfo();
             for (Iterator mIterator = tmJson.keys(); mIterator.hasNext(); ) {
               String mKey = (String) mIterator.next();
               if (mKey.equals("tabid")) {
                 listInfo.setTabid(tmJson.get(mKey).toString());
               } else if (mKey.equals("enname")) {
                 listInfo.setEnname(tmJson.get(mKey).toString());
               } else if (mKey.equals("cnname")) {
                 listInfo.setCnname(tmJson.get(mKey).toString());
               } else if (mKey.equals("twname")) {
                 listInfo.setTwname(tmJson.get(mKey).toString());
               } else if (mKey.equals("typeid")) {
                 listInfo.setTypeid(tmJson.get(mKey).toString());
               } else {
                 JSONObject jsObj = (JSONObject) tmJson.get(mKey);
                 ItemInfo itemInfo = new ItemInfo();
                 itemInfo.setIndex(mKey);
                 System.out.println(
                     "mKey = " + mKey + " jsObj.getString() = " + jsObj.getString("cnname"));
                 itemInfo.setResid(jsObj.getString("resid"));
                 itemInfo.setEnname(jsObj.getString("enname"));
                 itemInfo.setCnname(jsObj.getString("cnname"));
                 // itemInfo.setTwname(jsObj.getString("twname"));
                 itemInfo.setResurl(jsObj.getString("resurl"));
                 itemInfo.setPackname(jsObj.getString("packname"));
                 itemInfo.setSize(jsObj.getString("size"));
                 itemInfo.setAuthor(jsObj.getString("author"));
                 itemInfo.setAboutchinese(jsObj.getString("aboutchinese"));
                 itemInfo.setVersion(jsObj.getString("version"));
                 itemInfo.setVersionname(jsObj.getString("versionname"));
                 itemInfo.setAboutenglish(jsObj.getString("aboutenglish"));
                 itemInfo.setPrice(jsObj.getString("price"));
                 itemInfo.setPricedetail(jsObj.getString("pricedetail"));
                 itemInfo.setPricePoint(jsObj.getString("pricepoint"));
                 itemInfo.setIcon(jsObj.getString("icon"));
                 itemInfo.setThumbimg(jsObj.getString("thumbimg"));
                 try {
                   itemInfo.setEnginepackname(jsObj.getString("enginepackname"));
                   itemInfo.setEngineurl(jsObj.getString("engineurl"));
                   itemInfo.setEnginesize(jsObj.getString("enginesize"));
                 } catch (JSONException e) {
                   itemInfo.setEnginepackname(null);
                   itemInfo.setEngineurl(null);
                   itemInfo.setEnginesize(null);
                 }
                 try {
                   itemInfo.setEnginedesc(jsObj.getString("enginedesc"));
                 } catch (JSONException e) {
                   itemInfo.setEnginedesc(null);
                 }
                 try {
                   itemInfo.setThirdparty(jsObj.getString("thirdparty"));
                 } catch (JSONException e) {
                   itemInfo.setThirdparty(null);
                 }
                 try {
                   JSONArray preview = jsObj.getJSONArray("previewlist");
                   String[] pre = new String[preview.length()];
                   for (int k = 0; k < preview.length(); k++) {
                     pre[k] = preview.getString(k);
                   }
                   itemInfo.setPreviewlist(pre);
                 } catch (JSONException e) {
                   itemInfo.setPreviewlist(new String[] {itemInfo.getThumbimg()});
                 }
                 listInfo.getItemList().add(itemInfo);
               }
             }
             info.add(listInfo);
           }
           isSucceed = true;
         }
       } catch (JSONException e) {
         e.printStackTrace();
       }
     }
   }
   if (isSucceed) {
     downloadListFinish();
   }
   synchronized (syncObject) {
     downListThread = null;
     return;
   }
 }
Пример #17
0
 public final int getEnchantLevel() {
   return _itemInfo != null ? _itemInfo.getEnchantLevel() : 0;
 }
Пример #18
0
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof ItemInfo)) return false;
   ItemInfo other = (ItemInfo) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && this.itId == other.getItId()
           && this.itCountry == other.getItCountry()
           && ((this.itName == null && other.getItName() == null)
               || (this.itName != null && this.itName.equals(other.getItName())))
           && this.itPrice == other.getItPrice()
           && this.itBidCount == other.getItBidCount()
           && this.itEndingTime == other.getItEndingTime()
           && this.itSellerId == other.getItSellerId()
           && ((this.itSellerLogin == null && other.getItSellerLogin() == null)
               || (this.itSellerLogin != null
                   && this.itSellerLogin.equals(other.getItSellerLogin())))
           && this.itSellerRating == other.getItSellerRating()
           && this.itStartingTime == other.getItStartingTime()
           && this.itStartingPrice == other.getItStartingPrice()
           && this.itQuantity == other.getItQuantity()
           && this.itFotoCount == other.getItFotoCount()
           && this.itReservePrice == other.getItReservePrice()
           && ((this.itLocation == null && other.getItLocation() == null)
               || (this.itLocation != null && this.itLocation.equals(other.getItLocation())))
           && this.itBuyNowPrice == other.getItBuyNowPrice()
           && this.itBuyNowActive == other.getItBuyNowActive()
           && this.itHighBidder == other.getItHighBidder()
           && ((this.itHighBidderLogin == null && other.getItHighBidderLogin() == null)
               || (this.itHighBidderLogin != null
                   && this.itHighBidderLogin.equals(other.getItHighBidderLogin())))
           && ((this.itDescription == null && other.getItDescription() == null)
               || (this.itDescription != null
                   && this.itDescription.equals(other.getItDescription())))
           && this.itOptions == other.getItOptions()
           && this.itState == other.getItState()
           && this.itIsEco == other.getItIsEco()
           && this.itHitCount == other.getItHitCount()
           && ((this.itPostcode == null && other.getItPostcode() == null)
               || (this.itPostcode != null && this.itPostcode.equals(other.getItPostcode())))
           && this.itVatInvoice == other.getItVatInvoice()
           && ((this.itBankAccount1 == null && other.getItBankAccount1() == null)
               || (this.itBankAccount1 != null
                   && this.itBankAccount1.equals(other.getItBankAccount1())))
           && ((this.itBankAccount2 == null && other.getItBankAccount2() == null)
               || (this.itBankAccount2 != null
                   && this.itBankAccount2.equals(other.getItBankAccount2())))
           && this.itStartingQuantity == other.getItStartingQuantity()
           && this.itIsForGuests == other.getItIsForGuests()
           && this.itHasProduct == other.getItHasProduct()
           && this.itOrderFulfillmentTime == other.getItOrderFulfillmentTime()
           && this.itEndingInfo == other.getItEndingInfo()
           && this.itIsAllegroStandard == other.getItIsAllegroStandard()
           && this.itIsNewUsed == other.getItIsNewUsed()
           && this.itIsBrandZone == other.getItIsBrandZone()
           && ((this.itDurationInfo == null && other.getItDurationInfo() == null)
               || (this.itDurationInfo != null
                   && this.itDurationInfo.equals(other.getItDurationInfo())))
           && this.itIsFulfillmentTimeActive == other.getItIsFulfillmentTimeActive();
   __equalsCalc = null;
   return _equals;
 }
Пример #19
0
    public String encodeToString() {
      if (activityInfo != null) {
        try {
          // If it a launcher target, we only need component name, and user to
          // recreate this.
          return new JSONStringer()
              .object()
              .key(LAUNCH_INTENT_KEY)
              .value(launchIntent.toUri(0))
              .key(APP_SHORTCUT_TYPE_KEY)
              .value(true)
              .key(USER_HANDLE_KEY)
              .value(UserManagerCompat.getInstance(mContext).getSerialNumberForUser(user))
              .endObject()
              .toString();
        } catch (JSONException e) {
          Log.d(TAG, "Exception when adding shortcut: " + e);
          return null;
        }
      }

      if (launchIntent.getAction() == null) {
        launchIntent.setAction(Intent.ACTION_VIEW);
      } else if (launchIntent.getAction().equals(Intent.ACTION_MAIN)
          && launchIntent.getCategories() != null
          && launchIntent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
        launchIntent.addFlags(
            Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
      }

      // This name is only used for comparisons and notifications, so fall back to activity
      // name if not supplied
      String name = ensureValidName(mContext, launchIntent, label).toString();
      Bitmap icon = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON);
      Intent.ShortcutIconResource iconResource =
          data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE);

      // Only encode the parameters which are supported by the API.
      try {
        JSONStringer json =
            new JSONStringer()
                .object()
                .key(LAUNCH_INTENT_KEY)
                .value(launchIntent.toUri(0))
                .key(NAME_KEY)
                .value(name);
        if (icon != null) {
          byte[] iconByteArray = ItemInfo.flattenBitmap(icon);
          json =
              json.key(ICON_KEY)
                  .value(
                      Base64.encodeToString(
                          iconByteArray, 0, iconByteArray.length, Base64.DEFAULT));
        }
        if (iconResource != null) {
          json = json.key(ICON_RESOURCE_NAME_KEY).value(iconResource.resourceName);
          json = json.key(ICON_RESOURCE_PACKAGE_NAME_KEY).value(iconResource.packageName);
        }
        return json.endObject().toString();
      } catch (JSONException e) {
        Log.d(TAG, "Exception when adding shortcut: " + e);
      }
      return null;
    }