-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
30 changed files
with
1,219 additions
and
314 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<pre-dex-items> | ||
|
||
<item | ||
dex="C:\Users\alenin\AndroidStudioProjects\WhatsUp\whatsup\build\intermediates\pre-dexed\debug\support-v4-19.1.0-b99fbd4eb388c2e8066eaca369b841d505d70ed9.jar" | ||
jar="C:\Users\alenin\AppData\Local\Android\android-studio\sdk\extras\android\m2repository\com\android\support\support-v4\19.1.0\support-v4-19.1.0.jar" | ||
jumboMode="false" | ||
revision="19.1.0" | ||
sha1="85f201b380937e61a9dce6ca90ccf6872abbfb67"/> | ||
|
||
</pre-dex-items> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Wed Apr 10 15:27:10 PDT 2013 | ||
#Thu Jul 24 11:56:31 VET 2014 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip | ||
distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip |
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
41 changes: 41 additions & 0 deletions
41
whatsup/src/main/java/com/whatsup/whatsup/GVImageLoader.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,41 @@ | ||
package com.whatsup.whatsup; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.os.AsyncTask; | ||
import android.util.Log; | ||
import android.widget.ImageView; | ||
|
||
/** | ||
* Created by alenin on 28/07/2014. | ||
*/ | ||
public class GVImageLoader extends AsyncTask<WhatWasHereFragmentGV.ViewHolder, Void, Bitmap> { | ||
private ImageView iv; | ||
private WhatWasHereFragmentGV.ViewHolder vh; | ||
private String addr; | ||
private int position; | ||
|
||
public GVImageLoader( String pathFile, WhatWasHereFragmentGV.ViewHolder vh, int position ) { | ||
addr = pathFile; | ||
//this.iv = iv; | ||
this.vh = vh; | ||
this.position = position; | ||
execute(); | ||
} | ||
|
||
@Override | ||
protected Bitmap doInBackground(WhatWasHereFragmentGV.ViewHolder... viewHolders) { | ||
Log.d("doInBackground", "on GVImageLoader"); | ||
return BitmapFactory.decodeFile(addr); | ||
} | ||
|
||
@Override | ||
protected void onPostExecute( Bitmap result ) { | ||
Log.d("onPostExecute", "on GVImageLoader"); | ||
if( result != null ) | ||
Log.d("result", "null"); | ||
|
||
if( this.vh.position != this.position ) | ||
this.vh.icon.setImageBitmap( result ); | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
whatsup/src/main/java/com/whatsup/whatsup/ImageLoader.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,122 @@ | ||
package com.whatsup.whatsup; | ||
|
||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.os.Handler; | ||
import android.os.Looper; | ||
import android.util.Log; | ||
import android.widget.ImageView; | ||
import android.widget.ViewSwitcher; | ||
|
||
public class ImageLoader extends Thread { | ||
|
||
public interface ImageLoadListener { | ||
|
||
void handleImageLoaded(ViewSwitcher aViewSwitcher, ImageView aImageView, Bitmap aBitmap); | ||
} | ||
|
||
private static final String TAG = ImageLoader.class.getSimpleName(); | ||
ImageLoadListener mListener = null; | ||
private Handler handler; | ||
|
||
/** | ||
* Image loader takes an object that extends ImageLoadListener | ||
* @param lListener | ||
*/ | ||
ImageLoader(ImageLoadListener lListener){ | ||
mListener = lListener; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
|
||
// preparing a looper on current thread | ||
// the current thread is being detected implicitly | ||
Looper.prepare(); | ||
|
||
// Looper gets attached to the current thread by default | ||
handler = new Handler(); | ||
|
||
Looper.loop(); | ||
// Thread will start | ||
|
||
} catch (Throwable t) { | ||
Log.e(TAG, "ImageLoader halted due to a error: ", t); | ||
} | ||
} | ||
|
||
/** | ||
* Method stops the looper and thus the thread | ||
*/ | ||
public synchronized void stopThread() { | ||
|
||
// Use the handler to schedule a quit on the looper | ||
handler.post(new Runnable() { | ||
|
||
public void run() { | ||
// This runs on the ImageLoader thread | ||
Log.i(TAG, "DownloadThread loop quitting by request"); | ||
|
||
Looper.myLooper().quit(); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Method queues the image at path to load | ||
* Note that the actual loading takes place in the UI thread | ||
* the ImageView and ViewSwitcher are just references for the | ||
* UI thread. | ||
* @param aPath - Path where the bitmap is located to load | ||
* @param aImageView - The ImageView the UI thread will load | ||
* @param aViewSwitcher - The ViewSwitcher that needs to display the imageview | ||
*/ | ||
public synchronized void queueImageLoad( | ||
final String aPath, | ||
final ImageView aImageView, | ||
final ViewSwitcher aViewSwitcher) { | ||
|
||
// Wrap DownloadTask into another Runnable to track the statistics | ||
handler.post(new Runnable() { | ||
public void run() { | ||
try { | ||
|
||
synchronized (aImageView){ | ||
// make sure this thread is the only one performing activities on | ||
// this imageview | ||
BitmapFactory.Options lOptions = new BitmapFactory.Options(); | ||
lOptions.inSampleSize = 1; | ||
Bitmap lBitmap = BitmapFactory.decodeFile(aPath, lOptions); | ||
//aImage.setImageBitmap(lBitmap); | ||
|
||
// Load the image here | ||
signalUI(aViewSwitcher, aImageView, lBitmap); | ||
} | ||
} | ||
catch(Exception e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Method is called when the bitmap is loaded. The UI thread adds the bitmap to the imageview. | ||
* @param aViewSwitcher - The ViewSwitcher that needs to display the imageview | ||
* @param aImageView - The ImageView the UI thread will load | ||
* @param aImage - The Bitmap that gets loaded into the ImageView | ||
*/ | ||
private void signalUI( | ||
ViewSwitcher aViewSwitcher, | ||
ImageView aImageView, | ||
Bitmap aImage){ | ||
|
||
if(mListener != null){ | ||
// we have an object that implements ImageLoadListener | ||
|
||
mListener.handleImageLoaded(aViewSwitcher, aImageView, aImage); | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.