2 * ownCloud Android client application
5 * Copyright (C) 2015 ownCloud Inc.
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2,
9 * as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 package com
.owncloud
.android
.ui
.fragment
;
23 import android
.accounts
.Account
;
24 import android
.app
.Activity
;
25 import android
.net
.Uri
;
26 import android
.os
.Bundle
;
27 import android
.support
.v4
.app
.Fragment
;
28 import android
.view
.LayoutInflater
;
29 import android
.view
.View
;
30 import android
.view
.ViewGroup
;
32 import com
.owncloud
.android
.R
;
33 import com
.owncloud
.android
.datamodel
.OCFile
;
36 * Fragment for Searching users and groups
38 * A simple {@link Fragment} subclass.
39 * Activities that contain this fragment must implement the
40 * {@link SearchFragment.OnSearchFragmentInteractionListener} interface
41 * to handle interaction events.
42 * Use the {@link SearchFragment#newInstance} factory method to
43 * create an instance of this fragment.
45 public class SearchFragment
extends Fragment
{
46 private static final String TAG
= ShareFileFragment
.class.getSimpleName();
48 // the fragment initialization parameters
49 private static final String ARG_FILE
= "FILE";
50 private static final String ARG_ACCOUNT
= "ACCOUNT";
54 private Account mAccount
;
56 private OnSearchFragmentInteractionListener mListener
;
59 * Public factory method to create new SearchFragment instances.
61 * @param fileToShare An {@link OCFile} to show in the fragment
62 * @param account An ownCloud account
63 * @return A new instance of fragment SearchFragment.
65 // TODO: Rename and change types and number of parameters
66 public static SearchFragment
newInstance(OCFile fileToShare
, Account account
) {
67 SearchFragment fragment
= new SearchFragment();
68 Bundle args
= new Bundle();
69 args
.putParcelable(ARG_FILE
, fileToShare
);
70 args
.putParcelable(ARG_ACCOUNT
, account
);
71 fragment
.setArguments(args
);
75 public SearchFragment() {
76 // Required empty public constructor
80 public void onCreate(Bundle savedInstanceState
) {
81 super.onCreate(savedInstanceState
);
82 if (getArguments() != null
) {
83 mFile
= getArguments().getParcelable(ARG_FILE
);
84 mAccount
= getArguments().getParcelable(ARG_ACCOUNT
);
90 public View
onCreateView(LayoutInflater inflater
, ViewGroup container
,
91 Bundle savedInstanceState
) {
92 // Inflate the layout for this fragment
93 View view
= inflater
.inflate(R
.layout
.search_users_groups_layout
, container
, false
);
98 // TODO: Rename method, update argument and hook method into UI event
99 public void onButtonPressed(Uri uri
) {
100 if (mListener
!= null
) {
101 mListener
.onSearchFragmentInteraction(uri
);
106 public void onAttach(Activity activity
) {
107 super.onAttach(activity
);
109 mListener
= (OnSearchFragmentInteractionListener
) activity
;
110 } catch (ClassCastException e
) {
111 throw new ClassCastException(activity
.toString()
112 + " must implement OnFragmentInteractionListener");
117 public void onDetach() {
122 // TODO: review if it is necessary
124 * This interface must be implemented by activities that contain this
125 * fragment to allow an interaction in this fragment to be communicated
126 * to the activity and potentially other fragments contained in that
129 * See the Android Training lesson <a href=
130 * "http://developer.android.com/training/basics/fragments/communicating.html"
131 * >Communicating with Other Fragments</a> for more information.
133 public interface OnSearchFragmentInteractionListener
{
134 // TODO: Update argument type and name
135 public void onSearchFragmentInteraction(Uri uri
);