Android Open Source - Java-Yandex.Money-API-SDK History Adapter From Project Back to project page Java-Yandex.Money-API-SDK .
License The source code is released under:
MIT License
If you think the Android project Java-Yandex.Money-API-SDK 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 package ru.yandex.money.droid;
/ * w w w . j a v a 2 s . c o m * /
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import ru.yandex.money.api.enums.MoneyDirection;
import ru.yandex.money.api.response.util.Operation;
import java.text.DateFormat;
import java.util.List;
/**
* @author dvmelnikov
*/
class HistoryAdapter extends ArrayAdapter {
private final LayoutInflater inflater;
ViewHolder holder;
private final List<Operation> history;
private LoadHistoryTask loadHistoryTask;
private final Activity context;
private String accessToken;
private String clientId;
private DialogInterface.OnCancelListener onCancelListener;
public HistoryAdapter(Activity context, int textViewResourceId,
List<Operation> history, String clientId, String accessToken, DialogInterface.OnCancelListener onCancelListener) {
super (context, textViewResourceId, history);
this.onCancelListener = onCancelListener;
inflater = (LayoutInflater) context.getSystemService(
Context.LAYOUT_INFLATER_SERVICE);
this.history = history;
this.accessToken = accessToken;
this.clientId = clientId;
this.context = context;
}
@Override
public View getView(int position, View convertView,
ViewGroup parent) {
if (position == getCount() - 1) {
loadHistoryTask = new LoadHistoryTask(context, clientId, accessToken, this , onCancelListener);
if ((loadHistoryTask.getStatus() != AsyncTask.Status.RUNNING))
loadHistoryTask.execute(getCount());
}
if (convertView == null) {
convertView =
inflater.inflate(R.layout.ymd_history_item,
parent, false);
holder = new ViewHolder();
holder.header = (TextView) convertView.findViewById(R.id.header);
holder.date = (TextView) convertView.findViewById(R.id.date);
holder.sum = (TextView) convertView.findViewById(R.id.sum);
holder.image = (ImageView) convertView.findViewById(R.id.img_direction);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Operation op = history.get(position);
holder.header.setText(op.getTitle());
String df = DateFormat.getDateInstance().format(op.getDatetime());
holder.date.setText(df);
String sum = op.getAmount().toString();
Bitmap source;
if (op.getDirection() == MoneyDirection.in)
//// sum = "+" + sum;
source = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_plus);
else
//// sum = "-" + sum;
source = BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_minus_g);
holder.image.setImageBitmap(source);
holder.sum.setText(sum);
return convertView;
}
class ViewHolder {
ImageView image;
TextView header;
TextView date;
TextView sum;
}
}
Java Source Code List com.samples.client.Settings.java com.samples.server.SampleIncomingTransferListener.java com.samples.server.ServletListener.java com.samples.yamodroid.Consts.java com.samples.yamodroid.GreatAppActivity.java ru.yandex.money.api.ApiCommandsFacadeImpl.java ru.yandex.money.api.ApiCommandsFacade.java ru.yandex.money.api.CommandUrlHolder.java ru.yandex.money.api.InsufficientScopeException.java ru.yandex.money.api.InternalServerErrorException.java ru.yandex.money.api.InvalidTokenException.java ru.yandex.money.api.ProtocolRequestException.java ru.yandex.money.api.TestUrlHolder.java ru.yandex.money.api.TokenRequesterImpl.java ru.yandex.money.api.TokenRequester.java ru.yandex.money.api.YamoneyAccount.java ru.yandex.money.api.YamoneyApiClient.java ru.yandex.money.api.YandexMoneyImpl.java ru.yandex.money.api.YandexMoney.java ru.yandex.money.api.enums.Destination.java ru.yandex.money.api.enums.MoneyDirection.java ru.yandex.money.api.enums.MoneySource.java ru.yandex.money.api.enums.OperationHistoryType.java ru.yandex.money.api.enums.Status.java ru.yandex.money.api.notifications.IncomingTransferListener.java ru.yandex.money.api.notifications.IncomingTransfer.java ru.yandex.money.api.notifications.NotificationUtils.java ru.yandex.money.api.notifications.NotificationsServlet.java ru.yandex.money.api.response.AccountInfoResponse.java ru.yandex.money.api.response.FundraisingStatsResponse.java ru.yandex.money.api.response.OperationDetailResponse.java ru.yandex.money.api.response.OperationHistoryResponse.java ru.yandex.money.api.response.ProcessPaymentResponse.java ru.yandex.money.api.response.ReceiveOAuthTokenResponse.java ru.yandex.money.api.response.RequestPaymentResponse.java ru.yandex.money.api.response.util.OperationHistoryError.java ru.yandex.money.api.response.util.Operation.java ru.yandex.money.api.response.util.PaymentErrorCode.java ru.yandex.money.api.response.util.ProcessPaymentError.java ru.yandex.money.api.response.util.RequestPaymentError.java ru.yandex.money.api.response.util.money.PaymentMethods.java ru.yandex.money.api.rights.AbstractLimitedPermission.java ru.yandex.money.api.rights.AbstractPermission.java ru.yandex.money.api.rights.AccountInfo.java ru.yandex.money.api.rights.IdentifierType.java ru.yandex.money.api.rights.MoneySource.java ru.yandex.money.api.rights.OperationDetails.java ru.yandex.money.api.rights.OperationHistory.java ru.yandex.money.api.rights.PaymentP2P.java ru.yandex.money.api.rights.PaymentShop.java ru.yandex.money.api.rights.Payment.java ru.yandex.money.api.rights.Permission.java ru.yandex.money.droid.ActivityParams.java ru.yandex.money.droid.AuthActivity.java ru.yandex.money.droid.Consts.java ru.yandex.money.droid.DetailHistoryActivity.java ru.yandex.money.droid.HistoryActivity.java ru.yandex.money.droid.HistoryAdapter.java ru.yandex.money.droid.IntentCreator.java ru.yandex.money.droid.LoadHistoryTask.java ru.yandex.money.droid.PaymentActivity.java ru.yandex.money.droid.PaymentConfirmActivity.java ru.yandex.money.droid.PaymentShopParcelable.java ru.yandex.money.droid.ProcessPaymentTask.java ru.yandex.money.droid.Utils.java ru.yandex.money.droid.YandexMoneyDroid.java