Created
March 30, 2017 11:10
-
-
Save anonymous/ac97b84681aa933638ed6fda345bd633 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OnlineAdapter extends RecyclerView.Adapter<OnlineAdapter.RowsViewHolder> { | |
private List<PriceOffer> currentList = new ArrayList<>(); | |
public static ArrayList<BarEntry> entries = new ArrayList<>(); | |
public static ArrayList<String> list = new ArrayList<>(); | |
public static ArrayList<String> data = new ArrayList<>(); | |
Context context; | |
int count = 0; | |
public static class RowsViewHolder extends RecyclerView.ViewHolder{ | |
LinearLayout linearLayout; | |
HorizontalBarChart barChart; | |
public RowsViewHolder(View itemView) { | |
super(itemView); | |
linearLayout = (LinearLayout) itemView.findViewById(R.id.onlineauctionadapter_layout); | |
barChart = (HorizontalBarChart) itemView.findViewById(R.id.barchart); | |
} | |
} | |
public OnlineAdapter( Context context) { | |
this.context = context; | |
} | |
public OnlineAdapter(ArrayList<String> list){ | |
this.data = list; | |
} | |
public void setData(List<PriceOffer> data) { | |
// currentList.clear(); | |
currentList.size(); | |
currentList.addAll(data); | |
Log.d("SET DATA ", String.valueOf(currentList.size())); | |
notifyDataSetChanged(); | |
} | |
@Override | |
public OnlineAdapter.RowsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.onlineauction_adapter, parent, false); | |
return new RowsViewHolder(view); | |
} | |
@Override | |
public void onBindViewHolder(RowsViewHolder holder, int position) { | |
// ArrayList<BarEntry> barEntry = new ArrayList<BarEntry>(); | |
// barEntry.add(new BarEntry(currentList.get(position).getLotPriceOffer(), count++)); | |
// entries.add(barEntry); | |
// BarDataSet dataSet = new BarDataSet(barEntry, data.toString()); | |
// | |
// list.add(currentList.get(position).getFirmName()); | |
// BarData barData = new BarData(list, dataSet); | |
List<BarEntry> entries = new ArrayList<>(); | |
ArrayList<String> list = new ArrayList<>(); | |
for (int i = 0; i < currentList.size(); i++) { | |
BarEntry barEntry = new BarEntry(currentList.get(position).getLotPriceOffer(), i); | |
entries.add(barEntry); | |
list.add(currentList.get(i).getFirmName()); | |
} | |
BarDataSet dataSet = new BarDataSet(entries, data.toString()); | |
BarData barData = new BarData(list, dataSet); | |
dataSet.setColors(new int[]{Color.argb(42, 92, 92, 98)}); | |
barData.setValueTextSize(10f); | |
holder.barChart.setData(barData); | |
holder.barChart.animateY(5000); | |
holder.barChart.setDrawBarShadow(false); | |
holder.barChart.setDrawValueAboveBar(false); | |
holder.barChart.setDrawGridBackground(false); | |
holder.barChart.setDescription(""); | |
holder.barChart.setNoDataText(""); | |
holder.barChart.setNoDataTextDescription(""); | |
holder.barChart.getAxisLeft().setDrawLabels(false); | |
// barChart.getLegend().setEnabled(false); | |
holder.barChart.getAxisRight().setDrawLabels(false); | |
holder.barChart.setDescriptionTextSize(12); | |
} | |
@Override | |
public int getItemCount() { | |
return currentList.size(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment