Skip to content

Commit

Permalink
new commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kenmeidearu committed Nov 17, 2017
1 parent 5a25a7f commit fe0f9c0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 34 deletions.
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.4.0'
compile 'com.github.kenmeidearu:SearchableSpinner:1.5.4-4'
compile 'com.github.kenmeidearu:SearchableSpinner:1.5.4-6'
//compile project(':searchablespinnerlibrary')
//compile project(path: ':searchablespinnerlibrary', configuration: 'default')
}
2 changes: 1 addition & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kenmeidearu.sample">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
Expand Down
2 changes: 1 addition & 1 deletion searchablespinnerlibrary/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<manifest package="com.kenmeidearu.searchablespinnerlibrary"
xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"
>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -74,9 +75,7 @@ public long getItemId(int position) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
TextView nilai1, nilai2 = null, nilai3 = null, nilai4 = null;
ImageView images=null;

ViewHolder holder;
if (v == null) {
LayoutInflater vi;
vi = LayoutInflater.from(mContext);
Expand All @@ -93,29 +92,32 @@ public View getView(int position, View convertView, ViewGroup parent) {
} else {
v = vi.inflate(R.layout.spinner_item_code_1, null);
}

holder = new ViewHolder();
v.setTag(holder);
}else{
holder = (ViewHolder) v.getTag();
}

if (type == 0) {
images=(ImageView)v.findViewById(R.id.images);
nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
nilai2 = (TextView) v.findViewById(R.id.sub);
holder.images=(ImageView)v.findViewById(R.id.images);
holder.nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
holder.nilai2 = (TextView) v.findViewById(R.id.sub);
} else if (type == 1) {
nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
holder.nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
} else if (type == 2) {
nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
nilai2 = (TextView) v.findViewById(R.id.sub);
holder.nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
holder.nilai2 = (TextView) v.findViewById(R.id.sub);
} else if (type == 3) {
nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
nilai2 = (TextView) v.findViewById(R.id.sub);
nilai3 = (TextView) v.findViewById(R.id.sideHead);
holder.nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
holder.nilai2 = (TextView) v.findViewById(R.id.sub);
holder.nilai3 = (TextView) v.findViewById(R.id.sideHead);
} else if (type == 4) {
nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
nilai2 = (TextView) v.findViewById(R.id.sub);
nilai3 = (TextView) v.findViewById(R.id.sideHead);
nilai4 = (TextView) v.findViewById(R.id.sideSub);
holder.nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
holder.nilai2 = (TextView) v.findViewById(R.id.sub);
holder.nilai3 = (TextView) v.findViewById(R.id.sideHead);
holder.nilai4 = (TextView) v.findViewById(R.id.sideSub);
} else {
nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
holder.nilai1 = (TextView) v.findViewById(R.id.spinnerHead);
}

mListString p = getItem(position);
Expand All @@ -127,33 +129,48 @@ public View getView(int position, View convertView, ViewGroup parent) {
val4 = p.getNilai4();
valImage=p.getImageName();

if (nilai1 != null) {
nilai1.setText(val1);
if (holder.nilai1 != null) {
holder.nilai1.setText(val1);
}
if (nilai2 != null) {
nilai2.setText(val2);
if (holder.nilai2 != null) {
holder.nilai2.setText(val2);
}
if (nilai3 != null) {
nilai3.setText(val3);
if (holder.nilai3 != null) {
holder.nilai3.setText(val3);
}
if (nilai4 != null) {
nilai4.setText(val4);
if (holder.nilai4 != null) {
holder.nilai4.setText(val4);
}
if(images!=null){
// Log.e("isi image","image:"+valImage);
Picasso.with(mContext).setLoggingEnabled(true);
if(holder.images!=null){

/*Picasso.with(mContext).setLoggingEnabled(true);
Picasso.with(mContext)
.load("http://api.androidhive.info/json/movies/1.jpg")
.load(valImage)
.placeholder(R.drawable.noimage)
.error(R.drawable.noimage)
.into(holder.images);*/
Picasso picasso = new Picasso.Builder(mContext).listener(new Picasso.Listener() {
@Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
exception.printStackTrace();
}
}).build();
picasso.load(valImage)
.placeholder(R.drawable.noimage)
.error(R.drawable.noimage)
.into(images);
.into(holder.images);
Log.e("isi image","image:"+valImage);
}
}


return v;
}

public class ViewHolder {
public TextView nilai1, nilai2 = null, nilai3 = null, nilai4 = null;
public ImageView images=null;
}

// Filter Class
public void filter(String charText, int filter) {
charText = charText.toLowerCase(Locale.getDefault());
Expand Down

0 comments on commit fe0f9c0

Please sign in to comment.