Created
January 4, 2016 22:46
-
-
Save beall49/ce370c4b632dd4add867 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package rbeall.cfexcel; | |
| import android.app.Activity; | |
| import android.graphics.PorterDuff; | |
| import android.net.Uri; | |
| import android.os.Bundle; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.webkit.WebChromeClient; | |
| import android.webkit.WebSettings; | |
| import android.webkit.WebView; | |
| import android.widget.ProgressBar; | |
| import butterknife.Bind; | |
| import butterknife.ButterKnife; | |
| import rbeall.cfexcel.utils.SharedPrefMgr; | |
| public class Web extends android.support.v4.app.Fragment { | |
| @Bind(R.id.pBar) ProgressBar progress; | |
| @Bind(R.id.webView) WebView webView; | |
| private View view; | |
| @Override | |
| public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
| view = inflater.inflate(R.layout.fragment_web, container, false); | |
| ButterKnife.bind(this, view); | |
| progress.setProgress(0); | |
| progress.setMax(100); | |
| progress.getProgressDrawable().setColorFilter(getResources().getColor(R.color.accent), PorterDuff.Mode.SRC_IN); | |
| webView.setWebChromeClient(new MyWebViewClient()); | |
| WebSettings webSettings = webView.getSettings(); | |
| webSettings.setJavaScriptEnabled(true); | |
| webView.setFocusableInTouchMode(true); | |
| webView.requestFocus(); | |
| webView.loadUrl(SharedPrefMgr.SCHEDULE_URL); | |
| return view; | |
| } | |
| /* | |
| handles the progresss bar | |
| progress | |
| */ | |
| public void setValue(int progress) { | |
| this.progress.setProgress(progress); | |
| if (progress == 100) this.progress.setVisibility(View.GONE); | |
| } | |
| private class MyWebViewClient extends WebChromeClient { | |
| @Override | |
| public void onProgressChanged(WebView view, int newProgress) { | |
| Web.this.setValue(newProgress); | |
| super.onProgressChanged(view, newProgress); | |
| } | |
| } | |
| private OnFragmentInteractionListener mListener; | |
| public interface OnFragmentInteractionListener { | |
| public void onFragmentInteraction(Uri uri); | |
| } | |
| @Override | |
| public void onAttach(Activity activity) { | |
| super.onAttach(activity); | |
| mListener = (OnFragmentInteractionListener) activity; | |
| } | |
| @Override | |
| public void onDetach() { | |
| super.onDetach(); | |
| mListener = null; | |
| } | |
| public static Web newInstance() { | |
| return new Web(); | |
| } | |
| public Web() { | |
| // Required empty public constructor | |
| } | |
| @Override | |
| public void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment