編輯:關於Android編程
在與Android交互過程中,因為Android是從低位往高位讀,iOS是從高位往低位讀,所以交互數據需要進行轉換。
/* * convert big endian to little endian in C */ uint16_t swap_uint16( uint16_t val ); int16_t swap_int16( int16_t val ); uint32_t swap_uint32( uint32_t val ); int32_t swap_int32( int32_t val ); int64_t swap_int64( int64_t val ); uint64_t swap_uint64( uint64_t val ); //////////////////////////////////////////////////////////////////////////////////////////////////// //! Byte swap unsigned short uint16_t swap_uint16( uint16_t val ) { return (val << 8) | (val >> 8 ); } //! Byte swap short int16_t swap_int16( int16_t val ) { return (val << 8) | ((val >> 8) & 0xFF); } //! Byte swap unsigned int uint32_t swap_uint32( uint32_t val ) { val = ((val << 8) & 0xFF00FF00 ) | ((val >> 8) & 0xFF00FF ); return (val << 16) | (val >> 16); } //! Byte swap int int32_t swap_int32( int32_t val ) { val = ((val << 8) & 0xFF00FF00) | ((val >> 8) & 0xFF00FF ); return (val << 16) | ((val >> 16) & 0xFFFF); } int64_t swap_int64( int64_t val ) { val = ((val << 8) & 0xFF00FF00FF00FF00ULL ) | ((val >> 8) & 0x00FF00FF00FF00FFULL ); val = ((val << 16) & 0xFFFF0000FFFF0000ULL ) | ((val >> 16) & 0x0000FFFF0000FFFFULL ); val = (val << 32) | ((val >> 32) & 0xFFFFFFFFULL); return val; } uint64_t swap_uint64( uint64_t val ) { val = ((val << 8) & 0xFF00FF00FF00FF00ULL ) | ((val >> 8) & 0x00FF00FF00FF00FFULL ); val = ((val << 16) & 0xFFFF0000FFFF0000ULL ) | ((val >> 16) & 0x0000FFFF0000FFFFULL ); val = (val << 32) | (val >> 32); return val; }
調用:
UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000; UInt64 value = swap_uint64(recordTime);
效果圖一、繪制圓環圓環故名思意,第一個首先繪制是圓環1:圓環繪制函數圓環APIpublic void drawArc (RectF oval, float startAn
本文實例為大家分享了Android仿美團下拉菜單的實現代碼,分類進行選擇,供大家參考,具體內容如下效果圖操作平台AS2.0第三方框架:butterknifebuild.g
Android事件驅動編程-基於EventBus(一) 雖然在Android開發具有某些事件驅動的特性,但它還遠不是純粹的事件驅動架構。這算是好事還是壞事呢
屬性名 用途 hibernate.dialect 一個HibernateDialect類名允許Hibernate針對特定的關系數據庫生成優化的SQL.取值