`
苹果超人
  • 浏览: 199967 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

ebooks

阅读更多
ebooks
http://www.myexception.cn/j2se/36961.html
http://blog.sina.com.cn/s/blog_6fa4ebf401016k07.html
http://my.eoe.cn/fashr314/archive/10358.html
http://wenku.baidu.com/link?url=NKuh_joeXwS3pKVTie88WElzPGaHCLEAiRgqqfiE3xiVpCGwYn-oas7RmMBmll1pRubRlDpA7MDSeSUyy4uRcsdX8GDSegA0fogzBMSWFhq

http://blog.csdn.net/luoshengyang/article/details/6946067

android源码下载
http://blog.csdn.net/hudashi/article/details/7080056

package com.denong.app.plusplus.util;

import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import com.denong.app.plusplus.Constants;
import com.denong.app.plusplus.R;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentResolver;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v4.app.Fragment;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;

/**
 * 调用相机和相册辅助工具类
 * 
 * @author Patrick.Li
 *
 */
public class CameraUtil {

	/**
	 * 打开选择相机和相册对话框
	 * 
	 * @param fragment
	 */
	public static void showSelectDialog(final Fragment fragment) {
	    String[] options = {
	    			fragment.getResources().getString(R.string.photo_camera),
	    			fragment.getResources().getString(R.string.photo_gallery)
	    			};
	    final ListAdapter adapter = new ArrayAdapter<String>(fragment.getActivity(),  
                android.R.layout.simple_list_item_1, options); 
	    
	    AlertDialog.Builder cameraSelectDialog = new AlertDialog.Builder(fragment.getActivity());
	    cameraSelectDialog.setTitle(R.string.photo_title);
	    cameraSelectDialog.setSingleChoiceItems(adapter, -1,  
                new DialogInterface.OnClickListener() {  
                    public void onClick(DialogInterface dialog, int which) {  
                        dialog.dismiss();
                        switch (which) {  
                        case 0: {
                            // 相机拍照
                        	Intent cameraIntent = getCameraIntent();
    	                	fragment.startActivityForResult(cameraIntent, Constants.CAMERA_REQUEST);
                            break;
                        }
                        case 1:
                            // 相册选择
                        	Intent galleryIntent = getGalleryIntent();
    	                	fragment.startActivityForResult(galleryIntent, Constants.GALLERY_REQUEST);
                            break;
                        }
                    }
                });
	    cameraSelectDialog.setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() {  
            @Override  
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
	    cameraSelectDialog.show();
	}

	/**
	 * 打开选择相机和相册对话框
	 * 
	 * @param activity
	 */
	public static void showSelectDialog(final Activity activity) {
		String[] options = {
				activity.getResources().getString(R.string.photo_camera),
				activity.getResources().getString(R.string.photo_gallery)
    			};
	    final ListAdapter adapter = new ArrayAdapter<String>(activity,  
	            android.R.layout.simple_list_item_1, options); 
	    
	    AlertDialog.Builder cameraSelectDialog = new AlertDialog.Builder(activity);
	    cameraSelectDialog.setTitle(R.string.photo_title);
	    cameraSelectDialog.setSingleChoiceItems(adapter, -1,  
	            new DialogInterface.OnClickListener() {  
	                public void onClick(DialogInterface dialog, int which) {  
	                    dialog.dismiss();
	                    switch (which) {  
	                    case 0: {
	                        // 相机拍照
	                    	Intent cameraIntent = getCameraIntent();
	                    	activity.startActivityForResult(cameraIntent, Constants.CAMERA_REQUEST);
	                        break;
	                    }
	                    case 1:
	                        // 相册选择
	                    	Intent galleryIntent = getGalleryIntent();
	                    	activity.startActivityForResult(galleryIntent, Constants.GALLERY_REQUEST);
	                        break;
	                    }
	                }
	            });
	    cameraSelectDialog.setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() {  
	        @Override  
	        public void onClick(DialogInterface dialog, int which) {
	            dialog.dismiss();
	        }
	    });
	    cameraSelectDialog.show();
	}
	
	/**
	 * 打开相机Intent
	 * 
	 * @return
	 */
	public static Intent getCameraIntent() {
		Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        return cameraIntent;
	}
	
	/**
	 * 打开相册Intent
	 * 
	 * @return
	 */
	public static Intent getGalleryIntent() {
		Intent cameraIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
		cameraIntent.setType("image/*");
		cameraIntent.putExtra("return-data", true);
		return cameraIntent;
	}
	
	/**
	 * 返回编辑图片的Intent
	 * 
	 * @param photoUri
	 * @return
	 */
	public static Intent getCropImageIntent(Uri photoUri) {  
        Intent intent = new Intent("com.android.camera.action.CROP");  
        intent.setDataAndType(photoUri, "image/*");  
        intent.putExtra("crop", "true");
//        intent.putExtra("aspectX", 1);
//        intent.putExtra("aspectY", 1);
//        intent.putExtra("outputX", 80);
//        intent.putExtra("outputY", 80);
        intent.putExtra("return-data", true);
        return intent;  
    }
	
	/**
	 * 打开相册并且带编辑的Intent
	 * 
	 */
    public static Intent getGalleryCropIntent() {  
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null);  
        intent.setType("image/*");  
        intent.putExtra("crop", "true");  
//        intent.putExtra("aspectX", 1);  
//        intent.putExtra("aspectY", 1);  
//        intent.putExtra("outputX", 80);  
//        intent.putExtra("outputY", 80);  
        intent.putExtra("return-data", true);  
        return intent;  
    }
	
	/**
	 * 取得拍照或者相册返回的结图片对象
	 * 
	 * @param activity
	 * @param data
	 * @return
	 */
	public static Bitmap getBitmapFromActivityForResult(final Activity activity, Intent data) {
		Bitmap bitmap = null;
		ContentResolver resolver = activity.getContentResolver();
        // 照片的原始资源地址
        Uri imgUri = data.getData();
        // 使用ContentProvider通过Uri获取原始图片  
        try {
        	bitmap = MediaStore.Images.Media.getBitmap(resolver, imgUri);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
        return bitmap;
	}
	
	/**
	 * 压缩Bitmap
	 * 
	 * @param bitmap
	 * @return
	 */
	public static Bitmap compressBitmap(Bitmap bitmap) {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
		byte[] bitmapData = stream.toByteArray();
		Bitmap compressed = BitmapFactory.decodeByteArray(bitmapData , 0, bitmapData.length);
		return compressed;
	}
	
	/**
	 * 压缩Bitmap返回字符串
	 * 
	 * @param bitmap
	 * @return
	 */
	public static String compressBitmap2String(Bitmap bitmap) {
		return new String(compressBitmap2Byte(bitmap));
	}
	
	/**
	 * 压缩Bitmap返回字符数组
	 * 
	 * @param bitmap
	 * @return
	 */
	public static byte[] compressBitmap2Byte(Bitmap bitmap) {
		ByteArrayOutputStream stream = new ByteArrayOutputStream();
		bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
		return stream.toByteArray();
	}
	
	/**
	 * 旋转图片
	 * 
	 * @param bitmap
	 * @param angle
	 * @return
	 */
	public static Bitmap rotateBitmap(Bitmap bitmap, float angle) {
		// 旋转图片 动作
		Matrix matrix = new Matrix();
		matrix.postRotate(angle);
		// 创建新的图片
		Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0,
				bitmap.getWidth(), bitmap.getHeight(), matrix, true);
		return resizedBitmap;
	}
	
	/**
	 * 返回缩略图
	 * 
	 * @param bitmap
	 * @return
	 */
	public static Bitmap createThumbnails(Bitmap bitmap) {
		BitmapFactory.Options options = new BitmapFactory.Options();
        //options.inJustDecodeBounds = true;
        options.inSampleSize = 4;
        
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
		bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
		byte[] bitmapData = stream.toByteArray();
        Bitmap image = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length, options);
        return image;
	}

}


BEGIN
	declare  currentDate varchar;
	DECLARE 'maxNo' int default 0;
	DECLARE 'oldOrderNo' varchar(25) default '';
	
	if num = 8 then
		SELECT DATE_FORMAT(NOW(), '%Y%m%d') INTO currentDate;
	else if num = 14 then
		SELECT DATE_FORMAT(NOW(), '%Y%m%d%H%i%s') INTO currentDate;
	else 
		SELECT DATE_FORMAT(NOW(), '%Y%m%d%H%i') INTO currentDate;
	end if;
	
	SELECT 
		IFNULL(orderNo, '') INTO oldOrderNo 
	FROM 
		orderNoSequence 
	WHERE
		SUBSTRING(orderNo, 3, num) = currentDate
	AND
		SUBSTRING(orderNo, 1, 2) = orderNamePrefix
	AND
		LENGTH(orderNo) = 7 + num
	ORDER BY
		id DESC
	LIMIT
		1;
		
	if oldOrderNo != '' then
		SET maxNo = CONVERT(SUBSTRING(oldOrderNo, -5), DECIMAL);
	end if;
	
	SELECT CONCAT(orderNamePrefix, currentDate, LPAD((maxNo + 1), 5, '0') into newOrderNo;
	
	INSERT INTO orderNoSequence(orderNo, orderName) VALUES (newOrderNo);
	
	SELECT newOrderNo;
END;


CREATE TABLE orderNoSequence(
id int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
orderNo varchar(25) NOT NULL DEFAULT ''
);
  • git.zip (736.2 KB)
  • 下载次数: 1
  • cxf.zip (38.1 KB)
  • 下载次数: 1
  • jmx.zip (923.2 KB)
  • 下载次数: 1
分享到:
评论

相关推荐

    基于web的ebooks电子商城开发系统

    在本项目中,"基于web的ebooks电子商城开发系统"是一个在线平台,它允许用户浏览、购买和阅读电子书籍。这个系统的核心是利用Web技术构建一个交互性强、功能完善的电商平台,旨在为用户提供便捷的电子书购买体验。...

    SAP Collection Ebooks: Course Project

    SAP Collection Ebooks: Course Project

    Matlab.ebooks.MATLAB.学习书籍.rar

    Matlab.ebooks.MATLAB.学习书籍 包含几乎所有这方面的图书 本人精心收集

    it-ebooks-archive, 计算机开放电子书(不完全)汇总.zip

    it-ebooks-archive, 计算机开放电子书(不完全)汇总

    Ebooks_barcode_ebooks_

    "Ebooks_barcode_ebooks_"这个标题和描述暗示我们将深入探讨PDF417条形码在电子书和相关应用中的运用。 PDF417条形码得名于“Portable Data File 417”,它的设计初衷是为了能够存储大量数据,远超过传统的一维条形...

    Free-Security-eBooks, 免费安全和黑客电子书.zip

    Free-Security-eBooks, 免费安全和黑客电子书 免费安全电子书 免费的免费安全和Pentesting相关电子图书列表。如果要为这里列表提供( 请做),请发送一个请求请求。 所有贡献者都将被识别和欣赏。: 捐赠者不能对数据的...

    SQL Server 2000课程设计案例精编 5 ebooks 源代码

    《SQL Server 2000课程设计案例精编 5 ebooks 源代码》是一部集实用性与教学性于一体的资源包,旨在帮助学习者深入理解和掌握SQL Server 2000数据库管理系统的核心概念、功能和应用。这个压缩包包含了五个电子书和...

    osworkflow-developer-guide.rar_OSWorkflow ebooks_OsWorkFlow.rar_

    这个压缩包"osworkflow-developer-guide.rar_OSWorkflow ebooks_OsWorkFlow.rar_"包含了关于OSWorkflow的开发者指南和相关资源,非常适合那些想要深入理解并使用OSWorkflow进行开发的人。 **OSWorkflow 概述** ...

    【应用】-iPhone eBooks.7z

    标题中的"【应用】-iPhone eBooks.7z"暗示了这是一个与iPhone电子书相关的压缩文件,可能包含了用于iOS设备的eBooks应用的源代码或相关资源。描述中的内容较为简洁,与标题相同,没有提供额外的信息。标签"iOS-...

Global site tag (gtag.js) - Google Analytics