This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programming_tips_and_tricks [2017/05/15 13:44] – [Uri에서 실제 경로를 받아오는 Method] ledyx | programming_tips_and_tricks [2021/02/07 03:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 647: | Line 647: | ||
| === 합병 정렬(Merge Sort) === | === 합병 정렬(Merge Sort) === | ||
| [[algorithm: | [[algorithm: | ||
| - | |||
| - | |||
| - | = Design Pattern = | ||
| - | |||
| - | == Serialization을 이용한 Deep Copy == | ||
| - | <sxh java> | ||
| - | /* Java */ | ||
| - | @SuppressWarnings(" | ||
| - | public static <T> T deepCopy(T obj) { | ||
| - | try { | ||
| - | ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| - | ObjectOutputStream oos = new ObjectOutputStream(baos); | ||
| - | oos.writeObject(obj); | ||
| - | |||
| - | ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); | ||
| - | ObjectInputStream ois = new ObjectInputStream(bais); | ||
| - | return (T) ois.readObject(); | ||
| - | } catch (IOException e) { | ||
| - | return null; | ||
| - | } catch (ClassNotFoundException e) { | ||
| - | return null; | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | https:// | ||
| - | |||
| - | <sxh csharp> | ||
| - | /* C# */ | ||
| - | public static T DeepCopy< | ||
| - | { | ||
| - | using (var ms = new MemoryStream()) | ||
| - | { | ||
| - | var formatter = new BinaryFormatter(); | ||
| - | formatter.Serialize(ms, | ||
| - | ms.Position = 0; | ||
| - | |||
| - | return (T)formatter.Deserialize(ms); | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | https:// | ||
| - | |||
| - | |||
| Line 939: | Line 896: | ||
| Bitmap bitmap = BitmapFactory.decodeStream(bin, | Bitmap bitmap = BitmapFactory.decodeStream(bin, | ||
| - | // resize | + | // resize |
| - | bitmap = resizeBitmap(bitmap, | + | |
| + | | ||
| int compressQuality = 100; | int compressQuality = 100; | ||
| Line 1017: | Line 974: | ||
| * @return | * @return | ||
| */ | */ | ||
| - | public static String getRealImagePath (Context context, Uri uri) { | + | public static String getRealImagePath(Context context, Uri uri) { |
| Cursor cursor = context.getContentResolver().query(uri, | Cursor cursor = context.getContentResolver().query(uri, | ||
| cursor.moveToFirst(); | cursor.moveToFirst(); | ||
| int index = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); | int index = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); | ||
| return cursor.getString(index); | return cursor.getString(index); | ||
| + | } | ||
| + | |||
| + | /** | ||
| + | * [0] : fileName | ||
| + | * [1] : extension | ||
| + | * @param filePath | ||
| + | * @return | ||
| + | */ | ||
| + | public static String[] getFileNameAndExtension(String filePath) { | ||
| + | return new String[] {filePath.substring(filePath.lastIndexOf(File.pathSeparator) + 1), filePath.substring(filePath.lastIndexOf(' | ||
| } | } | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | = Intellij - Git Bash 연동 = | ||
| + | |||
| + | Tools -> Terminal | ||
| + | |||
| + | <sxh bash> | ||
| + | " | ||
| </ | </ | ||