Skip to content

Commit

Permalink
Refactor: #6394
Browse files Browse the repository at this point in the history
  • Loading branch information
josejcb committed Jul 23, 2016
1 parent 3a9a5e7 commit 1f9f918
Show file tree
Hide file tree
Showing 2 changed files with 151 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import android.app.Fragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
Expand All @@ -18,26 +17,20 @@
import com.bitdubai.fermat_android_api.ui.enums.FermatRefreshTypes;
import com.bitdubai.fermat_android_api.ui.fragments.FermatListFragment;
import com.bitdubai.fermat_android_api.ui.interfaces.FermatListItemListeners;
import com.bitdubai.fermat_android_api.ui.interfaces.FermatWorkerCallBack;
import com.bitdubai.fermat_android_api.ui.util.FermatWorker;
import com.bitdubai.fermat_api.FermatBroadcastReceiver;
import com.bitdubai.fermat_api.FermatException;
import com.bitdubai.fermat_api.FermatIntentFilter;
import com.bitdubai.fermat_api.layer.all_definition.common.system.interfaces.error_manager.enums.UnexpectedSubAppExceptionSeverity;
import com.bitdubai.fermat_api.layer.all_definition.common.system.interfaces.error_manager.enums.UnexpectedUIExceptionSeverity;
import com.bitdubai.fermat_api.layer.all_definition.enums.UISource;
import com.bitdubai.fermat_api.layer.all_definition.navigation_structure.enums.Activities;
import com.bitdubai.fermat_api.layer.dmp_engine.sub_app_runtime.enums.SubApps;
import com.bitdubai.fermat_api.layer.osa_android.broadcaster.Broadcaster;
import com.bitdubai.fermat_api.layer.osa_android.broadcaster.BroadcasterType;
import com.bitdubai.fermat_api.layer.osa_android.broadcaster.FermatBundle;
import com.bitdubai.fermat_cbp_api.all_definition.constants.CBPBroadcasterConstants;
import com.bitdubai.fermat_cbp_api.layer.identity.crypto_customer.exceptions.CantListCryptoCustomerIdentityException;
import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.IdentityBrokerPreferenceSettings;
import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.exceptions.CantListCryptoBrokersException;
import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityInformation;
import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_broker_identity.interfaces.CryptoBrokerIdentityModuleManager;
import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.exceptions.CantGetCryptoCustomerListException;
import com.bitdubai.fermat_cbp_api.layer.sub_app_module.crypto_customer_identity.interfaces.CryptoCustomerIdentityInformation;
import com.bitdubai.sub_app.crypto_broker_identity.R;
import com.bitdubai.sub_app.crypto_broker_identity.common.adapters.CryptoBrokerIdentityInfoAdapter;
Expand All @@ -62,7 +55,6 @@ public class CryptoBrokerIdentityListFragment

// Data
private ArrayList<CryptoBrokerIdentityInformation> identityInformationList;
private List<CryptoCustomerIdentityInformation> identityCustomerInformationList;

private ExecutorService executor;
View emptyListViewsContainer;
Expand Down Expand Up @@ -91,7 +83,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public void onStart() {
super.onStart();
onRefreshCustomer();
// onRefreshCustomer();
onRefresh();
}

Expand Down Expand Up @@ -289,81 +281,81 @@ private void cleanSessionData() {
/**
* Checking if a customer profile is already created before a broker is created
*/
public void onRefreshCustomer() {
try{
final FermatWorker worker = new FermatWorker() {
@Override
protected Object doInBackground() throws Exception {
return getMoreDataAsyncCustomer();
}
};
worker.setContext(getActivity());
worker.setCallBack(new FermatWorkerCallBack() {
@SuppressWarnings("unchecked")
@Override
public void onPostExecute(Object... result) {
if (isAttached) {
if (result != null &&
result.length > 0) {
if (getActivity() != null) {
existentCustomerIdentityDialog();
}
}
}
}

@Override
public void onErrorOccurred(Exception ex) {
try{
worker.shutdownNow();
} catch (Exception e) {
e.printStackTrace();
}
}
});
worker.execute();
}catch (Exception ignore){
if (executor != null) {
executor.shutdown();
executor = null;
}
}
}

public void existentCustomerIdentityDialog() {
try {
PresentationDialog pd = new PresentationDialog.Builder(getActivity(), appSession)
.setSubTitle(R.string.cbp_broker_identity_welcome_subTitle)
.setBody(R.string.cbp_broker_identity_existent_customer)
.setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION_WITHOUT_IDENTITIES)
.setIconRes(R.drawable.bi_icon)
.setCheckButtonAndTextVisible(0)
.setIsCheckEnabled(false)
.setBannerRes(R.drawable.banner_identity)
.setVIewColor(R.color.background_toolbar)
.build();
pd.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
getActivity().onBackPressed();
}
});
pd.show();
} catch (Exception e) {
e.printStackTrace();
}
}

