Android Open Source - Chopping Error Handler Activity






From Project

Back to project page Chopping.

License

The source code is released under:

Apache License

If you think the Android project Chopping listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.chopping.activities;
/*  w w  w  . j  a v a  2s  . c  o  m*/
import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import com.chopping.R;
import com.chopping.application.ErrorHandler;
import com.chopping.bus.ReloadEvent;
import com.chopping.utils.NetworkUtils;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.TextView;
import de.greenrobot.event.EventBus;

/**
 * {@link com.chopping.activities.ErrorHandlerActivity} provides basic logical for an error happens when internet is not
 * available.
 * <p/>
 * <b>Relate class</b>
 * <p/>
 * {@link com.chopping.fragments.ErrorHandlerFragment}
 */
public class ErrorHandlerActivity extends ActionBarActivity {
  private static final int LAYOUT = R.layout.activity_errorhandler;
  /**
   * Extras. {@link java.lang.String} description of error.
   * <p/>
   * Equal to {@link com.chopping.fragments.ErrorHandlerFragment#EXTRAS_ERR_MSG}.
   */
  public static final String EXTRAS_ERR_MSG = ErrorHandler.EXTRAS_ERR_MSG;
  /**
   * Extras. A {@link boolean}, {@code true} if shows error because of airplane mode being ON, and a button that opens
   * setting will be shown as well.
   * <p/>
   * Equal to {@link com.chopping.fragments.ErrorHandlerFragment#EXTRAS_AIRPLANE_MODE}.
   */
  public static final String EXTRAS_AIRPLANE_MODE = ErrorHandler.EXTRAS_AIRPLANE_MODE;
  /**
   * Message {@link android.widget.TextView}.
   */
  private TextView mErrMsgTv;

  //------------------------------------------------
  //Subscribes, event-handlers
  //------------------------------------------------

  /**
   * Handler for {@link }
   *
   * @param e
   *     Event {@link  }.
   */
  public void onEvent(Object e) {

  }

  //------------------------------------------------

  @Override
  protected void onResume() {
    EventBus.getDefault().register(this);
    super.onResume();
  }

  @Override
  protected void onPause() {
    EventBus.getDefault().unregister(this);
    super.onPause();
  }

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(LAYOUT);
    mErrMsgTv = (TextView) findViewById(R.id.err_msg_tv);
    View retryBtn = findViewById(R.id.err_retry_btn);
    retryBtn.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        onReload();
      }
    });
    handleIntent(getIntent());
  }

  /**
   * Call back for clicking a reload button.
   */
  protected void onReload() {
    EventBus.getDefault().postSticky(new ReloadEvent());
    finish();
  }

  @Override
  protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
  }

  /**
   * Handle {@link android.content.Intent}.
   *
   * @param i
   *     Current {@link android.content.Intent} values.
   */
  private void handleIntent(Intent i) {
    String msg = i.getStringExtra(EXTRAS_ERR_MSG);
    mErrMsgTv.setText(msg);

    View openAirplaneV = findViewById(R.id.open_airplane_setting_btn);
    boolean isAirplaneModeOn = i.getBooleanExtra(EXTRAS_AIRPLANE_MODE, false);
    openAirplaneV.setVisibility(isAirplaneModeOn ? VISIBLE : GONE);
    if(isAirplaneModeOn) {
      openAirplaneV.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          NetworkUtils.openNetworkSetting(v.getContext());
        }
      });
    }
  }
}




Java Source Code List

com.android.internal.telephony.ITelephony.java
com.chopping.ApplicationTest.java
com.chopping.activities.BaseActivity.java
com.chopping.activities.BrightnessRefreshActivity.java
com.chopping.activities.ErrorHandlerActivity.java
com.chopping.application.BasicPrefs.java
com.chopping.application.ErrorHandler.java
com.chopping.application.IApp.java
com.chopping.application.InstalledAppReceiver.java
com.chopping.application.LL.java
com.chopping.bus.AirplaneModeOnEvent.java
com.chopping.bus.ApplicationConfigurationDownloadedEvent.java
com.chopping.bus.ApplicationConfigurationLoadingIgnoredEvent.java
com.chopping.bus.CloseDrawerEvent.java
com.chopping.bus.ExternalAppChangedEvent.java
com.chopping.bus.LinkToExternalAppEvent.java
com.chopping.bus.ReloadEvent.java
com.chopping.data.AppListItem.java
com.chopping.data.AppList.java
com.chopping.exceptions.CanNotOpenOrFindAppPropertiesException.java
com.chopping.exceptions.InvalidAppPropertiesException.java
com.chopping.exceptions.OperationFailException.java
com.chopping.fragments.AppListFragment.java
com.chopping.fragments.BaseFragment.java
com.chopping.fragments.ErrorHandlerFragment.java
com.chopping.net.GsonRequestTask.java
com.chopping.net.TaskHelper.java
com.chopping.utils.Consts.java
com.chopping.utils.DeviceUtils.java
com.chopping.utils.IncomingCallReceiver.java
com.chopping.utils.MediaUtils.java
com.chopping.utils.NetworkUtils.java
com.chopping.utils.Utils.java
com.chopping.utils.views.OneDirectionScrollView.java