[IOT-1089] Change Android build system to accomodate both Android and Generic Java...
[contrib/iotivity.git] / java / examples-android / simplebase / src / main / java / org / iotivity / base / examples / TemplateFragment.java
1 /*
2  * ******************************************************************
3  *
4  * Copyright 2016 Samsung Electronics All Rights Reserved.
5  *
6  * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *     http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21  */
22
23 package org.iotivity.base.examples;
24
25 import android.app.Activity;
26 import android.app.Fragment;
27 import android.content.Context;
28 import android.os.Bundle;
29 import android.view.LayoutInflater;
30 import android.view.View;
31 import android.view.ViewGroup;
32 import android.widget.Button;
33
34 /**
35  * This class the template for the test.
36  */
37 public class TemplateFragment extends Fragment implements View.OnClickListener {
38
39     private Activity mActivity;
40     private Context  mContext;
41
42     Button           buttonA;
43     Button           buttonB;
44     Button           buttonC;
45
46     @Override
47     public View onCreateView(LayoutInflater inflater, ViewGroup container,
48                              Bundle savedInstanceState) {
49         View rootView = inflater.inflate(R.layout.fragment_template, container, false);
50
51         buttonA = (Button) rootView.findViewById(R.id.btn_A);
52         buttonB = (Button) rootView.findViewById(R.id.btn_B);
53         buttonC = (Button) rootView.findViewById(R.id.btn_C);
54
55         buttonA.setOnClickListener(this);
56         buttonB.setOnClickListener(this);
57         buttonC.setOnClickListener(this);
58
59         return rootView;
60     }
61
62     @Override
63     public void onCreate(Bundle savedInstanceState) {
64         super.onCreate(savedInstanceState);
65         mActivity = getActivity();
66         mContext = mActivity.getBaseContext();
67     }
68
69     @Override
70     public void onResume() {
71         super.onResume();
72     }
73
74     @Override
75     public void onPause() {
76         super.onPause();
77     }
78
79     @Override
80     public void onDestroy() {
81         super.onDestroy();
82     }
83
84     @Override
85     public void onClick(View view) {
86         StringBuilder sb = new StringBuilder(getString(R.string.action_onclick));
87         switch (view.getId()) {
88             case R.id.btn_A:
89                 sb.append(getString(R.string.button_A));
90                 break;
91             case R.id.btn_B:
92                 sb.append(getString(R.string.button_B));
93                 break;
94             case R.id.btn_C:
95                 sb.append(getString(R.string.button_C));
96                 break;
97         }
98         Common.showToast(mContext, sb.toString());
99     }
100 }