Search in sources :

Example 21 with SimpleAdapter

use of android.widget.SimpleAdapter in project Bitocle by mthli.

the class AddTask method onPostExecute.

@Override
protected void onPostExecute(Boolean result) {
    pull.setRefreshing(false);
    if (result) {
        RAction action = new RAction(context);
        try {
            action.openDatabase(true);
        } catch (SQLException s) {
            SuperToast.create(fragment.getActivity(), context.getString(R.string.repo_add_failed), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.RED)).show();
            return;
        }
        List<Repo> repos = action.listRepos();
        Collections.sort(repos);
        List<Map<String, String>> autoList = new ArrayList<Map<String, String>>();
        list.clear();
        autoList.clear();
        for (Repo r : repos) {
            list.add(new RepoItem(r.getName(), r.getDate(), r.getDescription(), r.getLang(), r.getStar(), r.getFork(), r.getOwner(), r.getGit()));
            Map<String, String> map = new HashMap<String, String>();
            map.put("owner", r.getOwner());
            map.put("name", r.getName());
            autoList.add(map);
        }
        action.closeDatabase();
        SimpleAdapter autoAdapter = new SimpleAdapter(context, autoList, R.layout.auto_item, new String[] { "owner", "name" }, new int[] { R.id.auto_item_owner, R.id.auto_item_name });
        autoAdapter.notifyDataSetChanged();
        fragment.getSearch().setAdapter(autoAdapter);
        if (list.size() <= 0) {
            fragment.setContentEmpty(true);
            fragment.setEmptyText(R.string.repo_empty_list);
            fragment.setContentShown(true);
        } else {
            int position = 0;
            for (RepoItem r : list) {
                if (r.getGit().equals(git)) {
                    break;
                }
                position++;
            }
            fragment.setContentEmpty(false);
            adapter.notifyDataSetChanged();
            fragment.setContentShown(true);
            listView.smoothScrollToPosition(position);
            SuperToast.create(fragment.getActivity(), context.getString(R.string.repo_add_successful), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.BLUE)).show();
        }
    } else {
        SuperToast.create(fragment.getActivity(), context.getString(R.string.repo_add_failed), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.RED)).show();
    }
}
Also used : SQLException(android.database.SQLException) SimpleAdapter(android.widget.SimpleAdapter) Repo(io.github.mthli.Bitocle.Database.Repo.Repo) RAction(io.github.mthli.Bitocle.Database.Repo.RAction)

Example 22 with SimpleAdapter

use of android.widget.SimpleAdapter in project Bitocle by mthli.

the class RepoTask method onPostExecute.

@Override
protected void onPostExecute(Boolean result) {
    if (result) {
        RAction action = new RAction(context);
        try {
            action.openDatabase(true);
        } catch (SQLException s) {
            fragment.setContentEmpty(true);
            fragment.setEmptyText(R.string.repo_empty_error);
            fragment.setContentShown(true);
            return;
        }
        List<Repo> repos = action.listRepos();
        Collections.sort(repos);
        List<Map<String, String>> autoList = new ArrayList<Map<String, String>>();
        list.clear();
        autoList.clear();
        for (Repo r : repos) {
            list.add(new RepoItem(r.getName(), r.getDate(), r.getDescription(), r.getLang(), r.getStar(), r.getFork(), r.getOwner(), r.getGit()));
            Map<String, String> map = new HashMap<String, String>();
            map.put("owner", r.getOwner());
            map.put("name", r.getName());
            autoList.add(map);
        }
        action.closeDatabase();
        SimpleAdapter autoAdapter = new SimpleAdapter(context, autoList, R.layout.auto_item, new String[] { "owner", "name" }, new int[] { R.id.auto_item_owner, R.id.auto_item_name });
        autoAdapter.notifyDataSetChanged();
        fragment.getSearch().setAdapter(autoAdapter);
        if (list.size() <= 0) {
            fragment.setContentEmpty(true);
            fragment.setEmptyText(R.string.repo_empty_list);
            fragment.setContentShown(true);
        } else {
            fragment.setContentEmpty(false);
            adapter.notifyDataSetChanged();
            fragment.setContentShown(true);
        }
        if (flag == Flag.REPO_REFRESH) {
            SuperToast.create(context, context.getString(R.string.repo_refresh_successful), SuperToast.Duration.VERY_SHORT, Style.getStyle(Style.BLUE)).show();
        }
    } else {
        fragment.setContentEmpty(true);
        fragment.setEmptyText(R.string.repo_empty_error);
        fragment.setContentShown(true);
    }
}
Also used : Repo(io.github.mthli.Bitocle.Database.Repo.Repo) SQLException(android.database.SQLException) SimpleAdapter(android.widget.SimpleAdapter) RAction(io.github.mthli.Bitocle.Database.Repo.RAction)

Example 23 with SimpleAdapter

use of android.widget.SimpleAdapter in project ActionBarSherlock by JakeWharton.

the class SampleList method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String path = intent.getStringExtra("com.example.android.apis.Path");
    if (path == null) {
        path = "";
    }
    setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
    getListView().setTextFilterEnabled(true);
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent)

Example 24 with SimpleAdapter

use of android.widget.SimpleAdapter in project ActionBarSherlock by JakeWharton.

the class SampleList method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    String path = intent.getStringExtra("com.example.android.apis.Path");
    if (path == null) {
        path = "";
    }
    setListAdapter(new SimpleAdapter(this, getData(path), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
    getListView().setTextFilterEnabled(true);
}
Also used : SimpleAdapter(android.widget.SimpleAdapter) Intent(android.content.Intent)

Example 25 with SimpleAdapter

use of android.widget.SimpleAdapter in project android_frameworks_base by DirtyUnicorns.

the class BiDiTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mList = (ListView) findViewById(R.id.testlist);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    mList.setFocusableInTouchMode(true);
    final SimpleAdapter adapter = new SimpleAdapter(this, getTests(), R.layout.custom_list_item, new String[] { "title" }, new int[] { android.R.id.text1 });
    mList.setAdapter(adapter);
    mList.setOnItemClickListener(mOnClickListener);
}
Also used : SimpleAdapter(android.widget.SimpleAdapter)

Aggregations

SimpleAdapter (android.widget.SimpleAdapter)72 Intent (android.content.Intent)29 ListView (android.widget.ListView)18 HashMap (java.util.HashMap)15 View (android.view.View)12 AdapterView (android.widget.AdapterView)12 Map (java.util.Map)9 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 FragmentManager (android.support.v4.app.FragmentManager)4 ListFragment (android.support.v4.app.ListFragment)4 OnClickListener (android.view.View.OnClickListener)4 ArrayList (java.util.ArrayList)4 Context (android.content.Context)3 ViewGroup (android.view.ViewGroup)3 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)3 ListAdapter (android.widget.ListAdapter)3 SharedPreferences (android.content.SharedPreferences)2 AssetManager (android.content.res.AssetManager)2 SQLException (android.database.SQLException)2