Back to project page android-drawer-tab.
The source code is released under:
Apache License
If you think the Android project android-drawer-tab listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2014 ech0s7r /*from w w w . j a va 2s .c o m*/ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.echlabsw.android.drawertab; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; public class ExampleFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { public static interface OnRefreshContentListener { /** * Notified when a refresh is triggered via the swipe gesture. * * @param swipeLayout */ void onRefreshFragmentContent(SwipeRefreshLayout swipeLayout); } private SwipeRefreshLayout mSwipeLayout; private OnRefreshContentListener mOnRefreshContentListener; @SuppressWarnings("deprecation") @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.example_fragment_layout, container, false); Bundle b = getArguments(); TextView txt = (TextView) rootView .findViewById(R.id.content_fragment_text); txt.setText(getString(R.string.text, b.getInt("index"))); mSwipeLayout = (SwipeRefreshLayout) rootView .findViewById(R.id.swipe_container); mSwipeLayout.setOnRefreshListener(this); mSwipeLayout.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); return rootView; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(MainActivity.TAG, "ExampleFragment onCreate()"); } @Override public void onAttach(Activity activity) { super.onAttach(activity); try { mOnRefreshContentListener = (OnRefreshContentListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnRefreshContentListener"); } } @Override public void onDestroy() { super.onDestroy(); } @Override public void onRefresh() { if (mOnRefreshContentListener != null) { mOnRefreshContentListener.onRefreshFragmentContent(mSwipeLayout); } } }