public List<CryptoCustomerIdentityInformation> getMoreDataAsyncCustomer() {
List<CryptoCustomerIdentityInformation> data = new ArrayList<>();
try {
data = appSession.getModuleManager().getAllCryptoCustomersIdentities(0, 0);
} catch (CantGetCryptoCustomerListException ex) {
appSession.getErrorManager().reportUnexpectedSubAppException(SubApps.CBP_CRYPTO_BROKER_IDENTITY,
UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, ex);
}
return data;
}
// public void onRefreshCustomer() {
// try{
// final FermatWorker worker = new FermatWorker() {
// @Override
// protected Object doInBackground() throws Exception {
// return getMoreDataAsyncCustomer();
// }
// };
// worker.setContext(getActivity());
// worker.setCallBack(new FermatWorkerCallBack() {
// @SuppressWarnings("unchecked")
// @Override
// public void onPostExecute(Object... result) {
// if (isAttached) {
// if (result != null &&
// result.length > 0) {
// if (getActivity() != null) {
// existentCustomerIdentityDialog();
// }
// }
// }
// }
//
// @Override
// public void onErrorOccurred(Exception ex) {
// try{
// worker.shutdownNow();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// });
// worker.execute();
// }catch (Exception ignore){
// if (executor != null) {
// executor.shutdown();
// executor = null;
// }
// }
// }
//
// public void existentCustomerIdentityDialog() {
// try {
// PresentationDialog pd = new PresentationDialog.Builder(getActivity(), appSession)
// .setSubTitle(R.string.cbp_broker_identity_welcome_subTitle)
// .setBody(R.string.cbp_broker_identity_existent_customer)
// .setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION_WITHOUT_IDENTITIES)
// .setIconRes(R.drawable.bi_icon)
// .setCheckButtonAndTextVisible(0)
// .setIsCheckEnabled(false)
// .setBannerRes(R.drawable.banner_identity)
// .setVIewColor(R.color.background_toolbar)
// .build();
// pd.setOnDismissListener(new DialogInterface.OnDismissListener() {
// @Override
// public void onDismiss(DialogInterface dialog) {
// getActivity().onBackPressed();
// }
// });
// pd.show();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public List<CryptoCustomerIdentityInformation> getMoreDataAsyncCustomer() {
// List<CryptoCustomerIdentityInformation> data = new ArrayList<>();
// try {
// data = appSession.getModuleManager().getAllCryptoCustomersIdentities(0, 0);
// } catch (CantGetCryptoCustomerListException ex) {
// appSession.getErrorManager().reportUnexpectedSubAppException(SubApps.CBP_CRYPTO_BROKER_IDENTITY,
// UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, ex);
// }
// return data;
// }

