Java tutorial
/* * ================================================================================= * Copyright (C) 2013 Martin Albedinsky [Wolf-ITechnologies] * ================================================================================= * Licensed under the Apache License, Version 2.0 or later (further "License" only); * --------------------------------------------------------------------------------- * You may use this file only in compliance with the License. More details and copy * of this License you may obtain at * * http://www.apache.org/licenses/LICENSE-2.0 * * You can redistribute, modify or publish any part of the code written in this * file but as it is described in the License, the software distributed under the * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES or CONDITIONS OF * ANY KIND. * * See the License for the specific language governing permissions and limitations * under the License. * ================================================================================= */ package com.wit.and.dialog.internal.xml; import android.content.res.XmlResourceParser; import android.support.v4.app.DialogFragment; import com.wit.and.dialog.ProgressDialog; import com.wit.and.dialog.R; import com.wit.and.dialog.manage.DialogFactory; import com.wit.and.dialog.manage.DialogOptions; import com.wit.and.dialog.xml.XmlDialogParser; /** * <h4>Class Overview</h4> * <p> * </p> * * @author Martin Albedinsky */ class XmlProgressDialog extends XmlDialogParser<ProgressDialog.ProgressOptions> { /** * Constants ============================= */ /** * Log TAG. */ // private static final String TAG = XmlProgressDialog.class.getSimpleName(); /** * Indicates if debug private output trough log-cat is enabled. */ // private static final boolean DEBUG = true; /** * Indicates if logging for user output trough log-cat is enabled. */ // private static final boolean USER_LOG = true; /** * <p> * XML tag of this XML dialog. * </p> */ public static final String XML_TAG = "ProgressDialog"; /** * Enums ================================= */ /** * Static members ======================== */ /** * Members =============================== */ /** * Listeners ----------------------------- */ /** * Arrays -------------------------------- */ /** * Booleans ------------------------------ */ /** * Constructors ========================== */ /** * Methods =============================== */ /** * Public -------------------------------- */ /** * Getters + Setters --------------------- */ /** */ @Override public String getXmlTag() { return XmlProgressDialog.XML_TAG; } /** */ @Override public int getDefaultIcon() { return DialogOptions.DIALOG_ICON_PROGRESS; } /** * Protected ----------------------------- */ /** */ @Override protected ProgressDialog.ProgressOptions onCreateEmptyOptions() { return new ProgressDialog.ProgressOptions(); } /** */ @Override protected void onParseAttribute(XmlResourceParser xmlParser, int attr, int index, ProgressDialog.ProgressOptions options) { if (attr == R.attr.dialogProgressType) { final int typeOrdinal = xmlParser.getAttributeIntValue(index, ProgressDialog.ProgressType.CIRCLE.ordinal()); options.progressType(ProgressDialog.ProgressType.values()[typeOrdinal]); } else if (attr == R.attr.dialogProgressIndicator) { final int indicatorOrdinal = xmlParser.getAttributeIntValue(index, ProgressDialog.ProgressIndicator.NONE.ordinal()); options.progressIndicator(ProgressDialog.ProgressIndicator.values()[indicatorOrdinal]); } else if (attr == R.attr.dialogProgressFormat) { options.progressFormat(resolveString(xmlParser, index)); } else if (attr == R.attr.dialogTimeFormat) { options.timeFormat(resolveString(xmlParser, index)); } else { super.onParseAttribute(xmlParser, attr, index, options); } } /** */ @Override protected DialogFragment onCreateDialog(ProgressDialog.ProgressOptions options) { return DialogFactory.progress(options); } /** * Private ------------------------------- */ /** * Abstract methods ---------------------- */ /** * Inner classes ========================= */ /** * <h4>Class Overview</h4> * <p> * </p> * * @author Martin Albedinsky */ static class XmlLoadingDialog extends XmlProgressDialog { /** * Constants ============================= */ /** * <p> * XML tag of this XML dialog. * </p> */ public static final String XML_TAG = "LoadingDialog"; /** * Methods =============================== */ /** * Public -------------------------------- */ /** * Getters + Setters --------------------- */ /** */ @Override public String getXmlTag() { return XmlLoadingDialog.XML_TAG; } /** * Protected ----------------------------- */ /** */ @Override protected DialogFragment onCreateDialog(ProgressDialog.ProgressOptions options) { return DialogFactory.loading(options.getMessage()); } } /** * Interface ============================= */ }