it.tidalwave.mobile.android.splash.SplashActivitySupport Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - Android - open source birding
* Copyright (C) 2009-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* WWW: http://bluebill.tidalwave.it/mobile
* SCM: https://java.net/hg/bluebill-mobile~android-src
*
**********************************************************************************************************************/
package it.tidalwave.mobile.android.splash;
import javax.annotation.Nonnull;
import javax.annotation.Nonnegative;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.widget.ProgressBar;
import android.widget.TextView;
import it.tidalwave.util.ui.UserNotificationWithFeedback;
import it.tidalwave.bluebill.mobile.splash.SplashActivityView;
import it.tidalwave.bluebill.mobile.splash.SplashActivityController;
import it.tidalwave.ui.android.app.AndroidActivityHelper;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public abstract class SplashActivitySupport extends Activity implements SplashActivityView
{
private final SplashActivityController controller = createController();
private final AndroidActivityHelper helper = new AndroidActivityHelper(this);
private ProgressBar pbInitProgress;
private TextView tvInitProgress;
private final int layoutId;
private final int pbInitProgressId;
private final int tvInitProgressId;
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
protected SplashActivitySupport (final int layoutId, final int pbInitProgressId, final int tvInitProgressId)
{
this.layoutId = layoutId;
this.pbInitProgressId = pbInitProgressId;
this.tvInitProgressId = tvInitProgressId;
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Override
public void onCreate (final @Nonnull Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(layoutId);
pbInitProgress = (ProgressBar)findViewById(pbInitProgressId);
tvInitProgress = (TextView)findViewById(tvInitProgressId);
controller.runInitialization();
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public void setInitializationText (final @Nonnull String text)
{
runOnUiThread(new Runnable()
{
public void run()
{
tvInitProgress.setText(Html.fromHtml(text));
}
});
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public void setInitializationProgress (final @Nonnegative int progress)
{
runOnUiThread(new Runnable()
{
public void run()
{
pbInitProgress.setProgress(progress);
}
});
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public void renderMainUI()
{
runOnUiThread(new Runnable()
{
public void run()
{
startActivity(createInitialIntent());
finish();
}
});
}
/*******************************************************************************************************************
*
* {@inheritDoc}
*
******************************************************************************************************************/
public void dismiss()
{
runOnUiThread(new Runnable()
{
public void run()
{
finish();
}
});
}
/*******************************************************************************************************************
*
* {@inheritDoc}BBMA-183
*
******************************************************************************************************************/
public void notifyFatalError (@Nonnull UserNotificationWithFeedback userNotificationWithFeedback)
{
helper.showErrorDialog(userNotificationWithFeedback);
}
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
protected abstract SplashActivityController createController();
/*******************************************************************************************************************
*
*
******************************************************************************************************************/
@Nonnull
protected abstract Intent createInitialIntent();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy