-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update mathpix apiv2 to v3, improved code quality
- Loading branch information
1 parent
24f87e9
commit 0ef3c70
Showing
9 changed files
with
169 additions
and
169 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
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 was deleted.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/app/mathpix_sample/api/request/SingleProcessRequest.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,27 @@ | ||
package com.app.mathpix_sample.api.request; | ||
|
||
import android.graphics.Bitmap; | ||
import android.util.Base64; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
|
||
public class SingleProcessRequest { | ||
@SerializedName("url") | ||
private String url; | ||
|
||
public SingleProcessRequest(Bitmap bm) { | ||
url = "data:image/jpeg;base64," + bitmapToBase64(bm); | ||
} | ||
|
||
public SingleProcessRequest(byte[] fileBytes) { | ||
url = "data:image/jpeg;base64," + Base64.encodeToString(fileBytes, Base64.DEFAULT); | ||
} | ||
|
||
private String bitmapToBase64(Bitmap image) { | ||
ByteArrayOutputStream os = new ByteArrayOutputStream(); | ||
image.compress(Bitmap.CompressFormat.JPEG, 100, os); | ||
return Base64.encodeToString(os.toByteArray(), Base64.DEFAULT); | ||
} | ||
} |
Oops, something went wrong.