Android Open Source - chat.android Service Details Activity






From Project

Back to project page chat.android.

License

The source code is released under:

GNU General Public License

If you think the Android project chat.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 org.chat.android;
/*  www  . j  a  va  2 s.c o  m*/
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.chat.android.models.Service;
import org.chat.android.models.ServiceAccessed;

import com.j256.ormlite.dao.Dao;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;

public class ServiceDetailsActivity extends BaseActivity {
  private int visitId = 0;
  private int hhId = 0;
  private List<Service> servicesList = new ArrayList<Service>();
  
  String selectedServices = null;
  
  ServicesAdapter sAdapter = null;
  String lang = Locale.getDefault().getLanguage();
  
    @Override    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Context context = getApplicationContext();
        setContentView(R.layout.activity_service_details);

    Bundle b = getIntent().getExtras();
    visitId = b.getInt("visitId");
    hhId = b.getInt("hhId");
    int tag = b.getInt("serviceTag") - 1;
    
    // TODO YUCKY HACK ALERT. WE'RE RUNNING OUT OF TIME, AND IT LOOKS LIKE WE WON'T BE DOING COUNSELLORS. THE BELOW ONLY WORKS FOR VOLUNTEERS, WAS AN EASY WAY TO DEAL WITH THE MULTIPLE LANGUAGES
    
    TextView tv = (TextView) findViewById(R.id.service_details_title_field);
    String[] serviceNames = getResources().getStringArray(R.array.volunteer_service_type_names);
    tv.setText(serviceNames[tag]);
    
    // grab list of services to show, based on the service subtype
    String[] serviceTags = getResources().getStringArray(R.array.volunteer_service_type_tags);
    populateServicesList(serviceTags[tag]);
    
    // grab the list of services already delivered
    List<ServiceAccessed> saList = ModelHelper.getServicesAccessedForVisitId(getHelper(), visitId);
    
    ListView lv = (ListView) findViewById(R.id.service_details_listview);
    sAdapter = new ServicesAdapter(context, android.R.layout.simple_list_item_multiple_choice, servicesList, saList, visitId, hhId);
  
      lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
      lv.setAdapter(sAdapter);         
    }
    
    // used to generate the list of services for serviceDelivery
    private void populateServicesList(String type) {
        try {
          Dao<Service, Integer> sDao = getHelper().getServicesDao();
      servicesList = sDao.queryBuilder().orderBy("en_name", true).where().eq("type",type).query();
    } catch (SQLException e) {
      // Auto-generated catch block
      e.printStackTrace();
    }        
    }
    
    public void openServiceDelivery() {
    Intent i = new Intent(this, ServiceDeliveryActivity.class);
      Bundle b = new Bundle();
      b.putInt("visitId",visitId);
      b.putInt("hhId",hhId);
      b.putString("serviceName", selectedServices);
      b.putBoolean("adInfoFlag",false);
      i.putExtras(b);
      startActivity(i);
    }
    
//    public void selectServiceTargets(View v) {
//      ArrayList<String> serviceNames = sAdapter.getSelectedServices();
//      if (serviceNames.size() > 0) {
//        Intent i = new Intent(ServiceDetailsActivity.this, ServiceDeliveryActivity.class);
//          Bundle b = new Bundle();
//          b.putInt("visitId",visitId);
//          b.putInt("hhId",hhId);
//          b.putStringArrayList("serviceNames", serviceNames);
//          b.putBoolean("adInfoFlag",false);
//          i.putExtras(b);
//          startActivity(i);
//      } else {
//        String msg = getResources().getString(getResources().getIdentifier("service_select_one_service_text", "string", getPackageName()));
//        BaseActivity.toastHelper(this, msg);
//      }
//    }
    
    
}




Java Source Code List

org.chat.android.BaseActivity.java
org.chat.android.CHADelivery.java
org.chat.android.CHAOverviewActivity.java
org.chat.android.CHASelectChildActivity.java
org.chat.android.CHASelectChildAdapter.java
org.chat.android.ChatUtil.java
org.chat.android.ClientsAdapter.java
org.chat.android.DatabaseHelper.java
org.chat.android.GPSTracker.java
org.chat.android.HealthDeliveryActivity.java
org.chat.android.HealthDetailsActivity.java
org.chat.android.HealthOverviewActivity.java
org.chat.android.HealthOverviewRecordActivity.java
org.chat.android.HomeActivity.java
org.chat.android.ImmunizationsReceivedActivity.java
org.chat.android.ImmunizationsSummaryActivity.java
org.chat.android.LoginActivity.java
org.chat.android.Mail.java
org.chat.android.ModelHelper.java
org.chat.android.MyApplication.java
org.chat.android.ResourcesActivity.java
org.chat.android.RestoreVisitActivity.java
org.chat.android.ServiceDeliveryActivity.java
org.chat.android.ServiceDeliveryAdapter.java
org.chat.android.ServiceDetailsActivity.java
org.chat.android.ServiceOtherActivity.java
org.chat.android.ServiceOverviewActivity.java
org.chat.android.ServicesAdapter.java
org.chat.android.SetupDB.java
org.chat.android.SetupVisitActivity.java
org.chat.android.SyncResourcesActivity.java
org.chat.android.Auth.AccountGeneral.java
org.chat.android.Auth.AuthenticatorService.java
org.chat.android.Auth.Authenticator.java
org.chat.android.Auth.ChatAuthServerAuthenticate.java
org.chat.android.Auth.MainActivity.java
org.chat.android.Auth.ServerAuthenticate.java
org.chat.android.Sync.StubProvider.java
org.chat.android.Sync.SyncAdapter.java
org.chat.android.Sync.SyncService.java
org.chat.android.Sync.provider.ChatContentProvider.java
org.chat.android.models.Attendance.java
org.chat.android.models.CHAAccessed.java
org.chat.android.models.Client.java
org.chat.android.models.HealthPage.java
org.chat.android.models.HealthSelectRecorded.java
org.chat.android.models.HealthSelect.java
org.chat.android.models.HealthTheme.java
org.chat.android.models.HealthTopicAccessed.java
org.chat.android.models.HealthTopic.java
org.chat.android.models.Household.java
org.chat.android.models.PageAssessment1.java
org.chat.android.models.PageSelect1.java
org.chat.android.models.PageText1.java
org.chat.android.models.PageVideo1.java
org.chat.android.models.ResourceAccessed.java
org.chat.android.models.Resource.java
org.chat.android.models.Role.java
org.chat.android.models.ServiceAccessed.java
org.chat.android.models.Service.java
org.chat.android.models.TopicVideo.java
org.chat.android.models.Util.java
org.chat.android.models.VaccineRecorded.java
org.chat.android.models.Vaccine.java
org.chat.android.models.VideoAccessed.java
org.chat.android.models.Video.java
org.chat.android.models.Visit.java
org.chat.android.models.Worker.java
org.chat.android.pages.Assessment1Fragment.java
org.chat.android.pages.BaseFragment.java
org.chat.android.pages.ReferralFragment.java
org.chat.android.pages.Select1Fragment.java
org.chat.android.pages.Text1Fragment.java
org.chat.android.pages.Video1Fragment.java