public void clickMe(View view) {
   if (view.getClass().equals(Button.class)) {
     Log.d(LabDemoActivity.LOG_TAG, "button clicked");
   } else {
     Log.d(LabDemoActivity.LOG_TAG, "clicked on " + view.getClass().getSimpleName());
   }
 }
    private void bindView(int position, View view) {
      final Map<String, ?> dataSet = map.get(position);
      if (dataSet == null) {
        return;
      }

      final ViewBinder binder = super.getViewBinder();
      final int count = to.length;

      for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
          final Object data = dataSet.get(from[i]);
          String text = data == null ? "" : data.toString();
          if (text == null) {
            text = "";
          }

          boolean bound = false;
          if (binder != null) {
            bound = binder.setViewValue(v, data, text);
          }

          if (!bound) {
            if (v instanceof Checkable) {
              if (data instanceof Boolean) {
                ((Checkable) v).setChecked((Boolean) data);
              } else if (v instanceof TextView) {
                //  Note: keep the instanceof TextView check at the bottom of these
                //  ifs since a lot of views are TextViews (e.g. CheckBoxes).
                setViewText((TextView) v, text);
              } else {
                throw new IllegalStateException(
                    v.getClass().getName()
                        + " should be bound to a Boolean, not a "
                        + (data == null ? "<unknown type>" : data.getClass()));
              }
            } else if (v instanceof TextView) {
              // Note: keep the instanceof TextView check at the bottom of these
              // ifs since a lot of views are TextViews (e.g. CheckBoxes).
              setViewText((TextView) v, text);
            } else if (v instanceof ImageView) {
              if (data instanceof Integer) {
                setViewImage((ImageView) v, (Integer) data);
              } else if (data instanceof Bitmap) {
                setViewImage((ImageView) v, (Bitmap) data);
              } else {
                setViewImage((ImageView) v, text);
              }
            } else {
              throw new IllegalStateException(
                  v.getClass().getName()
                      + " is not a "
                      + " view that can be bounds by this SimpleAdapter");
            }
          }
        }
      }
    }
 public static boolean view_setGravity(View v, int flags) {
   boolean ret = true;
   String methodName = "setGravity";
   Method setMethod;
   try { //
     setMethod = v.getClass().getMethod(methodName, int.class);
     setMethod.invoke(v, flags);
   } catch (Exception e) {
     Log.i(v.getClass().getSimpleName(), "fail to set gravity");
   }
   return ret;
 }
