Android Open Source - logmypain View List Fragment






From Project

Back to project page logmypain.

License

The source code is released under:

GNU General Public License

If you think the Android project logmypain 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.logmypain.tasks.framents;
//from w  ww .j  av a  2s.  c o  m
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;

import com.logmypain.tasks.listeners.YearSelectedListener;
import com.logmypain.utils.DatabaseHelper;
import com.logmypain.tasks.adapters.ViewRecordsAdapter;
import com.logmypain.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.TextView;

public class ViewListFragment extends Fragment{
  private ViewRecordsAdapter rAdapter;
  View view; 
  public View onCreateView(LayoutInflater inflater, ViewGroup container, 
            Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    view = inflater.inflate(R.layout.listview_view_records, container, false);
    final ListView list = (ListView) view.findViewById(R.id.list_view_records);
    final TextView emptyList = (TextView) view.findViewById(R.id.list_view_empty);
    //getActionBar().setDisplayHomeAsUpEnabled(true);

            DatabaseHelper db = new DatabaseHelper(this.getActivity());

    //rAdapter = new ViewRecordsAdapter(this.getActivity(),
        //       layout.activity_view_records, db.getAllHeadaches());
    //list.setAdapter(rAdapter);
    list.setEmptyView(emptyList);

        List<String> years = db.getYears();
    setupSpinners(list, years);

    return view;
  }

  public void setupSpinners(ListView list, List<String> years){
    if(years == null || years.size() == 0){
      years = new ArrayList<String>();
      Calendar cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
      int year = cal.get(Calendar.YEAR);
      years.add(Integer.toString(year));
    }
    Spinner yearSpinner = (Spinner) view.findViewById(R.id.view_records_year_spinner);
    Spinner monthSpinner = (Spinner) view.findViewById(R.id.view_records_month_spinner);
    
    ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this.getActivity(),
      android.R.layout.simple_spinner_item, years);
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    yearSpinner.setAdapter(dataAdapter);
       
    yearSpinner.setOnItemSelectedListener(new YearSelectedListener(list, monthSpinner, YearSelectedListener.Change.YEAR));
    monthSpinner.setOnItemSelectedListener(new YearSelectedListener(list, yearSpinner, YearSelectedListener.Change.MONTH));

  }
  
  public void onClickDeleteRecord(View v){
    rAdapter.deleteRecord(v);
    
    }

  
  
//  

}




Java Source Code List

com.logmypain.main.MainActivity.java
com.logmypain.main.record.HeadacheRecordFormActivity.java
com.logmypain.main.record.dialogs.AddTriggersDialogFragment.java
com.logmypain.main.record.dialogs.DateTimeDialogFragment.java
com.logmypain.main.record.toasties.RecordNowToastie.java
com.logmypain.tasks.ViewRecordsActivity.java
com.logmypain.tasks.adapters.CalendarGridViewAdapter.java
com.logmypain.tasks.adapters.TriggersAdapter.java
com.logmypain.tasks.adapters.ViewRecordsAdapter.java
com.logmypain.tasks.framents.ViewCalendarFragment.java
com.logmypain.tasks.framents.ViewListFragment.java
com.logmypain.tasks.listeners.MonthSelectedListener.java
com.logmypain.tasks.listeners.ViewRecordsTabListener.java
com.logmypain.tasks.listeners.YearSelectedListener.java
com.logmypain.utils.CalendarUtil.java
com.logmypain.utils.CalendarViewDay.java
com.logmypain.utils.DatabaseHelper.java
com.logmypain.utils.SquareLayout.java
com.logmypain.utils.Models.HeadacheRecord.java
com.logmypain.utils.Models.Headache.java
com.logmypain.utils.Models.Trigger.java