Android Open Source - chat.android Service Overview 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;
//w  w w. j a va  2s  .  c  o m
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public class ServiceOverviewActivity extends BaseActivity {
  Context context;
  int visitId = 0;
  int hhId = 0;
  String role = null;
  
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        context = getApplicationContext();
        setContentView(R.layout.activity_service_overview);
    
    Bundle b = getIntent().getExtras();
    visitId = b.getInt("visitId");
    hhId = b.getInt("hhId");
    //Visit v = ModelHelper.getVisitForId(getHelper(), visitId);
    role = ModelHelper.getVisitForId(getHelper(), visitId).getRole();
    
    setupServiceTypeButtons(role);
  }
    
    public void setupServiceTypeButtons(String role) {
      // TODO: put this all in a new DB table, instead of relying on strings array and ifs
      String[] serviceNames = null;
    String[] serviceTags = null;
    String[] serviceImages = null;
    String[] roleArray = getResources().getStringArray(R.array.role_array);
    if (role.equals(roleArray[0])) {
      serviceNames = getResources().getStringArray(R.array.volunteer_service_type_names);
      serviceTags = getResources().getStringArray(R.array.volunteer_service_type_tags);
      serviceImages = getResources().getStringArray(R.array.volunteer_service_type_images);
    } else if (role.equals(roleArray[1])) {
      serviceTags = getResources().getStringArray(R.array.counsellor_service_type_array);
      serviceImages = getResources().getStringArray(R.array.counsellor_service_type_images);
    } else if (role.equals(roleArray[2])) {
      // looks like we're not doing welfare - incorporate images later as necessary
      serviceTags = getResources().getStringArray(R.array.welfare_service_type_array);
    } else {
      // TODO: expand me? Also throw a proper error here
      serviceTags = getResources().getStringArray(R.array.volunteer_service_type_names);
      BaseActivity.toastHelper(this, "Role is undefined. Contact technical support.");
    }
    
    // cycle through the serviceTypes, populate the labels and tags
    for (int i = 1; i <= serviceTags.length; i++) {
      // set the text
      String tvId = "service_subtype" + i + "_text_field";
      int resId = getResources().getIdentifier(tvId, "id", "org.chat.android");
        TextView tv = (TextView) findViewById(resId);
      tv.setText(serviceNames[i-1]);
      tv.setTag(i);
      
      // tag the button
      String imgId = "service_subtype" + i + "_button";
      resId = getResources().getIdentifier(imgId, "id", "org.chat.android");
      ImageView iv = (ImageView) findViewById(resId);
      iv.setTag(i);
      
      // set the correct image
      if (serviceImages[i-1] != null) {
        int imageResId = getResources().getIdentifier("drawable/"+serviceImages[i-1], null, getPackageName());
        iv.setImageDrawable(getResources().getDrawable(imageResId));
      } else {
             Log.e("Missing resource", "serviceImages");
      }
      
    }
    }
  
  public void openServiceDetails(View v) {
    Integer serviceTag = 0;
    serviceTag = (Integer) v.getTag();
    Intent i = null;
        
        if (serviceTag == 6) {
          i = new Intent(ServiceOverviewActivity.this, ServiceOtherActivity.class);
        } else {
          i = new Intent(ServiceOverviewActivity.this, ServiceDetailsActivity.class);
        }
      Bundle b = new Bundle();
      b.putInt("visitId",visitId);
      b.putInt("hhId",hhId);
      b.putString("role",role);
      b.putInt("serviceTag",serviceTag);
      i.putExtras(b);
      startActivity(i);
  }
  
  @Override
    public void onBackPressed() {
    Intent i = new Intent(ServiceOverviewActivity.this, HomeActivity.class);
      Bundle b = new Bundle();
      b.putInt("visitId",visitId);
      b.putBoolean("fromBack", true);
      i.putExtras(b);
      startActivity(i);
    }
  
}




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