Exemple #4
0
 /**
  * For restoring states saved by {@link #save(View, Parcelable)}.Typical usage looks like:
  *
  * <pre>{@code
  * &#64;Override
  * protected void onRestoreInstanceState(Parcelable state) {
  *  super.onRestoreInstanceState(Akatsuki.restore(this, state));
  * }
  * }</pre>
  *
  * @param view the view that requires restoring
  * @param parcelable restored state from the parameter of {@link
  *     View#onRestoreInstanceState(Parcelable)}
  * @return a parcelable to be passed to {@code super.onRestoreInstanceState()}
  */
 public static Parcelable restore(View view, Parcelable parcelable) {
   if (parcelable instanceof Bundle) {
     final Bundle bundle = (Bundle) parcelable;
     restore((Object) view, bundle);
     return bundle.getParcelable(view.getClass().getName());
   } else {
     throw new RuntimeException(
         "View state of view "
             + view.getClass()
             + " is not saved with Akatsuki View.onSaveInstanceState()");
   }
 }
  private static Rule<View> getEmailRule(Field field, View view, Email email) {
    if (!TextView.class.isAssignableFrom(view.getClass())) {
      Log.w(TAG, String.format(WARN_TEXT, field.getName(), Regex.class.getSimpleName()));
      return null;
    }
    //		int messageResId = email.messageResId();
    //		String message = messageResId != 0 ? view.getContext().getString(messageResId) :
    // email.message();
    //		return Rules.or(message, Rules.eq(null, Rules.EMPTY_STRING), Rules.regex(message,
    // Rules.REGEX_EMAIL, true));

    int messageResId = email.messageResId();
    String message =
        messageResId != 0 ? view.getContext().getString(messageResId) : email.message();

    if (email.empty()) {
      return Rules.or(
          message,
          Rules.eq(null, Rules.EMPTY_STRING),
          Rules.regex(message, Rules.REGEX_EMAIL, true));
    }
    List<Rule<?>> rules = new ArrayList<Rule<?>>();
    rules.add(Rules.required(message, true));
    rules.add(Rules.regex(message, Rules.REGEX_EMAIL, true));
    Rule<?>[] ruleArray = new Rule<?>[rules.size()];
    rules.toArray(ruleArray);
    return Rules.and(message, ruleArray);
  }
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    Boolean isDrawerOpen = mDrawerLayout.isDrawerOpen(Gravity.RIGHT);
    Boolean isMenuListFocused = false;
    if (mList != null) {
      isMenuListFocused = mList.hasFocus();
    }
    View view = this.getCurrentFocus();

    if (isDrawerOpen) {
      if (!view.getClass()
          .getName()
          .equalsIgnoreCase("com.android.internal.view.menu.ActionMenuItemView")) {
        mDrawerLayout.closeDrawers();
        mDrawerLayout.getChildAt(0).requestFocus();
      }
    } else {
      if (KeyEvent.KEYCODE_DPAD_UP == keyCode) {
        // action bar
        mDrawerLayout.getChildAt(1).requestFocus();
      } else if (KeyEvent.KEYCODE_DPAD_DOWN == keyCode) {
        // grid view
        mDrawerLayout.getChildAt(0).requestFocus();
      } else if (KeyEvent.KEYCODE_DPAD_LEFT == keyCode) {
      } else if (KeyEvent.KEYCODE_MENU == keyCode) {
        if (!mDrawerLayout.isDrawerOpen(Gravity.RIGHT)) {
          mDrawerLayout.openDrawer(Gravity.RIGHT);
        } else {
          mDrawerLayout.closeDrawer(Gravity.RIGHT);
        }
      }
    }

    return super.onKeyDown(keyCode, event);
  }
  /**
   * Binds all of the field names passed into the "to" parameter of the constructor with their
   * corresponding cursor columns as specified in the "from" parameter.
   *
   * <p>Binding occurs in two phases. First, if a {@link
   * android.widget.SimpleCursorAdapter.ViewBinder} is available, {@link
   * ViewBinder#setViewValue(android.view.View, android.database.Cursor, int)} is invoked. If the
   * returned value is true, binding has occured. If the returned value is false and the view to
   * bind is a TextView, {@link #setViewText(TextView, String)} is invoked. If the returned value is
   * false and the view to bind is an ImageView, {@link #setViewImage(ImageView, String)} is
   * invoked. If no appropriate binding can be found, an {@link IllegalStateException} is thrown.
   *
   * @throws IllegalStateException if binding cannot occur
   * @see android.widget.CursorAdapter#bindView(android.view.View, android.content.Context,
   *     android.database.Cursor)
   * @see #getViewBinder()
   * @see #setViewBinder(android.widget.SimpleCursorAdapter.ViewBinder)
   * @see #setViewImage(ImageView, String)
   * @see #setViewText(TextView, String)
   */
  @Override
  public void bindView(View view, Context context, Cursor cursor) {
    final ViewBinder binder = mViewBinder;
    final int count = mTo.length;
    final int[] from = mFrom;
    final int[] to = mTo;

    for (int i = 0; i < count; i++) {
      final View v = view.findViewById(to[i]);
      if (v != null) {
        boolean bound = false;
        if (binder != null) {
          bound = binder.setViewValue(v, cursor, from[i]);
        }

        if (!bound) {
          String text = cursor.getString(from[i]);
          if (text == null) {
            text = "";
          }

          if (v instanceof TextView) {
            setViewText((TextView) v, text);
          } else if (v instanceof ImageView) {
            setViewImage((ImageView) v, text);
          } else {
            throw new IllegalStateException(
                v.getClass().getName()
                    + " is not a "
                    + " view that can be bounds by this SimpleCursorAdapter");
          }
        }
      }
    }
  }
  /*
   * Enabled aggressive block sorting
   * Enabled unnecessary exception pruning
   * Enabled aggressive exception aggregation
   */
  public void onClick(View view) {
    view = new PopupMenu(this.getContext(), (View) this);
    view.getMenuInflater().inflate(2131689474, view.getMenu());
    for (Object object : view.getClass().getDeclaredFields()) {
      try {
        if (!"mPopup".equals(object.getName())) continue;
        object.setAccessible(true);
        object = object.get((Object) view);
        Class.forName(object.getClass().getName())
            .getMethod("setForceShowIcon", Boolean.TYPE)
            .invoke(object, true);
        break;
      } catch (Exception var5_6) {
        // empty catch block
      }
    }
    view.setOnMenuItemClickListener(
        new PopupMenu.OnMenuItemClickListener() {

          /*
           * Enabled aggressive block sorting
           */
          public boolean onMenuItemClick(MenuItem menuItem) {
            if (menuItem.getItemId() == 2131493173) {
              OverflowImageButton.this.share();
              return true;
            }
            if (menuItem.getItemId() != 2131493174) return true;
            OverflowImageButton.this.openImageInWeb();
            return true;
          }
        });
    view.show();
  }
 @Override
 public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
   if (DEBUG) Timber.d("layoutDependsOn " + dependency.getClass());
   return super.layoutDependsOn(parent, child, dependency)
       // || dependency instanceof NestedScrollView
       || dependency instanceof Snackbar.SnackbarLayout;
 }
