@Override protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); Attraction attraction = intent.getParcelableExtra("attraction"); setTitle(attraction.getName()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_image_viewer); ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager); ImageAdapter adapter = new ImageAdapter(this, attraction); viewPager.setAdapter(adapter); CirclePageIndicator indicator = (CirclePageIndicator) findViewById(R.id.indicator); indicator.setViewPager(viewPager); final float density = getResources().getDisplayMetrics().density; // Set circle indicator radius indicator.setRadius(5 * density); indicator.setFillColor(R.color.colorPrimaryDark); indicator.setStrokeColor(R.color.text_color); }
/** * Creates a attractive or repulsive force between the two given nodes. If the two nodes already * have a force between them, it will be replaced by this one. * * @param node1 First of the two nodes to have a force between them. * @param node2 Second of the two nodes to have a force between them. * @param force Force to create between the two nodes. If positive, the nodes will attract each * other, if negative they will repulse. The larger the magnitude the stronger the force. * @param minDistance Minimum distance within which no force is applied. * @return True if the viewer contains the two nodes and a force between them has been created. */ public boolean addForce(N node1, N node2, float force, float minDistance) { Particle p1 = nodes.get(node1); if (p1 == null) { return false; } Particle p2 = nodes.get(node2); if (p2 == null) { return false; } // We may have to remove existing force if it exists between these two nodes. for (int i = 0; i < physics.getNumAttractions(); i++) { Attraction a = physics.getAttraction(i); if (((a.getOneEnd() == p1) && (a.getTheOtherEnd() == p2)) || ((a.getOneEnd() == p2) && (a.getTheOtherEnd() == p1))) { physics.removeAttraction(a); break; } } // Add the new force. physics.makeAttraction(p1, p2, force, minDistance); return false; }