1
0
mirror of https://github.com/nerzhul/ownCloud-SMS-App.git synced 2026-08-23 06:13:04 +00:00

Refactor code with Java best practices, helped by AS

This commit is contained in:
Loic Blot
2015-11-03 23:00:31 +01:00
parent 2576ca7468
commit 9d61d6c732
17 changed files with 365 additions and 371 deletions
@@ -1,50 +1,48 @@
package fr.unix_experience.owncloud_sms.adapters;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import java.util.ArrayList;
public class ContactListAdapter extends ArrayAdapter<String> {
private final ArrayList<String> _objects;
private static int _itemLayout;
private static int _fieldId;
private Activity _activity;
private final Activity _activity;
public ContactListAdapter(final Context context, final int resource,
final ArrayList<String> objects, final int itemLayout,
final int fieldId, final Activity activity) {
public ContactListAdapter(Context context, int resource,
ArrayList<String> objects, int itemLayout,
int fieldId, Activity activity) {
super(context, resource, objects);
_objects = objects;
_itemLayout = itemLayout;
_fieldId = fieldId;
ContactListAdapter._itemLayout = itemLayout;
ContactListAdapter._fieldId = fieldId;
_activity = activity;
}
@Override
public View getView(final int position, final View convertView, final ViewGroup parent) {
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
final LayoutInflater inflater =
LayoutInflater inflater =
(LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(_itemLayout, null);
v = inflater.inflate(ContactListAdapter._itemLayout, null);
}
if (_objects.size() == 0) {
if (_objects.isEmpty()) {
return null;
}
final String element = _objects.get(position);
String element = _objects.get(position);
if (element != null) {
final TextView label = (TextView) v.findViewById(_fieldId);
TextView label = (TextView) v.findViewById(ContactListAdapter._fieldId);
if (label != null) {
label.setText(element);
}
@@ -52,6 +50,4 @@ public class ContactListAdapter extends ArrayAdapter<String> {
return v;
}
private static final String TAG = ContactListAdapter.class.getSimpleName();
}