Android Open Source - DynamicGrid Dynamic Grid Utils






From Project

Back to project page DynamicGrid.

License

The source code is released under:

Apache License

If you think the Android project DynamicGrid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.askerov.dynamicgrid;
//from w w  w. j a  v  a2 s  . c  om
import android.view.View;

import java.util.ArrayList;
import java.util.List;

/**
 * Author: alex askerov
 * Date: 9/7/13
 * Time: 10:14 PM
 */
public class DynamicGridUtils {
    /**
     * Delete item in <code>list</code> from position <code>indexFrom</code> and insert it to <code>indexTwo</code>
     *
     * @param list
     * @param indexFrom
     * @param indexTwo
     */
    public static void reorder(List list, int indexFrom, int indexTwo) {
        Object obj = list.remove(indexFrom);
        list.add(indexTwo, obj);
    }

    /**
     * Swap item in <code>list</code> at position <code>firstIndex</code> with item at position <code>secondIndex</code>
     *
     * @param list The list in which to swap the items.
     * @param firstIndex The position of the first item in the list.
     * @param secondIndex The position of the second item in the list.
     */
    public static void swap(List list, int firstIndex, int secondIndex) {
        Object firstObject = list.get(firstIndex);
        Object secondObject = list.get(secondIndex);
        list.set(firstIndex, secondObject);
        list.set(secondIndex, firstObject);
    }

    public static float getViewX(View view) {
        return Math.abs((view.getRight() - view.getLeft()) / 2);
    }

    public static float getViewY(View view) {
        return Math.abs((view.getBottom() - view.getTop()) / 2);
    }
}




Java Source Code List

org.askerov.dynamicgrid.AbstractDynamicGridAdapter.java
org.askerov.dynamicgrid.BaseDynamicGridAdapter.java
org.askerov.dynamicgrid.DynamicGridAdapterInterface.java
org.askerov.dynamicgrid.DynamicGridUtils.java
org.askerov.dynamicgrid.DynamicGridView.java
org.askerov.dynamicgrid.example.CheeseDynamicAdapter.java
org.askerov.dynamicgrid.example.Cheeses.java
org.askerov.dynamicgrid.example.GridActivity.java