Skip to content

Commit

Permalink
Merge pull request #64 from orhanobut/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
orhanobut committed Feb 12, 2015
2 parents 1cacfe8 + 69aadc8 commit 82c5513
Show file tree
Hide file tree
Showing 36 changed files with 857 additions and 268 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
compile 'com.orhanobut:wasp:1.6-SNAPSHOT'
compile 'com.orhanobut:wasp:1.7-SNAPSHOT'
}
```

Expand Down
7 changes: 3 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
}
}

packagingOptions{
packagingOptions {
exclude 'LICENSE'
exclude 'NOTICE'
exclude 'asm-license.txt'
Expand All @@ -29,7 +29,7 @@ android {
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/"}
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
Expand All @@ -38,7 +38,6 @@ dependencies {
androidTestCompile 'org.mockito:mockito-core:1.9.5'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.0'
androidTestCompile 'com.google.dexmaker:dexmaker:1.0'

compile 'com.android.support:recyclerview-v7:21.0.+'
compile project(':wasp')
// compile 'com.orhanobut:wasp:1.2-SNAPSHOT'
}
21 changes: 15 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.orhanobut.waspsample" >
<manifest
package="com.orhanobut.waspsample"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".WaspApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
android:label="@string/app_name">
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".RecyclerViewActivity"
android:label="@string/title_activity_list_test">
</activity>
<activity
android:name=".ListViewActivity"
android:label="@string/title_activity_list_view">
</activity>
</application>

</manifest>
42 changes: 42 additions & 0 deletions app/src/main/java/com/orhanobut/waspsample/Dummy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.orhanobut.waspsample;

/**
* @author Orhan Obut
*/
public class Dummy {

static String[] IMAGE_LIST = {
"http://imgsv.imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample" +
"/sample4_l.jpg",
"http://upload.wikimedia.org/wikipedia/commons/1/16/HDRI_Sample_Scene_Balls_%28JPEG-HDR%29.jpg",
"http://blogs.ubc.ca/CourseBlogSample01/wp-content/themes/thesis/rotator/sample-1.jpg",
"http://res.cloudinary.com/demo/image/upload/sample.jpg",
"http://imgsv.imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-140mmf_35-56g_ed_vr/img/sample" +
"/sample1_l.jpg",
"http://imgsv.imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_nikkor28-300mmf_35-56gd_ed_vr/img" +
"/sample/sample4_l.jpg",
"http://upload.wikimedia.org/wikipedia/en/9/9e/Lensbaby-sample.JPG",
"http://petapixel.com/assets/uploads/2012/02/sample1_mini.jpg",
"http://imgsv.imaging.nikon.com/lineup/lens/zoom/normalzoom/af-s_dx_18-300mmf_35-56g_ed_vr/img/sample" +
"/sample1_l.jpg",
"https://www.panda3d.org/manual/images/8/82/Screenshot-Sample-Programs-Media-Player.jpg",
"http://upload.wikimedia.org/wikipedia/commons/5/55/Joe_Sample.jpg",
"http://www.visioncritical.com/wp-content/uploads/2014/12/BLG_Andrew-G.-River-Sample_09.13.12.png",
"http://cdn.redmondpie.com/wp-content/uploads/2010/06/iPhone4CameraSample3.jpg",
"http://static.projects.iq.harvard" +
".edu/files/styles/os_files_medium/public/smms/files/autosampler_vials_sample_vials_glass_vials_9-425_1.jpg%3Fitok%3DikJIf0xN",
"http://cnet4.cbsistatic.com/hub/i/2011/10/27/a66dfbb7-fdc7-11e2-8c7c-d4ae52e62bcc/android" +
"-wallpaper5_2560x1600_1.jpg",
"http://1.bp.blogspot.com/-zudLVLaSBEY/T6puWoYjUsI/AAAAAAAAAV0/siDQwzx0uCw/s1600/Natural%2Bpictures-7.jpg",
"http://www.natural-beginning.com/wp-content/uploads/2013/09/natural-beginning-home-4.png",
"http://www.c2es.org/docUploads/nat-gas-photo.jpg",
"http://www.mrshultz.com/lessons/economicresources/NaturalResources.JPG",
"http://www.fubiz.net/wp-content/uploads/2012/05/Natural-Art-Installations13.jpg",
"http://www.funmag.org/wp-content/uploads/2012/05/beautiful-natural-lakes-26-photos-04.jpg",
"http://www.naturalnorthflorida.com/images/ss-home/Canoeing-a-Spring-Run-in-Natural-North-Florida.jpg",
"https://www.sciencenews.org/sites/default/files/main/articles/gp_20100417_4_17gigjok_gos_free.jpg",
"http://2.bp.blogspot.com/-urElkzK12z8/UDepIin-F8I/AAAAAAAAd9g/LeP2DaAReXk/s1600/Natural%2B%283%29.jpg",
"http://www.fubiz.net/wp-content/uploads/2012/05/Natural-Art-Installations13.jpg"

};
}
34 changes: 34 additions & 0 deletions app/src/main/java/com/orhanobut/waspsample/ImageHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.orhanobut.waspsample;

import android.content.Context;
import android.widget.ImageView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.android.volley.toolbox.Volley;
import com.orhanobut.wasp.Wasp;

/**
* @author Orhan Obut
*/
public class ImageHandler {

static RequestQueue requestQueue;
static ImageLoader imageLoader;


public static void volley(Context context, ImageView imageView, String url) {
if (requestQueue == null) {
requestQueue = Volley.newRequestQueue(context);
// imageLoader = new ImageLoader(requestQueue, new BitmapWaspCache());
}

((NetworkImageView) imageView).setImageUrl(url, imageLoader);

}

public static void wasp(Context context, ImageView imageView, String url) {
Wasp.Image.from(url).to(imageView).load();
}
}
50 changes: 50 additions & 0 deletions app/src/main/java/com/orhanobut/waspsample/ListViewActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.orhanobut.waspsample;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;


public class ListViewActivity extends Activity {


public static Intent newIntent(Context context) {
return new Intent(context, ListViewActivity.class);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_view);

ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(new MyListAdapter(this, Dummy.IMAGE_LIST));

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_list_view, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}
40 changes: 36 additions & 4 deletions app/src/main/java/com/orhanobut/waspsample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

Expand All @@ -14,14 +15,13 @@
import java.util.Map;


@SuppressWarnings("unused")
public class MainActivity extends BaseActivity {

private static final String TAG = MainActivity.class.getSimpleName();

private TextView textView;
private ImageView imageView;
private Object image;
private Object foo;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -38,9 +38,41 @@ protected void onCreate(Bundle savedInstanceState) {
//putFoo();

// putFooMap();
loadImage();
// loadImage();

getFoo();
// getFoo();

//startListViewActivity();

findViewById(R.id.listView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startListViewActivity();
}
});

findViewById(R.id.recycler_view).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startRecyclerViewActivity();
}
});

findViewById(R.id.clear_cache).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Wasp.Image.clearCache();
}
});

}

private void startListViewActivity() {
startActivity(ListViewActivity.newIntent(this));
}

private void startRecyclerViewActivity() {
startActivity(RecyclerViewActivity.newIntent(this));
}

private void fetchIp() {
Expand Down
65 changes: 65 additions & 0 deletions app/src/main/java/com/orhanobut/waspsample/MyListAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package com.orhanobut.waspsample;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

/**
* @author Orhan Obut
*/
public class MyListAdapter extends BaseAdapter {

final String[] list;
final LayoutInflater layoutInflater;
final Context context;

public MyListAdapter(Context context, String[] list) {
this.list = list;
this.layoutInflater = LayoutInflater.from(context);
this.context = context;
}

@Override
public int getCount() {
return list.length;
}

@Override
public String getItem(int position) {
return list[position];
}

@Override
public long getItemId(int position) {
return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
Holder holder;

if (view == null) {
view = layoutInflater.inflate(R.layout.item_list, parent, false);

holder = new Holder();
holder.image = (ImageView) view.findViewById(R.id.image);

view.setTag(holder);
} else {
holder = (Holder) view.getTag();
}

// ImageHandler.volley(context, holder.image, getItem(position));
ImageHandler.wasp(context, holder.image, getItem(position));

return view;
}

static class Holder {
ImageView image;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package com.orhanobut.waspsample;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

/**
* @author Orhan Obut
*/
@SuppressWarnings("unused")
public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder> {

private final String[] imageList;
private final LayoutInflater layoutInflater;
private final Context context;

public MyRecyclerViewAdapter(Context context, String[] imageList) {
this.imageList = imageList;
this.layoutInflater = LayoutInflater.from(context);
this.context = context;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = layoutInflater.inflate(R.layout.item_list, parent, false);
return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
// ImageHandler.volley(context, holder.image, imageList[position]);
ImageHandler.wasp(context, holder.image, imageList[position]);
}

@Override
public int getItemCount() {
return imageList.length;
}

static class ViewHolder extends RecyclerView.ViewHolder {

ImageView image;

public ViewHolder(View v) {
super(v);

image = (ImageView) v.findViewById(R.id.image);
}
}

}
Loading

0 comments on commit 82c5513

Please sign in to comment.