Android Open Source - chat.android Video1 Fragment






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.pages;
/*ww  w.  java 2  s  . co  m*/
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.chat.android.ModelHelper;
import org.chat.android.R;
import org.chat.android.models.HealthTheme;
import org.chat.android.models.PageVideo1;
import org.chat.android.models.TopicVideo;
import org.chat.android.models.Video;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class Video1Fragment extends BaseFragment {
  Context context;
  int visitId = 0;
    TextView title = null;
    TextView content1 = null;
    List<LinearLayout> videoBoxList = null;
    List<ImageView> imgViewList = null;
    List<TextView> videoNameList = null;
    
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.fragment_video1, container, false);
      context = getActivity();
      
      visitId = getArguments().getInt("visitId"); 
      
      title = (TextView) view.findViewById(R.id.v1title);
      content1 = (TextView) view.findViewById(R.id.v1content1);
      
      videoBoxList = new ArrayList<LinearLayout>();
      videoBoxList.add((LinearLayout) view.findViewById(R.id.v1videoBox1));
      videoBoxList.add((LinearLayout) view.findViewById(R.id.v1videoBox2));
      videoBoxList.add((LinearLayout) view.findViewById(R.id.v1videoBox3));
      videoBoxList.add((LinearLayout) view.findViewById(R.id.v1videoBox4));
      
      imgViewList = new ArrayList<ImageView>();
      imgViewList.add((ImageView) view.findViewById(R.id.v1videoImage1));
      imgViewList.add((ImageView) view.findViewById(R.id.v1videoImage2));
      imgViewList.add((ImageView) view.findViewById(R.id.v1videoImage3));
      imgViewList.add((ImageView) view.findViewById(R.id.v1videoImage4));
      // make them not clickable until (and if) they've been pulled from DB - ie they should not be clickable if that image is not filled
      for (ImageView i : imgViewList) {
        i.setEnabled(false);
      }
      
      videoNameList = new ArrayList<TextView>();
      videoNameList.add((TextView) view.findViewById(R.id.v1videoText1));
      videoNameList.add((TextView) view.findViewById(R.id.v1videoText2));
      videoNameList.add((TextView) view.findViewById(R.id.v1videoText3));
      videoNameList.add((TextView) view.findViewById(R.id.v1videoText4));
      
      String lang = Locale.getDefault().getLanguage();
      
      populateDisplayedFragment(getArguments().getString("themeName"), getArguments().getString("type"), getArguments().getInt("id"), lang);

      return view;
    }

  public void populateDisplayedFragment(String themeName, String type, int pageContentId, String lang) {
    PageVideo1 pv = ModelHelper.getPageVideo1ForId(getHelper(), pageContentId);

    content1.setText(pv.getContent(lang, "content1"));
    
    HealthTheme theme = ModelHelper.getThemeForName(getHelper(), themeName);
    int colorRef = Color.parseColor(theme.getColor());
    title.setTextColor(colorRef);
    
    // grab the videos for this page
    List<TopicVideo> topicVideos = ModelHelper.getVideoIdsForPageVideo1Id(getHelper(), pv.getId());        // this is from a bridge table, containing page_video1_ids and video_ids
    
    // populate the images and text from video list
    //v1videoImage1  v1videoText1
    for (int i = 0; i < topicVideos.size(); i++) {
      Video video = ModelHelper.getVideoForId(getHelper(), topicVideos.get(i).getVideoId());
      int screenshotId = getResources().getIdentifier(video.getScreenshot(), "drawable", context.getPackageName());
      imgViewList.get(i).setImageResource(screenshotId);
      imgViewList.get(i).setTag(video.getId());
      imgViewList.get(i).setEnabled(true);
      videoNameList.get(i).setText(video.getName());
      videoBoxList.get(i).setVisibility(View.VISIBLE);
    }  
    }
}




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