use of org.qii.weiciyuan.bean.AtUserBean in project weiciyuan by qii.
the class AtUsersDBTask method get.
public static List<AtUserBean> get(SQLiteDatabase db, String accountId) {
List<AtUserBean> msgList = new ArrayList<AtUserBean>();
String sql = "select * from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + " = " + accountId + " order by " + AtUsersTable.ID + " desc";
Cursor c = db.rawQuery(sql, null);
Gson gson = new Gson();
while (c.moveToNext()) {
String json = c.getString(c.getColumnIndex(AtUsersTable.JSONDATA));
try {
AtUserBean value = gson.fromJson(json, AtUserBean.class);
msgList.add(value);
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
}
c.close();
return msgList;
}
use of org.qii.weiciyuan.bean.AtUserBean in project weiciyuan by qii.
the class AtUserFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.actionbar_menu_atuserfragment, menu);
SearchManager searchManager = (SearchManager) getActivity().getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
searchView.setSearchableInfo(searchManager.getSearchableInfo(getActivity().getComponentName()));
searchView.setIconifiedByDefault(false);
searchView.setQueryHint(getString(R.string.at_other));
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (!TextUtils.isEmpty(newText)) {
if (task != null) {
task.cancel(true);
}
task = new AtUserTask(newText);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
if (task != null) {
task.cancel(true);
}
atList.clear();
result.clear();
atList = AtUsersDBTask.get(GlobalContext.getInstance().getCurrentAccountId());
for (AtUserBean b : atList) {
result.add(b.getNickname());
}
adapter.notifyDataSetChanged();
}
return false;
}
});
searchView.requestFocus();
}
use of org.qii.weiciyuan.bean.AtUserBean in project weiciyuan by qii.
the class AtUserFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
token = getArguments().getString("token");
adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, result);
setListAdapter(adapter);
getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent();
intent.putExtra("name", "@" + atList.get(position).getNickname() + " ");
getActivity().setResult(Activity.RESULT_OK, intent);
AtUsersDBTask.add(atList.get(position), GlobalContext.getInstance().getCurrentAccountId());
getActivity().finish();
}
});
atList = AtUsersDBTask.get(GlobalContext.getInstance().getCurrentAccountId());
for (AtUserBean b : atList) {
result.add(b.getNickname());
}
adapter.notifyDataSetChanged();
}
use of org.qii.weiciyuan.bean.AtUserBean in project weiciyuan by qii.
the class AtUserDao method getUserInfo.
public List<AtUserBean> getUserInfo() throws WeiboException {
String url = URLHelper.AT_USER;
Map<String, String> map = new HashMap<String, String>();
map.put("access_token", access_token);
map.put("q", q);
map.put("count", count);
map.put("type", type);
map.put("range", range);
String jsonData = HttpUtility.getInstance().executeNormalTask(HttpMethod.Get, url, map);
Gson gson = new Gson();
List<AtUserBean> value = null;
try {
value = gson.fromJson(jsonData, new TypeToken<List<AtUserBean>>() {
}.getType());
} catch (JsonSyntaxException e) {
AppLogger.e(e.getMessage());
}
return value;
}
Aggregations