<commit_before>/**
 * Copyright 2012 Muzima Team
 *
 * 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 com.muzima.adapters.forms;

import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckedTextView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.muzima.MuzimaApplication;
import com.muzima.R;
import com.muzima.api.model.Tag;
import com.muzima.controller.FormController;
import com.muzima.model.AvailableForm;
import com.muzima.model.collections.AvailableForms;
import com.muzima.search.api.util.StringUtil;
import com.muzima.service.MuzimaSyncService;
import com.muzima.tasks.FormsAdapterBackgroundQueryTask;
import com.muzima.view.CheckedLinearLayout;
import com.muzima.view.CheckedRelativeLayout;

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

/**
 * Responsible to list down all the available forms in the server including Tags and img to indicate whether downloaded or not.
 */
public class AllAvailableFormsAdapter extends FormsAdapter<AvailableForm> implements TagsListAdapter.TagsChangedListener {
    private static final String TAG = "AllAvailableFormsAdapter";
    private final MuzimaSyncService muzimaSyncService;


    public AllAvailableFormsAdapter(Context context, int textViewResourceId, FormController formController) {
        super(context, textViewResourceId, formController);
        muzimaSyncService = ((MuzimaApplication) (getContext().getApplicationContext())).getMuzimaSyncService();

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = super.getView(position, convertView, parent);

        ViewHolder viewHolder = (ViewHolder) convertView.getTag();
        addTags(viewHolder, getItem(position));
        markIfDownloaded(viewHolder.downloadedImg, getItem(position));
        setRegistrationFormSelected(convertView, getItem(position));
        return convertView;
    }

    private void setRegistrationFormSelected(View convertView, AvailableForm item) {
        if (item.isRegistrationForm()) {
            if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                convertView.findViewById(R.id.form_name_layout).setActivated(true);
                convertView.findViewById(R.id.form_description).setActivated(true);
                convertView.findViewById(R.id.form_name).setActivated(true);
                convertView.findViewById(R.id.tags_scroller).setActivated(true);
            }
            ((CheckedLinearLayout) convertView.findViewById(R.id.form_name_layout)).setChecked(true);
            ((CheckedTextView)convertView.findViewById(R.id.form_name)).setChecked(true);
            ((CheckedTextView)convertView.findViewById(R.id.form_description)).setChecked(true);
            ((CheckedRelativeLayout) convertView.findViewById(R.id.tags_scroller)).setChecked(true);

            convertView.findViewById(R.id.form_name_layout).setSelected(true);
            convertView.findViewById(R.id.form_name).setSelected(true);
            convertView.findViewById(R.id.form_description).setSelected(true);
            convertView.findViewById(R.id.tags_scroller).setSelected(true);
        }
    }

    @Override
    protected int getFormItemLayout() {
        return R.layout.item_forms_list_selectable;
    }

    private void markIfDownloaded(View downloadedImg, AvailableForm form) {
        if (form.isDownloaded()) {
            downloadedImg.setVisibility(View.VISIBLE);
        } else {
            downloadedImg.setVisibility(View.GONE);
        }
    }

    protected void addTags(ViewHolder holder, AvailableForm form) {
        Tag[] tags = form.getTags();
        if (tags.length > 0) {
            holder.tagsScroller.setVisibility(View.VISIBLE);
            LayoutInflater layoutInflater = LayoutInflater.from(getContext());
<commit_msg>Removed the activation of Registration form<commit_after>/**
 * Copyright 2012 Muzima Team
 *
 * 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 com.muzima.adapters.forms;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.muzima.MuzimaApplication;
import com.muzima.R;
import com.muzima.api.model.Tag;
import com.muzima.controller.FormController;
import com.muzima.model.AvailableForm;
import com.muzima.model.collections.AvailableForms;
import com.muzima.search.api.util.StringUtil;
import com.muzima.service.MuzimaSyncService;
import com.muzima.tasks.FormsAdapterBackgroundQueryTask;

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

/**
 * Responsible to list down all the available forms in the server including Tags and img to indicate whether downloaded or not.
 */
public class AllAvailableFormsAdapter extends FormsAdapter<AvailableForm> implements TagsListAdapter.TagsChangedListener {
    private static final String TAG = "AllAvailableFormsAdapter";
    private final MuzimaSyncService muzimaSyncService;


    public AllAvailableFormsAdapter(Context context, int textViewResourceId, FormController formController) {
        super(context, textViewResourceId, formController);
        muzimaSyncService = ((MuzimaApplication) (getContext().getApplicationContext())).getMuzimaSyncService();

    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = super.getView(position, convertView, parent);

        ViewHolder viewHolder = (ViewHolder) convertView.getTag();
        addTags(viewHolder, getItem(position));
        markIfDownloaded(viewHolder.downloadedImg, getItem(position));
        return convertView;
    }


    @Override
    protected int getFormItemLayout() {
        return R.layout.item_forms_list_selectable;
    }

    private void markIfDownloaded(View downloadedImg, AvailableForm form) {
        if (form.isDownloaded()) {
            downloadedImg.setVisibility(View.VISIBLE);
        } else {
            downloadedImg.setVisibility(View.GONE);
        }
    }

    protected void addTags(ViewHolder holder, AvailableForm form) {
        Tag[] tags = form.getTags();
        if (tags.length > 0) {
            holder.tagsScroller.setVisibility(View.VISIBLE);
            LayoutInflater layoutInflater = LayoutInflater.from(getContext());

{'fraction_non_alphanumeric': 0.08973505525229664, 'fraction_numerical': 0.0023964851551058447, 'mean_word_length': 4.00133155792277, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6079771', 'n_tokens_mistral': 2065, 'n_tokens_neox': 1984, 'n_words': 496}