Android Open Source - Custom-SwipeListView Custom Swipe Utils






From Project

Back to project page Custom-SwipeListView.

License

The source code is released under:

Apache License

If you think the Android project Custom-SwipeListView 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

/*
 *  COPYRIGHT NOTICE  //from   w  w  w.  ja v a  2s . co m
 *  Copyright (C) 2015, xyczero <xiayuncheng1991@gmail.com>
 *  
 *    http://www.xyczero.com/
 *   
 *  @license under the Apache License, Version 2.0 
 *
 *  @file    CustomSwipeUtils.java
 *  @brief   Custom Swipe Tool Set
 *  
 *  @version 1.0     
 *  @author  xyczero
 *  @date    2015/01/12    
 */
package com.xyczero.customswipelistview;

import android.content.Context;

/**
 * Common utils is designed for CustomSwipeListview
 * 
 * @author xyczero
 * 
 */
public class CustomSwipeUtils {

  /**
   * convert dp(dip) to pixel
   * 
   * @param context
   *            The context of the Activity
   * @param dpValue
   *            The value of dp(dip)
   * @return
   */
  public static int convertDptoPx(Context context, final float dpValue) {
    final float density = context.getResources().getDisplayMetrics().density;
    // +0.5f is designed to prevent that one dip convert zero pixel when the
    // machine's density is less than one;
    return (int) (dpValue * density + 0.5f);
  }

  /**
   * 
   * @param context
   *            The context of the Activity
   * @return get the width of the screen in pixel
   */
  public static int getScreenWidth(Context context) {
    return context.getResources().getDisplayMetrics().widthPixels;
  }
}




Java Source Code List

com.xyczero.customswipelistview.CustomSwipeBaseAdapter.java
com.xyczero.customswipelistview.CustomSwipeBaseAdapter.java
com.xyczero.customswipelistview.CustomSwipeListView.java
com.xyczero.customswipelistview.CustomSwipeListView.java
com.xyczero.customswipelistview.CustomSwipeUndoDialog.java
com.xyczero.customswipelistview.CustomSwipeUndoDialog.java
com.xyczero.customswipelistview.CustomSwipeUtils.java
com.xyczero.customswipelistview.CustomSwipeUtils.java
com.xyczero.customswipelistview.OnUndoActionListener.java
com.xyczero.customswipelistview.OnUndoActionListener.java