Exemple #10
0
  private void dumpSubView(View view, Element pElem) {
    if (view == null) {
      final View[] views = this.viewFetcher.getWindowDecorViews();
      view = viewFetcher.getRecentDecorView(views);
    }

    if (!view.isShown()) return;

    Element elem = pElem.addElement(view.getClass().getSimpleName());
    int[] local = new int[2];
    view.getLocationOnScreen(local);
    elem.addAttribute("x", local[0] + "");
    elem.addAttribute("y", local[1] + "");
    elem.addAttribute("w", view.getWidth() + "");
    elem.addAttribute("h", view.getHeight() + "");

    int id = view.getId();
    if (id != -1) elem.addAttribute("id", id + "");

    Matcher match = Pattern.compile("(?<=:id/).*?(?=\\})").matcher(view.toString());
    if (match.find()) elem.addAttribute("resId", match.group());

    if (view instanceof TextView) elem.addAttribute("text", ((TextView) view).getText().toString());

    if (view instanceof ViewGroup) {
      ViewGroup group = (ViewGroup) view;
      for (int i = 0; i < group.getChildCount(); i++) {
        View v = group.getChildAt(i);
        dumpSubView(v, elem);
      }
    }
  }
Exemple #11
0
  public boolean checkWidgetEquivalence(View testee, String theType, String theName) {
    Log.i("nofatclips", "Retrieved from return list id=" + testee.getId());
    String testeeSimpleType = getSimpleType(testee);
    String testeeType = testee.getClass().getName();
    Log.i(
        "nofatclips",
        "Testing for type (" + testeeType + ") against the original (" + theType + ")");
    String testeeText =
        (testee instanceof TextView) ? (((TextView) testee).getText().toString()) : "";

    String testeeName = testeeText;
    if (testee instanceof EditText) {
      CharSequence hint = ((EditText) testee).getHint();
      testeeName = (hint == null) ? "" : hint.toString();
    }

    //		String testeeName = (testee instanceof
    // EditText)?(((EditText)testee).getHint().toString()):testeeText;
    Log.i(
        "nofatclips",
        "Testing for name (" + testeeName + ") against the original (" + theName + ")");
    if (((theType.equals(testeeType)) || (theType.equals(testeeSimpleType)))
        && (theName.equals(testeeName))) {
      return true;
    }
    return false;
  }
 public BarTransitions(View view, int gradientResourceId) {
   mTag = "BarTransitions." + view.getClass().getSimpleName();
   mView = view;
   mBarBackground = new BarBackgroundDrawable(mView.getContext(), gradientResourceId);
   if (HIGH_END) {
     mView.setBackground(mBarBackground);
   }
 }
Exemple #13
0
 public static void registerWidgetByName(String name, View widget) {
   utilSys.objectSacPut("javaj." + name, widget);
   getListOfWidgetNames().add(name);
   if (log_widgetRegister.isDebugging(2)) {
     log_widgetRegister.dbg(
         2, "register", "add", new String[] {name, widget.getClass().toString()});
   }
 }
