gt:         if (dataTables != null) {
context: package com.mifos.mifosxdroid.online.groupdetails;
  
  import android.app.Activity;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.preference.PreferenceManager;
  import android.support.v4.app.FragmentTransaction;
  import android.text.TextUtils;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.TableRow;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.joanzapata.iconify.fonts.MaterialIcons;
  import com.joanzapata.iconify.widget.IconTextView;
  import com.mifos.mifosxdroid.R;
  import com.mifos.mifosxdroid.adapters.LoanAccountsListAdapter;
  import com.mifos.mifosxdroid.adapters.SavingsAccountsListAdapter;
  import com.mifos.mifosxdroid.core.MifosBaseActivity;
  import com.mifos.mifosxdroid.core.ProgressableFragment;
  import com.mifos.mifosxdroid.online.documentlist.DocumentListFragment;
  import com.mifos.mifosxdroid.online.grouploanaccount.GroupLoanAccountFragment;
  import com.mifos.objects.accounts.GroupAccounts;
  import com.mifos.objects.accounts.savings.DepositType;
  import com.mifos.objects.group.Group;
  import com.mifos.objects.noncore.DataTable;
  import com.mifos.utils.Constants;
  import com.mifos.utils.DateHelper;
  import com.mifos.utils.FragmentConstants;
  
  import java.text.DateFormat;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Locale;
  
  import javax.inject.Inject;
  
  import butterknife.BindView;
  import butterknife.ButterKnife;
  
  import static android.view.View.GONE;
  import static android.view.View.VISIBLE;
  
  /**
   * Created by nellyk on 2/27/2016.
   */
  public class GroupDetailsFragment extends ProgressableFragment implements GroupDetailsMvpView {
  
      public final String LOG_TAG = getClass().getSimpleName();
      public int groupId;
      public List<DataTable> clientDataTables = new ArrayList<>();
      @BindView(R.id.tv_groupsName)
      TextView tv_fullName;
      @BindView(R.id.tv_groupexternalId)
      TextView tv_externalId;
      @BindView(R.id.tv_groupactivationDate)
      TextView tv_activationDate;
      @BindView(R.id.tv_groupoffice)
      TextView tv_office;
      @BindView(R.id.row_account)
      TableRow rowAccount;
      @BindView(R.id.row_external)
      TableRow rowExternal;
      @BindView(R.id.row_activation)
      TableRow rowActivation;
      @BindView(R.id.row_office)
      TableRow rowOffice;
      @BindView(R.id.row_group)
      TableRow rowGroup;
      @BindView(R.id.row_staff)
      TableRow rowStaff;
      @BindView(R.id.row_loan)
      TableRow rowLoan;
      @Inject
      GroupDetailsPresenter mGroupDetailsPresenter;
      private View rootView;
      private SharedPreferences sharedPreferences;
      private OnFragmentInteractionListener mListener;
      private AccountAccordion accountAccordion;
  
      public static GroupDetailsFragment newInstance(int groupId) {
          GroupDetailsFragment fragment = new GroupDetailsFragment();
          Bundle args = new Bundle();
          args.putInt(Constants.GROUP_ID, groupId);
          fragment.setArguments(args);
          return fragment;
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          ((MifosBaseActivity) getActivity()).getActivityComponent().inject(this);
          if (getArguments() != null)
              groupId = getArguments().getInt(Constants.GROUP_ID);
          setHasOptionsMenu(true);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle
              savedInstanceState) {
          rootView = inflater.inflate(R.layout.fragment_group_details, container, false);
  
          sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
  
          ButterKnife.bind(this, rootView);
          mGroupDetailsPresenter.attachView(this);
  
          inflateClientInformation();
  
          return rootView;
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
          try {
              mListener = (OnFragmentInteractionListener) activity;
          } catch (ClassCastException e) {
              throw new ClassCastException(getActivity().getClass().getSimpleName() + " must " +
                      "implement OnFragmentInteractionListener");
          }
      }
  
  
      @Override
      public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
          inflater.inflate(R.menu.group, menu);
          super.onCreateOptionsMenu(menu, inflater);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
              case R.id.documents:
                  loadDocuments();
                  break;
              case R.id.add_group_loan:
                  addgrouploanaccount();
                  break;
  
          }
          return super.onOptionsItemSelected(item);
      }
  
      public void inflateClientInformation() {
          mGroupDetailsPresenter.loadGroup(groupId);
      }
  
  
      public void inflateClientsAccounts() {
          mGroupDetailsPresenter.loadGroupsOfClients(groupId);
      }
  
      /**
       * Use this method to fetch all datatables for client and inflate them as
       * menu options
       */
      public void inflateDataTablesList() {
          mGroupDetailsPresenter.loadClientDataTable();
      }
  
  
      public void loadDocuments() {
          DocumentListFragment documentListFragment = DocumentListFragment.newInstance(Constants
                  .ENTITY_TYPE_CLIENTS, groupId);
          FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager()
                  .beginTransaction();
          fragmentTransaction.addToBackStack(FragmentConstants.FRAG_GROUP_DETAILS);
          fragmentTransaction.replace(R.id.container, documentListFragment);
          fragmentTransaction.commit();
      }
  
      public void addgrouploanaccount() {
          GroupLoanAccountFragment grouploanAccountFragment = GroupLoanAccountFragment.newInstance
                  (groupId);
          FragmentTransaction fragmentTransaction = getActivity().getSupportFragmentManager()
                  .beginTransaction();
          fragmentTransaction.addToBackStack(FragmentConstants.FRAG_GROUP_DETAILS);
          fragmentTransaction.replace(R.id.container, grouploanAccountFragment);
          fragmentTransaction.commit();
      }
  
      @Override
      public void showProgressbar(boolean b) {
          showProgress(b);
      }
  
      @Override
      public void showGroup(Group group) {
          if (group != null) {
              setToolbarTitle(getString(R.string.group) + " - " + group.getName());
              tv_fullName.setText(group.getName());
              tv_externalId.setText(group.getExternalId());
  
              try {
                  List<Integer> dateObj = group.getActivationDate();
                  SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy");
                  Date date = simpleDateFormat.parse(DateHelper.getDateAsString(dateObj));
                  Locale currentLocale = getResources().getConfiguration().locale;
                  DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM,
                          currentLocale);
                  String dateString = df.format(date);
                  tv_activationDate.setText(dateString);
  
                  if (TextUtils.isEmpty(dateString))
                      rowActivation.setVisibility(GONE);
  
              } catch (IndexOutOfBoundsException e) {
                  Toast.makeText(getActivity(), getString(R.string.error_group_inactive),
                          Toast.LENGTH_SHORT).show();
                  tv_activationDate.setText("");
              } catch (ParseException e) {
                  Log.d(LOG_TAG, e.getMessage());
              }
              tv_office.setText(group.getOfficeName());
  
              if (TextUtils.isEmpty(group.getOfficeName()))
                  rowOffice.setVisibility(GONE);
  
              inflateClientsAccounts();
          }
      }
  
      @Override
      public void showGroupsOfClient(GroupAccounts groupAccounts) {
          // Proceed only when the fragment is added to the activity.
          if (!isAdded()) {
              return;
          }
          accountAccordion = new AccountAccordion(getActivity());
          if (groupAccounts.getLoanAccounts().size() > 0) {
              AccountAccordion.Section section = AccountAccordion.Section.LOANS;
              final LoanAccountsListAdapter adapter =
                      new LoanAccountsListAdapter(getActivity().getApplicationContext(),
                              groupAccounts.getLoanAccounts());
              section.connect(getActivity(), adapter, new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView<?> adapterView, View view, int i,
                                          long l) {
                      mListener.loadLoanAccountSummary(adapter.getItem(i).getId());
                  }
              });
          }
  
          if (groupAccounts.getNonRecurringSavingsAccounts().size() > 0) {
              AccountAccordion.Section section = AccountAccordion.Section.SAVINGS;
              final SavingsAccountsListAdapter adapter =
                      new SavingsAccountsListAdapter(getActivity().getApplicationContext(),
                              groupAccounts.getNonRecurringSavingsAccounts());
              section.connect(getActivity(), adapter, new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView<?> adapterView, View view, int i,
                                          long l) {
                      mListener.loadSavingsAccountSummary(adapter.getItem(i).getId(),
                              adapter.getItem(i).getDepositType());
                  }
              });
          }
  
          if (groupAccounts.getRecurringSavingsAccounts().size() > 0) {
              AccountAccordion.Section section = AccountAccordion.Section.RECURRING;
              final SavingsAccountsListAdapter adapter =
                      new SavingsAccountsListAdapter(getActivity().getApplicationContext(),
                              groupAccounts.getRecurringSavingsAccounts());
              section.connect(getActivity(), adapter, new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView<?> adapterView, View view, int i,
                                          long l) {
                      mListener.loadSavingsAccountSummary(adapter.getItem(i).getId(),
                              adapter.getItem(i).getDepositType());
                  }
              });
          }
          inflateDataTablesList();
      }
  
      @Override
      public void showClientDataTable(List<DataTable> dataTables) {
  