<commit_before>package org.onestraw.poovali.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import org.onestraw.poovali.R;
import org.onestraw.poovali.ViewEventActivity;
import org.onestraw.poovali.model.BatchContent;
import org.onestraw.poovali.model.EventContent;
import org.onestraw.poovali.utility.Helper;

import java.text.DateFormat;
import java.util.List;

public class EventsFragment extends Fragment {

    RecyclerView recyclerView;

    public EventsFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.events_fragment, container, false);

        recyclerView = (RecyclerView) rootView.findViewById(R.id.activities_list);
        assert recyclerView != null;
        setupRecyclerView(recyclerView);

        return rootView;
    }

    @Override
    public void onResume() {
        super.onResume();
        recyclerView.getAdapter().notifyDataSetChanged(); // For adding activity
    }

    private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
        recyclerView.setAdapter(new EventsFragment.SimpleItemRecyclerViewAdapter(EventContent.getItems(getActivity())));
    }

    public class SimpleItemRecyclerViewAdapter
            extends RecyclerView.Adapter<EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder> {

        private final List<EventContent.Event> mValues;

        SimpleItemRecyclerViewAdapter(List<EventContent.Event> items) {
            mValues = items;
        }

        @Override
        public EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.event_list_item, parent, false);
            return new EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(final EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder holder, int position) {
            holder.mItem = mValues.get(position);
            final int eventId = position;
            BatchContent.Batch batch = holder.mItem.getBatch(getActivity());

            DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT);
            String date = format.format(holder.mItem.getCreatedDate());
            holder.mEventCreatedDateView.setText(date);
            String description = holder.mItem.getDescription();
            if (description.isEmpty()) {
                holder.mEventDescriptionView.setText(holder.mItem.getName());
            } else {
                holder.mEventDescriptionView.setText(description);
            }

            holder.mBatchNameView.setText(batch.getName());
            if (batch.getPlant() != null) {
                holder.mBatchStatusView.setText(batch.getPlant().getStage(batch.getCreatedDate()).toString());
                holder.mProgressBar.setProgress(batch.getPlant().getProgress(batch.getCreatedDate()));
            }

            holder.mPlantIconView.setImageResource(getResources().getIdentifier(batch.getImageName(),
                    "drawable",
                    holder.mPlantIconView.getContext().getPackageName()));
            holder.mEventIconView.setImageResource(getResources().getIdentifier(holder.mItem.getImageName(),
                    "drawable",
                    holder.mPlantIconView.getContext().getPackageName()));
            holder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (holder.mItem.getClass() == EventContent.BatchActivityEvent.class) {
                        Context context = v.getContext();
                        Intent intent = new Intent(context, ViewEventActivity.class);
                        intent.putExtra(Helper.ARG_EVENT_ID, eventId);
                        context.startActivity(intent);
                    }
                }
            });
        }

        @Override
        public int getItemCount() {
            return mValues.size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {
            final View mView;
            final TextView mBatchNameView;
            final TextView mEventCreatedDateView;
            final TextView mEventDescriptionView;
            final TextView mBatchStatusView;
            final ImageView mPlantIconView;
            final ImageView mEventIconView;
            final ProgressBar mProgressBar;
            EventContent.Event mItem;

            ViewHolder(View view) {
                super(view);
                mView = view;
                mBatchNameView = (TextView) view.findViewById(R.id.batch);
                mEventCreatedDateView = (TextView) view.findViewById(R.id.event_created_date);
                mEventDescriptionView = (TextView) view.findViewById(R.id.event_description);
                mBatchStatusView = (TextView) view.findViewById(R.id.batch_status);
                mEventIconView = (ImageView) view.findViewById(R.id.event_type_icon);
                mPlantIconView = (ImageView) view.findViewById(R.id.plant_type_icon);
                mProgressBar = (ProgressBar) view.findViewById(R.id.batch_status_progress);
            }

            @Override
            public String toString() {
                return super.toString() + " '" + mEventDescriptionView.getText() + "'";
            }
        }
    }
}
<commit_msg>Hid the batch status progress bar for garden activities<commit_after>package org.onestraw.poovali.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import org.onestraw.poovali.R;
import org.onestraw.poovali.ViewEventActivity;
import org.onestraw.poovali.model.BatchContent;
import org.onestraw.poovali.model.EventContent;
import org.onestraw.poovali.utility.Helper;

