Add volume chart highlight synchronization | fix transactions order
This commit is contained in:
parent
db013dab1e
commit
d2aaec536d
@ -621,6 +621,26 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
barChart.getXAxis().setEnabled(false);
|
barChart.getXAxis().setEnabled(false);
|
||||||
barChart.setViewPortOffsets(0, 0, 0, 0);
|
barChart.setViewPortOffsets(0, 0, 0, 0);
|
||||||
barChart.setFitBars(true);
|
barChart.setFitBars(true);
|
||||||
|
barChart.setHighlightFullBarEnabled(true);
|
||||||
|
|
||||||
|
barChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||||
|
@Override
|
||||||
|
public void onValueSelected(Entry e, Highlight h) {
|
||||||
|
barChartValueSelected(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNothingSelected() {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
barChart.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||||
|
return toucheEvent(motionEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawPriceCandleStickChart()
|
private void drawPriceCandleStickChart()
|
||||||
@ -636,7 +656,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
lineChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
lineChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onValueSelected(Entry e, Highlight h) {
|
public void onValueSelected(Entry e, Highlight h) {
|
||||||
valueSelectedEvent(e);
|
lineChartValueSelected(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -683,16 +703,29 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
lineChart.setViewPortOffsets(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void valueSelectedEvent(Entry e)
|
private void barChartValueSelected(Entry e)
|
||||||
|
{
|
||||||
|
int index = barChart.getData().getDataSets().get(0).getEntryIndex((BarEntry) e);
|
||||||
|
|
||||||
|
lineChart.highlightValue(lineChart.getData().getDataSets().get(0).getEntryForIndex(index).getX(), lineChart.getData().getDataSets().get(0).getEntryForIndex(index).getY(), 0);
|
||||||
|
generatePlaceHoldersFromIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lineChartValueSelected(Entry e)
|
||||||
{
|
{
|
||||||
int index = lineChart.getData().getDataSets().get(0).getEntryIndex(e);
|
int index = lineChart.getData().getDataSets().get(0).getEntryIndex(e);
|
||||||
|
|
||||||
|
barChart.highlightValue(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getX(), 0, index);
|
||||||
|
generatePlaceHoldersFromIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void generatePlaceHoldersFromIndex(int index)
|
||||||
|
{
|
||||||
String date;
|
String date;
|
||||||
String volumePlaceholder;
|
String volumePlaceholder;
|
||||||
String pricePlaceholder;
|
String pricePlaceholder;
|
||||||
String timestampPlaceholder;
|
String timestampPlaceholder;
|
||||||
|
|
||||||
barChart.highlightValue(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getX(), 0, index);
|
|
||||||
|
|
||||||
if(dataChartList.size() > 200)
|
if(dataChartList.size() > 200)
|
||||||
{
|
{
|
||||||
date = getDateFromTimestamp(dataChartList.get((int) Math.floor(dataChartList.size() / 200) * index).getTimestamp() * 1000);
|
date = getDateFromTimestamp(dataChartList.get((int) Math.floor(dataChartList.size() / 200) * index).getTimestamp() * 1000);
|
||||||
@ -703,7 +736,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
volumePlaceholder = PlaceholderManager.getVolumeString(numberConformer(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getY()), this);
|
volumePlaceholder = PlaceholderManager.getVolumeString(numberConformer(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getY()), this);
|
||||||
pricePlaceholder = PlaceholderManager.getPriceString(numberConformer(e.getY()), this);
|
pricePlaceholder = PlaceholderManager.getPriceString(numberConformer((lineChart.getHighlighted())[0].getY()), this);
|
||||||
timestampPlaceholder = PlaceholderManager.getTimestampString(date, this);
|
timestampPlaceholder = PlaceholderManager.getTimestampString(date, this);
|
||||||
|
|
||||||
((TextView) findViewById(R.id.volumeHightlight)).setText(volumePlaceholder);
|
((TextView) findViewById(R.id.volumeHightlight)).setText(volumePlaceholder);
|
||||||
@ -712,7 +745,6 @@ public class CurrencyDetailsActivity extends AppCompatActivity {
|
|||||||
findViewById(R.id.priceHightlight).setVisibility(View.VISIBLE);
|
findViewById(R.id.priceHightlight).setVisibility(View.VISIBLE);
|
||||||
((TextView) findViewById(R.id.timestampHightlight)).setText(timestampPlaceholder);
|
((TextView) findViewById(R.id.timestampHightlight)).setText(timestampPlaceholder);
|
||||||
findViewById(R.id.timestampHightlight).setVisibility(View.VISIBLE);
|
findViewById(R.id.timestampHightlight).setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean toucheEvent(MotionEvent motionEvent)
|
private boolean toucheEvent(MotionEvent motionEvent)
|
||||||
|
@ -204,10 +204,11 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
|
|
||||||
ArrayList<Transaction> transactionList = new ArrayList<>();
|
ArrayList<Transaction> transactionList = new ArrayList<>();
|
||||||
|
|
||||||
while(resultatList.moveToNext())
|
resultatList.moveToLast();
|
||||||
{
|
|
||||||
|
do {
|
||||||
transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(3), resultatList.getLong(4), resultatList.getLong(5), resultatList.getDouble(7)));
|
transactionList.add(new Transaction(resultatList.getInt(0), resultatList.getString(1), resultatList.getDouble(3), resultatList.getLong(4), resultatList.getLong(5), resultatList.getDouble(7)));
|
||||||
}
|
} while(resultatList.moveToPrevious());
|
||||||
|
|
||||||
resultatList.close();
|
resultatList.close();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user