Exemplo n.º 1
0
 @Override
 public Fuzzy<T> convert(String string, Type type) {
   string = string.trim();
   if (string.startsWith("[") && string.endsWith("]")) {
     string = string.substring(1, string.length() - 1);
   }
   String[] parts = string.split(",", 0);
   Builder<T> builder = new Builder<T>();
   for (String part : parts) {
     int colon = part.indexOf(':');
     if (colon < 0) {
       builder.addWeighted(parse(part.trim()), 1.0);
     } else {
       int percent = part.indexOf('%');
       if (percent >= 0 && percent < colon) {
         double probability = Double.parseDouble(part.substring(0, percent).trim()) / 100;
         builder.addFixed(parse(part.substring(colon + 1).trim()), probability);
       } else {
         double weight = Double.parseDouble(part.substring(0, colon).trim());
         builder.addWeighted(parse(part.substring(colon + 1).trim()), weight);
       }
     }
   }
   return builder.create();
 }
Exemplo n.º 2
0
 /** 选择两种图片方式,最终需要在活动中监听forresult方法 */
 public void choiceItem() {
   AlertDialog.Builder builder = Builder.create(baseActivity);
   builder.setTitle(R.string.picupload_title);
   builder.setItems(
       R.array.upload_type,
       new DialogInterface.OnClickListener() {
         @Override
         public void onClick(DialogInterface dialog, int which) {
           switch (which) {
             case 0:
               getFromLocal();
               break;
             case 1:
               getFromCamera(uri);
               break;
           }
         }
       });
   builder.create();
   builder.show();
 }
  private void build() {
    final WorkoutsActivity activity = (WorkoutsActivity) context;

    Builder builder = new Builder(context);
    builder.setTitle(R.string.delete_workout);
    builder.setMessage(
        Html.fromHtml(
            getContext().getString(R.string.really_delete_workout) + ": <b>" + name + "</b>"));
    builder
        .setPositiveButton(
            R.string.delete,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                activity.removeWorkout(position);
              }
            })
        .setNegativeButton(
            R.string.cancel,
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {}
            });
    builder.create().show();
  }
Exemplo n.º 4
0
    /**
     * @deprecated in API 16 Creates the mesh object from the current state of the builder
     * @param uploadToBufferObject specifies whether the vertex data is to be uploaded into the
     *     buffer object indicating that it's likely not going to be modified and rendered many
     *     times. Alternatively, it indicates the mesh data will be updated frequently and remain in
     *     script accessible memory
     */
    public Mesh create(boolean uploadToBufferObject) {
      Element.Builder b = new Element.Builder(mRS);
      b.add(Element.createVector(mRS, Element.DataType.FLOAT_32, mVtxSize), "position");
      if ((mFlags & COLOR) != 0) {
        b.add(Element.F32_4(mRS), "color");
      }
      if ((mFlags & TEXTURE_0) != 0) {
        b.add(Element.F32_2(mRS), "texture0");
      }
      if ((mFlags & NORMAL) != 0) {
        b.add(Element.F32_3(mRS), "normal");
      }
      mElement = b.create();

      int usage = Allocation.USAGE_SCRIPT;
      if (uploadToBufferObject) {
        usage |= Allocation.USAGE_GRAPHICS_VERTEX;
      }

      Builder smb = new Builder(mRS, usage);
      smb.addVertexType(mElement, mMaxIndex);
      smb.addIndexSetType(Element.U16(mRS), mIndexCount, Primitive.TRIANGLE);

      Mesh sm = smb.create();

      sm.getVertexAllocation(0).copy1DRangeFromUnchecked(0, mMaxIndex, mVtxData);
      if (uploadToBufferObject) {
        sm.getVertexAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
      }

      sm.getIndexSetAllocation(0).copy1DRangeFromUnchecked(0, mIndexCount, mIndexData);
      if (uploadToBufferObject) {
        sm.getIndexSetAllocation(0).syncAll(Allocation.USAGE_SCRIPT);
      }

      return sm;
    }
Exemplo n.º 5
0
 public static Builder newBuilder() {
   return Builder.create();
 }
 public Builder transform(TermParameterDefinitionContract input) {
   return Builder.create(input);
 };
 /**
  * Convenience method for creating a FreshRequestOptions with the given disabled columns and
  * default timeout and parameters. Default parameters are empty.
  *
  * @param disabledColumns set of columns which will not be freshened by this request.
  * @return a new FreshRequestOptions with the given disabled columns and default timeout and
  *     parameters.
  */
 public static FreshRequestOptions withDisabledColumns(
     final Set<KijiColumnName> disabledColumns) {
   return Builder.create().withDisabledColumns(disabledColumns).build();
 }
 /**
  * Convenience method for creating a FreshRequestOptions with the given parameters and default
  * timeout and disabled columns. Default disabled columns are empty.
  *
  * @param parameters configuration parameters which will be available to all Fresheners run in
  *     response to this request.
  * @return a new FreshRequestOptions with the given parameters and default timeout and disabled
  *     columns.
  */
 public static FreshRequestOptions withParameters(final Map<String, String> parameters) {
   return Builder.create().withParameters(parameters).build();
 }
 /**
  * Convenience method for creating a FreshRequestOptions with the given timeout and default
  * parameters and disabled columns. Default parameters and disabled columns are empty.
  *
  * @param timeout time in milliseconds to wait for this freshening request to finish.
  * @return a new FreshRequestOptions with the given timeout and default parameters and disabled
  *     columns.
  */
 public static FreshRequestOptions withTimeout(final long timeout) {
   return Builder.create().withTimeout(timeout).build();
 }