Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change to support righ to left #35

Open
pishguy opened this issue May 26, 2017 · 2 comments
Open

change to support righ to left #35

pishguy opened this issue May 26, 2017 · 2 comments

Comments

@pishguy
Copy link

pishguy commented May 26, 2017

can any body help me how can i modify source code ti support right to left? reference is on this link, but i can't understand me how can i modify that:

@3llomi @abbasalim

private void maybeInitProperties(CircleImageView child, View dependency) {
        if (mStartYPosition == 0)
            mStartYPosition = (int) (dependency.getY());

        if (mFinalYPosition == 0)
            mFinalYPosition = (dependency.getHeight() / 2);

        if (mStartHeight == 0)
            mStartHeight = child.getHeight();

        if (mStartXPosition == 0)
            mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));

        if (mFinalXPosition == 0)
            mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);

        if (mStartToolbarPosition == 0)
            mStartToolbarPosition = dependency.getY();

        if (mChangeBehaviorPoint == 0) {
            mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
        }
    }

@3llomi
Copy link

3llomi commented May 29, 2017

@MahdiPishguy Hi,sorry for late
here is my Full Code with support for Older APIs
`private void maybeInitProperties(CircleImageView child, View dependency) {
if (mStartYPosition == 0)
mStartYPosition = (int) (dependency.getY());

    if (mFinalYPosition == 0)
        mFinalYPosition = (dependency.getHeight() / 2);

    if (mStartHeight == 0)
        mStartHeight = child.getHeight();

    if (mStartXPosition == 0)
        mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));

    if (mFinalXPosition == 0)
        if (Utilities.getLanguage(mContext).equals("العربية")) {
            if (Build.VERSION.SDK_INT < 17 && Utilities.getLanguage(mContext).equals("العربية"))
                mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);
            else
                mFinalXPosition = mContext.getResources().getDisplayMetrics().widthPixels - 50;
        } else
            mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);

    if (mStartToolbarPosition == 0)
        mStartToolbarPosition = dependency.getY();

    if (mChangeBehaviorPoint == 0) {
        mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
    }
}`

and here is the getLanguage method in Utilities Class
public static String getLanguage(Context mContext) { Locale current = mContext.getResources().getConfiguration().locale; return current.getDisplayLanguage(); }

you can replace "العربية" with your language

@pishguy
Copy link
Author

pishguy commented May 29, 2017

@3llomi how can i change code to force move avatar image to right?

this code as:

mFinalXPosition = mContext.getResources().getDisplayMetrics().widthPixels - 50;

not work correctly

please see this code:

    private void maybeInitProperties(CircleImageView child, View dependency) {
        if (mStartYPosition == 0)
            mStartYPosition = (int) (dependency.getY());

        if (mFinalYPosition == 0)
            mFinalYPosition = (dependency.getHeight() / 2);

        if (mStartHeight == 0)
            mStartHeight = child.getHeight();

        if (mStartXPosition == 0)
            mStartXPosition = (int) (child.getX() + (child.getWidth() / 2));

        if (mFinalXPosition == 0)
            mFinalXPosition = mContext.getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material) + ((int) mCustomFinalHeight / 2);                //else

        if (mStartToolbarPosition == 0)
            mStartToolbarPosition = dependency.getY();

        if (mChangeBehaviorPoint == 0) {
            mChangeBehaviorPoint = (child.getHeight() - mCustomFinalHeight) / (2f * (mStartYPosition - mFinalYPosition));
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants