<commit_before>/*
 * Copyright 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.app.material.widget;

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

import org.app.material.AndroidUtilities;

public class LayoutHelper {

    public static final int MATCH_PARENT = -1;
    public static final int WRAP_CONTENT = -2;

    private static int getSize(Context context, float size) {
        return (int) (size < 0 ? size : AndroidUtilities.dp(context, size));
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height) {
        return new ScrollView.LayoutParams(getSize(context, width), getSize(context, height));
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height, int gravity) {
        return new ScrollView.LayoutParams(getSize(context, width), getSize(context, height), gravity);
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
        ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(context, width), getSize(context, height), gravity);
        layoutParams.setMargins(AndroidUtilities.dp(context, leftMargin), AndroidUtilities.dp(context, topMargin), AndroidUtilities.dp(context, rightMargin), AndroidUtilities.dp(context, bottomMargin));
        return layoutParams;
    }

    public static FrameLayout.LayoutParams makeFrame(Context context, int width, float height) {
        return new FrameLayout.LayoutParams(getSize(context, width), getSize(context, height));<commit_msg>* improve method for ScrollView<commit_after>/*
 * Copyright 2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.app.material.widget;

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;

import org.app.material.AndroidUtilities;

public class LayoutHelper {

    public static final int MATCH_PARENT = -1;
    public static final int WRAP_CONTENT = -2;

    private static int getSize(Context context, float size) {
        return (int) (size < 0 ? size : AndroidUtilities.dp(context, size));
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height) {
        return new ScrollView.LayoutParams(getSize(context, width), getSize(context, height));
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height, int gravity) {
        return new ScrollView.LayoutParams(getSize(context, width), getSize(context, height), gravity);
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
        ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(context, width), getSize(context, height));
        layoutParams.setMargins(AndroidUtilities.dp(context, leftMargin), AndroidUtilities.dp(context, topMargin), AndroidUtilities.dp(context, rightMargin), AndroidUtilities.dp(context, bottomMargin));
        return layoutParams;
    }

    public static ScrollView.LayoutParams makeScroll(Context context, int width, int height, int gravity, float leftMargin, float topMargin, float rightMargin, float bottomMargin) {
        ScrollView.LayoutParams layoutParams = new ScrollView.LayoutParams(getSize(context, width), getSize(context, height), gravity);
        layoutParams.setMargins(AndroidUtilities.dp(context, leftMargin), AndroidUtilities.dp(context, topMargin), AndroidUtilities.dp(context, rightMargin), AndroidUtilities.dp(context, bottomMargin));
        return layoutParams;
    }

    public static FrameLayout.LayoutParams makeFrame(Context context, int width, float height) {
        return new FrameLayout.LayoutParams(getSize(context, width), getSize(context, height));
{'fraction_non_alphanumeric': 0.08625592417061612, 'fraction_numerical': 0.004170616113744076, 'mean_word_length': 4.728555917480999, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3139540', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1348, 'n_words': 461}