Example #1
0
 void insert(int d) {
   TN p = new TN(d);
   if (root == null) root = p;
   else {
     TN nd = root, q = null;
     while (nd != null) {
       q = nd;
       if (d < nd.val) nd = nd.left;
       else nd = nd.right;
     }
     if (q.val > d) q.left = p;
     if (q.val <= d) q.right = p;
   }
 }
Example #2
0
  /** Show the view for the specified duration. */
  public void show() {
    if (mNextView == null) {
      throw new RuntimeException("setView must have been called");
    }

    INotificationManager service = getService();
    String pkg = mContext.getPackageName();
    TN tn = mTN;
    tn.mNextView = mNextView;

    try {
      service.enqueueToast(pkg, tn, mDuration);
    } catch (RemoteException e) {
      // Empty
    }
  }
Example #3
0
  public boolean goThrough(TN head, int i) {
    if (i == ls.length) {
      if (head.get('#') != null) return true;
      else return false;
    }

    TN p1 = head.get(ls[i]);
    TN p2 = head.get('#');
    boolean b1 = false;
    boolean b2 = false;
    if (p1 != null) b1 = goThrough(p1, i + 1);
    if (b1) return true;
    if (p2 != null) b2 = goThrough(p2, i);
    if (b2) return true;
    return false;
  }
Example #4
0
 public TN buildTire(Set<String> dict) {
   TN head = new TN('#');
   TN fatherNode = head;
   for (String s : dict) {
     fatherNode = head;
     char[] ss = s.toCharArray();
     if (ss.length == 0) continue;
     for (int i = 0; i < ss.length; i++) {
       TN tnode = fatherNode.get(ss[i]);
       if (tnode == null) tnode = fatherNode.add(ss[i]);
       fatherNode = tnode;
     }
     fatherNode.ends(head);
   }
   return head;
 }
Example #5
0
  /**
   * Close the view if it's showing, or don't show it if it isn't showing yet. You do not normally
   * have to call this. Normally view will disappear on its own after the appropriate duration.
   */
  public void cancel() {
    mTN.hide();

    try {
      getService().cancelToast(mContext.getPackageName(), mTN);
    } catch (RemoteException e) {
      // Empty
    }
  }
Example #6
0
 /**
  * Construct an empty Toast object. You must call {@link #setView} before you can call {@link
  * #show}.
  *
  * @param context The context to use. Usually your {@link android.app.Application} or {@link
  *     android.app.Activity} object.
  */
 public Toast(Context context) {
   mContext = context;
   mTN = new TN();
   mTN.mY =
       context.getResources().getDimensionPixelSize(com.android.internal.R.dimen.toast_y_offset);
 }
Example #7
0
 /**
  * Set the location at which the notification should appear on the screen.
  *
  * @see android.view.Gravity
  * @see #getGravity
  */
 public void setGravity(int gravity, int xOffset, int yOffset) {
   mTN.mGravity = gravity;
   mTN.mX = xOffset;
   mTN.mY = yOffset;
 }
Example #8
0
 /**
  * Set the margins of the view.
  *
  * @param horizontalMargin The horizontal margin, in percentage of the container width, between
  *     the container's edges and the notification
  * @param verticalMargin The vertical margin, in percentage of the container height, between the
  *     container's edges and the notification
  */
 public void setMargin(float horizontalMargin, float verticalMargin) {
   mTN.mHorizontalMargin = horizontalMargin;
   mTN.mVerticalMargin = verticalMargin;
 }
Example #9
0
 /**
  * Close the view if it's showing, or don't show it if it isn't showing yet. You do not normally
  * have to call this. Normally view will disappear on its own after the appropriate duration.
  */
 public void cancel() {
   mTN.hide();
   // TODO this still needs to cancel the inflight notification if any
 }