android my gridview数据未显示来自服务器的所有项目? 公共类ExploresScreenActivity扩展活动实现OnClickListener、OnItemClickListener、IServResponse{ 私有图像按钮_ref
android my gridview数据未显示来自服务器的所有项目?android my gridview数据未显示来自服务器的所有项目? 公共类ExploresScreenActivity扩展活动实现OnClickListener、OnItemClickListener、IServResponse{ 私有图像按钮_ref,android,Android,android my gridview数据未显示来自服务器的所有项目? 公共类ExploresScreenActivity扩展活动实现OnClickListener、OnItemClickListener、IServResponse{ 私有图像按钮_refreshBtn=null; 私有图像按钮_searchBtn=null; 私有按钮_cancelBtn=null; 私有EditText _searchText=null; 公共TextWatcher过滤器TextWatcher; 私有文本视图
公共类ExploresScreenActivity扩展活动实现OnClickListener、OnItemClickListener、IServResponse{
私有图像按钮_refreshBtn=null;
私有图像按钮_searchBtn=null;
私有按钮_cancelBtn=null;
私有EditText _searchText=null;
公共TextWatcher过滤器TextWatcher;
私有文本视图_exploreTxt=null;
private LinearLayout\u search\u all\u layout=null;
私有图像按钮_allSearchBtn=null;
私有ImageButton_brandsSearchBtn=null;
私有ImageButton _itemsSearchBtn=null;
private ImageButton_peopleSearchBtn=null;
私有SharedReferences\u sPrefs=null;
public ArrayList _itemList=null;
private ArrayList_brandlist=null;
私有ArrayList_alluserlist=null;
private ArrayList_peoplelist=null;
private ArrayList_defaultlist=null;
私有字符串类型=null;;
私有字符串searchString=null;;
私有GridView _explorGridView=null;
私有GridSearchNewAdapter适配器=null;
私有GridBrandadapter brandadapter=null;
私有GridAllUserAdapter alladapter=null;
私有GridItemAdapter itemadapter=null;
私有GridUserAdapter useradapter=null;
private Defaultadapter adapter11=null;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u屏幕);
_sPrefs=getSharedReferences(“myPrefs”,Context.MODE\u PRIVATE);
_itemList=新的ArrayList();
_brandlist=新的ArrayList();
_alluserlist=新的ArrayList();
_peoplelist=newArrayList();
_defaultlist=新的ArrayList();
_refreshBtn=(ImageButton)findViewById(R.id.refresh\u btn);
_refreshBtn.setOnClickListener(此);
_search\u all\u layout=(LinearLayout)findViewById(R.id.search\u all\u layout);
_searchBtn=(ImageButton)findViewById(R.id.search\u btn);
_searchBtn.setOnClickListener(此);
_searchText=(EditText)findViewById(R.id.search\u edtTxt);
_searchText.setOnClickListener(此);
_cancelBtn=(按钮)findViewById(R.id.cancel\u btn);
_cancelBtn.setOnClickListener(此);
_explorGridView=(GridView)findViewById(R.id.explor\u GridView);
_exploreTxt=(TextView)findViewById(R.id.explor\u TextView);
_allSearchBtn=(ImageButton)findViewById(R.id.all\u search\u btn);
_allSearchBtn.setOnClickListener(此);
_brandsSearchBtn=(图像按钮)findViewById(R.id.brands\u search\u btn);
_brandsSearchBtn.setOnClickListener(此);
_itemsSearchBtn=(ImageButton)findViewById(R.id.items\u search\u btn);
_itemsSearchBtn.setOnClickListener(此);
_peopleSearchBtn=(ImageButton)findViewById(R.id.people\u search\u btn);
_peopleSearchBtn.setOnClickListener(此);
类型=_searchText.getText().toString();
searchString=\u searchText.getText().toString();
getSearch(类型、搜索字符串);
_explorGridView.setOnItemClickListener(此);
_searchText.setOnEditorActionListener(新的TextView.OnEditorActionListener(){
@凌驾
公共布尔onEditorAction(TextView v、int actionId、KeyEvent事件){
if(actionId==EditorInfo.IME\u ACTION\u SEARCH){
意向意向=新意向(explorescreeeActivity.this,FeedSelectedActivity.class);
TabGroupActivity parentActivity=(TabGroupActivity)getParent();
parentActivity.startChildActivity(“feedselected”,意图);
返回true;
}
返回false;
}
});
onResume();
{
super.onResume();
getSearch(类型、搜索字符串);
}
_searchText.addTextChangedListener(新的TextWatcher(){
@凌驾
公共无效后文本已更改(可编辑){
//TODO自动生成的方法存根
searchString=\u searchText.getText().toString().toLowerCase(Locale.getDefault());
searchString=s.toString();
getSearch(类型、搜索字符串);
alladapter.filter(搜索字符串);
}
@凌驾
更改前的公共无效(字符序列arg0,int arg1,
整数arg2,整数arg3){
//TODO自动生成的方法存根
}
@凌驾
public void onTextChanged(字符序列arg0、int arg1、int arg2、,
int arg3){
//TODO自动生成的方法存根
}
});
}
@凌驾
公共void onClick(视图v){
TabGroupActivity parentActivity=(TabGroupActivity)getParent();
意向=无效;
开关(v.getId()){
案例R.id.refresh\u btn:
打破
案例R.id.search\u btn:
_searchText.setText(“”);
intent=新intent(这个FeedSelectedActivity.class);
parentActivity.startChildActivity(“feedselect”,意图);
打破
案例R.id.cancel\u btn:
_exploreTxt.setVisibility(View.VISIBLE);
_searchBtn.setVisibility(View.VISIBLE);
_搜索所有布局。设置可见性(View.GONE);
_取消btn.setVisibility(视图已消失);
_searchText.setText(“”);
//_explorGridView.setAdapter(mAdapter);
打破
案例R.id.search\u EDTXT:
_exploreTxt.setVisibility(View.GONE);
_searchBtn.setVisibility(View.GONE);
_取消btn.setVisibility(视图可见);
_搜索所有布局。设置可见性(View.VISIBLE);
打破
案例R.id.all\u search\u btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_取消选择);
_itemsSearchBtn.setBackgroundResource(R.drawable.items\u取消选择);
_peopleSearchBtn.setBackgroundResource(R.drawable.people\u取消选择);
_allSearchBtn.setBackgroundResource(R.drawable.all_selected);
type=“全部”;
getSearch(类型、搜索字符串);
打破
案例R.id.brands\u search\u btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_selected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items\u取消选择);
_peopleSearchBtn.setBackgroundResource(R.drawable.people\u取消选择);
_allSearchBtn.setBackgroundResource(R.drawable.all_取消选择);
type=“b
public class ExploreScreenActivity extends Activity implements OnClickListener, OnItemClickListener,IServerResponse{
private ImageButton _refreshBtn=null;
private ImageButton _searchBtn=null;
private Button _cancelBtn=null;
private EditText _searchText=null;
public TextWatcher filterTextWatcher;
private TextView _exploreTxt=null;
private LinearLayout _search_all_layout=null;
private ImageButton _allSearchBtn=null;
private ImageButton _brandsSearchBtn=null;
private ImageButton _itemsSearchBtn=null;
private ImageButton _peopleSearchBtn=null;
private SharedPreferences _sPrefs=null;
public ArrayList<Object> _itemList=null;
private ArrayList<Object>_brandlist=null;
private ArrayList<Object>_alluserlist=null;
private ArrayList<Object>_peoplelist=null;
private ArrayList<Object>_defaultlist=null;
private String type=null;;
private String searchString=null;;
private GridView _explorGridView=null;
private GridSearchNewAdapter adapter=null;
private GridBrandadapter brandadapter=null;
private GridAllUserAdapter alladapter=null;
private GridItemAdapter itemadapter=null;
private GridUserAdapter useradapter=null;
private Defaultadapter adapter11=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explorscreen);
_sPrefs=getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
_itemList = new ArrayList<Object>();
_brandlist=new ArrayList<Object>();
_alluserlist=new ArrayList<Object>();
_peoplelist=new ArrayList<Object>();
_defaultlist=new ArrayList<Object>();
_refreshBtn=(ImageButton)findViewById(R.id.refresh_btn);
_refreshBtn.setOnClickListener(this);
_search_all_layout=(LinearLayout)findViewById(R.id.search_all_layout);
_searchBtn=(ImageButton)findViewById(R.id.search_btn);
_searchBtn.setOnClickListener(this);
_searchText=(EditText)findViewById(R.id.search_edtTxt);
_searchText.setOnClickListener(this);
_cancelBtn=(Button)findViewById(R.id.cancel_btn);
_cancelBtn.setOnClickListener(this);
_explorGridView=(GridView)findViewById(R.id.explor_gridView);
_exploreTxt=(TextView)findViewById(R.id.explor_textView);
_allSearchBtn=(ImageButton)findViewById(R.id.all_search_btn);
_allSearchBtn.setOnClickListener(this);
_brandsSearchBtn=(ImageButton)findViewById(R.id.brands_search_btn);
_brandsSearchBtn.setOnClickListener(this);
_itemsSearchBtn=(ImageButton)findViewById(R.id.items_search_btn);
_itemsSearchBtn.setOnClickListener(this);
_peopleSearchBtn=(ImageButton)findViewById(R.id.people_search_btn);
_peopleSearchBtn.setOnClickListener(this);
type= _searchText.getText().toString();
searchString=_searchText.getText().toString();
getSearch(type,searchString);
_explorGridView.setOnItemClickListener(this);
_searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Intent intent=new Intent(ExploreScreenActivity.this, FeedSelectedActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("feedselected", intent);
return true;
}
return false;
}
});
onResume();
{
super.onResume();
getSearch(type, searchString);
}
_searchText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
searchString = _searchText.getText().toString().toLowerCase(Locale.getDefault());
searchString =s.toString();
getSearch(type,searchString);
alladapter.filter(searchString);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
});
}
@Override
public void onClick(View v) {
TabGroupActivity parentActivity=(TabGroupActivity)getParent();
Intent intent=null;
switch (v.getId()) {
case R.id.refresh_btn:
break;
case R.id.search_btn:
_searchText.setText("");
intent=new Intent(this, FeedSelectedActivity.class);
parentActivity.startChildActivity("feedselect", intent);
break;
case R.id.cancel_btn:
_exploreTxt.setVisibility(View.VISIBLE);
_searchBtn.setVisibility(View.VISIBLE);
_search_all_layout.setVisibility(View.GONE);
_cancelBtn.setVisibility(View.GONE);
_searchText.setText("");
// _explorGridView.setAdapter(mAdapter);
break;
case R.id.search_edtTxt:
_exploreTxt.setVisibility(View.GONE);
_searchBtn.setVisibility(View.GONE);
_cancelBtn.setVisibility(View.VISIBLE);
_search_all_layout.setVisibility(View.VISIBLE);
break;
case R.id.all_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_deselected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_deselected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_deselected);
_allSearchBtn.setBackgroundResource(R.drawable.all_selected);
type="all";
getSearch( type, searchString);
break;
case R.id.brands_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_selected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_deselected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_deselected);
_allSearchBtn.setBackgroundResource(R.drawable.all_deselected);
type="brand";
getSearch(type,searchString);
break;
case R.id.items_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_deselected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_selected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_deselected);
_allSearchBtn.setBackgroundResource(R.drawable.all_deselected);
type="item";
getSearch(type,searchString);
break;
case R.id.people_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_deselected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_deselected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_selected);
_allSearchBtn.setBackgroundResource(R.drawable.all_deselected);
type="user";
getSearch(type,searchString);
break;
default:
break;
}
}
private void getSearch(String type,String searchString) {
if (NetworkAvailablity.checkNetworkStatus(ExploreScreenActivity.this)) {
ArrayList<NameValuePair> requestParaList = new ArrayList<NameValuePair>();
requestParaList.add(new BasicNameValuePair("type", _sPrefs.getString("type",type)));
requestParaList.add(new BasicNameValuePair("searchstring", _sPrefs.getString("searchstring",searchString)));
// requestParaList.add(new BasicNameValuePair("type", type));
// requestParaList.add(new BasicNameValuePair("searchstring",searchString));
WebServiceCommunicator.getInstance().registerForServerResponse((IServerResponse) ExploreScreenActivity.this);
WebServiceCommunicator.getInstance().callGetAppWebService(false,
this,
WSConstant.getUrl(WSConstant.METHOD_SEARCH),
ExploreScreenActivity.this, WSConstant.PID_SEARCH, false,
requestParaList);
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Intent intent=new Intent(this, FeedSelectedActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("feedselected", intent);
//startActivity(intent);
}
private Handler _handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.arg2) {
case WSConstant.PID_SEARCH:
getJsonResponse(msg.obj.toString(), msg.arg2);
break;
default:
break;
}
}
};
private void getJsonResponse(String response, int arg2) {
JSONObject jObject=null;
try {
jObject = new JSONObject(response);
JSONArray list = jObject.getJSONArray("posts");
for (int i = 0; i < list.length(); i++) {
JSONObject element = list.getJSONObject(i);
if ( type.equalsIgnoreCase("all")) {
AllBean bean= new AllBean();
bean.setid(element.getString("id"));
bean.setfullname(element.getString("fullname"));
bean.setusername(element.getString("username"));
bean.setprofile_photo(element.getString("profile_photo"));
bean.setprofile_type(element.getString("profile_type"));
bean.setprofile(element.getString("profile"));
// _alluserlist.clear();
_alluserlist.add(bean);
}
if (_alluserlist.size()!=0) {
alladapter=new GridAllUserAdapter(ExploreScreenActivity.this, _alluserlist);
_explorGridView.setAdapter(alladapter);
}
else if (type.equalsIgnoreCase("brand")) {
BrandBean bean= new BrandBean();
bean.setbrand_id(element.getString("brand_id"));
bean.setbrand_name(element.getString("brand_name"));
bean.setbrand_photo(element.getString("brand_photo"));
_brandlist.add(bean);
}
if (_brandlist.size()!=0) {
brandadapter=new GridBrandadapter(ExploreScreenActivity.this, _brandlist);
_explorGridView.setAdapter(brandadapter);
}
else if ( type.equalsIgnoreCase("item")) {
ItemBean bean= new ItemBean();
bean.setitem_id(element.getString("item_id"));
bean.setitem_name(element.getString("item_name"));
bean.setitem_photo(element.getString("item_photo"));
_itemList.add(bean);
}
if (_itemList.size()!=0) {
itemadapter=new GridItemAdapter(ExploreScreenActivity.this, _itemList);
_explorGridView.setAdapter(itemadapter);
}
else if (type.equalsIgnoreCase("user")) {
UserBean bean= new UserBean();
bean.setid(element.getString("id"));
bean.setfullname(element.getString("fullname"));
bean.setusername(element.getString("username"));
bean.setprofile_photo(element.getString("profile_photo"));
_peoplelist.add(bean);
}
if (_peoplelist.size()!=0) {
useradapter=new GridUserAdapter(ExploreScreenActivity.this, _peoplelist);
_explorGridView.setAdapter(useradapter);
}
else {
DefaultBean bean=new DefaultBean();
bean.setmedia_id(element.getString("media_id"));
bean.setthumbnail_image(element.getString("thumbnail_image"));
bean.setmedia_owner(element.getString("media_owner"));
_defaultlist.add(bean);
}
if (_defaultlist.size()!=0) {
adapter11=new Defaultadapter(ExploreScreenActivity.this, _defaultlist);
adapter11.notifyDataSetChanged();
_explorGridView.setAdapter(adapter11);
}
}
}
catch (Exception e) {
// TODO: handle exception
}
}
@Override
public void serverResponse(String response, int processid) {
// TODO Auto-generated method stub
Message msg = new Message();
msg.obj = response;
msg.arg2 = processid;
_handler.sendMessage(msg);
}
}
public class ExploreScreenActivity extends Activity implements OnClickListener, OnItemClickListener,IServerResponse{
private ImageButton _refreshBtn=null;
private ImageButton _searchBtn=null;
private Button _cancelBtn=null;
private EditText _searchText=null;
public TextWatcher filterTextWatcher;
private TextView _exploreTxt=null;
private LinearLayout _search_all_layout=null;
private ImageButton _allSearchBtn=null;
private ImageButton _brandsSearchBtn=null;
private ImageButton _itemsSearchBtn=null;
private ImageButton _peopleSearchBtn=null;
private SharedPreferences _sPrefs=null;
private ArrayList<Object>_alluserlist=null;
private String type=null;;
private String searchString=null;;
private GridView _explorGridView=null;
private GridSearchNewAdapter adapter=null;
private GridAllUserAdapter alladapter=null;
private Defaultadapter adapter11=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_explorscreen);
_sPrefs=getSharedPreferences("myPrefs", Context.MODE_PRIVATE);
_alluserlist=new ArrayList<Object>();
_refreshBtn=(ImageButton)findViewById(R.id.refresh_btn);
_refreshBtn.setOnClickListener(this);
_search_all_layout=(LinearLayout)findViewById(R.id.search_all_layout);
_searchBtn=(ImageButton)findViewById(R.id.search_btn);
_searchBtn.setOnClickListener(this);
_searchText=(EditText)findViewById(R.id.search_edtTxt);
_searchText.setOnClickListener(this);
_cancelBtn=(Button)findViewById(R.id.cancel_btn);
_cancelBtn.setOnClickListener(this);
_explorGridView=(GridView)findViewById(R.id.explor_gridView);
_exploreTxt=(TextView)findViewById(R.id.explor_textView);
_allSearchBtn=(ImageButton)findViewById(R.id.all_search_btn);
_allSearchBtn.setOnClickListener(this);
_brandsSearchBtn=(ImageButton)findViewById(R.id.brands_search_btn);
_brandsSearchBtn.setOnClickListener(this);
_itemsSearchBtn=(ImageButton)findViewById(R.id.items_search_btn);
_itemsSearchBtn.setOnClickListener(this);
_peopleSearchBtn=(ImageButton)findViewById(R.id.people_search_btn);
_peopleSearchBtn.setOnClickListener(this);
type= _searchText.getText().toString();
searchString=_searchText.getText().toString();
getSearch(type,searchString);
_explorGridView.setOnItemClickListener(this);
_searchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Intent intent=new Intent(ExploreScreenActivity.this, FeedSelectedActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("feedselected", intent);
return true;
}
return false;
}
});
onResume();
{
super.onResume();
type="all";
getSearch(type, searchString);
}
_searchText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
searchString = _searchText.getText().toString().toLowerCase(Locale.getDefault());
searchString =s.toString();
getSearch(type,searchString);
alladapter.filter(searchString);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1,
int arg2, int arg3) {
// TODO Auto-generated method stub
}
@Override
public void onTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
});
}
@Override
public void onClick(View v) {
TabGroupActivity parentActivity=(TabGroupActivity)getParent();
Intent intent=null;
switch (v.getId()) {
case R.id.refresh_btn:
break;
case R.id.search_btn:
_searchText.setText("");
intent=new Intent(this, FeedSelectedActivity.class);
parentActivity.startChildActivity("feedselect", intent);
break;
case R.id.cancel_btn:
_exploreTxt.setVisibility(View.VISIBLE);
_searchBtn.setVisibility(View.VISIBLE);
_search_all_layout.setVisibility(View.GONE);
_cancelBtn.setVisibility(View.GONE);
_searchText.setText("");
break;
case R.id.search_edtTxt:
_exploreTxt.setVisibility(View.GONE);
_searchBtn.setVisibility(View.GONE);
_cancelBtn.setVisibility(View.VISIBLE);
_search_all_layout.setVisibility(View.VISIBLE);
break;
case R.id.all_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_deselected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_deselected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_deselected);
_allSearchBtn.setBackgroundResource(R.drawable.all_selected);
type="all";
getSearch( type, searchString);
break;
case R.id.brands_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_selected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_deselected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_deselected);
_allSearchBtn.setBackgroundResource(R.drawable.all_deselected);
type="brand";
getSearch(type,searchString);
break;
case R.id.items_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_deselected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_selected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_deselected);
_allSearchBtn.setBackgroundResource(R.drawable.all_deselected);
type="item";
getSearch(type,searchString);
break;
case R.id.people_search_btn:
_brandsSearchBtn.setBackgroundResource(R.drawable.brand_deselected);
_itemsSearchBtn.setBackgroundResource(R.drawable.items_deselected);
_peopleSearchBtn.setBackgroundResource(R.drawable.people_selected);
_allSearchBtn.setBackgroundResource(R.drawable.all_deselected);
type="user";
getSearch(type,searchString);
break;
default:
break;
}
}
private void getSearch(String type,String searchString) {
if (NetworkAvailablity.checkNetworkStatus(ExploreScreenActivity.this)) {
ArrayList<NameValuePair> requestParaList = new ArrayList<NameValuePair>();
requestParaList.add(new BasicNameValuePair("type", _sPrefs.getString("type",type)));
requestParaList.add(new BasicNameValuePair("searchstring", _sPrefs.getString("searchstring",searchString)));
WebServiceCommunicator.getInstance().registerForServerResponse((IServerResponse) ExploreScreenActivity.this);
WebServiceCommunicator.getInstance().callGetAppWebService(false,
this,
WSConstant.getUrl(WSConstant.METHOD_SEARCH),
ExploreScreenActivity.this, WSConstant.PID_SEARCH, false,
requestParaList);
}
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Intent intent=new Intent(this, FeedSelectedActivity.class);
TabGroupActivity parentActivity = (TabGroupActivity)getParent();
parentActivity.startChildActivity("feedselected", intent);
}
private Handler _handler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.arg2) {
case WSConstant.PID_SEARCH:
getJsonResponse(msg.obj.toString(), msg.arg2);
break;
default:
break;
}
}
};
private void getJsonResponse(String response, int arg2) {
JSONObject jObject=null;
try {
jObject = new JSONObject(response);
JSONArray list = jObject.getJSONArray("posts");
_alluserlist.clear();
for (int i = 0; i < list.length(); i++) {
JSONObject element = list.getJSONObject(i);
if ( type.equalsIgnoreCase("all")) {
AllBean bean= new AllBean();
bean.setid(element.getString("id"));
bean.setfullname(element.getString("fullname"));
bean.setusername(element.getString("username"));
bean.setprofile_photo(element.getString("profile_photo"));
bean.setprofile_type(element.getString("profile_type"));
bean.setprofile(element.getString("profile"));
_alluserlist.add(bean);
}
else if (type.equalsIgnoreCase("brand")) {
AllBean bean= new AllBean();
bean.setid(element.getString("brand_id"));
bean.setusername(element.getString("brand_name"));
bean.setprofile_photo(element.getString("brand_photo"));
_alluserlist.add(bean);
}
else if ( type.equalsIgnoreCase("item")) {
AllBean bean= new AllBean();
bean.setid(element.getString("item_id"));
bean.setusername(element.getString("item_name"));
bean.setprofile_photo(element.getString("item_photo"));
_alluserlist.add(bean);
}
else if (type.equalsIgnoreCase("user")) {
AllBean bean= new AllBean();
bean.setid(element.getString("id"));
bean.setfullname(element.getString("fullname"));
bean.setusername(element.getString("username"));
bean.setprofile_photo(element.getString("profile_photo"));
_alluserlist.add(bean);
}
else {
AllBean bean= new AllBean();
bean.setid(element.getString("id"));
bean.setfullname(element.getString("fullname"));
bean.setusername(element.getString("username"));
bean.setprofile_photo(element.getString("profile_photo"));
bean.setprofile_type(element.getString("profile_type"));
bean.setprofile(element.getString("profile"));
_alluserlist.add(bean);
}
if (_alluserlist.size()!=0) {
alladapter=new GridAllUserAdapter(ExploreScreenActivity.this, _alluserlist);
_explorGridView.setAdapter(alladapter);
}
}
if (_alluserlist.size()!=0) {
alladapter=new GridAllUserAdapter(ExploreScreenActivity.this, _alluserlist);
_explorGridView.setAdapter(alladapter);
}
if (_alluserlist.size()!=0) {
alladapter=new GridAllUserAdapter(ExploreScreenActivity.this, _alluserlist);
_explorGridView.setAdapter(alladapter);
}
if (_alluserlist.size()!=0) {
alladapter=new GridAllUserAdapter(ExploreScreenActivity.this, _alluserlist);
_explorGridView.setAdapter(alladapter);
}
if (_alluserlist.size()!=0) {
alladapter=new GridAllUserAdapter(ExploreScreenActivity.this, _alluserlist);
_explorGridView.setAdapter(alladapter);
}
}
catch (Exception e) {
// TODO: handle exception
}
}
@Override
public void serverResponse(String response, int processid) {
// TODO Auto-generated method stub
Message msg = new Message();
msg.obj = response;
msg.arg2 = processid;
_handler.sendMessage(msg);
}
}