// Path: opfpush/src/main/java/org/onepf/opfpush/model/State.java
// public enum State {
// 
//     /**
//      * Indicates that an unregistration has been completed.
//      */
//     UNREGISTERED(0),
// 
//     /**
//      * Indicates that a registration has been completed.
//      */
//     REGISTERED(2),
// 
//     /**
//      * Indicates that a registration is being performed.
//      */
//     REGISTERING(3);
// 
//     private int value;
// 
//     State(int value) {
//         this.value = value;
//     }
// 
//     public int getValue() {
//         return value;
//     }
// 
//     @Nullable
//     public static State fromValue(final int fromValue) {
//         final State[] values = values();
//         for (final State state : values) {
//             final int stateValue = state.getValue();
//             if (stateValue == fromValue) {
//                 return state;
//             }
//         }
// 
//         return null;
//     }
// }
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// static final String ACTION_CHECK_REGISTERING_TIMEOUT = BuildConfig.APPLICATION_ID + "intent.CHECK_REGISTERING_TIMEOUT";
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// public static final String ACTION_RETRY_REGISTER = BuildConfig.APPLICATION_ID + "intent.RETRY_REGISTER";
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// public static final String ACTION_RETRY_UNREGISTER = BuildConfig.APPLICATION_ID + "intent.RETRY_UNREGISTER";
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// public static final String EXTRA_PROVIDER_NAME = "org.onepf.opfpush.intent.EXTRA_PROVIDER_NAME";


import static org.onepf.opfpush.OPFConstants.EXTRA_PROVIDER_NAME;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import org.onepf.opfpush.model.State;
import org.onepf.opfutils.OPFLog;
import org.onepf.opfutils.OPFUtils;
import java.util.Locale;
import static org.onepf.opfpush.OPFConstants.ACTION_CHECK_REGISTERING_TIMEOUT;
import static org.onepf.opfpush.OPFConstants.ACTION_RETRY_REGISTER;
import static org.onepf.opfpush.OPFConstants.ACTION_RETRY_UNREGISTER;
/*
 * Copyright 2012-2015 One Platform Foundation
 *
 * 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.
 */

package org.onepf.opfpush;





/**
 * @author Kirill Rozov
 * @author Roman Savin
 * @since 01.10.14.
 */
public final class RetryBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(@NonNull final Context context, @NonNull final Intent intent) {
        OPFLog.logMethod(context, OPFUtils.toString(intent));

        final OPFPushHelper helper = OPFPush.getHelper();
        if (helper.isInitDone()) {
            OPFLog.d("Initialisation is done");

            final String action = intent.getAction();
            final String providerName = intent.getStringExtra(EXTRA_PROVIDER_NAME);
            switch (action) {
// Path: opfpush/src/main/java/org/onepf/opfpush/model/State.java
// public enum State {
// 
//     /**
//      * Indicates that an unregistration has been completed.
//      */
//     UNREGISTERED(0),
// 
//     /**
//      * Indicates that a registration has been completed.
//      */
//     REGISTERED(2),
// 
//     /**
//      * Indicates that a registration is being performed.
//      */
//     REGISTERING(3);
// 
//     private int value;
// 
//     State(int value) {
//         this.value = value;
//     }
// 
//     public int getValue() {
//         return value;
//     }
// 
//     @Nullable
//     public static State fromValue(final int fromValue) {
//         final State[] values = values();
//         for (final State state : values) {
//             final int stateValue = state.getValue();
//             if (stateValue == fromValue) {
//                 return state;
//             }
//         }
// 
//         return null;
//     }
// }
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// static final String ACTION_CHECK_REGISTERING_TIMEOUT = BuildConfig.APPLICATION_ID + "intent.CHECK_REGISTERING_TIMEOUT";
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// public static final String ACTION_RETRY_REGISTER = BuildConfig.APPLICATION_ID + "intent.RETRY_REGISTER";
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// public static final String ACTION_RETRY_UNREGISTER = BuildConfig.APPLICATION_ID + "intent.RETRY_UNREGISTER";
// 
// Path: opfpush/src/main/java/org/onepf/opfpush/OPFConstants.java
// public static final String EXTRA_PROVIDER_NAME = "org.onepf.opfpush.intent.EXTRA_PROVIDER_NAME";


// Path: opfpush/src/main/java/org/onepf/opfpush/RetryBroadcastReceiver.java
import static org.onepf.opfpush.OPFConstants.EXTRA_PROVIDER_NAME;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import org.onepf.opfpush.model.State;
import org.onepf.opfutils.OPFLog;
import org.onepf.opfutils.OPFUtils;
import java.util.Locale;
import static org.onepf.opfpush.OPFConstants.ACTION_CHECK_REGISTERING_TIMEOUT;
import static org.onepf.opfpush.OPFConstants.ACTION_RETRY_REGISTER;
import static org.onepf.opfpush.OPFConstants.ACTION_RETRY_UNREGISTER;

/*
 * Copyright 2012-2015 One Platform Foundation
 *
 * 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.
 */

package org.onepf.opfpush;





/**
 * @author Kirill Rozov
 * @author Roman Savin
 * @since 01.10.14.
 */
public final class RetryBroadcastReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(@NonNull final Context context, @NonNull final Intent intent) {
        OPFLog.logMethod(context, OPFUtils.toString(intent));

        final OPFPushHelper helper = OPFPush.getHelper();
        if (helper.isInitDone()) {
            OPFLog.d("Initialisation is done");

            final String action = intent.getAction();
            final String providerName = intent.getStringExtra(EXTRA_PROVIDER_NAME);
            switch (action) {
                case ACTION_RETRY_REGISTER: