Example #1
0
  public RuleAdapter(DatabaseHelper dh, Activity context) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

    this.context = context;
    this.dh = dh;
    this.filter = prefs.getBoolean("filter", false);
    this.debuggable = Util.isDebuggable(context);

    if (prefs.getBoolean("dark_theme", false))
      colorChanged =
          Color.argb(
              128, Color.red(Color.DKGRAY), Color.green(Color.DKGRAY), Color.blue(Color.DKGRAY));
    else
      colorChanged =
          Color.argb(
              128, Color.red(Color.LTGRAY), Color.green(Color.LTGRAY), Color.blue(Color.LTGRAY));

    TypedArray ta =
        context.getTheme().obtainStyledAttributes(new int[] {android.R.attr.textColorSecondary});
    try {
      colorText = ta.getColor(0, 0);
    } finally {
      ta.recycle();
    }

    TypedValue tv = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorAccent, tv, true);
    colorAccent = tv.data;
    context.getTheme().resolveAttribute(R.attr.colorOn, tv, true);
    colorOn = tv.data;
    context.getTheme().resolveAttribute(R.attr.colorOff, tv, true);
    colorOff = tv.data;
  }
Example #2
0
  private void init(AttributeSet attrs, int defStyle) {
    if (isInEditMode()) return;
    TypedArray a =
        getContext()
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.SVGImageView, defStyle, 0);
    try {
      int resourceId = a.getResourceId(R.styleable.SVGImageView_svg, -1);
      if (resourceId != -1) {
        setImageResource(resourceId);
        return;
      }

      String url = a.getString(R.styleable.SVGImageView_svg);
      if (url != null) {
        Uri uri = Uri.parse(url);
        if (internalSetImageURI(uri, false)) return;

        // Last chance, try loading it as an asset filename
        setImageAsset(url);
      }

    } finally {
      a.recycle();
    }
  }
 public static Drawable getDrawableFromAttribute(Context ctx, @AttrRes int attr) {
   int[] attrs = new int[] {attr};
   TypedArray ta = ctx.obtainStyledAttributes(attrs);
   Drawable d = ta.getDrawable(0);
   ta.recycle();
   return d;
 }
  private static int preloadDrawables(VMRuntime runtime, TypedArray ar) {
    int N = ar.length();
    for (int i = 0; i < N; i++) {
      if (Debug.getGlobalAllocSize() > PRELOAD_GC_THRESHOLD) {

        Log.i(TAG, " GC at " + Debug.getGlobalAllocSize());

        System.gc();
        runtime.runFinalizationSync();
        Debug.resetGlobalAllocSize();
      }
      int id = ar.getResourceId(i, 0);
      if (false) {
        Log.v(TAG, "Preloading resource #" + Integer.toHexString(id));
      }
      if (id != 0) {
        Drawable dr = mResources.getDrawable(id);
        if ((dr.getChangingConfigurations() & ~ActivityInfo.CONFIG_FONT_SCALE) != 0) {
          Log.w(
              TAG,
              "Preloaded drawable resource #0x"
                  + Integer.toHexString(id)
                  + " ("
                  + ar.getString(i)
                  + ") that varies with configuration!!");
        }
      }
    }
    return N;
  }
  public VerticalCardView(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a =
        context
            .getTheme()
            .obtainStyledAttributes(attrs, R.styleable.com_gabm_fancyplaces_VerticalCardView, 0, 0);

    try {
      title = a.getString(R.styleable.com_gabm_fancyplaces_VerticalCardView_card_title);
    } finally {
      a.recycle();
    }

    // own settings
    this.setOrientation(VERTICAL);
    this.setPadding(30, 30, 30, 30);

    // text view as title
    TextView textView = new TextView(context);
    textView.setText(title);
    textView.setTextAppearance(context, R.style.TextAppearance_AppCompat_Large);
    textView.setTypeface(null, Typeface.BOLD);
    textView.setPadding(0, 20, 0, 10);
    this.addView(textView);
  }
  @Override
  protected void handleStyledAttributes(TypedArray a) {
    super.handleStyledAttributes(a);

    mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true);

    if (mListViewExtrasEnabled) {
      final FrameLayout.LayoutParams lp =
          new FrameLayout.LayoutParams(
              FrameLayout.LayoutParams.MATCH_PARENT,
              FrameLayout.LayoutParams.WRAP_CONTENT,
              Gravity.CENTER_HORIZONTAL);

      // Create Loading Views ready for use later
      FrameLayout frame = new FrameLayout(getContext());
      mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a);
      mHeaderLoadingView.setVisibility(View.GONE);
      frame.addView(mHeaderLoadingView, lp);
      mRefreshableView.addHeaderView(frame, null, false);

      mLvFooterLoadingFrame = new FrameLayout(getContext());
      mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a);
      mFooterLoadingView.setVisibility(View.GONE);
      mLvFooterLoadingFrame.addView(mFooterLoadingView, lp);

      /**
       * If the value for Scrolling While Refreshing hasn't been explicitly set via XML, enable
       * Scrolling While Refreshing.
       */
      if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) {
        setScrollingWhileRefreshingEnabled(true);
      }
    }
  }
  public ForegroundLinearLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray a =
        context.obtainStyledAttributes(attrs, R.styleable.ForegroundLayout, defStyle, 0);

    final Drawable d = a.getDrawable(R.styleable.ForegroundLayout_foreground);
    foregroundPadding =
        a.getBoolean(R.styleable.ForegroundLayout_foregroundLayoutInsidePadding, false);

    backgroundAsForeground =
        a.getBoolean(R.styleable.ForegroundLayout_backgroundAsForeground, false);

    // Apply foreground padding for ninepatches automatically
    if (!foregroundPadding && getBackground() instanceof NinePatchDrawable) {
      final NinePatchDrawable npd = (NinePatchDrawable) getBackground();
      if (npd != null && npd.getPadding(rectPadding)) {
        foregroundPadding = true;
      }
    }

    final Drawable b = getBackground();
    if (backgroundAsForeground && b != null) {
      setForeground(b);
    } else if (d != null) {
      setForeground(d);
    }

    a.recycle();
  }
  /** Constructor used when this widget is created from a layout file. */
  public SlidingTab(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Allocate a temporary once that can be used everywhere.
    mTmpRect = new Rect();

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlidingTab);
    mOrientation = a.getInt(R.styleable.SlidingTab_orientation, HORIZONTAL);
    a.recycle();

    Resources r = getResources();
    mDensity = r.getDisplayMetrics().density;
    if (DBG) log("- Density: " + mDensity);

    mLeftSlider =
        new Slider(
            this,
            R.drawable.jog_tab_left_generic,
            R.drawable.jog_tab_bar_left_generic,
            R.drawable.jog_tab_target_gray);
    mRightSlider =
        new Slider(
            this,
            R.drawable.jog_tab_right_generic,
            R.drawable.jog_tab_bar_right_generic,
            R.drawable.jog_tab_target_gray);

    // setBackgroundColor(0x80808080);
  }
  public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    strokeWidth = 5f;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.com_displayer_CircleImageView);
    strokeWidth = a.getFloat(R.styleable.com_displayer_CircleImageView_stroke_width, 5f);
    String tempColor = a.getString(R.styleable.com_displayer_CircleImageView_stroke_color);
    Log.d("CircularImageView", "ColorTag: " + tempColor);

    if (tempColor != null && !tempColor.equalsIgnoreCase("#0")) {
      String black = tempColor.replaceAll("0", "");
      String white = tempColor.replaceAll("f", "");
      white = white.replaceAll("F", "");

      if (black.equalsIgnoreCase("#")) {
        tempColor = "#000000";
      }

      if (white.equalsIgnoreCase("#")) {
        tempColor = "#ffffff";
      }

      strokeColor = Color.parseColor(tempColor);
    } else {
      strokeColor = Color.TRANSPARENT;
    }
    a.recycle();
  }
