OSDN Git Service

Add MIPS support
[android-x86/external-koush-Superuser.git] / Superuser / src / com / koushikdutta / superuser / LogNativeFragment.java
1 /*
2  * Copyright (C) 2013 Koushik Dutta (@koush)
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package com.koushikdutta.superuser;
18
19 import android.annotation.SuppressLint;
20 import android.app.Fragment;
21 import android.content.Context;
22 import android.os.Bundle;
23 import android.view.ContextThemeWrapper;
24 import android.view.LayoutInflater;
25 import android.view.View;
26 import android.view.ViewGroup;
27
28 import com.koushikdutta.widgets.NativeFragment;
29
30 @SuppressLint("NewApi")
31 public class LogNativeFragment extends NativeFragment<LogFragmentInternal> {
32     ContextThemeWrapper mWrapper;
33     public Context getContext() {
34         if (mWrapper != null)
35             return mWrapper;
36         mWrapper = new ContextThemeWrapper(super.getContext(), R.style.SuperuserDark);
37         return mWrapper;
38     }
39
40     @Override
41     public LogFragmentInternal createFragmentInterface() {
42         return new LogFragmentInternal(this) {
43             @Override
44             public Context getContext() {
45                 return LogNativeFragment.this.getContext();
46             }
47             
48             @Override
49             void onDelete() {
50                 super.onDelete();
51                 LogNativeFragment.this.onDelete(getListContentId());
52             }
53         };
54     }
55     
56     @Override
57     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
58         return super.onCreateView((LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE), container, savedInstanceState);
59     }
60
61     void onDelete(int id) {
62 //        getFragmentManager().beginTransaction().remove(this).commit();
63 //        getFragmentManager().popBackStack("content", FragmentManager.POP_BACK_STACK_INCLUSIVE);
64         Fragment f = getFragmentManager().findFragmentById(id);
65         if (f != null && f instanceof PolicyNativeFragment) {
66             PolicyNativeFragment p = (PolicyNativeFragment)f;
67             ((PolicyFragmentInternal)p.getInternal()).load();
68             ((PolicyFragmentInternal)p.getInternal()).showAllLogs();
69         }
70     }
71 }