-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'teamOSC/signon'
Conflicts: app/build.gradle app/src/main/java/in/tosc/studddin/externalapi/FacebookApi.java app/src/main/java/in/tosc/studddin/fragments/people/ViewPerson.java
- Loading branch information
Showing
14 changed files
with
180 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
app/src/main/java/in/tosc/studddin/fragments/signon/FetchUserPhotos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package in.tosc.studddin.fragments.signon; | ||
|
||
import android.graphics.Bitmap; | ||
import android.util.Log; | ||
|
||
import com.parse.ParseException; | ||
import com.parse.ParseFile; | ||
import com.parse.ParseUser; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
import in.tosc.studddin.externalapi.ParseTables; | ||
|
||
/** | ||
* Created by omerjerk on 26/4/15. | ||
*/ | ||
public class FetchUserPhotos extends Thread { | ||
|
||
private PhotosFetcher photosFetcher; | ||
|
||
private static final String TAG = "FetchUserPhotos"; | ||
|
||
public FetchUserPhotos(PhotosFetcher pf) { | ||
photosFetcher = pf; | ||
} | ||
|
||
public interface PhotosFetcher { | ||
public Bitmap downloadCoverPhoto(); | ||
public Bitmap downloadProfilePhoto(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
Log.d(TAG, "starting download pictures thread"); | ||
ParseUser currentUser = ParseUser.getCurrentUser(); | ||
|
||
Bitmap coverPhoto = photosFetcher.downloadCoverPhoto(); | ||
Log.d(TAG, "Downloaded cover photo"); | ||
Bitmap profilePhoto = photosFetcher.downloadProfilePhoto(); | ||
Log.d(TAG, "downloaded profile photo"); | ||
|
||
// Compress image to lower quality scale 1 - 100 | ||
if (coverPhoto != null) { | ||
ByteArrayOutputStream profilePhotoStream = new ByteArrayOutputStream(); | ||
coverPhoto.compress(Bitmap.CompressFormat.PNG, 100, profilePhotoStream); | ||
byte[] profilePhotoBytes = profilePhotoStream.toByteArray(); | ||
ParseFile profilePhotoFile = new ParseFile("profilePicture.png", profilePhotoBytes); | ||
profilePhotoFile.save(); | ||
currentUser.put(ParseTables.Users.IMAGE, profilePhotoFile); | ||
} | ||
|
||
if (profilePhoto != null) { | ||
ByteArrayOutputStream coverPhotoStream = new ByteArrayOutputStream(); | ||
profilePhoto.compress(Bitmap.CompressFormat.PNG, 100, coverPhotoStream); | ||
byte[] coverPhotoBytes = coverPhotoStream.toByteArray(); | ||
ParseFile coverPhotoFile = new ParseFile("coverPicture.png", coverPhotoBytes); | ||
coverPhotoFile.save(); | ||
currentUser.put(ParseTables.Users.COVER, coverPhotoFile); | ||
} | ||
|
||
currentUser.save(); | ||
Log.d(TAG, "Done with everything"); | ||
} catch (ParseException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
Oops, something went wrong.