/**
* Receiver class implemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static CryptoCustomerIdentityListFragment newInstance() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
onRefreshBroker();
// onRefreshBroker();
cleanSessionData();
onRefresh();
}
Expand Down Expand Up @@ -299,78 +299,78 @@ private void cleanSessionData() {
/**
* Checking if a broker profile is already created before a customer is created
*/
public void onRefreshBroker() {
try{
final FermatWorker worker = new FermatWorker() {
@Override
protected Object doInBackground() throws Exception {
return getMoreDataAsyncBroker();
}
};
worker.setContext(getActivity());
worker.setCallBack(new FermatWorkerCallBack() {
@SuppressWarnings("unchecked")
@Override
public void onPostExecute(Object... result) {
if (isAttached) {
if (result != null &&
result.length > 0) {
if (getActivity() != null) {
existentBrokerIdentityDialog();
}
}
}
}

@Override
public void onErrorOccurred(Exception ex) {
try{
worker.shutdownNow();
} catch (Exception e) {
e.printStackTrace();
}
}
});
worker.execute();
}catch (Exception ignore){
if (executor != null) {
executor.shutdown();
executor = null;
}
}
}

public void existentBrokerIdentityDialog() {
try {
PresentationDialog pd = new PresentationDialog.Builder(getActivity(), appSession)
.setSubTitle(R.string.cbp_customer_identity_welcome_subTitle)
.setBody(R.string.cbp_customer_identity_existent_broker)
.setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION_WITHOUT_IDENTITIES)
.setCheckButtonAndTextVisible(0)
.setIsCheckEnabled(false)
.setBannerRes(R.drawable.banner_identity_customer)
.setVIewColor(R.color.ccc_color_dialog_identity)
.build();
pd.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
getActivity().onBackPressed();
}
});
pd.show();
} catch (Exception e) {
e.printStackTrace();
}
}

public List<CryptoBrokerIdentityInformation> getMoreDataAsyncBroker() {
List<CryptoBrokerIdentityInformation> data = new ArrayList<>();
try {
data = appSession.getModuleManager().listIdentities(0, 0);
} catch (CantListCryptoBrokersException ex) {
appSession.getErrorManager().reportUnexpectedSubAppException(SubApps.CBP_CRYPTO_CUSTOMER_IDENTITY,
UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, ex);
}
return data;
}
// public void onRefreshBroker() {
// try{
// final FermatWorker worker = new FermatWorker() {
// @Override
// protected Object doInBackground() throws Exception {
// return getMoreDataAsyncBroker();
// }
// };
// worker.setContext(getActivity());
// worker.setCallBack(new FermatWorkerCallBack() {
// @SuppressWarnings("unchecked")
// @Override
// public void onPostExecute(Object... result) {
// if (isAttached) {
// if (result != null &&
// result.length > 0) {
// if (getActivity() != null) {
// existentBrokerIdentityDialog();
// }
// }
// }
// }
//
// @Override
// public void onErrorOccurred(Exception ex) {
// try{
// worker.shutdownNow();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// });
// worker.execute();
// }catch (Exception ignore){
// if (executor != null) {
// executor.shutdown();
// executor = null;
// }
// }
// }
//
// public void existentBrokerIdentityDialog() {
// try {
// PresentationDialog pd = new PresentationDialog.Builder(getActivity(), appSession)
// .setSubTitle(R.string.cbp_customer_identity_welcome_subTitle)
// .setBody(R.string.cbp_customer_identity_existent_broker)
// .setTemplateType(PresentationDialog.TemplateType.TYPE_PRESENTATION_WITHOUT_IDENTITIES)
// .setCheckButtonAndTextVisible(0)
// .setIsCheckEnabled(false)
// .setBannerRes(R.drawable.banner_identity_customer)
// .setVIewColor(R.color.ccc_color_dialog_identity)
// .build();
// pd.setOnDismissListener(new DialogInterface.OnDismissListener() {
// @Override
// public void onDismiss(DialogInterface dialog) {
// getActivity().onBackPressed();
// }
// });
// pd.show();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
//
// public List<CryptoBrokerIdentityInformation> getMoreDataAsyncBroker() {
// List<CryptoBrokerIdentityInformation> data = new ArrayList<>();
// try {
// data = appSession.getModuleManager().listIdentities(0, 0);
// } catch (CantListCryptoBrokersException ex) {
// appSession.getErrorManager().reportUnexpectedSubAppException(SubApps.CBP_CRYPTO_CUSTOMER_IDENTITY,
// UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, ex);
// }
// return data;
// }
}

0 comments on commit 1f9f918

Please sign in to comment.