Example #10
0
 private void initIndexBarColorPressed(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_indexBarColorPressed)) {
     mIndexBarColorPressed =
         attributes.getColor(R.styleable.IndexBar_indexBarColorPressed, mIndexBarColorPressed);
     Log.v(LOG_TAG, "Initialized Index Bar Color Pressed: " + getIndexBarColorPressed());
   }
 }
Example #11
0
 private void initIndexBarColor(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_indexBarColorNormal)) {
     mIndexBarColorNormal =
         attributes.getColor(R.styleable.IndexBar_indexBarColorNormal, mIndexBarColorNormal);
     Log.v(LOG_TAG, "Initialized Index Bar Color: " + getIndexBarColor());
   }
 }
Example #12
0
 private void initAlphabetTextColor(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_alphabetTextColor)) {
     mAlphabetTextColor =
         attributes.getColor(R.styleable.IndexBar_alphabetTextColor, mAlphabetTextColor);
     Log.v(LOG_TAG, "Initialized Alphabet TextColor: " + getAlphabetTextColor());
   }
 }
Example #13
0
 private void initAlphabetTextSize(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_alphabetTextSize)) {
     mAlphabetTextSize =
         attributes.getDimension(R.styleable.IndexBar_alphabetTextSize, mAlphabetTextSize);
     Log.v(LOG_TAG, "Initialized Alphabet TextSize: " + getAlphabetTextSize());
   }
 }
