Back to project page Android-Apps.
The source code is released under:
Apache License
If you think the Android project Android-Apps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2011 Tom Quist// ww w .j a va 2 s .c o m * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You can get the GNU General Public License at * http://www.gnu.org/licenses/gpl.html */ package com.kniezrec.voiceremotefree; import android.content.Context; import android.content.SharedPreferences; public abstract class SenderFactory { public static final Sender createKeyCodeSender(Context ctx, SharedPreferences prefs) { String factoryClassString = prefs.getString( MainActivity.PREFS_SENDER_FACTORY_KEY, MainActivity.PREFS_SENDER_FACTORY_DEFAULT); // com.kniezrec.voiceremote.FSeriesKeyCodeSenderFactory if (factoryClassString .equals("com.kniezrec.voiceremotefree.FSeriesKeyCodeSenderFactory")) { factoryClassString = "com.kniezrec.voiceremotefree.CSeriesKeyCodeSenderFactory"; } try { @SuppressWarnings("unchecked") Class<SenderFactory> factoryClass = (Class<SenderFactory>) Class.forName(factoryClassString); SenderFactory factory = factoryClass.newInstance(); return factory.create(ctx, prefs); } catch (ClassNotFoundException e1) { e1.printStackTrace(); return null; } catch (IllegalAccessException e) { e.printStackTrace(); return null; } catch (InstantiationException e) { e.printStackTrace(); return null; } } protected abstract Sender create(Context ctx, SharedPreferences prefs); }