/**
* Copyright (C) 2013 by Raphael Michel under the MIT license:
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
* is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package de.geeksfactory.opacclient.frontend;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import com.heinrichreimersoftware.materialintro.app.IntroActivity;
import com.heinrichreimersoftware.materialintro.slide.SimpleSlide;
import java.io.IOException;
import de.geeksfactory.opacclient.OpacClient;
import de.geeksfactory.opacclient.R;
import de.geeksfactory.opacclient.utils.ErrorReporter;
public class WelcomeActivity extends IntroActivity {
protected OpacClient app;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = (OpacClient) getApplication();
addSlide(new SimpleSlide.Builder()
.title(R.string.intro_title_0)
.description(R.string.intro_description_0)
.background(R.color.intro_library_bg)
.backgroundDark(R.color.intro_library_bg_dark)
.layout(R.layout.intro_library)
.build());
addSlide(new SimpleSlide.Builder()
.title(R.string.intro_title_1)
.description(R.string.intro_description_1)
.background(R.color.intro_notifications_bg)
.backgroundDark(R.color.intro_notifications_bg_dark)
.layout(R.layout.intro_notifications)
.build());
addSlide(new SimpleSlide.Builder()
.title(R.string.intro_title_2)
.description(R.string.intro_description_2)
.background(R.color.intro_world_bg)
.backgroundDark(R.color.intro_world_bg_dark)
.layout(R.layout.intro_world)
.buttonCtaLabel(R.string.select_library)
.buttonCtaClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
})
.build());
setButtonNextFunction(BUTTON_NEXT_FUNCTION_NEXT);
}
@Override
public void onBackPressed() {
System.exit(0);
super.onBackPressed();
}
public class InitTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... voids) {
try {
app.getApi().start();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
ErrorReporter.handleException(e);
}
return null;
}
@Override
protected void onPostExecute(Void result) {
Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
startActivity(intent);
}
}
}