Beispiel #1
0
 private boolean checkBarcode(String ean) {
   // catch isbn10 numbers
   if (ean.length() == 10 && !ean.startsWith("978")) {
     ean = "978" + ean;
   }
   if (ean.length() < 13) {
     clearFields();
     return false;
   }
   // Once we have an ISBN, start a book intent
   Intent bookIntent = new Intent(getActivity(), BookService.class);
   bookIntent.putExtra(BookService.EAN, ean);
   bookIntent.setAction(BookService.FETCH_BOOK);
   if (Utility.isNetworkAvailable(getActivity())) getActivity().startService(bookIntent);
   else Utility.showToast(getActivity(), getString(R.string.bad_connection));
   AddBook.this.restartLoader();
   return true;
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    IS_TABLET = Utility.isTablet(this);
    if (IS_TABLET) {
      setContentView(R.layout.activity_main_tablet);
    } else {
      setContentView(R.layout.activity_main);
    }

    messageReciever = new MessageReciever();
    IntentFilter filter = new IntentFilter(MESSAGE_EVENT);
    LocalBroadcastManager.getInstance(this).registerReceiver(messageReciever, filter);

    navigationDrawerFragment =
        (NavigationDrawerFragment)
            getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
    title = getTitle();

    // Set up the drawer.
    navigationDrawerFragment.setUp(
        R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout));
  }