Exemple #14
0
  protected void dumpFirstPart(PrintStream out, int indent) {
    dumpIndent(out, indent);

    out.print("<" + realView.getClass().getSimpleName());
    if (id > 0) {
      out.print(" id=\"" + shadowOf(context).getResourceLoader().getNameForId(id) + "\"");
    }
  }
Exemple #15
0
 private View autowired(View view, AttributeSet attrs) {
   if (!(view.getClass().isAnnotationPresent(Autowired.class))) return view;
   String elStr = getScopeKey(attrs, view);
   GIntent gintent = new GIntent(view);
   Params params = new Params(el.analyzeTag(elStr == null ? "${bean}" : elStr));
   gintent.setParams(params);
   return new ViewManager(gintent).flate();
 }
  public void onDestroy() {

    // it is too late to call graphics.destroy - it needs live gl GLThread and gl context, otherwise
    // it will cause of deadlock
    // if (graphics != null) {
    // graphics.clearManagedCaches();
    // graphics.destroy();
    // }

    // so we do what we can..
    if (graphics != null) {
      // not necessary - already called in AndroidLiveWallpaperService.onDeepPauseApplication
      // app.graphics.clearManagedCaches();

      // kill the GLThread managed by GLSurfaceView (only for GLSurfaceView because
      // GLSurffaceViewCupcake stops thread in
      // onPause events - which is not as easy and safe for GLSurfaceView)
      if (graphics.view != null
          && (graphics.view instanceof GLSurfaceView
              || graphics.view instanceof GLSurfaceViewAPI18)) {
        View glSurfaceView = graphics.view;
        try {
          Method method = null;
          for (Method m : glSurfaceView.getClass().getMethods()) {
            if (m.getName()
                .equals("onDestroy")) // implemented in AndroidGraphicsLiveWallpaper, redirects to
            // onDetachedFromWindow - which stops GLThread by calling mGLThread.requestExitAndWait()
            {
              method = m;
              break;
            }
          }

          if (method != null) {
            method.invoke(glSurfaceView);
            if (AndroidLiveWallpaperService.DEBUG)
              Log.d(
                  AndroidLiveWallpaperService.TAG,
                  " > AndroidLiveWallpaper - onDestroy() stopped GLThread managed by GLSurfaceView");
          } else throw new Exception("method not found!");
        } catch (Throwable t) {
          // error while scheduling exit of GLThread, GLThread will remain live and wallpaper
          // service wouldn't be able to
          // shutdown completely
          Log.e(
              AndroidLiveWallpaperService.TAG,
              "failed to destroy GLSurfaceView's thread! GLSurfaceView.onDetachedFromWindow impl changed since API lvl 16!");
          t.printStackTrace();
        }
      }
    }

    if (audio != null) {
      // dispose audio and free native resources, mandatory since graphics.pause is never called in
      // live wallpaper
      audio.dispose();
    }
  }
Exemple #17
0
  public static void setActionBarTranslation(Activity activity, float y) {
    ViewGroup vg = (ViewGroup) activity.findViewById(android.R.id.content).getParent();
    int count = vg.getChildCount();

    if (DEBUG) {
      Log.d(TAG, "==========================");
    }

    // Get the class of action bar
    Class<?> actionBarContainer = null;
    Field isSplit = null;

    try {
      actionBarContainer = Class.forName("com.android.internal.widget.ActionBarContainer");
      isSplit = actionBarContainer.getDeclaredField("mIsSplit");
      isSplit.setAccessible(true);
    } catch (Exception e) {
      if (DEBUG) {
        Log.e(TAG, Log.getStackTraceString(e));
      }
    }

    for (int i = 0; i < count; i++) {
      View v = vg.getChildAt(i);

      if (v.getId() != android.R.id.content) {
        if (DEBUG) {
          Log.d(TAG, "Found View: " + v.getClass().getName());
        }

        try {
          if (actionBarContainer.isInstance(v)) {
            if (DEBUG) {
              Log.d(TAG, "Found ActionBarContainer");
            }

            if (isSplit.getBoolean(v)) {
              if (DEBUG) {
                Log.d(TAG, "Found Split Action Bar");
              }

              continue;
            }
          }
        } catch (Exception e) {
          if (DEBUG) {
            Log.e(TAG, Log.getStackTraceString(e));
          }
        }

        v.setTranslationY(y);
      }
    }

    if (DEBUG) {
      Log.d(TAG, "==========================");
    }
  }