Example #14
0
 private void initAlphabetPadding(TypedArray attributes) {
   if (attributes.hasValue(R.styleable.IndexBar_alphabetPadding)) {
     mAlphabetPadding =
         attributes.getDimension(R.styleable.IndexBar_alphabetPadding, mAlphabetPadding);
     Log.v(LOG_TAG, "Initialized Alphabet Offset: " + getAlphabetPadding());
   }
 }
Example #15
0
 private void changeColorTheme(TypedArray colorSet) {
   changeInterfaceHeadColorTheme(
       colorSet.getColor(0, 0),
       colorSet.getColor(1, 0),
       colorSet.getColor(2, 0),
       colorSet.getColor(3, 0));
 }
Example #16
0
 private void setCustomAttributes(AttributeSet attrs) {
   TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.roundedimageview);
   mBorderThickness = a.getDimensionPixelSize(R.styleable.roundedimageview_border_thickness, 0);
   mBorderOutsideColor =
       a.getColor(R.styleable.roundedimageview_border_outside_color, defaultColor);
   mBorderInsideColor = a.getColor(R.styleable.roundedimageview_border_inside_color, defaultColor);
 }
Example #17
0
 public static int getActionBarHeight(Context context) {
   int[] attrs = new int[] {android.R.attr.actionBarSize};
   TypedArray styledAttributes = context.getTheme().obtainStyledAttributes(attrs);
   int actionBarHeight = (int) styledAttributes.getDimension(0, 0);
   styledAttributes.recycle();
   return actionBarHeight;
 }
 private void init(Context context, AttributeSet attrs, int defStyle) {
   TypedArray a =
       context.obtainStyledAttributes(attrs, R.styleable.EffectThumbLayout, defStyle, 0);
   mThumbAnimationDuration =
       a.getInteger(R.styleable.EffectThumbLayout_selectionAnimationDuration, 200);
   a.recycle();
 }
