| 1 | package tw.nekomimi.nekogram; |
| 2 | |
| 3 | import android.app.Activity; |
| 4 | |
| 5 | import org.telegram.messenger.FileLog; |
| 6 | |
| 7 | public class ExternalGcm { |
| 8 | |
| 9 | interface Interface { |
| 10 | boolean checkPlayServices(); |
| 11 | |
| 12 | void initPlayServices(); |
| 13 | |
| 14 | void sendRegistrationToServer(); |
| 15 | |
| 16 | void checkUpdate(Activity ctx); |
| 17 | } |
| 18 | |
| 19 | static class NoImpl implements Interface { |
| 20 | |
| 21 | @Override |
| 22 | public boolean checkPlayServices() { |
| 23 | return false; |
| 24 | } |
| 25 | |
| 26 | @Override |
| 27 | public void initPlayServices() { |
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public void sendRegistrationToServer() { |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public void checkUpdate(Activity ctx) { |
| 36 | } |
| 37 | |
| 38 | } |
| 39 | |
| 40 | private static Interface impl; |
| 41 | |
| 42 | static { |
| 43 | try { |
| 44 | impl = (Interface) Class.forName("tw.nekomimi.nekogram.GcmImpl").newInstance(); |
| 45 | } catch (ClassNotFoundException e) { |
| 46 | impl = new NoImpl(); |
| 47 | } catch (Exception e) { |
| 48 | impl = new NoImpl(); |
| 49 | FileLog.e(e); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | public static void initPlayServices() { |
| 54 | impl.initPlayServices(); |
| 55 | } |
| 56 | |
| 57 | public static boolean checkPlayServices() { |
| 58 | return impl.checkPlayServices(); |
| 59 | } |
| 60 | |
| 61 | public static void sendRegistrationToServer() { |
| 62 | impl.sendRegistrationToServer(); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | public static void checkUpdate(Activity ctx) { |
| 67 | impl.checkUpdate(ctx); |
| 68 | } |
| 69 | |
| 70 | } |
| 71 | |