Exemple #18
0
 /*
  * Non-Android accessor.
  */
 public void finishedAnimation() {
   try {
     Method onAnimationEnd = realView.getClass().getDeclaredMethod("onAnimationEnd", new Class[0]);
     onAnimationEnd.setAccessible(true);
     onAnimationEnd.invoke(realView);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
 /**
  * This method will search the requested view / control by its name in the currentViews <br>
  *
  * @param viewName the name of the view
  * @return response with the status of the command
  * @throws Exception
  */
 private View findViewByName(String viewName) throws Exception {
   ArrayList<View> currentViews = this.solo.getCurrentViews();
   for (View view : currentViews) {
     if (view.getClass().getName().contains(viewName)) {
       return view;
     }
   }
   throw new Exception("View : " + viewName + " was not found in current views ");
 }
 public static View debugViewIds(View view, String logtag) {
   Log.v(logtag, "traversing: " + view.getClass().getSimpleName() + ", id: " + view.getId());
   if (view.getParent() != null && (view.getParent() instanceof ViewGroup)) {
     return debugViewIds((View) view.getParent(), logtag);
   } else {
     debugChildViewIds(view, logtag, 0);
     return view;
   }
 }
  public static void findWithClass(ViewGroup viewGroup, String clazz, FindCallBack callBack) {
    if (viewGroup == null || clazz == null || callBack == null) {
      return;
    }

    int count = viewGroup.getChildCount();
    for (int i = 0; i < count; i++) {
      final View child = viewGroup.getChildAt(i);
      Log.d("test_ad", "====1====" + child.getClass().getCanonicalName() + ":" + clazz);
      if (child.getClass().getCanonicalName().equals(clazz)) {
        // 结果
        callBack.onResult(child);
      }
      if (child instanceof ViewGroup) {
        findWithClass((ViewGroup) child, clazz, callBack);
      }
    }
  }
 private <T extends View> T findView(Class<? extends View> clazz, int id)
     throws ViewNotFoundException {
   View view = getActivity().findViewById(id);
   if (view != null && view.getClass().isAssignableFrom(clazz)) {
     return (T) view;
   }
   log.error("Cannot find view of {} with id {}", clazz.toString(), id);
   throw new ViewNotFoundException();
 }
Exemple #23
0
 public ArrayList<View> getWidgetsByType(String type) {
   ArrayList<View> theList = new ArrayList<View>();
   for (View theView : getAllWidgets()) {
     if (theView.getClass().getName().equals(type)) {
       Log.i("nofatclips", "Added to return list " + type + " with id=" + theView.getId());
       theList.add(theView);
     }
   }
   return theList;
 }
Exemple #24
0
 @Override
 public String toString() {
   return "Cell[view="
       + (cell == null ? "null" : cell.getClass())
       + ", x="
       + cellX
       + ", y="
       + cellY
       + "]";
 }
 private void addProperties(JsonWriter paramJsonWriter, View paramView) throws IOException {
   Class localClass = paramView.getClass();
   Iterator localIterator = this.mProperties.iterator();
   while (localIterator.hasNext()) {
     Object localObject1 = (PropertyDescription) localIterator.next();
     if ((((PropertyDescription) localObject1).targetClass.isAssignableFrom(localClass))
         && (((PropertyDescription) localObject1).accessor != null)) {
       Object localObject2 = ((PropertyDescription) localObject1).accessor.applyMethod(paramView);
       if (localObject2 != null) {
         if ((localObject2 instanceof Number)) {
           paramJsonWriter
               .name(((PropertyDescription) localObject1).name)
               .value((Number) localObject2);
         } else if ((localObject2 instanceof Boolean)) {
           paramJsonWriter
               .name(((PropertyDescription) localObject1).name)
               .value(((Boolean) localObject2).booleanValue());
         } else if ((localObject2 instanceof ColorStateList)) {
           paramJsonWriter
               .name(((PropertyDescription) localObject1).name)
               .value(Integer.valueOf(((ColorStateList) localObject2).getDefaultColor()));
         } else if ((localObject2 instanceof Drawable)) {
           localObject2 = (Drawable) localObject2;
           Rect localRect = ((Drawable) localObject2).getBounds();
           paramJsonWriter.name(((PropertyDescription) localObject1).name);
           paramJsonWriter.beginObject();
           paramJsonWriter.name("classes");
           paramJsonWriter.beginArray();
           for (localObject1 = localObject2.getClass();
               localObject1 != Object.class;
               localObject1 = ((Class) localObject1).getSuperclass()) {
             paramJsonWriter.value(((Class) localObject1).getCanonicalName());
           }
           paramJsonWriter.endArray();
           paramJsonWriter.name("dimensions");
           paramJsonWriter.beginObject();
           paramJsonWriter.name("left").value(localRect.left);
           paramJsonWriter.name("right").value(localRect.right);
           paramJsonWriter.name("top").value(localRect.top);
           paramJsonWriter.name("bottom").value(localRect.bottom);
           paramJsonWriter.endObject();
           if ((localObject2 instanceof ColorDrawable)) {
             localObject1 = (ColorDrawable) localObject2;
             paramJsonWriter.name("color").value(((ColorDrawable) localObject1).getColor());
           }
           paramJsonWriter.endObject();
         } else {
           paramJsonWriter
               .name(((PropertyDescription) localObject1).name)
               .value(localObject2.toString());
         }
       }
     }
   }
 }
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   // TODO Auto-generated method stub
   super.onListItemClick(l, v, position, id);
   Toast.makeText(getApplicationContext(), "class" + v.getClass().toString(), Toast.LENGTH_SHORT)
       .show();
   TextView tv = (TextView) ((LinearLayout) v).findViewById(R.id.customListId);
   mSelectedAgentId = tv.getText().toString();
   mQuickAction.show(v);
   mQuickAction.setAnimStyle(QuickAction.ANIM_GROW_FROM_CENTER);
 }
  private static Rule<Checkable> getCheckedRule(Field field, View view, Checked checked) {
    if (!Checkable.class.isAssignableFrom(view.getClass())) {
      Log.w(TAG, String.format(WARN_CHECKABLE, field.getName(), Checked.class.getSimpleName()));
      return null;
    }

    int messageResId = checked.messageResId();
    String message =
        messageResId != 0 ? view.getContext().getString(messageResId) : checked.message();

    return Rules.checked(message, checked.checked());
  }
  private static Rule<TextView> getRequiredRule(Field field, View view, Required required) {
    if (!TextView.class.isAssignableFrom(view.getClass())) {
      Log.w(TAG, String.format(WARN_TEXT, field.getName(), Required.class.getSimpleName()));
      return null;
    }

    int messageResId = required.messageResId();
    String message =
        messageResId != 0 ? view.getContext().getString(messageResId) : required.message();

    return Rules.required(message, required.trim());
  }
  public void table_click(View v) throws InvalidCredentialsException {
    if (v.getClass() != Button.class)
      throw new InvalidCredentialsException("No button click. The view passed is invalid");
    Button btn = (Button) v;

    int tableNr = Integer.parseInt(btn.getText().toString().replace("Bord ", ""));
    WaiterOrdersActivity.tableOrder = tableOrders.getDishesFromTable(tableNr - 1);
    WaiterOrdersActivity.order = tableOrders.getTableOrder(tableNr - 1);
    Intent ordersActivity = new Intent(getApplicationContext(), WaiterOrdersActivity.class);
    ordersActivity.putExtra("bord_str", btn.getText());
    startActivityForResult(ordersActivity, RESPONSE);
  }
 @Override
 public Result execute(String... args) {
   View view = TestHelpers.getTextViewByDescription(args[1]);
   if (view == null) {
     return new Result(false, "No view found with content description: '" + args[1] + "'");
   } else if (!(view instanceof EditText)) {
     return new Result(false, "Expected EditText found: '" + view.getClass() + "'");
   } else {
     InstrumentationBackend.solo.enterText((EditText) view, args[0]);
     return Result.successResult();
   }
 }