Example #19
0
 public ImageAdapter(Context c) {
   context = c;
   // ---setting the style---
   TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
   itemBackground = a.getResourceId(R.styleable.Gallery1_android_galleryItemBackground, 0);
   a.recycle();
 }
  public void init(
      @NonNull View view, @Nullable AttributeSet attrs, @NonNull TextPaint baseTextPaint) {
    final Context context = view.getContext();
    final int defColor = baseTextPaint.getColor();
    final int defPadding =
        context.getResources().getDimensionPixelSize(R.dimen.drag_direction_text_default_padding);
    final float minTextSize =
        context.getResources().getDimensionPixelSize(R.dimen.drag_direction_text_min_size);

    if (attrs == null) {
      for (DragDirection direction : DragDirection.values()) {
        final Text text = new Text(direction, view, minTextSize);
        text.init(baseTextPaint, null, DEF_SCALE, defColor, DEF_ALPHA, defPadding);
        texts.put(direction, text);
      }
      return;
    }
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.DirectionText);
    final float scale = array.getFloat(R.styleable.DirectionText_directionTextScale, DEF_SCALE);
    final float alpha = array.getFloat(R.styleable.DirectionText_directionTextAlpha, DEF_ALPHA);
    final int color = array.getColor(R.styleable.DirectionText_directionTextColor, defColor);
    final int padding =
        array.getDimensionPixelSize(R.styleable.DirectionText_directionTextPadding, defPadding);
    for (DragDirection direction : DragDirection.values()) {
      final Text text = new Text(direction, view, minTextSize);
      text.init(baseTextPaint, array, scale, color, alpha, padding);
      texts.put(direction, text);
    }
    array.recycle();
  }
Example #21
0
  @Override
  protected final ListView createRefreshableView(Context context, AttributeSet attrs) {
    ListView lv = new InternalListView(context, attrs);

    // Get Styles from attrs
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PullToRefresh);

    // Create Loading Views ready for use later
    FrameLayout frame = new FrameLayout(context);
    mHeaderLoadingView = new LoadingLayout(context, Mode.PULL_DOWN_TO_REFRESH, a);
    frame.addView(
        mHeaderLoadingView,
        FrameLayout.LayoutParams.MATCH_PARENT,
        FrameLayout.LayoutParams.WRAP_CONTENT);
    mHeaderLoadingView.setVisibility(View.GONE);
    lv.addHeaderView(frame, null, false);

    mLvFooterLoadingFrame = new FrameLayout(context);
    mFooterLoadingView = new LoadingLayout(context, Mode.PULL_UP_TO_REFRESH, a);
    mLvFooterLoadingFrame.addView(
        mFooterLoadingView,
        FrameLayout.LayoutParams.MATCH_PARENT,
        FrameLayout.LayoutParams.WRAP_CONTENT);
    mFooterLoadingView.setVisibility(View.GONE);

    a.recycle();

    // Set it to this so it can be used in ListActivity/ListFragment
    lv.setId(android.R.id.list);
    return lv;
  }
 public DividerItemDecoration(Context context, int orientation, boolean hasFooter) {
   this.hasFooter = hasFooter;
   final TypedArray a = context.obtainStyledAttributes(ATTRS);
   mDivider = a.getDrawable(0);
   a.recycle();
   setOrientation(orientation);
 }
Example #23
0
  public IPSelector(Context context, AttributeSet attrs) {
    super(context, attrs);
    populateSelf(context);

    TypedArray sa = context.obtainStyledAttributes(attrs, R.styleable.IPSelector);
    setValue(sa.getInt(R.styleable.IPSelector_value, 1));
  }
 public MediaAdapter(Context ctx, List<Uri> tappedUri) {
   mContext = ctx;
   mTappedUri = tappedUri;
   TypedArray a = mContext.obtainStyledAttributes(R.styleable.gallery);
   itemBackground = a.getResourceId(R.styleable.gallery_android_galleryItemBackground, 0);
   a.recycle();
 }
