Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programming_tips_and_tricks [2017/05/15 14:44] – [Uri에서 실제 경로를 받아오는 Method] ledyxprogramming_tips_and_tricks [2021/02/07 03:15] (current) – external edit 127.0.0.1
Line 647: Line 647:
 === 합병 정렬(Merge Sort) === === 합병 정렬(Merge Sort) ===
 [[algorithm:Merge Sort | 합병 정렬(Merge Sort)]] [[algorithm:Merge Sort | 합병 정렬(Merge Sort)]]
- 
- 
-= Design Pattern = 
- 
-== Serialization을 이용한 Deep Copy == 
-<sxh java> 
-/* Java */ 
-@SuppressWarnings("unchecked") 
-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; 
- } 
-} 
-</sxh> 
-https://github.com/xeyez/CSharp-PrototypePattern 
- 
-<sxh csharp> 
-/* C# */ 
-public static T DeepCopy<T>(T obj) 
-{ 
-        using (var ms = new MemoryStream()) 
-        { 
-            var formatter = new BinaryFormatter(); 
-            formatter.Serialize(ms, obj); 
-            ms.Position = 0; 
- 
-            return (T)formatter.Deserialize(ms); 
-        } 
-} 
-</sxh> 
-https://github.com/xeyez/Java-PrototypePattern 
- 
- 
  
  
Line 939: Line 896:
         Bitmap bitmap = BitmapFactory.decodeStream(bin, null, options);         Bitmap bitmap = BitmapFactory.decodeStream(bin, null, options);
  
-        // resize +        // resize (지정한 크기보다 작은 경우만) 
-        bitmap = resizeBitmap(bitmap, MAX_IMAGE_SIZE); +        if(bitmap.getWidth() * bitmap.getHeight() > MAX_IMAGE_SIZE * 2) 
 +            bitmap = resizeBitmap(bitmap, MAX_IMAGE_SIZE);
  
         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, null, null, null, null);         Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
         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('.') + 1)};
     }     }
 } }
 +</sxh>
 +
 +
 += Intellij - Git Bash 연동 =
 +
 +Tools -> Terminal
 +
 +<sxh bash>
 +"C:\Program Files\Git\bin\sh.exe" -login -i
 </sxh> </sxh>
programming_tips_and_tricks.1494855872.txt.gz · Last modified: 2021/02/07 03:15 (external edit)