lmw
2023-06-07 f9dd2cdac746d308d5c4bcfdbea389ab67a66b12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.yalantis.ucrop.view;
 
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
 
import androidx.annotation.NonNull;
 
import com.yalantis.ucrop.R;
 
public class UCropView extends FrameLayout {
 
    private final GestureCropImageView mGestureCropImageView;
    private final OverlayView mViewOverlay;
 
    public UCropView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
 
    public UCropView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
 
        LayoutInflater.from(context).inflate(R.layout.ucrop_view, this, true);
        mGestureCropImageView = findViewById(R.id.image_view_crop);
        mViewOverlay = findViewById(R.id.view_overlay);
 
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ucrop_UCropView);
        mViewOverlay.processStyledAttributes(a);
        mGestureCropImageView.processStyledAttributes(a);
        a.recycle();
 
 
        mGestureCropImageView.setCropBoundsChangeListener(cropRatio -> mViewOverlay.setTargetAspectRatio(cropRatio));
        mViewOverlay.setOverlayViewChangeListener(cropRect -> mGestureCropImageView.setCropRect(cropRect));
    }
 
    @Override
    public boolean shouldDelayChildPressedState() {
        return false;
    }
 
    @NonNull
    public GestureCropImageView getCropImageView() {
        return mGestureCropImageView;
    }
 
    @NonNull
    public OverlayView getOverlayView() {
        return mViewOverlay;
    }
 
}