* Settings now use the database instead of SharedPreferences (which are bad) * Changed many constants to now be ENUMs. * Changed some character mappings which were too big. * Added limit to number of results returned to stop crash. * Changed Lang id so can do binary operations on it * Removed some old code
45 lines
1.5 KiB
Java
45 lines
1.5 KiB
Java
package org.nyanya.android.traditionalt9.settings;
|
|
|
|
// https://github.com/codepath/android_guides/wiki/Using-an-ArrayAdapter-with-ListView
|
|
|
|
import android.content.Context;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ArrayAdapter;
|
|
import android.widget.TextView;
|
|
|
|
import org.nyanya.android.traditionalt9.R;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class SettingAdapter extends ArrayAdapter<Setting> {
|
|
public SettingAdapter(Context context, ArrayList<Setting> settings) {
|
|
super(context, 0, settings);
|
|
}
|
|
|
|
@Override
|
|
public View getView(int position, View convertView, ViewGroup parent) {
|
|
// Get the data item for this position
|
|
Setting setting = getItem(position);
|
|
final LayoutInflater layoutInflater = LayoutInflater.from(getContext());
|
|
// Check if an existing view is being reused, otherwise inflate the view
|
|
if (convertView == null) {
|
|
convertView = layoutInflater.inflate(setting.layout, parent, false);
|
|
}
|
|
setting.setView(convertView);
|
|
// Lookup view for data population
|
|
((TextView) convertView.findViewById(R.id.title)).setText(setting.title);
|
|
if (setting.summary != null)
|
|
((TextView) convertView.findViewById(R.id.summary)).setText(setting.summary);
|
|
|
|
if (setting.widgetID != 0) {
|
|
final ViewGroup widgetFrame = (ViewGroup) convertView.findViewById(R.id.widget_frame);
|
|
layoutInflater.inflate(setting.widgetID, widgetFrame);
|
|
}
|
|
|
|
// Return the completed view to render on screen
|
|
return convertView;
|
|
}
|
|
}
|