If you think the Android project ponyville-live-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.ponyvillelive.app.ui;
/*fromwww.java2s.com*/import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
importstatic butterknife.ButterKnife.findById;
class NetworkDelayAdapter extends BindableAdapter<Long> {
privatestaticfinallong[] VALUES = {
250, 500, 1000, 2000, 3000
};
publicstaticint getPositionForValue(long value) {
for (int i = 0; i < VALUES.length; i++) {
if (VALUES[i] == value) {
return i;
}
}
return 3; // Default to 2000 if something changes.
}
NetworkDelayAdapter(Context context) {
super(context);
}
@Override
publicint getCount() {
return VALUES.length;
}
@Override
public Long getItem(int position) {
return VALUES[position];
}
@Override
publiclong getItemId(int position) {
return position;
}
@Override
public View newView(LayoutInflater inflater, int position, ViewGroup container) {
return inflater.inflate(android.R.layout.simple_spinner_item, container, false);
}
@Override
publicvoid bindView(Long item, int position, View view) {
TextView tv = findById(view, android.R.id.text1);
tv.setText(item + "ms");
}
@Override
public View newDropDownView(LayoutInflater inflater, int position, ViewGroup container) {
return inflater.inflate(android.R.layout.simple_spinner_dropdown_item, container, false);
}
}