Skip to content

Commit

Permalink
Merge pull request #2264 from wordpress-mobile/issue/2222-theme-previ…
Browse files Browse the repository at this point in the history
…ew-title

issue/2222 theme preview title
  • Loading branch information
daniloercoli committed Jan 29, 2015
2 parents 706a65f + e873ea3 commit 4c02650
Showing 1 changed file with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,35 @@
import android.widget.ProgressBar;

public class WPWebChromeClient extends WebChromeClient {
private ProgressBar mProgressBar;
private Activity mActivity;
private final ProgressBar mProgressBar;
private final Activity mActivity;
private final boolean mAutoUpdateActivityTitle;

public WPWebChromeClient(Activity activity, ProgressBar progressBar) {
mActivity = activity;
mProgressBar = progressBar;
mAutoUpdateActivityTitle = true;
}

public WPWebChromeClient(Activity activity,
ProgressBar progressBar,
boolean autoUpdateActivityTitle) {
mActivity = activity;
mProgressBar = progressBar;
mAutoUpdateActivityTitle = autoUpdateActivityTitle;
}

public void onProgressChanged(WebView webView, int progress) {
if (!mActivity.isFinishing()) {
if (mActivity != null && !mActivity.isFinishing() && mAutoUpdateActivityTitle) {
mActivity.setTitle(webView.getTitle());
}
if (progress == 100) {
mProgressBar.setVisibility(View.GONE);
} else {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(progress);
if (mProgressBar != null) {
if (progress == 100) {
mProgressBar.setVisibility(View.GONE);
} else {
mProgressBar.setVisibility(View.VISIBLE);
mProgressBar.setProgress(progress);
}
}
}
}

0 comments on commit 4c02650

Please sign in to comment.