Android Open Source - QBWebserviceDemo---Android Q B Webservice Demo Activity






From Project

Back to project page QBWebserviceDemo---Android.

License

The source code is released under:

Copyright (c) 2011 QBurst, http://qburst.com/ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redi...

If you think the Android project QBWebserviceDemo---Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.qburst.qbwebservice;
//from  ww  w.  j av a2 s  . c o  m
import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.qburst.qbwebservice.api.QBTestApi;
import com.qburst.qbwebservice.listeners.QBWebserviceListener;
import com.qburst.qbwebservice.models.QBWebserviceModel;
import com.qburst.qbwebservice.utilities.QBUtility;

public class QBWebserviceDemoActivity extends Activity implements QBWebserviceListener {
    
  ListView _subcategoriesLv;
  String _email, _password;
  int _categoryId = 5;
  QBTestApi _subcategoriesApi;
  QBInternAdapter _InternAdapter;
  private Context _context;
  
  /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        _email = "a";
        _password = "a";
    _context = this;
    
        _subcategoriesLv = (ListView)findViewById(R.id.listView1);
        
        _subcategoriesApi = new QBTestApi( _email, _password, _categoryId, QBWebserviceDemoActivity.this);
        _subcategoriesApi.invoke();
    
    }


  @Override
  public void onSuccess(ArrayList<QBWebserviceModel> subcatList, int apiID) {
    
    _InternAdapter = new QBInternAdapter(subcatList);
    _subcategoriesLv.setAdapter(_InternAdapter);
    //_InternAdapter.notifyDataSetChanged();
  }


  @Override
  public void onFail(String errorResponse, int apiID) {
    QBUtility.showDialogOkWithGoBack("Fetch fail", errorResponse, this);
  }
  
  public class QBInternAdapter extends BaseAdapter{
    
    ArrayList<QBWebserviceModel> _subcatList;

    public QBInternAdapter(ArrayList<QBWebserviceModel> subcatList) {
      this._subcatList = subcatList;
    }

    @Override
    public int getCount() {
      return _subcatList.size();
    }

    @Override
    public Object getItem(int position) {
      return _subcatList.get(position);
    }

    @Override
    public long getItemId(int position) {
      return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      
      convertView = LayoutInflater.from(_context).inflate(R.layout.cell, null);
      
      TextView _subcatTv = (TextView)convertView.findViewById(R.id.textView1);
      _subcatTv.setText(_subcatList.get(position).getName());
      return convertView;
    }
    
  }
}




Java Source Code List

com.qburst.qbwebservice.QBWebserviceDemoActivity.java
com.qburst.qbwebservice.api.QBApiConstants.java
com.qburst.qbwebservice.api.QBBaseWebService.java
com.qburst.qbwebservice.api.QBTestApi.java
com.qburst.qbwebservice.api.QMApiConstants.java
com.qburst.qbwebservice.app.QBWebserviceDemoApp.java
com.qburst.qbwebservice.listeners.QBApiResponseListener.java
com.qburst.qbwebservice.listeners.QBWebserviceListener.java
com.qburst.qbwebservice.models.QBBaseBean.java
com.qburst.qbwebservice.models.QBRequestBean.java
com.qburst.qbwebservice.models.QBResponseBean.java
com.qburst.qbwebservice.models.QBWebserviceModel.java
com.qburst.qbwebservice.utilities.QBUtility.java