Back to project page Android-ProgressFragment.
The source code is released under:
Apache License
If you think the Android project Android-ProgressFragment 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) 2013 Evgeny Shishkin/*from w w w . ja v a 2 s .co 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.devspark.progressfragment.sample.sherlock; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import com.actionbarsherlock.view.Menu; import com.actionbarsherlock.view.MenuInflater; import com.actionbarsherlock.view.MenuItem; import com.devspark.progressfragment.SherlockProgressGridFragment; /** * Sample implementation of {@link com.devspark.progressfragment.SherlockProgressGridFragment}. * * @author Evgeny Shishkin */ public class DefaultProgressGridFragment extends SherlockProgressGridFragment { private Handler mHandler; private Runnable mShowContentRunnable = new Runnable() { @Override public void run() { setGridAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.sweets))); setGridShown(true); } }; public static DefaultProgressGridFragment newInstance() { DefaultProgressGridFragment fragment = new DefaultProgressGridFragment(); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); } @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); getGridView().setNumColumns(2); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Setup text for empty content setEmptyText(R.string.empty); obtainData(); } @Override public void onDestroyView() { super.onDestroyView(); mHandler.removeCallbacks(mShowContentRunnable); } @Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.refresh, menu); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_refresh: obtainData(); return true; default: return super.onOptionsItemSelected(item); } } private void obtainData() { // Show indeterminate progress setGridShown(false); mHandler = new Handler(); mHandler.postDelayed(mShowContentRunnable, 3000); } }