This file contains hidden or 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
/** | |
* Sends data back to client by using HTTPServletResponse object and adding data into JSON Array | |
* then flushes out the stream and closes the response | |
* Sends data | |
* @param resp | |
* @param result | |
* @param message | |
* @param stringData | |
* @throws IOException | |
*/ |
This file contains hidden or 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
/** | |
* A static method which sends request to server by creating | |
* a HTTP connection with provided URL as parameter and converts | |
* the returned bytes data into readable form. | |
* | |
* @param parameterUrl | |
* @return {@code List<String>} | |
* @throws Exception | |
*/ | |
public static List<String> queryServer(String parameterUrl) throws Exception{ |
This file contains hidden or 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
public static void uploadBufferedImageToServer(BufferedImage image, String fileName, String imageType) throws IOException, NullPointerException { | |
ByteArrayOutputStream outstream = new ByteArrayOutputStream(); | |
ImageIO.write(image, "png", outstream); | |
byte[] buffer = outstream.toByteArray(); | |
InputStream is = new ByteArrayInputStream(buffer); | |
ObjectMetadata meta = new ObjectMetadata(); | |
meta.setContentType("image/" + imageType); | |
meta.setContentLength(buffer.length); | |
AmazonS3 s3client = new AmazonS3Client(new BasicAWSCredentials(accessKey, secretKey)); | |
s3client.putObject(new PutObjectRequest(awsBucketName, fileName, is, meta).withCannedAcl(CannedAccessControlList.PublicRead)); |
This file contains hidden or 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
private class TextureDownloader | |
{ | |
public WWW www; | |
public string url; | |
public Texture2D tex; | |
public string atlasName; | |
} | |
IEnumerator _UpdateAtlas(List<TextureDownloader> texIndex) | |
{ |
This file contains hidden or 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
string relativePathToAssets = "//GUI//productImages2//"; | |
List<Texture> LoadTextures () | |
{ | |
List<Texture> textures = new List<Texture>(); | |
string[] productImagesNames = Directory.GetFiles(Application.dataPath + relativePathToAssets, "*.jpg", SearchOption.AllDirectories); | |
foreach(string imagePath in productImagesNames){ | |
string relativeImagePath = ("Assets" + imagePath.Replace(Application.dataPath, "")).Replace("//","/"); | |
textures.Add(AssetDatabase.LoadAssetAtPath(relativeImagePath, typeof(Texture)) as Texture); |
This file contains hidden or 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
private Texture2D MakeTex(int width, int height, Color col) | |
{ | |
Color[] pix = new Color[width * height]; | |
for( int i = 0; i < pix.Length; ++i ) | |
{ | |
pix[ i ] = col; | |
} | |
Texture2D result = new Texture2D( width, height ); | |
result.SetPixels( pix ); | |
result.Apply(); |
This file contains hidden or 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
public void onShareClick(View v) { | |
Resources resources = getResources(); | |
Intent emailIntent = new Intent(); | |
emailIntent.setAction(Intent.ACTION_SEND); | |
// Native email client doesn't currently support HTML, but it doesn't hurt to try in case they fix it | |
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(resources.getString(R.string.share_email_native))); | |
emailIntent.putExtra(Intent.EXTRA_SUBJECT, resources.getString(R.string.share_email_subject)); | |
emailIntent.setType("message/rfc822"); |
This file contains hidden or 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
private static char[] VALID_CHARACTERS = | |
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456879".toCharArray(); | |
public static String csRandomAlphaNumericString(int numChars) throws Exception{ | |
SecureRandom srand = new SecureRandom(); | |
Random rand = new Random(); | |
char[] buff = new char[numChars]; | |
for (int i = 0; i < numChars; ++i) { | |
if ((i % 10) == 0) { |
This file contains hidden or 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
public class OrmLiteConfigurationApp extends OrmLiteConfigUtil{ | |
/** | |
* classes represents the models to use for generating the ormlite_config.txt file | |
*/ | |
private static final Class<?>[] classes = new Class[] {TimeEntries.class}; | |
/** | |
* Given that this is a separate program from the android app, we have to use | |
* a static main java method to create the configuration file. |
OlderNewer