Skip to content

Commit

Permalink
Added iOS Version. Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cinder92 committed Nov 30, 2017
1 parent 88c2c0c commit 2996a87
Show file tree
Hide file tree
Showing 11 changed files with 655 additions and 190 deletions.
10 changes: 7 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ buildscript {
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 16
targetSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
Expand All @@ -30,7 +30,11 @@ repositories {
mavenCentral()
}


dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.facebook.react:react-native:+'
compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
compile files('src/main/libs/jid3lib-0.5.4.jar')
}

Large diffs are not rendered by default.

29 changes: 20 additions & 9 deletions android/src/main/java/com/reactlibrary/ReactNativeFileManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.reactlibrary;

import android.graphics.Bitmap;
import android.util.Base64;
import android.util.Log;

import java.io.ByteArrayOutputStream;
import java.io.File;
Expand All @@ -13,29 +15,38 @@

public class ReactNativeFileManager extends ReactNativeBlurImage{
public String saveImageToStorageAndGetPath(String pathToImg, Bitmap songImage) throws IOException {
if (songImage != null) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
songImage.compress(Bitmap.CompressFormat.JPEG, 60, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
try{

if(byteArray != null) {
this.saveToStorage(pathToImg, byteArray);
if (songImage != null) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
songImage.compress(Bitmap.CompressFormat.JPEG, 60, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream.toByteArray();
String encodedImage = Base64.encodeToString(byteArray, Base64.DEFAULT);
byte[] imageByte = Base64.decode(encodedImage, Base64.DEFAULT);

return pathToImg;
if(byteArray != null) {
saveToStorage(pathToImg, imageByte);

return pathToImg;
}
}

} catch (IOException e){
Log.e("Error savingImageAfter",e.getMessage());
}

return null;
return "";
}



public void saveToStorage(String pathToImg, byte[] imageBytes) throws IOException {
FileOutputStream fos = null;
try {
File filePath = new File(pathToImg);
fos = new FileOutputStream(filePath, true);
fos.write(imageBytes);
} catch (IOException e){
Log.e("Error saving image => ",e.getMessage());
} finally {
if (fos != null) {
fos.flush();
Expand Down
Binary file added android/src/main/libs/jid3lib-0.5.4.jar
Binary file not shown.
31 changes: 28 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@

import { NativeModules } from 'react-native';
import { NativeModules, Platform } from 'react-native';

const { RNReatNativeGetMusicFiles } = NativeModules;
const { RNReactNativeGetMusicFiles } = NativeModules;

export default RNReatNativeGetMusicFiles;
const MusicFiles = {
getAll(options){

return new Promise((resolve, reject) => {

if(Platform.OS === "android"){
RNReactNativeGetMusicFiles.getAll(options,(response) => {
resolve(response);
},(error) => {
reject(error);
});
}else{
RNReactNativeGetMusicFiles.getAll(options, (tracks) => {
if(tracks.length > 0){
resolve(tracks);
}else{
reject(false);
}
});
}

});

}
}
export default MusicFiles;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#import <React/RCTBridgeModule.h>
#endif

@interface RNReatNativeGetMusicFiles : NSObject <RCTBridgeModule>
#import <Foundation/Foundation.h>

@interface RNReactNativeGetMusicFiles : NSObject <RCTBridgeModule>

@end

Loading

0 comments on commit 2996a87

Please sign in to comment.