gt:         Log.d(getClassName(), message, throwable);
context: /*
   *  Copyright (C) 2011-2015 Tri plus grupa d.o.o <info@3plus.hr>
   *  All rights reserved.
   */
  
  package com.zipato.appv2.activities;
  
  import android.app.AlertDialog;
  import android.app.AlertDialog.Builder;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.content.DialogInterface.OnClickListener;
  import android.content.Intent;
  import android.content.pm.ActivityInfo;
  import android.content.res.Configuration;
  import android.os.Build.VERSION;
  import android.os.Build.VERSION_CODES;
  import android.os.Bundle;
  import android.os.Parcelable;
  import android.os.Vibrator;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentTransaction;
  import android.support.v4.content.IntentCompat;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.WindowManager.LayoutParams;
  import android.widget.ProgressBar;
  import android.widget.Toast;
  
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.GooglePlayServicesUtil;
  import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
  import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnCloseListener;
  import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnClosedListener;
  import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.OnOpenedListener;
  import com.readystatesoftware.systembartint.SystemBarTintManager;
  import com.readystatesoftware.systembartint.SystemBarTintManager.SystemBarConfig;
  import com.zipato.appv2.B;import com.zipato.appv2.R;
  import com.zipato.appv2.R.anim;
  import com.zipato.appv2.R.bool;
  import com.zipato.appv2.R.color;
  import com.zipato.appv2.R.drawable;
  import com.zipato.appv2.R.id;
  import com.zipato.appv2.R.string;
  import com.zipato.appv2.ZipatoApplication;
  import com.zipato.appv2.ui.fragments.settings.BoxInfoFragment;
  import com.zipato.appv2.ui.fragments.settings.SettingMenuFragment;
  import com.zipato.appv2.ui.fragments.settings.SubSettingsFragment;
  import com.zipato.helper.InternetConnectionHelper;
  import com.zipato.helper.PopUpMessageHelper;
  import com.zipato.helper.PreferenceHelper;
  import com.zipato.helper.PreferenceHelper.Preference;
  import com.zipato.model.attribute.AttributeValueRepository;
  import com.zipato.model.device.DeviceStateRepository;
  import com.zipato.model.event.Event;
  import com.zipato.model.event.ObjectConnectivity;
  import com.zipato.model.event.ObjectLauncher;
  import com.zipato.model.event.ObjectMenu;
  import com.zipato.translation.LanguageManager;
  import com.zipato.util.ShakeUtils;
  import com.zipato.util.ShakeUtils.OnShakeListener;
  import com.zipato.util.TypeFaceUtils;
  import com.zipato.v2.client.APIV2RestCallback;
  import com.zipato.v2.client.ApiV2RestTemplate;
  import com.zipato.v2.client.RestObjectClientException;
  import com.zipato.v2.client.RestObjectException;
  
  import org.springframework.web.client.ResourceAccessException;
  
  import java.util.concurrent.ExecutorService;
  
  import javax.inject.Inject;
  
  import de.greenrobot.event.EventBus;
  
  //import com.google.android.gms.common.AccountPicker;
  
  /**
   * Created by murielK on 4.6.2014..
   */
  public abstract class BaseActivity extends AppCompatActivity implements OnShakeListener, OnClosedListener, OnCloseListener,
          OnOpenedListener, SlidingMenu.OnOpenListener {
  
      private static final String TAG = BaseActivity.class.getSimpleName();
      private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
  
      @Inject
      protected ShakeUtils shakeUtils;
      @Inject
      protected ApiV2RestTemplate restTemplate;
      @Inject
      protected PreferenceHelper preferenceHelper;
      protected Vibrator vib;
      protected SlidingMenu slidingMenu;
      @Inject
      LanguageManager languageManager;
      @Inject
      AttributeValueRepository attributeValueRepository;
      @Inject
      DeviceStateRepository deviceStateRepository;
      @Inject
      InternetConnectionHelper internetConnectionHelper;
      @Inject
      EventBus eventBus;
      @Inject
      ExecutorService executor;
      @Inject
      TypeFaceUtils typeFaceUtils;
      private PopUpMessageHelper popUpMessageHelper;
      private ProgressDialog progressDialog;
      private boolean isDestroyed;
      private Context context;
      private ProgressBar progressBar;
  
      /**
       * @return Application's version code from the {@code PackageManager}.
       */
  
      protected abstract boolean provideMenu();
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          ((ZipatoApplication) getApplication()).inject(this);
  
          if (getResources().getBoolean(R.bool.portrait_only))
              setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
  
          context = this;
  
          onPreContentView(savedInstanceState);
          setStatusBarTint();
          setContentView(getContentViewID());
          setToolbar();
          setBehindView(savedInstanceState);
          onPostContentView(savedInstanceState);
  
          typeFaceUtils.applyTypefaceFor(this);
          languageManager.translateFields(this);
  
          vib = (Vibrator) getSystemService(VIBRATOR_SERVICE);
  
          popUpMessageHelper = new PopUpMessageHelper(this);
          progressDialog = new ProgressDialog(context);
          progressDialog.setIndeterminate(true);
  
      }
  
      protected abstract void onPreContentView(Bundle savedInstanceState);
  
      protected abstract int getContentViewID();
  
      protected abstract void onPostContentView(Bundle savedInstanceState);
  
      @Override
      public void onClosed() {
  
      }
  
      @Override
      public void onClose() {
  
      }
  
      @Override
      public void onOpen() {
  
      }
  
      @Override
      public void onOpened() {
  
      }
  
      @Override
      public void onShake() {
  
      }
  
      private void setUpShakeUtils() {
          shakeUtils.setOnShakeListener(this);
          shakeUtils.registerToSensor();
          shakeUtils.setForceTimeOut(preferenceHelper.getInt(Preference.SHAKE_FORCE, 500),
                  preferenceHelper.getInt(Preference.SHAKE_TIME_OUT, 500));
          shakeUtils.setEnableShake(preferenceHelper.getBooleanPref(Preference.SHAKE_ENABLE));
      }
  
      @Override
      public void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
      }
  
      public void setSlidingEnabled(boolean sliding) {
          slidingMenu.setSlidingEnabled(sliding);
      }
  
  //    public void setSlidingMenuBehindViewoffset(int offset){
  //        slidingMenu.setBehindOffset(offset);
  //    }
  
      protected void setBehindView(Bundle savedInstanceState) {
          if (!provideMenu()) {
              return;
          }
          slidingMenu = new SlidingMenu(this);
          slidingMenu.setMenu(R.layout.menu_right);
          slidingMenu.setMode(SlidingMenu.RIGHT);
          slidingMenu.setShadowWidthRes(R.dimen.shadow_width);
          slidingMenu.setShadowDrawable(R.drawable.shadow_slider_activity);
          slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
          slidingMenu.setFadeDegree(0.35f);
          slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
          slidingMenu.setOnClosedListener(this);
          slidingMenu.setOnCloseListener(this);
          slidingMenu.setOnOpenedListener(this);
          slidingMenu.setOnOpenListener(this);
          slidingMenu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
          if (savedInstanceState == null) {
              FragmentTransaction t = getSupportFragmentManager().beginTransaction();
              Fragment fragment = new SettingMenuFragment();
              t.replace(id.menu_frame, fragment);
              t.commit();
          } else {
              // fragment = (BoxInfoFragment) getSupportFragmentManager().findFragmentById(R.id.menu_frame);
          }
      }
  
      @Override
      protected void onDestroy() {
          try {
              super.onDestroy();
          } catch (Exception e) {
              Log.e(TAG, "onDestroy crashed",e);
          }
          isDestroyed = true;
      }
  
      public void showProgressDialog(String title, String message, boolean cancelable) {
          progressDialog.setTitle(title);
          showProgressDialog(message, cancelable);
      }
  
      public void showProgressDialog(String message, boolean cancelable) {
          progressDialog.setCancelable(cancelable);
          progressDialog.setMessage(message);
          if (!progressDialog.isShowing())
              progressDialog.show();
      }
  
      public void dismissProgressDialog() {
          if (((progressDialog != null) & !isDestroyed) && progressDialog.isShowing()) {
              progressDialog.dismiss();
          }
      }
  
      public void toast(CharSequence message) {
          Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
      }
  
      protected void logD(String message, Throwable throwable) {
  