import java.text.DateFormat;
import java.util.List;

public class EventsFragment extends Fragment {

    RecyclerView recyclerView;

    public EventsFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.events_fragment, container, false);

        recyclerView = (RecyclerView) rootView.findViewById(R.id.activities_list);
        assert recyclerView != null;
        setupRecyclerView(recyclerView);

        return rootView;
    }

    @Override
    public void onResume() {
        super.onResume();
        recyclerView.getAdapter().notifyDataSetChanged(); // For adding activity
    }

    private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
        recyclerView.setAdapter(new EventsFragment.SimpleItemRecyclerViewAdapter(EventContent.getItems(getActivity())));
    }

    public class SimpleItemRecyclerViewAdapter
            extends RecyclerView.Adapter<EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder> {

        private final List<EventContent.Event> mValues;

        SimpleItemRecyclerViewAdapter(List<EventContent.Event> items) {
            mValues = items;
        }

        @Override
        public EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.event_list_item, parent, false);
            return new EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(final EventsFragment.SimpleItemRecyclerViewAdapter.ViewHolder holder, int position) {
            holder.mItem = mValues.get(position);
            final int eventId = position;
            BatchContent.Batch batch = holder.mItem.getBatch(getActivity());

            DateFormat format = DateFormat.getDateInstance(DateFormat.SHORT);
            String date = format.format(holder.mItem.getCreatedDate());
            holder.mEventCreatedDateView.setText(date);
            String description = holder.mItem.getDescription();
            if (description.isEmpty()) {
                holder.mEventDescriptionView.setText(holder.mItem.getName());
            } else {
                holder.mEventDescriptionView.setText(description);
            }

            holder.mBatchNameView.setText(batch.getName());
            if (batch.getPlant() != null) {
                holder.mProgressBar.setVisibility(View.VISIBLE);
                holder.mBatchStatusView.setText(batch.getPlant().getStage(batch.getCreatedDate()).toString());
                holder.mProgressBar.setProgress(batch.getPlant().getProgress(batch.getCreatedDate()));
            } else {
                holder.mProgressBar.setVisibility(View.GONE);
            }

            holder.mPlantIconView.setImageResource(getResources().getIdentifier(batch.getImageName(),
                    "drawable",
                    holder.mPlantIconView.getContext().getPackageName()));
            holder.mEventIconView.setImageResource(getResources().getIdentifier(holder.mItem.getImageName(),
                    "drawable",
                    holder.mPlantIconView.getContext().getPackageName()));
            holder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    if (holder.mItem.getClass() == EventContent.BatchActivityEvent.class) {
                        Context context = v.getContext();
                        Intent intent = new Intent(context, ViewEventActivity.class);
                        intent.putExtra(Helper.ARG_EVENT_ID, eventId);
                        context.startActivity(intent);
                    }
                }
            });
        }

        @Override
        public int getItemCount() {
            return mValues.size();
        }

        class ViewHolder extends RecyclerView.ViewHolder {
            final View mView;
            final TextView mBatchNameView;
            final TextView mEventCreatedDateView;
            final TextView mEventDescriptionView;
            final TextView mBatchStatusView;
            final ImageView mPlantIconView;
            final ImageView mEventIconView;
            final ProgressBar mProgressBar;
            EventContent.Event mItem;

            ViewHolder(View view) {
                super(view);
                mView = view;
                mBatchNameView = (TextView) view.findViewById(R.id.batch);
                mEventCreatedDateView = (TextView) view.findViewById(R.id.event_created_date);
                mEventDescriptionView = (TextView) view.findViewById(R.id.event_description);
                mBatchStatusView = (TextView) view.findViewById(R.id.batch_status);
                mEventIconView = (ImageView) view.findViewById(R.id.event_type_icon);
                mPlantIconView = (ImageView) view.findViewById(R.id.plant_type_icon);
                mProgressBar = (ProgressBar) view.findViewById(R.id.batch_status_progress);
            }

            @Override
            public String toString() {
                return super.toString() + " '" + mEventDescriptionView.getText() + "'";
            }
        }
    }
}

{'fraction_non_alphanumeric': 0.08898578811369509, 'fraction_numerical': 0.00032299741602067185, 'mean_word_length': 2.4614309670206818, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, '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': '1565300', 'n_tokens_mistral': 3236, 'n_tokens_neox': 3070, 'n_words': 533}