Skip to content

Commit

Permalink
added time to CSV for data logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadroid committed Sep 10, 2014
1 parent 8c749fe commit 2ff1a42
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class FacebookShield extends ControllerParent<FacebookShield> {
private String lastPost;
private Fragment fragment;
private static final byte UPDATE_STATUS_METHOD_ID = (byte) 0x01;
// private static final byte SEND_MESSAGE_METHOD_ID = (byte) 0x03;
// private static final byte SEND_MESSAGE_METHOD_ID = (byte) 0x03;
private static final byte UPLOAD_PHOTO_METHOD_ID = (byte) 0x02;

static final String PREF_KEY_FACEBOOK_USERNAME = "FacebookName";
Expand Down Expand Up @@ -133,14 +133,14 @@ public static interface FacebookEventHandler {
void stopProgress();
}

public void loginToFacebook(boolean isBtnPressed) {
public void loginToFacebook() {
Session session = Session.getActiveSession();
if (session == null) {
session = new Session.Builder(activity).setApplicationId(
activity.getThisApplication().socialKeys.facebookID)
.build();
Session.setActiveSession(session);
loginToFacebook(isBtnPressed);
loginToFacebook();
} else if (!session.isOpened()) {
session.openForRead(new Session.OpenRequest(fragment)
.setCallback(statusCallback));
Expand Down Expand Up @@ -306,42 +306,42 @@ public void onCompleted(Response response) {

}

// private void sendMessage(final String message, final String to) {
// Session session = Session.getActiveSession();
//
// if (session != null) {
//
// Bundle postParams = new Bundle();
// postParams.putString("message", message);
// postParams.putString("to", to);
// Request.Callback callback = new Request.Callback() {
// public void onCompleted(Response response) {
// FacebookRequestError error = response.getError();
// if (error != null) {
// if (eventHandler != null) {
// Log.sysOut("$#$#$ " + error);
// eventHandler.stopProgress();
// eventHandler.onFacebookError(error
// .getErrorMessage());
// }
// return;
// }
// if (eventHandler != null) {
// eventHandler.onRecievePost("Message Sent to " + to
// + " Saying " + message);
// eventHandler.stopProgress();
// }
// }
// };
//
// Request request = new Request(session, "me/messages", postParams,
// HttpMethod.POST, callback);
//
// RequestAsyncTask task = new RequestAsyncTask(request);
// task.execute();
// }
//
// }
// private void sendMessage(final String message, final String to) {
// Session session = Session.getActiveSession();
//
// if (session != null) {
//
// Bundle postParams = new Bundle();
// postParams.putString("message", message);
// postParams.putString("to", to);
// Request.Callback callback = new Request.Callback() {
// public void onCompleted(Response response) {
// FacebookRequestError error = response.getError();
// if (error != null) {
// if (eventHandler != null) {
// Log.sysOut("$#$#$ " + error);
// eventHandler.stopProgress();
// eventHandler.onFacebookError(error
// .getErrorMessage());
// }
// return;
// }
// if (eventHandler != null) {
// eventHandler.onRecievePost("Message Sent to " + to
// + " Saying " + message);
// eventHandler.stopProgress();
// }
// }
// };
//
// Request request = new Request(session, "me/messages", postParams,
// HttpMethod.POST, callback);
//
// RequestAsyncTask task = new RequestAsyncTask(request);
// task.execute();
// }
//
// }

public void uploadImage(final String path, final String msg) {
new AsyncTask<Void, Void, Void>() {
Expand All @@ -351,14 +351,11 @@ public void uploadImage(final String path, final String msg) {
@Override
protected Void doInBackground(Void... params) {
int rotate = ImageUtils.getCameraPhotoOrientation(path);
Bitmap scaledBitmap = ImageUtils.decodeFile(new File(path),
1024);
Bitmap scaledBitmap = ImageUtils.decodeFile(new File(path),1024);
Matrix matrix = new Matrix();
matrix.postRotate(rotate);
bi = Bitmap.createBitmap(scaledBitmap, 0, 0,
scaledBitmap.getWidth(), scaledBitmap.getHeight(),
matrix, true);
// scaledBitmap.recycle();
bi = Bitmap.createBitmap(scaledBitmap , 0, 0, scaledBitmap .getWidth(), scaledBitmap .getHeight(), matrix, true);
//scaledBitmap.recycle();
return null;
}

Expand All @@ -373,7 +370,7 @@ protected void onPostExecute(final Void result1) {
data = baos.toByteArray();
Bundle postParams = new Bundle();
postParams.putString("message", msg);
// postParams.putString("method", "photos.upload");
//postParams.putString("method", "photos.upload");
postParams.putByteArray("source", data);
Request.Callback callback = new Request.Callback() {
public void onCompleted(Response response) {
Expand All @@ -393,14 +390,12 @@ public void onCompleted(Response response) {
System.gc();
if (eventHandler != null) {
eventHandler.stopProgress();
Toast.makeText(activity, "Image Uploaded!",
Toast.LENGTH_SHORT).show();
Toast.makeText(activity, "Image Uploaded!", Toast.LENGTH_SHORT).show();
eventHandler.onRecievePost(msg);
}
}
};
Toast.makeText(activity, "Uploading your image!",
Toast.LENGTH_SHORT).show();
Toast.makeText(activity, "Uploading your image!", Toast.LENGTH_SHORT).show();
Request request = new Request(session, "me/photos",
postParams, HttpMethod.POST, callback);

Expand Down Expand Up @@ -428,17 +423,16 @@ public void onNewShieldFrameReceived(ShieldFrame frame) {
if (frame.getFunctionId() == UPDATE_STATUS_METHOD_ID)
publishStory(lastPost);
else if (frame.getFunctionId() == UPLOAD_PHOTO_METHOD_ID) {
String imgPath = null;
byte sourceFolderId = frame.getArgument(1)[0];
if (sourceFolderId == SocialUtils.FROM_ONESHEELD_FOLDER)
imgPath = SocialUtils
.getLastCapturedImagePathFromOneSheeldFolder(activity);
else if (sourceFolderId == SocialUtils.FROM_CAMERA_FOLDER)
imgPath = SocialUtils
.getLastCapturedImagePathFromCameraFolder(activity);
if (imgPath != null) {
uploadImage(imgPath, lastPost);
}
String imgPath=null;
byte sourceFolderId=frame.getArgument(1)[0];
if(sourceFolderId==SocialUtils.FROM_ONESHEELD_FOLDER)
imgPath=SocialUtils.getLastCapturedImagePathFromOneSheeldFolder(activity);
else if (sourceFolderId==SocialUtils.FROM_CAMERA_FOLDER)
imgPath=SocialUtils.getLastCapturedImagePathFromCameraFolder(activity);
if (imgPath!=null){
uploadImage(
imgPath,
lastPost);}
}
// if (frame.getFunctionId() == SEND_MESSAGE_METHOD_ID)
// sendMessage(lastPost, frame.getArgumentAsString(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ private void checkLogin() {
buttonToLoggedIn();
} else {
buttonToLoggedOut();
((FacebookShield) getApplication().getRunningShields().get(
getControllerTag())).loginToFacebook(false);
}
}

Expand Down Expand Up @@ -244,7 +242,7 @@ private void loginToFacebook() {
if (ConnectionDetector.isConnectingToInternet(activity))

((FacebookShield) getApplication().getRunningShields().get(
getControllerTag())).loginToFacebook(true);
getControllerTag())).loginToFacebook();
else
Toast.makeText(getApplication().getApplicationContext(),
"Please check your Internet connection and try again.",
Expand Down

0 comments on commit 2ff1a42

Please sign in to comment.