Example #25
0
  public MButton(Context context, AttributeSet attrs) {
    super(context, attrs);
    TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.MTextView, 0, 0);

    try {
      txtFont = a.getInteger(R.styleable.MTextView_txtFont, -1);
      txtTouch = a.getInteger(R.styleable.MTextView_txtTouch, -1);
      if (txtFont != -1) {
        Fonts.getIntance(getContext()).setFont(this, txtFont);
      }

      if (txtTouch != -1) {
        CommonAndroid.setAnimationOnClick(this);
      }
    } finally {
      a.recycle();
    }

    try {
      // ((SkypeApplication)
      // getContext().getApplicationContext()).setFonts(txtFont, this);
    } catch (Exception x) {

    }
  }
 public static int getType(TypedArray array, int index) {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) return array.getType(index);
   else {
     TypedValue value = array.peekValue(index);
     return value == null ? TypedValue.TYPE_NULL : value.type;
   }
 }
  public void init(Context context, AttributeSet attrs, int defStyle) {
    mActiveMediaPlayer = new MediaPlayer();
    if (attrs != null) {
      TypedArray ta =
          context.getTheme().obtainStyledAttributes(attrs, R.styleable.OnemomentPlayerView, 0, 0);

      try {
        mShowPlayBtn = ta.getBoolean(R.styleable.OnemomentPlayerView_showPlayButton, true);
        mAutoplay = ta.getBoolean(R.styleable.OnemomentPlayerView_autoplay, false);
        mShowTags = ta.getBoolean(R.styleable.OnemomentPlayerView_showTags, true);
      } finally {
        ta.recycle();
      }
    }
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (inflater != null) {
      inflater.inflate(R.layout.onemoment_player_view, this);
    }

    // get views
    mVideo = (SurfaceView) findViewById(R.id.om_video_surface);
    mPlayBtn = (ImageView) findViewById(R.id.om_play_btn);
    mTagsContainer = (VideoTagsContainer) findViewById(R.id.om_tags_container);
    mHeadsContainer = (LinearLayout) findViewById(R.id.om_heads_container);

    // add listeners
    mVideoSurfaceHolder = mVideo.getHolder();
    mVideoSurfaceHolder.addCallback(this);
    mActiveMediaPlayer.setOnCompletionListener(this);
  }
  public void init(AttributeSet attrs) {
    TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.SlantedTextView);

    mTextSize = array.getDimension(R.styleable.SlantedTextView_slantedTextSize, mTextSize);
    mTextColor = array.getColor(R.styleable.SlantedTextView_slantedTextColor, mTextColor);
    mSlantedLength = array.getDimension(R.styleable.SlantedTextView_slantedLength, mSlantedLength);
    mSlantedBackgroundColor =
        array.getColor(R.styleable.SlantedTextView_slantedBackgroundColor, mSlantedBackgroundColor);

    if (array.hasValue(R.styleable.SlantedTextView_slantedText)) {
      mSlantedText = array.getString(R.styleable.SlantedTextView_slantedText);
    }

    if (array.hasValue(R.styleable.SlantedTextView_slantedMode)) {
      mMode = array.getInt(R.styleable.SlantedTextView_slantedMode, 0);
    }
    array.recycle();

    mPaint = new Paint();
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
    mPaint.setAntiAlias(true);
    mPaint.setColor(mSlantedBackgroundColor);

    mTextPaint = new TextPaint();
    mTextPaint.setAntiAlias(true);
    mTextPaint.setTextSize(mTextSize);
    mTextPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
    mTextPaint.setColor(mTextColor);
    mTextPaint.setTextAlign(Paint.Align.CENTER);
  }
 public FloatingMenuLayout(Context context, AttributeSet attrs, int defStyleAttr) {
   super(context, attrs, defStyleAttr);
   TypedArray attr =
       context.obtainStyledAttributes(attrs, R.styleable.CustomFloatingActionMenu, 0, 0);
   mLabelStyle = attr.getResourceId(R.styleable.CustomFloatingActionMenu_menu_label_style, 0);
   attr.recycle();
 }
  private void init(Context context, AttributeSet attrs) {

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.LoadingView);
    loadText = typedArray.getString(R.styleable.LoadingView_loadingText);

    typedArray.recycle();
  }