Search in sources :

Example 1 with HighlightType

use of com.quran.labs.androidquran.ui.helpers.HighlightType in project quran_android by quran.

the class HighlightingImageView method onDraw.

@Override
protected void onDraw(@NonNull Canvas canvas) {
    super.onDraw(canvas);
    final Drawable d = getDrawable();
    if (d == null) {
        // no image, forget it.
        return;
    }
    final Matrix matrix = getImageMatrix();
    // Draw overlay text
    didDraw = false;
    if (overlayParams != null) {
        overlayText(canvas, matrix);
    }
    // Draw each ayah highlight
    if (coordinatesData != null && !currentHighlights.isEmpty()) {
        alreadyHighlighted.clear();
        for (Map.Entry<HighlightType, Set<String>> entry : currentHighlights.entrySet()) {
            Paint paint = getPaintForHighlightType(entry.getKey());
            for (String ayah : entry.getValue()) {
                if (alreadyHighlighted.contains(ayah))
                    continue;
                List<AyahBounds> rangesToDraw = coordinatesData.get(ayah);
                if (rangesToDraw != null && !rangesToDraw.isEmpty()) {
                    for (AyahBounds b : rangesToDraw) {
                        matrix.mapRect(scaledRect, b.getBounds());
                        scaledRect.offset(0, getPaddingTop());
                        canvas.drawRect(scaledRect, paint);
                    }
                    alreadyHighlighted.add(ayah);
                }
            }
        }
    }
}
Also used : HighlightType(com.quran.labs.androidquran.ui.helpers.HighlightType) Matrix(android.graphics.Matrix) HashSet(java.util.HashSet) AttributeSet(android.util.AttributeSet) Set(java.util.Set) Drawable(android.graphics.drawable.Drawable) Paint(android.graphics.Paint) Map(java.util.Map) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap) AyahBounds(com.quran.labs.androidquran.common.AyahBounds)

Aggregations

Matrix (android.graphics.Matrix)1 Paint (android.graphics.Paint)1 Drawable (android.graphics.drawable.Drawable)1 AttributeSet (android.util.AttributeSet)1 AyahBounds (com.quran.labs.androidquran.common.AyahBounds)1 HighlightType (com.quran.labs.androidquran.ui.helpers.HighlightType)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1