@Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   context = getActivity();
   application = (WebCloudApplication) context.getApplication();
 }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    final View view = inflater.inflate(R.layout.fragment_wallet, container, false);
    Log.i(TAG, "onCreateView");

    syncingLayout = (LinearLayout) view.findViewById(R.id.syncingLayout);
    syncedLayout = (LinearLayout) view.findViewById(R.id.syncedLayout);
    linearLayout = (LinearLayout) view.findViewById(R.id.linearLayout);
    syncingText = (TextView) view.findViewById(R.id.syncingText);
    aliasNameText = (TextView) view.findViewById(R.id.aliasName);
    aliasNameUnconfirmed = (TextView) view.findViewById(R.id.aliasNameUnconfirmed);
    currentAddressText = (TextView) view.findViewById(R.id.currentAddress);
    currentQrCode = (ImageView) view.findViewById(R.id.currentQrCode);
    identicon = (ImageView) view.findViewById(R.id.identicon);
    btcBalance = (CurrencyView) view.findViewById(R.id.btcBalance);
    setAliasButton = (Button) view.findViewById(R.id.setAlias);
    btcBalanceUnconfirmed = (TextView) view.findViewById(R.id.btcBalanceUnconfirmed);
    messagePending = (TextView) view.findViewById(R.id.messagePending);
    btcQR = (IconTextView) view.findViewById(R.id.btcQR);
    txtHeader = (TextView) view.findViewById(R.id.txtHeader);
    // myMessageList       = (ListView) view.findViewById(R.id.myMessageList);
    recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
    walletWarning = (TextView) view.findViewById(R.id.wallet_warning);

    btcQR.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            QRDialogFragment qrDialogFragment = new QRDialogFragment();
            qrDialogFragment.show(
                getFragmentManager(), PersonalNodeDialogFragment.class.toString());
          }
        });

    setAliasButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Long walletBalance = walletObservable.getWalletBalance().longValue();
            Log.i(TAG, "walletBalance=" + walletBalance);
            if (walletBalance < (EWWalletService.DUST + EWWalletService.FEE)) {
              Toast.makeText(
                      getActivity(),
                      "You need at least 0.2 mBTC confirmed balance to register an alias",
                      Toast.LENGTH_LONG)
                  .show();
              return;
            }

            FragmentTransaction ft = getFragmentManager().beginTransaction();
            Fragment prev = getFragmentManager().findFragmentByTag("dialog");
            if (prev != null) ft.remove(prev);
            ft.addToBackStack(null);

            RegAliasDialogFragment frag = new RegAliasDialogFragment();
            frag.setWalletObservable(walletObservable);
            frag.show(ft, "dialog");
          }
        });

    currentQrCode.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (walletObservable != null
                && walletObservable.getCurrent() != null
                && Bitcoin.isValidAddress(walletObservable.getCurrent().toString())) {
              Intent i =
                  new Intent(
                      Intent.ACTION_VIEW,
                      Uri.parse("bitcoin:" + walletObservable.getCurrent().toString()));
              if (isAvailable(i)) startActivity(i);
              else {
                AlertDialog d =
                    new AlertDialog.Builder(getActivity())
                        .setTitle(getString(R.string.app_name))
                        .setMessage(
                            "There are no bitcoin wallet app installed, do you want to install GreenBits?")
                        .setNegativeButton(
                            "No, thanks",
                            new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                              }
                            })
                        .setPositiveButton(
                            "Yes" + "!",
                            new DialogInterface.OnClickListener() {
                              @Override
                              public void onClick(DialogInterface dialog, int which) {
                                dialog.dismiss();
                                startActivity(
                                    new Intent(
                                        Intent.ACTION_VIEW,
                                        Uri.parse(
                                            "market://details?id="
                                                + "com.greenaddress.greenbits_android_wallet")));
                              }
                            })
                        .create();
                d.show();
              }
            }
          }
        });

    // Show / Hide write button
    payButton =
        (android.support.design.widget.FloatingActionButton) view.findViewById(R.id.payButton);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
    String passphrase = sharedPref.getString(Preferences.PASSPHRASE, null);
    if (passphrase == null) {
      // Hide write button on activity if there is no account
      payButton.setVisibility(View.GONE);
    } else {
      // Show write button on activity if there is one account
      payButton.setVisibility(View.VISIBLE);
      payButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent i = new Intent(getActivity(), WriteActivity.class);
              startActivity(i);
            }
          });
    }

    // Set Recyclerview
    final LinearLayoutManager mLayoutManager =
        new LinearLayoutManager(getActivity().getApplicationContext());
    mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
    recyclerView.setLayoutManager(mLayoutManager);

    // Load my messages
    messages = new ArrayList<Message>();
    inQueue = null;

    // Set Message RecyclerView Adapter
    LruCache<String, Bitmap> bitmapCache = null;
    final FragmentActivity activity = getActivity();
    if (activity != null) {
      bitmapCache = ((EWApplication) activity.getApplication()).getBitmapCache();
    }
    messageRecyclerViewAdapter =
        new MessageRecyclerViewAdapter(messages, inQueue, WalletFragment.this, bitmapCache);
    recyclerView.setAdapter(messageRecyclerViewAdapter);

    // check on wallet observable
    if (walletObservable == null) {
      // do nothig.. wait
    } else if (walletObservable.isSyncedOrPending()) {
      syncedLayout.setVisibility(View.VISIBLE);
      syncingLayout.setVisibility(View.GONE);
      loadMoreData();
    } else {
      syncedLayout.setVisibility(View.GONE);
      syncingLayout.setVisibility(View.VISIBLE);
    }

    return view;
  }