Skip to content

Instantly share code, notes, and snippets.

@btow
Created August 18, 2017 11:52
Show Gist options
  • Save btow/adeb619808aa8583eadb5e32d00e698a to your computer and use it in GitHub Desktop.
Save btow/adeb619808aa8583eadb5e32d00e698a to your computer and use it in GitHub Desktop.
ErrorReport ListQiwiUsersBalancesAdapter
package com.example.module_00_lib.model;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.example.module_00_lib.R;
import java.text.DecimalFormat;
import java.util.List;
public class ListQiwiUsersBalancesAdapter extends RecyclerView.Adapter<ListQiwiUsersBalancesAdapter.ViewHolder>{
private List<QiwiUsersBalances> mDataset;
private OnItemClickListener mOnItemClickListener;
// класс view holder-а с помощью которого мы получаем ссылку на каждый элемент
// отдельного пункта списка
public static class ViewHolder extends RecyclerView.ViewHolder {
// ълемент состоит из двух TextView
private TextView mTvRecyclerItemBalance;
public ViewHolder(View v) {
super(v);
mTvRecyclerItemBalance = (TextView) v.findViewById(R.id.tvRecyclerItemBalance);
}
public TextView getTvRecyclerItemBalance() {
return mTvRecyclerItemBalance;
}
}
// Конструктор
public ListQiwiUsersBalancesAdapter(List<QiwiUsersBalances> dataset) {
mDataset = dataset;
}
// Создает новые views (вызывается layout manager-ом)
@Override
public ListQiwiUsersBalancesAdapter.ViewHolder onCreateViewHolder(
ViewGroup parent, int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_item_balances, parent, false);
// тут можно программно менять атрибуты лэйаута (size, margins, paddings и др.)
ViewHolder vh = new ViewHolder(v);
return vh;
}
// Заменяет контент отдельного view (вызывается layout manager-ом)
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
String pattern = "###,###.##";
switch (mDataset.get(position).getCurrency()) {
case "KZT":
pattern += " тңг";
break;
case "RUB":
pattern += " руб.";
break;
case "USD":
pattern = "$ " + pattern;
break;
case "EUR":
pattern = "€ " + pattern;
break;
default:
break;
}
DecimalFormat df = new DecimalFormat(pattern);
String output = df.format(mDataset.get(position).getAmount());
holder.getTvRecyclerItemBalance().setText(output);
}
// Возвращает размер данных (вызывается layout manager-ом)
@Override
public int getItemCount() {
return mDataset.size();
}
//Интерфейс обработки нажатия на элемент списка
public interface OnItemClickListener {
public void onItemClick(View view, int position);
}
public void SetOnItemClickListener(final ListQiwiUsersBalancesAdapter.OnItemClickListener onItemClickListener) {
mOnItemClickListener = onItemClickListener;
}
}
08-18 11:49:34.669 18656-18656/com.example.users_interface E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.users_interface, PID: 18656
java.lang.IllegalArgumentException: Unquoted special character '.' in pattern "###,###.## руб."
at android.icu.text.DecimalFormat.patternError(DecimalFormat.java:5171)
at android.icu.text.DecimalFormat.applyPatternWithoutExpandAffix(DecimalFormat.java:4894)
at android.icu.text.DecimalFormat.createFromPatternAndSymbols(DecimalFormat.java:704)
at android.icu.text.DecimalFormat.<init>(DecimalFormat.java:693)
at java.text.DecimalFormat.init(DecimalFormat.java:470)
at java.text.DecimalFormat.<init>(DecimalFormat.java:438)
at com.example.module_00_lib.model.ListQiwiUsersBalancesAdapter.onBindViewHolder(ListQiwiUsersBalancesAdapter.java:77)
at com.example.module_00_lib.model.ListQiwiUsersBalancesAdapter.onBindViewHolder(ListQiwiUsersBalancesAdapter.java:14)
at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6400)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6433)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5377)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5640)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5482)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5478)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2215)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1542)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1502)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3625)
at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3067)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:21998)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1148)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:687)
at android.view.View.measure(View.java:21998)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:958)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:21998)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6580)
08-18 11:49:34.669 18656-18656/com.example.users_interface E/AndroidRuntime: at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:721)
at android.view.View.measure(View.java:21998)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2410)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1498)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1751)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1386)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6733)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment