<commit_before>package com.example.bkkinfoplus.ui.alert;

import android.app.Dialog;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.design.widget.CoordinatorLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.bkkinfoplus.R;
import com.example.bkkinfoplus.Utils;
import com.example.bkkinfoplus.model.Alert;
import com.example.bkkinfoplus.model.Route;
import com.example.bkkinfoplus.ui.UiUtils;
import com.wefika.flowlayout.FlowLayout;

import org.sufficientlysecure.htmltextview.HtmlTextView;

import java.util.ArrayList;
import java.util.List;

public class AlertDetailFragment extends BottomSheetDialogFragment {
    private static final String ARG_ALERT_OBJECT = "alert_object";

    private Alert mAlert;

    private TextView mTitleTextView;
    private TextView mDateTextView;
    private FlowLayout mRouteIconsLayout;
    private HtmlTextView mDescriptionTextView;
    private TextView mUrlTextView;

    /**
     * List of currently displayed route icons. This list is needed in order to find visually
     * duplicate route data, and not to display them twice.
     */
    private List<Route> mDisplayedRoutes = new ArrayList<>();

    private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback =
            new AlertDetailCallback();

    public static AlertDetailFragment newInstance(@NonNull Alert alert) {
        AlertDetailFragment fragment = new AlertDetailFragment();
        Bundle args = new Bundle();
        args.putSerializable(ARG_ALERT_OBJECT, alert);
        fragment.setArguments(args);
        return fragment;
    }

    /**
     * Sets up the fragment as a child of a BottomSheetDialogFragment
     * @param dialog
     * @param style
     */
    @Override
    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);

        View contentView = View.inflate(getActivity(), R.layout.fragment_alert_detail, null);
        dialog.setContentView(contentView);

        View parentView = (View) contentView.getParent();
        CoordinatorLayout.LayoutParams params =
                (CoordinatorLayout.LayoutParams) parentView.getLayoutParams();
        CoordinatorLayout.Behavior behavior = params.getBehavior();

        if (behavior != null && behavior instanceof BottomSheetBehavior ) {
            ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mAlert = (Alert) getArguments().getSerializable(ARG_ALERT_OBJECT);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_alert_detail, container, false);
        mTitleTextView = (TextView) view.findViewById(R.id.alert_detail_title);
        mDateTextView = (TextView) view.findViewById(R.id.alert_detail_date);
        mRouteIconsLayout = (FlowLayout) view.findViewById(R.id.alert_detail_route_icons_wrapper);
        mDescriptionTextView = (HtmlTextView) view.findViewById(R.id.alert_detail_description);
        mUrlTextView = (TextView) view.findViewById(R.id.alert_detail_url);

        mTitleTextView.setText(mAlert.getHeader());

        String dateString = UiUtils.alertDateFormatter(getActivity(), mAlert.getStart(), mAlert.getEnd());
        mDateTextView.setText(dateString);

        // There are alerts without affected routes, eg. announcements
        if (mAlert.getRouteIds() != null) {
            for (Route route : mAlert.getAffectedRoutes()) {
                // Some affected routes are visually identical to others in the list, no need
                // to diplay them again.
                if (!Utils.isRouteVisuallyDuplicate(route, mDisplayedRoutes)) {
                    mDisplayedRoutes.add(route);
                    UiUtils.addRouteIcon(getActivity(), mRouteIconsLayout, route);<commit_msg>Fixed BottomSheetDialog turning statusbar to black<commit_after>package com.example.bkkinfoplus.ui.alert;

import android.app.Dialog;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.design.widget.CoordinatorLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.TextView;

import com.example.bkkinfoplus.R;
import com.example.bkkinfoplus.Utils;
import com.example.bkkinfoplus.model.Alert;
import com.example.bkkinfoplus.model.Route;
import com.example.bkkinfoplus.ui.UiUtils;
import com.wefika.flowlayout.FlowLayout;

import org.sufficientlysecure.htmltextview.HtmlTextView;

import java.util.ArrayList;
import java.util.List;

public class AlertDetailFragment extends BottomSheetDialogFragment {
    private static final String ARG_ALERT_OBJECT = "alert_object";

    private Alert mAlert;

    private TextView mTitleTextView;
    private TextView mDateTextView;
    private FlowLayout mRouteIconsLayout;
    private HtmlTextView mDescriptionTextView;
    private TextView mUrlTextView;

    /**
     * List of currently displayed route icons. This list is needed in order to find visually
     * duplicate route data, and not to display them twice.
     */
    private List<Route> mDisplayedRoutes = new ArrayList<>();

    private BottomSheetBehavior.BottomSheetCallback mBottomSheetBehaviorCallback =
            new AlertDetailCallback();

    public static AlertDetailFragment newInstance(@NonNull Alert alert) {
        AlertDetailFragment fragment = new AlertDetailFragment();
        Bundle args = new Bundle();
        args.putSerializable(ARG_ALERT_OBJECT, alert);
        fragment.setArguments(args);
        return fragment;
    }

    /**
     * Sets up the fragment as a child of a BottomSheetDialogFragment
     * @param dialog
     * @param style
     */
    @Override
    public void setupDialog(Dialog dialog, int style) {
        super.setupDialog(dialog, style);

        View contentView = View.inflate(getActivity(), R.layout.fragment_alert_detail, null);
        dialog.setContentView(contentView);

        View parentView = (View) contentView.getParent();
        CoordinatorLayout.LayoutParams params =
                (CoordinatorLayout.LayoutParams) parentView.getLayoutParams();
        CoordinatorLayout.Behavior behavior = params.getBehavior();

        if (behavior != null && behavior instanceof BottomSheetBehavior ) {
            ((BottomSheetBehavior) behavior).setBottomSheetCallback(mBottomSheetBehaviorCallback);
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mAlert = (Alert) getArguments().getSerializable(ARG_ALERT_OBJECT);
        }
    }

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        // By default, the BottomSheetDialog changes the statusbar's color to black.
        // Found this solution here: https://code.google.com/p/android/issues/detail?id=202691
        BottomSheetDialog dialog = (BottomSheetDialog) super.onCreateDialog(savedInstanceState);
        dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        return dialog;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_alert_detail, container, false);
        mTitleTextView = (TextView) view.findViewById(R.id.alert_detail_title);
        mDateTextView = (TextView) view.findViewById(R.id.alert_detail_date);
        mRouteIconsLayout = (FlowLayout) view.findViewById(R.id.alert_detail_route_icons_wrapper);
        mDescriptionTextView = (HtmlTextView) view.findViewById(R.id.alert_detail_description);
        mUrlTextView = (TextView) view.findViewById(R.id.alert_detail_url);

        mTitleTextView.setText(mAlert.getHeader());

        String dateString = UiUtils.alertDateFormatter(getActivity(), mAlert.getStart(), mAlert.getEnd());
        mDateTextView.setText(dateString);

        // There are alerts without affected routes, eg. announcements
        if (mAlert.getRouteIds() != null) {
            for (Route route : mAlert.getAffectedRoutes()) {
                // Some affected routes are visually identical to others in the list, no need
                // to diplay them again.
                if (!Utils.isRouteVisuallyDuplicate(route, mDisplayedRoutes)) {
                    mDisplayedRoutes.add(route);
                    UiUtils.addRouteIcon(getActivity(), mRouteIconsLayout, route);
{'fraction_non_alphanumeric': 0.08594420600858368, 'fraction_numerical': 0.0006437768240343348, 'mean_word_length': 3.5357664233576642, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, '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': '984628', 'n_tokens_mistral': 2511, 'n_tokens_neox': 2377, 'n_words': 557}