Example #1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(setLayout());
   ButterKnife.bind(this);
   init();
 }
 @Override
 protected void onPause() {
   super.onPause();
   // disabling foreground dispatch:
   NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
   if (nfcAdapter != null) {
     nfcAdapter.disableForegroundDispatch(this);
   }
 }
 @Override
 public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
   super.onScrolled(recyclerView, dx, dy);
   int itemCount = mLayoutManager.getItemCount();
   int lastVisibleItemPosition = mLayoutManager.findLastVisibleItemPosition();
   if (lastVisibleItemPosition == itemCount - 1 && PhotosValidator.hasAfter(mPhotos)) {
     mFetchAfterSubject.onNext(mPhotos.getAfter());
   }
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_episodes);

    apiAdapter = ApiAdapter.build();

    final Category category = (Category) getIntent().getSerializableExtra(ARG_CATEGORY);

    initUI(category);
    loadAndShowEpisodes(category);
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nfc);

    prefs = PreferenceManager.getDefaultSharedPreferences(this);

    deviceOptions.put(getString(R.string.device_cat), UnityActivity.MARKER_CAT);
    deviceOptions.put(getString(R.string.device_dog), UnityActivity.MARKER_DOG);
    deviceOptions.put(getString(R.string.device_snail), UnityActivity.MARKER_SNAIL);

    optionsDialogFragment =
        OptionsDialogFragment.newInstance(deviceOptions.keySet().toArray(new String[] {}));

    txtUsername = (TextView) findViewById(R.id.txt_username);

    user = (User) getIntent().getExtras().getSerializable(EXTRA_USER);
    presentation = (Presentation) getIntent().getExtras().getSerializable(EXTRA_PRESENTATION);

    txtUsername.setText(getString(R.string.welcome) + "\n" + user.getName());

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setTitle(user.getName());

    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });
    toolbar.inflateMenu(R.menu.nfc);
    toolbar.setOnMenuItemClickListener(
        new Toolbar.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
              case R.id.action_log_out:
                RestClient.getInstance().setUser(null, null);
                finish();
                break;
              case R.id.action_join:
                optionsDialogFragment.show(getSupportFragmentManager(), DIALOG_TAG_OPTIONS_DIALOG);
                break;
            }
            return false;
          }
        });

    requestPermissionsInit();
  }
Example #6
0
  public static <T> Observable.Transformer<T, T> bindNetworking(
      @Nullable RxAppCompatActivity activity, @Nullable SwipeRefreshLayout indicator) {
    return observable -> {
      observable =
          observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());

      if (activity != null) {
        observable = observable.compose(activity.bindToLifecycle());
      }

      if (indicator != null) {
        observable = observable.compose(bindRefreshing(indicator));
      }

      return observable;
    };
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Init UI components
    ButterKnife.inject(this);
    setSupportActionBar(mToolbar);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.addOnScrollListener(mOnScrollListener);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    mSwipeRefreshLayout.setColorSchemeColors(
        getResources().getColor(R.color.accent), getResources().getColor(R.color.flipagram_red));

    initServices();
    initData();
  }
  @Override
  protected void onResume() {

    super.onResume();

    // creating pending intent:
    PendingIntent pendingIntent =
        PendingIntent.getActivity(
            this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
    // creating intent receiver for NFC events:
    IntentFilter filter = new IntentFilter();
    filter.addAction(NfcAdapter.ACTION_TAG_DISCOVERED);
    filter.addAction(NfcAdapter.ACTION_NDEF_DISCOVERED);
    filter.addAction(NfcAdapter.ACTION_TECH_DISCOVERED);
    // enabling foreground dispatch for getting intent from NFC event:
    NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
    if (nfcAdapter != null) {
      nfcAdapter.enableForegroundDispatch(
          this, pendingIntent, new IntentFilter[] {filter}, this.NTC_TECH_LIST);
    }
  }
 @Override
 protected void onDestroy() {
   super.onDestroy();
   mRecyclerView.removeOnScrollListener(mOnScrollListener);
 }