I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit e1236d28 authored by str4d's avatar str4d
Browse files

Replaced list header with Toast in Addressbook

parent d7ac916e
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:textSize="18sp"
android:text="Address Book" >
</TextView>
package net.i2p.android.router.fragment; package net.i2p.android.router.fragment;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.ListFragment; import android.support.v4.app.ListFragment;
...@@ -13,6 +14,8 @@ import android.widget.AdapterView; ...@@ -13,6 +14,8 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.ListView; import android.widget.ListView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -52,16 +55,6 @@ public class AddressbookFragment extends ListFragment { ...@@ -52,16 +55,6 @@ public class AddressbookFragment extends ListFragment {
// After router shutdown we get nothing... why? // After router shutdown we get nothing... why?
Set<String> names = ns.getNames(); Set<String> names = ns.getNames();
// set the header
int sz = names.size();
if (sz > 0) {
TextView tv = (TextView) getActivity().getLayoutInflater().inflate(R.layout.addressbook_header, null);
if (sz > 1)
tv.setText(sz + " hosts in address book.");
else
tv.setText("1 host in address book.");
getListView().addHeaderView(tv, "", false);
}
// set the empty text // set the empty text
setEmptyText("No hosts in address book, or your router is not up."); setEmptyText("No hosts in address book, or your router is not up.");
...@@ -70,6 +63,14 @@ public class AddressbookFragment extends ListFragment { ...@@ -70,6 +63,14 @@ public class AddressbookFragment extends ListFragment {
Collections.sort(nameList); Collections.sort(nameList);
mAdapter = new ArrayAdapter<String>(getActivity(), R.layout.addressbook_list_item, nameList); mAdapter = new ArrayAdapter<String>(getActivity(), R.layout.addressbook_list_item, nameList);
setListAdapter(mAdapter); setListAdapter(mAdapter);
// Show Toast with addressbook size
int sz = names.size();
Context context = getActivity().getApplicationContext();
CharSequence text = sz + " hosts in address book.";
if (sz == 1)
text = "1 host in address book.";
Toast.makeText(context, text, Toast.LENGTH_LONG).show();
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment