MoveViewJob.java
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.github.mikephil.charting.jobs;
import android.view.View;
import com.github.mikephil.charting.utils.ObjectPool;
import com.github.mikephil.charting.utils.Transformer;
import com.github.mikephil.charting.utils.ViewPortHandler;
/**
* Created by Philipp Jahoda on 19/02/16.
*/
public class MoveViewJob extends ViewPortJob {
private static ObjectPool<MoveViewJob> pool;
static {
pool = ObjectPool.create(2, new MoveViewJob(null,0,0,null,null));
pool.setReplenishPercentage(0.5f);
}
public static MoveViewJob getInstance(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v){
MoveViewJob result = pool.get();
result.mViewPortHandler = viewPortHandler;
result.xValue = xValue;
result.yValue = yValue;
result.mTrans = trans;
result.view = v;
return result;
}
public static void recycleInstance(MoveViewJob instance){
pool.recycle(instance);
}
public MoveViewJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, View v) {
super(viewPortHandler, xValue, yValue, trans, v);
}
@Override
public void run() {
pts[0] = xValue;
pts[1] = yValue;
mTrans.pointValuesToPixel(pts);
mViewPortHandler.centerViewPort(pts, view);
this.recycleInstance(this);
}
@Override
protected ObjectPool.Poolable instantiate() {
return new MoveViewJob(mViewPortHandler, xValue, yValue, mTrans, view);
}
}