If you think the Android project esr-scanner listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
* Copyright 2012 ZXing authors/*www.java2s.com*/
*
* 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 ch.luklanis.esscan.history;
import android.app.Activity;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.ArrayList;
import ch.luklanis.esscan.R;
import ch.luklanis.esscan.paymentslip.PsResult;
finalclass HistoryItemAdapter extends ArrayAdapter<HistoryItem> {
privatefinal Activity activity;
HistoryItemAdapter(Activity activity) {
super(activity, R.layout.history_list_item, new ArrayList<HistoryItem>());
this.activity = activity;
}
@Override
public View getView(int position, View view, ViewGroup viewGroup) {
LinearLayout layout;
if (view instanceof LinearLayout) {
layout = (LinearLayout) view;
} else {
LayoutInflater factory = LayoutInflater.from(activity);
layout = (LinearLayout) factory.inflate(R.layout.history_list_item, viewGroup, false);
}
HistoryItem item = getItem(position);
PsResult result = item.getResult();
String title;
String address;
if (result != null) {
title = result.toString() + " " + item.getAmount();
address = item.getAddress().replaceAll("[\\r\\n]+", ", ");
String status = item.getDTAFilename();
if (!TextUtils.isEmpty(status)) {
address += TextUtils.isEmpty(address) ? status : "\r\n" + status;
}
} else {
Resources resources = getContext().getResources();
title = resources.getString(R.string.history_empty);
address = resources.getString(R.string.history_empty_detail);
}
((TextView) layout.findViewById(R.id.history_title)).setText(title);
((TextView) layout.findViewById(R.id.history_detail)).setText(address);
return layout;
}
}