2 * Copyright (C) 2013 Koushik Dutta (@koush)
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.koushikdutta.widgets;
19 import android.app.Activity;
20 import android.app.Fragment;
21 import android.content.Context;
22 import android.content.res.Configuration;
23 import android.os.Bundle;
24 import android.view.LayoutInflater;
25 import android.view.Menu;
26 import android.view.MenuInflater;
27 import android.view.View;
28 import android.view.ViewGroup;
31 public abstract class NativeFragment<T extends FragmentInterface> extends Fragment implements FragmentInterfaceWrapper {
32 public abstract T createFragmentInterface();
35 public void onResume() {
40 public Context getContext() {
44 public void onDetach() {
49 public void onAttach(Activity activity) {
50 super.onAttach(activity);
51 internal.onAttach(activity);
55 public NativeFragment() {
56 internal = createFragmentInterface();
60 public T getInternal() {
65 public void onCreate(Bundle savedInstanceState) {
66 super.onCreate(savedInstanceState);
67 internal.onCreate(savedInstanceState);
71 public void onConfigurationChanged(Configuration newConfig) {
72 super.onConfigurationChanged(newConfig);
73 internal.onConfigurationChanged(newConfig);
77 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
78 return internal.onCreateView(inflater, container, savedInstanceState);
82 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
83 super.onCreateOptionsMenu(menu, inflater);
85 internal.onCreateOptionsMenu(menu, inflater);