<commit_before>package net.x4a42.volksempfaenger.ui;

import net.x4a42.volksempfaenger.R;
import net.x4a42.volksempfaenger.data.DatabaseHelper;
import net.x4a42.volksempfaenger.data.SubscriptionListAdapter;
import net.x4a42.volksempfaenger.service.UpdateService;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;

public class SubscriptionGridFragment extends Fragment implements
		OnItemClickListener {

	private static final int CONTEXT_EDIT = 0;
	private static final int CONTEXT_DELETE = 1;

	private DatabaseHelper dbHelper;
	private Cursor cursor;
	private GridView subscriptionList;
	private SubscriptionListAdapter adapter;
	private AdapterView.AdapterContextMenuInfo currentMenuInfo;

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

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

		dbHelper = DatabaseHelper.getInstance(getActivity());

		subscriptionList = (GridView) view.findViewById(R.id.subscription_list);
		subscriptionList.setEmptyView(view
				.findViewById(R.id.subscription_list_empty));
		subscriptionList.setOnItemClickListener(this);
		subscriptionList.setOnCreateContextMenuListener(this);

		cursor = dbHelper.getReadableDatabase().query(
				DatabaseHelper.ExtendedPodcast._TABLE, null, null, null, null,
				null, DatabaseHelper.ExtendedPodcast.TITLE);
		getActivity().startManagingCursor(cursor);

		adapter = new SubscriptionListAdapter(getActivity(), cursor);
		subscriptionList.setAdapter(adapter);

		return view;
	}

	@Override
	public void onResume() {
		super.onResume();

		cursor.requery();
	}

	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		inflater.inflate(R.menu.subscription_list, menu);
	}
<commit_msg>SubscriptionGridFragment: Move initialisation of adapter to onCreate to prevent a memory leak<commit_after>package net.x4a42.volksempfaenger.ui;

import net.x4a42.volksempfaenger.R;
import net.x4a42.volksempfaenger.data.DatabaseHelper;
import net.x4a42.volksempfaenger.data.SubscriptionListAdapter;
import net.x4a42.volksempfaenger.service.UpdateService;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.TextView;
import android.widget.Toast;

public class SubscriptionGridFragment extends Fragment implements
		OnItemClickListener {

	private static final int CONTEXT_EDIT = 0;
	private static final int CONTEXT_DELETE = 1;

	private DatabaseHelper dbHelper;
	private Cursor cursor;
	private GridView subscriptionList;
	private SubscriptionListAdapter adapter;
	private AdapterView.AdapterContextMenuInfo currentMenuInfo;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
		
		dbHelper = DatabaseHelper.getInstance(getActivity());

		cursor = dbHelper.getReadableDatabase().query(
				DatabaseHelper.ExtendedPodcast._TABLE, null, null, null, null,
				null, DatabaseHelper.ExtendedPodcast.TITLE);
		getActivity().startManagingCursor(cursor);
		
		adapter = new SubscriptionListAdapter(getActivity(), cursor);
	}

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

		subscriptionList = (GridView) view.findViewById(R.id.subscription_list);
		subscriptionList.setEmptyView(view
				.findViewById(R.id.subscription_list_empty));
		subscriptionList.setOnItemClickListener(this);
		subscriptionList.setOnCreateContextMenuListener(this);

		subscriptionList.setAdapter(adapter);

		return view;
	}

	@Override
	public void onResume() {
		super.onResume();

		cursor.requery();
	}

	@Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
		inflater.inflate(R.menu.subscription_list, menu);
	}

{'fraction_non_alphanumeric': 0.08680765357502518, 'fraction_numerical': 0.0072507552870090634, 'mean_word_length': 6.423019431988042, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2368774', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1424, 'n_words': 291}