@TargetApi(Build.VERSION_CODES.LOLLIPOP)
 private static void setEdgeGlowColor(@NonNull EdgeEffectCompat edgeEffect, @ColorInt int color)
     throws Exception {
   Field field = EdgeEffectCompat.class.getDeclaredField("mEdgeEffect");
   field.setAccessible(true);
   EdgeEffect effect = (EdgeEffect) field.get(edgeEffect);
   if (effect != null) effect.setColor(color);
 }
Exemplo n.º 2
0
 @TargetApi(21)
 private static void trySetEdgeEffectColor(ListView view, String fieldName, int color) {
   try {
     Field effectField = AbsListView.class.getDeclaredField(fieldName);
     effectField.setAccessible(true);
     EdgeEffect effect = (EdgeEffect) effectField.get(view);
     final int alpha = Color.alpha(effect.getColor());
     effect.setColor(Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)));
   } catch (NoSuchFieldException e) {
     // ignored
   } catch (IllegalAccessException e) {
     // ignored
   }
 }
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public static void setEdgeGlowColor(@NonNull ScrollView scrollView, @ColorInt int color) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      try {
        Field edgeGlowTop = ScrollView.class.getDeclaredField("mEdgeGlowTop");
        edgeGlowTop.setAccessible(true);
        Field edgeGlowBottom = ScrollView.class.getDeclaredField("mEdgeGlowBottom");
        edgeGlowBottom.setAccessible(true);

        EdgeEffect ee = (EdgeEffect) edgeGlowTop.get(scrollView);
        ee.setColor(color);
        ee = (EdgeEffect) edgeGlowBottom.get(scrollView);
        ee.setColor(color);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
  }
Exemplo n.º 4
0
 public static boolean onAbsorb(Object edgeEffect, int velocity) {
   ((EdgeEffect) edgeEffect).onAbsorb(velocity);
   return true;
 }
Exemplo n.º 5
0
 public static boolean onRelease(Object edgeEffect) {
   EdgeEffect eff = (EdgeEffect) edgeEffect;
   eff.onRelease();
   return eff.isFinished();
 }
Exemplo n.º 6
0
 public static boolean onPull(Object edgeEffect, float deltaDistance) {
   ((EdgeEffect) edgeEffect).onPull(deltaDistance);
   return true;
 }
Exemplo n.º 7
0
 public static void finish(Object edgeEffect) {
   ((EdgeEffect) edgeEffect).finish();
 }
Exemplo n.º 8
0
 public static void setSize(Object edgeEffect, int width, int height) {
   ((EdgeEffect) edgeEffect).setSize(width, height);
 }