Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="AndroidCodingExercise" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="android-coding-exercise" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -71,6 +71,8 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/22.0.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
Expand All @@ -94,6 +96,7 @@
<orderEntry type="library" exported="" name="flickrj-android-2.1.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-22.0.0" level="project" />
<orderEntry type="library" exported="" name="slf4j-android-1.6.1-RC1" level="project" />
<orderEntry type="library" exported="" name="glide-3.6.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-22.0.0" level="project" />
</component>
</module>
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ dependencies {
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.googlecode.flickrj-android:flickrj-android:2.1.0'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.android.support:support-v4:19.1.0'
}
41 changes: 41 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,46 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gstv.androidcodingexercise" >

<!--
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
-->
<uses-permission android:name="android.permission.INTERNET" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<!--
<activity
android:name=".controller.LoginActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-->

<activity
android:name=".joel.activities.Main"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".joel.activities.ImageListDisplay"
android:label="@string/title_activity_image_display" >
</activity>

<!--
<activity
android:name=".controller.MainActivity"
android:label="@string/app_name" >
Expand All @@ -16,6 +51,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
-->

<activity
android:name=".joel.activities.FullSizeImageDisplay"
android:label="@string/title_activity_full_size_image_display" >
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public FlickrPictureAdapter(Context context, PhotoList photos) {
}

@Override public View getView(int position, View convertView, ViewGroup parent) {
View cellView;
return cellView;
// return cellView;
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ public class LargePictureFragment extends Fragment {

@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstance) {
//TODO: implement method
return null;
}
}
35 changes: 35 additions & 0 deletions app/src/main/java/com/gstv/androidcodingexercise/joel/Mutex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.gstv.androidcodingexercise.joel;

import java.util.concurrent.Semaphore;
/**
*
* @author user
*/
public class Mutex {
private final Semaphore lock;

public Mutex() {
lock = new Semaphore(1);
}

public boolean lock() {
boolean ret = false;

try {
lock.acquire();
ret = true;
} catch(InterruptedException _e) {
}

return ret;
}

public void unlock() {
lock.release();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package com.gstv.androidcodingexercise.joel.activities;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.gstv.androidcodingexercise.R;
import com.gstv.androidcodingexercise.joel.activities.data_types.ImageDisplayArrayAdapterData;

/**
* Created by user on 8/16/15.
*/
public class FullSizeImageDisplay extends Activity {
private ImageView imageView;
private ImageDisplayArrayAdapterData imageData;
private GetFullSizeUserPhotoAsyncTask getFullSizeUserPhotoAsyncTask;

@Override
protected void onCreate(Bundle _bundle) {
super.onCreate(_bundle);
setContentView(R.layout.activity_full_size_image_display);
imageView = (ImageView) findViewById(R.id.full_size_image_view);
imageData = (ImageDisplayArrayAdapterData)getIntent()
.getParcelableExtra("ImageDisplayArrayAdapterData");
}

@Override
public void onResume() {
super.onResume();
getFullSizeUserPhotoAsyncTask = new GetFullSizeUserPhotoAsyncTask();
getFullSizeUserPhotoAsyncTask.execute();
}

@Override
public void onPause() {
super.onPause();
getFullSizeUserPhotoAsyncTask.cancel(true);
}

@Override
public void onDestroy() {
super.onDestroy();
}


private Handler loadFullSizeBitmapIntoImageView = new Handler() {
@Override
public void handleMessage(Message _message) {
if(_message == null) {
} else if(_message.obj == null) {
} else if(_message.arg1 == 100) {
imageView.setImageBitmap((Bitmap) _message.obj);
}
}
};


// generic types are Params, Progress, and Result
private class GetFullSizeUserPhotoAsyncTask extends AsyncTask<String, String, Void> {
private Context asyncContext;
private Handler asyncHandler;
private ImageDisplayArrayAdapterData asyncImageData;
private ProgressDialog progressDialog;

public GetFullSizeUserPhotoAsyncTask() {
progressDialog = new ProgressDialog(FullSizeImageDisplay.this);
}

@Override
public void onCancelled() {

}

@Override
public void onPreExecute() {
asyncContext = getApplicationContext();
asyncHandler = loadFullSizeBitmapIntoImageView;
asyncImageData = imageData;
progressDialog.setMessage("Please Wait...");
progressDialog.show();
}

@Override
public Void doInBackground(String[] params) {
int photoWidth = Integer.valueOf(asyncImageData.fullSizeImageWidth);
int photoHeight = Integer.valueOf(asyncImageData.fullSizeImageHeight);
try {
Bitmap bitmap = Glide
.with(asyncContext)
.load(asyncImageData.fullSizeImageUrl)
.asBitmap()
.into(photoWidth, photoHeight)
.get();
sendBitmapToHandler(bitmap);
} catch (java.lang.InterruptedException _e) {
} catch (java.util.concurrent.ExecutionException _e) {
}

return null;
}

private void sendBitmapToHandler(Bitmap _bitmap) {
Message message = asyncHandler.obtainMessage();
message.arg1 = 100;
message.obj = _bitmap;
asyncHandler.sendMessage(message);
}

@Override
public void onProgressUpdate(String[] progress) {
}

@Override
public void onPostExecute(Void _v) {
if(progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.gstv.androidcodingexercise.joel.activities;

import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.app.Activity;
import android.widget.ImageView;
import android.widget.TextView;

import com.gstv.androidcodingexercise.joel.activities.data_types.ImageDisplayArrayAdapterData;

import com.gstv.androidcodingexercise.R;

import java.util.ArrayList;

/**
* Created by user on 8/16/15.
*/
public class ImageDisplayArrayAdapter extends ArrayAdapter<ImageDisplayArrayAdapterData> {
private final Activity context;
private final ArrayList<ImageDisplayArrayAdapterData> bitmapData;

public ImageDisplayArrayAdapter(Activity _context, ArrayList<ImageDisplayArrayAdapterData> _bitmapData) {
super(_context, R.layout.joel_thumbnail_list_item, _bitmapData);
this.context = _context;
this.bitmapData = _bitmapData;
}

@Override
public View getView(int _position, View _view, ViewGroup _parent) {
View rowView = _view;

if(rowView != null) {
} else {
LayoutInflater layoutInflater = context.getLayoutInflater();
rowView = layoutInflater.inflate(R.layout.joel_thumbnail_list_item, null);
ImageView imageView = (ImageView) rowView.findViewById(R.id.image_list_main_image);
TextView textView = (TextView) rowView.findViewById(R.id.image_list_image_name);
imageView.setImageBitmap(bitmapData.get(_position).bitmap);
textView.setText(bitmapData.get(_position).imageName);
rowView.setTag(_position);
setUpRowViewOnClickListener(rowView, _position);
}

return rowView;
}

private void setUpRowViewOnClickListener(View _rowView, int _position) {
_rowView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(context, FullSizeImageDisplay.class);
Bundle bundle = new Bundle();
bundle.putParcelable("ImageDisplayArrayAdapterData", bitmapData.get((int) v.getTag()));
intent.putExtras(bundle);
context.startActivity(intent);
}
});
}

@Override
public void add(ImageDisplayArrayAdapterData _data) {
bitmapData.add(_data);
notifyDataSetChanged();
}

@Override
public void clear() {
bitmapData.clear();
notifyDataSetChanged();
}
}
Loading