	public View getView(int position, View convertView, ViewGroup parent) {
		View res;
		final MagazineModel currentMagazine = magazine.get(position);
		if(convertView == null){
			res = LayoutInflater.from(context).inflate(R.layout.magazine_list_item, null);
		} else {
			res = convertView;
		}
		TextView title = (TextView)res.findViewById(R.id.item_title);
		TextView subtitle = (TextView)res.findViewById(R.id.item_subtitle);
		ImageView thumbnail = (ImageView)res.findViewById(R.id.item_thumbnail);
		title.setText(currentMagazine.getTitle());
		subtitle.setText(currentMagazine.getSubtitle());
		String imagePath = currentMagazine.getPngPath();
		thumbnail.setImageBitmap(BitmapFactory.decodeFile(imagePath));
		Button downloadOrReadButton = (Button)res.findViewById(R.id.item_button_one);
		Button sampleOrDeleteButton = (Button)res.findViewById(R.id.item_button_two);
		if (currentMagazine.isDownloaded()) {
			downloadOrReadButton.setText(context.getResources().getString(
					R.string.read));
			downloadOrReadButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					LibrelioApplication.startPDFActivity(context,
							currentMagazine.getPdfPath());
				}
			});
		} else {
			downloadOrReadButton.setText(context.getResources().getString(
					R.string.download));
			downloadOrReadButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					if(currentMagazine.isPaid()){
						Intent intent = new Intent(context,BillingActivity.class);
						intent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());
						intent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());
						intent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());
						context.startActivity(intent);
					} else {
						Intent intent = new Intent(context,
								DownloadActivity.class);
						intent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());
						intent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());
						intent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());
						intent.putExtra(DownloadActivity.IS_SAMPLE_KEY,false);
						intent.putExtra(DownloadActivity.ORIENTATION_KEY,
								context.getResources().getConfiguration().orientation);
						context.startActivity(intent);
					}
				}
			});
		}
		if (!currentMagazine.isPaid() && !currentMagazine.isDownloaded()) {
			sampleOrDeleteButton.setVisibility(View.INVISIBLE);
		} else if (currentMagazine.isDownloaded()) {
				sampleOrDeleteButton.setVisibility(View.VISIBLE);
				sampleOrDeleteButton.setText(context.getResources().getString(
						R.string.delete));
				sampleOrDeleteButton.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						currentMagazine.delete();
					}
				});
		} else {
			sampleOrDeleteButton.setText(context.getResources().getString(
					R.string.sample));
			sampleOrDeleteButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					File sample = new File(currentMagazine.getSamplePath());
					Log.d(TAG, "test: " + sample.exists() + " "
							+ currentMagazine.isSampleDownloaded());
					if (currentMagazine.isSampleDownloaded()) {
						LibrelioApplication.startPDFActivity(context,
								currentMagazine.getSamplePath());
					} else {
						Intent intent = new Intent(context,
								DownloadActivity.class);
						intent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());
						intent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());
						intent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());
						intent.putExtra(DownloadActivity.ORIENTATION_KEY,
								context.getResources().getConfiguration().orientation);
						intent.putExtra(DownloadActivity.IS_SAMPLE_KEY,true);
						context.startActivity(intent);
					}
				}
			});
		}
		return res;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		View res;
		final MagazineModel currentMagazine = magazine.get(position);
		if(convertView == null){
			res = LayoutInflater.from(context).inflate(R.layout.magazine_list_item, null);
		} else {
			res = convertView;
		}
		TextView title = (TextView)res.findViewById(R.id.item_title);
		TextView subtitle = (TextView)res.findViewById(R.id.item_subtitle);
		ImageView thumbnail = (ImageView)res.findViewById(R.id.item_thumbnail);
		title.setText(currentMagazine.getTitle());
		subtitle.setText(currentMagazine.getSubtitle());
		String imagePath = currentMagazine.getPngPath();
		thumbnail.setImageBitmap(BitmapFactory.decodeFile(imagePath));
		Button downloadOrReadButton = (Button)res.findViewById(R.id.item_button_one);
		Button sampleOrDeleteButton = (Button)res.findViewById(R.id.item_button_two);
		if (currentMagazine.isDownloaded()) {
			downloadOrReadButton.setText(context.getResources().getString(
					R.string.read));
			downloadOrReadButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					LibrelioApplication.startPDFActivity(context,
							currentMagazine.getPdfPath());
				}
			});
		} else {
			downloadOrReadButton.setText(context.getResources().getString(
					R.string.download));
			downloadOrReadButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					if(currentMagazine.isPaid()){
						Intent intent = new Intent(context,BillingActivity.class);
						intent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());
						intent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());
						intent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());
						context.startActivity(intent);
					} else {
						Intent intent = new Intent(context,
								DownloadActivity.class);
						intent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());
						intent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());
						intent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());
						intent.putExtra(DownloadActivity.IS_SAMPLE_KEY,false);
						intent.putExtra(DownloadActivity.ORIENTATION_KEY,
								context.getResources().getConfiguration().orientation);
						context.startActivity(intent);
					}
				}
			});
		}
		sampleOrDeleteButton.setVisibility(View.VISIBLE);
		if (!currentMagazine.isPaid() && !currentMagazine.isDownloaded()) {
			sampleOrDeleteButton.setVisibility(View.INVISIBLE);
		} else if (currentMagazine.isDownloaded()) {
				sampleOrDeleteButton.setText(context.getResources().getString(
						R.string.delete));
				sampleOrDeleteButton.setOnClickListener(new OnClickListener() {
					@Override
					public void onClick(View v) {
						currentMagazine.delete();
					}
				});
		} else {
			sampleOrDeleteButton.setText(context.getResources().getString(
					R.string.sample));
			sampleOrDeleteButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					File sample = new File(currentMagazine.getSamplePath());
					Log.d(TAG, "test: " + sample.exists() + " "
							+ currentMagazine.isSampleDownloaded());
					if (currentMagazine.isSampleDownloaded()) {
						LibrelioApplication.startPDFActivity(context,
								currentMagazine.getSamplePath());
					} else {
						Intent intent = new Intent(context,
								DownloadActivity.class);
						intent.putExtra(DownloadActivity.FILE_NAME_KEY,currentMagazine.getFileName());
						intent.putExtra(DownloadActivity.TITLE_KEY,currentMagazine.getTitle());
						intent.putExtra(DownloadActivity.SUBTITLE_KEY,currentMagazine.getSubtitle());
						intent.putExtra(DownloadActivity.ORIENTATION_KEY,
								context.getResources().getConfiguration().orientation);
						intent.putExtra(DownloadActivity.IS_SAMPLE_KEY,true);
						context.startActivity(intent);
					}
				}
			});
		}
		return res;
	}
