Search in sources :

Example 1 with RingAccountViewModelImpl

use of cx.ring.account.RingAccountViewModelImpl in project ring-client-android by savoirfairelinux.

the class TVHomeAccountCreationFragment method goToAccountCreation.

@Override
public void goToAccountCreation() {
    RingAccountViewModelImpl ringAccountViewModel = new RingAccountViewModelImpl();
    ringAccountViewModel.setLink(false);
    GuidedStepFragment.add(getFragmentManager(), TVProfileCreationFragment.newInstance(ringAccountViewModel));
}
Also used : RingAccountViewModelImpl(cx.ring.account.RingAccountViewModelImpl)

Example 2 with RingAccountViewModelImpl

use of cx.ring.account.RingAccountViewModelImpl in project ring-client-android by savoirfairelinux.

the class TVHomeAccountCreationFragment method goToAccountLink.

@Override
public void goToAccountLink() {
    RingAccountViewModelImpl ringAccountViewModel = new RingAccountViewModelImpl();
    ringAccountViewModel.setLink(true);
    GuidedStepFragment.add(getFragmentManager(), TVProfileCreationFragment.newInstance(ringAccountViewModel));
}
Also used : RingAccountViewModelImpl(cx.ring.account.RingAccountViewModelImpl)

Example 3 with RingAccountViewModelImpl

use of cx.ring.account.RingAccountViewModelImpl in project ring-client-android by savoirfairelinux.

the class TVProfileCreationFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    ((RingApplication) getActivity().getApplication()).getRingInjectionComponent().inject(this);
    super.onViewCreated(view, savedInstanceState);
    RingAccountViewModelImpl ringAccountViewModel = (RingAccountViewModelImpl) getArguments().get(RingAccountCreationFragment.KEY_RING_ACCOUNT);
    presenter.initPresenter(ringAccountViewModel);
    if (ringAccountViewModel != null && ringAccountViewModel.getPhoto() != null) {
        getGuidanceStylist().getIconView().setImageBitmap(ringAccountViewModel.getPhoto());
    }
}
Also used : RingAccountViewModelImpl(cx.ring.account.RingAccountViewModelImpl)

Example 4 with RingAccountViewModelImpl

use of cx.ring.account.RingAccountViewModelImpl in project ring-client-android by savoirfairelinux.

the class TVProfileCreationFragment method photoUpdate.

@Override
public void photoUpdate(RingAccountViewModel ringAccountViewModel) {
    ((RingAccountViewModelImpl) ringAccountViewModel).setPhoto(mSourcePhoto);
    RingAccountViewModelImpl model = (RingAccountViewModelImpl) ringAccountViewModel;
    Glide.with(getActivity()).load(model.getPhoto()).apply(AvatarFactory.getGlideOptions(true, false)).transition(DrawableTransitionOptions.withCrossFade()).into(getGuidanceStylist().getIconView());
}
Also used : RingAccountViewModelImpl(cx.ring.account.RingAccountViewModelImpl)

Example 5 with RingAccountViewModelImpl

use of cx.ring.account.RingAccountViewModelImpl in project ring-client-android by savoirfairelinux.

the class TVAccountWizard method saveProfile.

@Override
public void saveProfile(final String accountID, final RingAccountViewModel ringAccountViewModel) {
    runOnUiThread(() -> {
        RingAccountViewModelImpl ringAccountViewModelImpl = (RingAccountViewModelImpl) ringAccountViewModel;
        VCard vcard = new VCard();
        vcard.setFormattedName(new FormattedName(ringAccountViewModelImpl.getFullName()));
        vcard.setUid(new Uid(ringAccountViewModelImpl.getUsername()));
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        if (ringAccountViewModelImpl.getPhoto() != null) {
            Bitmap reduced = BitmapUtils.reduceBitmap(ringAccountViewModelImpl.getPhoto(), VCardUtils.VCARD_PHOTO_SIZE);
            reduced.compress(Bitmap.CompressFormat.PNG, 100, stream);
            Photo photoVCard = new Photo(stream.toByteArray(), ImageType.PNG);
            vcard.removeProperties(Photo.class);
            vcard.addPhoto(photoVCard);
        }
        vcard.removeProperties(RawProperty.class);
        VCardUtils.saveLocalProfileToDisk(vcard, accountID, getFilesDir());
    });
}
Also used : Uid(ezvcard.property.Uid) Bitmap(android.graphics.Bitmap) FormattedName(ezvcard.property.FormattedName) Photo(ezvcard.property.Photo) ByteArrayOutputStream(java.io.ByteArrayOutputStream) RingAccountViewModelImpl(cx.ring.account.RingAccountViewModelImpl) VCard(ezvcard.VCard)

Aggregations

RingAccountViewModelImpl (cx.ring.account.RingAccountViewModelImpl)8 Bitmap (android.graphics.Bitmap)1 GuidedStepFragment (android.support.v17.leanback.app.GuidedStepFragment)1 VCard (ezvcard.VCard)1 FormattedName (ezvcard.property.FormattedName)1 Photo (ezvcard.property.Photo)1 Uid (ezvcard.property.Uid)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1