use of com.aviary.android.feather.widget.HighlightView in project mobile-android by photo.
the class CropPanel method onActivate.
/*
* (non-Javadoc)
*
* @see com.aviary.android.feather.effects.AbstractEffectPanel#onActivate()
*/
@Override
public void onActivate() {
super.onActivate();
int position = mGallery.getSelectedItemPosition();
final double ratio = calculateAspectRatio(position, false);
disableHapticIsNecessary(mGallery);
setIsChanged(true);
contentReady();
mGallery.setOnItemsScrollListener(new OnItemsScrollListener() {
@Override
public void onScrollFinished(AdapterView<?> parent, View view, int position, long id) {
if (!isActive())
return;
if (position == mSelectedPosition) {
if (!strict && !nonInvertOptions.contains(position)) {
isChecked = !isChecked;
CropImageView cview = (CropImageView) mImageView;
double currentAspectRatio = cview.getAspectRatio();
HighlightView hv = cview.getHighlightView();
if (!cview.getAspectRatioIsFixed() && hv != null) {
currentAspectRatio = (double) hv.getDrawRect().width() / (double) hv.getDrawRect().height();
}
double invertedAspectRatio = 1 / currentAspectRatio;
cview.setAspectRatio(invertedAspectRatio, cview.getAspectRatioIsFixed());
invertRatios(mCropNames, mCropValues);
mGallery.invalidateViews();
}
} else {
double ratio = calculateAspectRatio(position, false);
setCustomRatio(ratio, ratio != 0);
}
updateSelection(view, position);
}
@Override
public void onScrollStarted(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onScroll(AdapterView<?> parent, View view, int position, long id) {
}
});
getOptionView().getHandler().post(new Runnable() {
@Override
public void run() {
createCropView(ratio, ratio != 0);
updateSelection((View) mGallery.getSelectedView(), mGallery.getSelectedItemPosition());
}
});
}
Aggregations