├── .Archive └── code block.md │ ├── 2017-08-04 16-43-49.md │ ├── 2017-08-04 16-44-59.md │ └── 2017-08-04 16-46-19.md ├── OpenSysMedia ├── .gitignore ├── .idea │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── gradle.xml │ ├── misc.xml │ ├── modules.xml │ ├── runConfigurations.xml │ └── vcs.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ └── com │ │ │ └── codexiaosheng │ │ │ └── opensysmedia │ │ │ └── MainActivity.java │ │ └── res │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle ├── README.md ├── _image └── 项目分包.png ├── codeBlock.md ├── codeXiaoSheng17_end.md ├── codeXiaoSheng17_middle.md └── codexiaosheng18.md /.Archive/code block.md/2017-08-04 16-43-49.md: -------------------------------------------------------------------------------- 1 | ```java 2 | /** 3 | * bitmap转为base64 4 | * @param bitmap 5 | * @return 6 | */ 7 | public static String bitmapToBase64(Bitmap bitmap) { 8 | 9 | String result = null; 10 | ByteArrayOutputStream baos = null; 11 | try { 12 | if (bitmap != null) { 13 | baos = new ByteArrayOutputStream(); 14 | bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); 15 | 16 | baos.flush(); 17 | baos.close(); 18 | 19 | byte[] bitmapBytes = baos.toByteArray(); 20 | result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT); 21 | } 22 | } catch (IOException e) { 23 | e.printStackTrace(); 24 | } finally { 25 | try { 26 | if (baos != null) { 27 | baos.flush(); 28 | baos.close(); 29 | } 30 | } catch (IOException e) { 31 | e.printStackTrace(); 32 | } 33 | } 34 | return result; 35 | } 36 | 37 | /** 38 | * base64转为bitmap 39 | * @param base64Data 40 | * @return 41 | */ 42 | public static Bitmap base64ToBitmap(String base64Data) { 43 | byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT); 44 | return BitmapFactory.decodeByteArray(bytes, 0, bytes.length); 45 | } 46 | ``` 47 | - - - 48 | ```java 49 | //ScrollView嵌套WebView(ViewPager等)冲突解决 50 | webView.setOnTouchListener(new View.OnTouchListener() { 51 | @Override 52 | public boolean onTouch(View view, MotionEvent motionEvent) { 53 | switch (motionEvent.getAction()) { 54 | case MotionEvent.ACTION_DOWN: 55 | case MotionEvent.ACTION_MOVE: 56 | scrollView.requestDisallowInterceptTouchEvent(true); 57 | break; 58 | case MotionEvent.ACTION_UP: 59 | scrollView.requestDisallowInterceptTouchEvent(false); 60 | break; 61 | } 62 | return false; 63 | } 64 | }); 65 | ``` 66 | - - - 67 | ```java 68 | /** 69 | * EditText设置编辑和不可编辑,相互切换 70 | *①在xml中设置属性 focusable="false"; 71 | *②可编辑代码 72 | */ 73 | editText.setFocusableInTouchMode(true); 74 | editText.setFocusable(true); 75 | editText.requestFocus(); 76 | //不可编辑代码: 77 | editText.setFocusable(false); 78 | editText.setFocusableInTouchMode(false); 79 | ``` 80 | - - - 81 | ```java 82 | /** 83 | * 毫秒值(long)转指定日期格式 84 | */ 85 | SimpleDateFormat simple = new SimpleDateFormat("yyyy年MM月dd日 HH:mm"); 86 | Date date = new Date(Long.parseLong("时间字符串")); 87 | String time = simple.format(date); 88 | ``` 89 | - - - - - 90 | ```java 91 | /** 92 | * 获取本地时间,显示指定格式 93 | */ 94 | SimpleDateFormat simple = new SimpleDateFormat("yyyy年MM月dd日"); 95 | Date date = new Date(System.currentTimeMillis()); 96 | String currentTime = simple.format(date); 97 | ``` 98 | - - - - - 99 | ```xml 100 | /** 101 | * Android 5.0以上版本去掉 Button 自带阴影效果 102 | */ 103 |