Android Open Source - TimeSheets Time Fragment






From Project

Back to project page TimeSheets.

License

The source code is released under:

MIT License

If you think the Android project TimeSheets 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.powerblock.timesheets.fragments;
/*  w  w  w.j a  v  a  2  s  . c  om*/
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.powerblock.timesheets.ExcelHandler;
import com.powerblock.timesheets.MainActivity;
import com.powerblock.timesheets.R;
import com.powerblock.timesheets.signatures.SignatureActivity;

public class TimeFragment extends Fragment {
  
  private ExcelHandler mExcelHandler;
  static final int TIME_FRAGMENT_REQUEST_CODE = 1;
  public static final String TIME_FRAGMENT_SIGNATURE_CODE = "Signature Type";
  private View mView;
  
  public TimeFragment(){
    mExcelHandler = MainActivity.getExcelHandler();
  }
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
    setHasOptionsMenu(true);
    mView = mExcelHandler.read(inflater, container, R.layout.time_layout, ExcelHandler.EXCEL_SECTION_TIME);
    if(mView == null)
      mView = inflater.inflate(R.layout.time_layout, container,false);
    Button b = (Button) mView.findViewById(R.id.time_customer_signature_button);
    b.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        Intent i = new Intent(getActivity(),SignatureActivity.class);
        i.putExtra(TIME_FRAGMENT_SIGNATURE_CODE, SignatureActivity.SIG_IDENTIFIER_CUST);
        startActivityForResult(i,TIME_FRAGMENT_REQUEST_CODE);
      }
    });
    b = (Button) mView.findViewById(R.id.time_employee_signature_button);
    b.setOnClickListener(new View.OnClickListener() {
      
      @Override
      public void onClick(View v) {
        Intent i = new Intent(getActivity(), SignatureActivity.class);
        i.putExtra(TIME_FRAGMENT_SIGNATURE_CODE, SignatureActivity.SIG_IDENTIFIER_EMP);
        startActivityForResult(i, TIME_FRAGMENT_REQUEST_CODE);
      }
    });
    return mView;  
  }
  
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
    inflater.inflate(R.menu.save_menu, menu);
    super.onCreateOptionsMenu(menu, inflater);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item){
    if(item.getItemId() == R.id.action_save){
      mExcelHandler.write(ExcelHandler.EXCEL_SECTION_TIME,mView);
      getActivity().getSupportFragmentManager().popBackStack();
      return true;
    }
    return false;
  }
  
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == TIME_FRAGMENT_REQUEST_CODE){
      if(resultCode == Activity.RESULT_OK){
        String code = data.getStringExtra(SignatureActivity.SIG_IDENTIFIER_FILE);
        String type = data.getStringExtra(SignatureActivity.SIG_IDENTIFIER_TYPE);
        if(!code.equalsIgnoreCase("Error")){
          mExcelHandler.saveImage(code, type);
        }
      }
    }
  }
}




Java Source Code List

com.powerblock.timesheets.CustomCheckBox.java
com.powerblock.timesheets.CustomEditText.java
com.powerblock.timesheets.CustomSpinner.java
com.powerblock.timesheets.ExcelHandler.java
com.powerblock.timesheets.MainActivity.java
com.powerblock.timesheets.MultiChoiceSpinner.java
com.powerblock.timesheets.PBSpinner.java
com.powerblock.timesheets.XmlHandler.java
com.powerblock.timesheets.fragments.MainFragment.java
com.powerblock.timesheets.fragments.MaterialsFragment.java
com.powerblock.timesheets.fragments.SafetyFragment.java
com.powerblock.timesheets.fragments.SectionTemplate.java
com.powerblock.timesheets.fragments.TimeFragment.java
com.powerblock.timesheets.signatures.SignatureActivity.java
com.powerblock.timesheets.signatures.SignatureView.java