Skip to content
Snippets Groups Projects
Commit a95732e2 authored by Hadrien De Sousa's avatar Hadrien De Sousa
Browse files

mvp: refactor HomeAccountCreationFragment


Apply MVP to HomeAccountCreationFragment

Tuleap: #1369
Change-Id: Id5217e5ec4eda17d18398388b3f3477afed6a14d
Reviewed-by: default avatarAline Bonnet <aline.bonnet@savoirfairelinux.com>
parent f5774ee6
No related branches found
No related tags found
No related merge requests found
......@@ -18,9 +18,8 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.fragments;
package cx.ring.account;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
......@@ -31,31 +30,46 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cx.ring.R;
import cx.ring.application.RingApplication;
import cx.ring.client.AccountWizard;
import cx.ring.mvp.BaseFragment;
public class HomeAccountCreationFragment extends Fragment {
public class HomeAccountCreationFragment extends BaseFragment<HomeAccountCreationPresenter> implements HomeAccountCreationView {
@BindView(R.id.ring_add_account)
Button mLinkButton;
protected Button mLinkButton;
@BindView(R.id.ring_create_btn)
Button mCreateButton;
protected Button mCreateButton;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.frag_acc_home_create, parent, false);
ButterKnife.bind(this, view);
// dependency injection
((RingApplication) getActivity().getApplication()).getRingInjectionComponent().inject(this);
return view;
}
@OnClick(R.id.ring_add_account)
public void linkAccountClicked() {
((AccountWizard) getActivity()).newAccount(true);
presenter.clickOnCreateAccount();
}
@OnClick(R.id.ring_create_btn)
public void createAccountClicked() {
presenter.clickOnLinkAccount();
}
@Override
public void goToAccountCreation() {
((AccountWizard) getActivity()).newAccount(true);
}
@Override
public void goToAccountLink() {
((AccountWizard) getActivity()).newAccount(false);
}
}
/*
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
import javax.inject.Inject;
import cx.ring.mvp.RootPresenter;
public class HomeAccountCreationPresenter extends RootPresenter<HomeAccountCreationView> {
@Inject
public HomeAccountCreationPresenter() {
}
public void clickOnCreateAccount() {
getView().goToAccountCreation();
}
public void clickOnLinkAccount() {
getView().goToAccountLink();
}
@Override
public void afterInjection() {
}
}
/*
* Copyright (C) 2017 Savoir-faire Linux Inc.
*
* Author: Hadrien De Sousa <hadrien.desousa@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package cx.ring.account;
public interface HomeAccountCreationView {
void goToAccountCreation();
void goToAccountLink();
}
......@@ -53,7 +53,7 @@ import butterknife.ButterKnife;
import cx.ring.R;
import cx.ring.application.RingApplication;
import cx.ring.fragments.AccountMigrationFragment;
import cx.ring.fragments.HomeAccountCreationFragment;
import cx.ring.account.HomeAccountCreationFragment;
import cx.ring.fragments.ProfileCreationFragment;
import cx.ring.fragments.RingAccountCreationFragment;
import cx.ring.fragments.RingLinkAccountFragment;
......
......@@ -24,6 +24,7 @@ import javax.inject.Singleton;
import cx.ring.about.AboutFragment;
import cx.ring.about.AboutPresenter;
import cx.ring.account.AccountEditionActivity;
import cx.ring.account.HomeAccountCreationFragment;
import cx.ring.account.RegisterNameDialog;
import cx.ring.account.RingAccountSummaryFragment;
import cx.ring.account.RingAccountSummaryPresenter;
......@@ -154,4 +155,6 @@ public interface RingInjectionComponent {
void inject(AdvancedAccountFragment fragment);
void inject(GeneralAccountFragment fragment);
void inject(HomeAccountCreationFragment fragment);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment