|  | 
|  | 1 | +package org.codedocs.codedocsapp | 
|  | 2 | + | 
|  | 3 | +import android.content.Context | 
|  | 4 | +import android.net.Uri | 
|  | 5 | +import android.os.Bundle | 
|  | 6 | +import android.support.v4.app.Fragment | 
|  | 7 | +import android.view.LayoutInflater | 
|  | 8 | +import android.view.View | 
|  | 9 | +import android.view.ViewGroup | 
|  | 10 | + | 
|  | 11 | + | 
|  | 12 | +// TODO: Rename parameter arguments, choose names that match | 
|  | 13 | +// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | 
|  | 14 | +private const val ARG_PARAM1 = "param1" | 
|  | 15 | +private const val ARG_PARAM2 = "param2" | 
|  | 16 | + | 
|  | 17 | +/** | 
|  | 18 | + * A simple [Fragment] subclass. | 
|  | 19 | + * Activities that contain this fragment must implement the | 
|  | 20 | + * [calander.OnFragmentInteractionListener] interface | 
|  | 21 | + * to handle interaction events. | 
|  | 22 | + * Use the [calander.newInstance] factory method to | 
|  | 23 | + * create an instance of this fragment. | 
|  | 24 | + * | 
|  | 25 | + */ | 
|  | 26 | +class calander : Fragment() { | 
|  | 27 | + var mView:View?=null | 
|  | 28 | + // TODO: Rename and change types of parameters | 
|  | 29 | + private var param1: String? = null | 
|  | 30 | + private var param2: String? = null | 
|  | 31 | + private var listener: OnFragmentInteractionListener? = null | 
|  | 32 | + | 
|  | 33 | + override fun onCreate(savedInstanceState: Bundle?) { | 
|  | 34 | + super.onCreate(savedInstanceState) | 
|  | 35 | + arguments?.let { | 
|  | 36 | + param1 = it.getString(ARG_PARAM1) | 
|  | 37 | + param2 = it.getString(ARG_PARAM2) | 
|  | 38 | + } | 
|  | 39 | + } | 
|  | 40 | + | 
|  | 41 | + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, | 
|  | 42 | + savedInstanceState: Bundle?): View? { | 
|  | 43 | + mView=inflater.inflate(R.layout.fragment_calander, container, false) | 
|  | 44 | + return mView | 
|  | 45 | + } | 
|  | 46 | + | 
|  | 47 | + // TODO: Rename method, update argument and hook method into UI event | 
|  | 48 | + fun onButtonPressed(uri: Uri) { | 
|  | 49 | + listener?.onFragmentInteraction(uri) | 
|  | 50 | + } | 
|  | 51 | + | 
|  | 52 | + override fun onAttach(context: Context) { | 
|  | 53 | + super.onAttach(context) | 
|  | 54 | + if (context is OnFragmentInteractionListener) { | 
|  | 55 | + listener = context | 
|  | 56 | + } else { | 
|  | 57 | + | 
|  | 58 | + } | 
|  | 59 | + } | 
|  | 60 | + | 
|  | 61 | + override fun onDetach() { | 
|  | 62 | + super.onDetach() | 
|  | 63 | + listener = null | 
|  | 64 | + } | 
|  | 65 | + | 
|  | 66 | + /** | 
|  | 67 | + * This interface must be implemented by activities that contain this | 
|  | 68 | + * fragment to allow an interaction in this fragment to be communicated | 
|  | 69 | + * to the activity and potentially other fragments contained in that | 
|  | 70 | + * activity. | 
|  | 71 | + * | 
|  | 72 | + * | 
|  | 73 | + * See the Android Training lesson [Communicating with Other Fragments] | 
|  | 74 | + * (http://developer.android.com/training/basics/fragments/communicating.html) | 
|  | 75 | + * for more information. | 
|  | 76 | + */ | 
|  | 77 | + interface OnFragmentInteractionListener { | 
|  | 78 | + // TODO: Update argument type and name | 
|  | 79 | + fun onFragmentInteraction(uri: Uri) | 
|  | 80 | + } | 
|  | 81 | + | 
|  | 82 | + companion object { | 
|  | 83 | + /** | 
|  | 84 | + * Use this factory method to create a new instance of | 
|  | 85 | + * this fragment using the provided parameters. | 
|  | 86 | + * | 
|  | 87 | + * @param param1 Parameter 1. | 
|  | 88 | + * @param param2 Parameter 2. | 
|  | 89 | + * @return A new instance of fragment calander. | 
|  | 90 | + */ | 
|  | 91 | + // TODO: Rename and change types and number of parameters | 
|  | 92 | + @JvmStatic | 
|  | 93 | + fun newInstance(param1: String, param2: String) = | 
|  | 94 | + calander().apply { | 
|  | 95 | + arguments = Bundle().apply { | 
|  | 96 | + putString(ARG_PARAM1, param1) | 
|  | 97 | + putString(ARG_PARAM2, param2) | 
|  | 98 | + } | 
|  | 99 | + } | 
|  | 100 | + } | 
|  | 101 | +} | 
0 commit comments