Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java b/evraz-wallet/app/src/main/java/com/ngse/ui/CreateAccountActivity.java
- similarity index 69%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/CreateAccountActivity.java
- index 6ab3d5e..083021f 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/CreateAccountActivity.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/CreateAccountActivity.java
- @@ -1,9 +1,9 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui;
- import android.content.Intent;
- +import android.os.Bundle;
- import android.support.v7.app.AlertDialog;
- import android.support.v7.app.AppCompatActivity;
- -import android.os.Bundle;
- import android.support.v7.widget.Toolbar;
- import android.text.Editable;
- import android.text.InputFilter;
- @@ -22,6 +22,8 @@ import com.bitshares.bitshareswallet.wallet.exception.NetworkStatusException;
- import com.bitshares.bitshareswallet.wallet.faucet.CreateAccountException;
- import com.kaopiz.kprogresshud.KProgressHUD;
- +import org.evrazcoin.evrazwallet.R;
- +
- import io.reactivex.Flowable;
- import io.reactivex.Observable;
- import io.reactivex.android.schedulers.AndroidSchedulers;
- @@ -29,7 +31,17 @@ import io.reactivex.schedulers.Schedulers;
- import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
- import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
- -import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.*;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_ACCOUNT_OBJECT_EXIST;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_FILE_NOT_FOUND;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_FILE_READ_FAIL;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_IMPORT_NOT_MATCH_PRIVATE_KEY;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_NETWORK_FAIL;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_NO_ACCOUNT_OBJECT;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_PASSWORD_CONFIRM_FAIL;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_PASSWORD_INVALID;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_SERVER_CREATE_ACCOUNT_FAIL;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_SERVER_RESPONSE_FAIL;
- +import static com.bitshares.bitshareswallet.wallet.common.ErrorCode.ERROR_UNKNOWN;
- public class CreateAccountActivity extends AppCompatActivity {
- private Toolbar mToolbar;
- @@ -38,16 +50,11 @@ public class CreateAccountActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- - setContentView(R.layout.activity_create_account);
- + setContentView(R.layout.new_activity_create_account);
- - mToolbar = (Toolbar) findViewById(R.id.toolbar);
- + mToolbar = findViewById(R.id.toolbar);
- setSupportActionBar(mToolbar);
- - mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
- - @Override
- - public void onClick(View v) {
- - onBackPressed();
- - }
- - });
- + mToolbar.setNavigationOnClickListener(v -> onBackPressed());
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- @@ -59,20 +66,20 @@ public class CreateAccountActivity extends AppCompatActivity {
- .setAnimationSpeed(2)
- .setDimAmount(0.5f);
- - findViewById(R.id.buttonCreate).setOnClickListener(new View.OnClickListener() {
- - @Override
- - public void onClick(View v) {
- + findViewById(R.id.buttonCreate).setOnClickListener(v -> {
- mProcessHud.show();
- String strAccount = ((EditText) findViewById(R.id.editTextAccountName)).getText().toString();
- String strPassword = ((EditText) findViewById(R.id.editTextPassword)).getText().toString();
- String strPasswordConfirm = ((EditText) findViewById(R.id.editTextPasswordConfirm)).getText().toString();
- - CheckBox checkBox = (CheckBox)findViewById(R.id.checkBoxConfirm);
- + CheckBox checkBox = findViewById(R.id.checkBoxConfirm);
- + CheckBox checkBox2 = findViewById(R.id.checkBoxConfirm2);
- + CheckBox checkBox3 = findViewById(R.id.checkBoxConfirm3);
- - TextView textViewAccountError = (TextView)findViewById(R.id.textViewErrorAccount);
- - TextView textViewPasswordError = (TextView)findViewById(R.id.textViewErrorPasswrod);
- - TextView textViewPasswordConfirmError = (TextView)findViewById(R.id.textViewErrorInfo);
- + TextView textViewAccountError = findViewById(R.id.textViewErrorAccount);
- + TextView textViewPasswordError = findViewById(R.id.textViewErrorPasswrod);
- + TextView textViewPasswordConfirmError = findViewById(R.id.textViewErrorInfo);
- boolean bError = false;
- if (strAccount.isEmpty()) {
- @@ -91,10 +98,10 @@ public class CreateAccountActivity extends AppCompatActivity {
- }
- if (bError == false && textViewAccountError.getText().length() == 0 && textViewPasswordError.getText().length() == 0) {
- - if (checkBox.isChecked() == true) {
- + if (checkBox.isChecked() && checkBox2.isChecked() && checkBox3.isChecked()) {
- processCreateAccount(strAccount, strPassword, strPasswordConfirm);
- } else {
- - AlertDialog.Builder builder = new AlertDialog.Builder(CreateAccountActivity.this);
- + AlertDialog.Builder builder = new AlertDialog.Builder(CreateAccountActivity.this, R.style.CustomDialogTheme);
- builder.setMessage(R.string.create_account_check_box_confirm);
- builder.show();
- mProcessHud.dismiss();
- @@ -102,16 +109,10 @@ public class CreateAccountActivity extends AppCompatActivity {
- } else {
- mProcessHud.dismiss();
- }
- - }
- });
- - EditText editTextAccountName = (EditText)findViewById(R.id.editTextAccountName);
- - InputFilter lowercaseFilter = new InputFilter() {
- - @Override
- - public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
- - return source.toString().toLowerCase();
- - }
- - };
- + EditText editTextAccountName = findViewById(R.id.editTextAccountName);
- + InputFilter lowercaseFilter = (source, start, end, dest, dstart, dend) -> source.toString().toLowerCase();
- editTextAccountName.setFilters(new InputFilter[]{lowercaseFilter, new InputFilter.LengthFilter(63)});
- editTextAccountName.addTextChangedListener(new TextWatcher() {
- @@ -132,7 +133,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- return;
- }
- - TextView textViewError = (TextView)findViewById(R.id.textViewErrorAccount);
- + TextView textViewError = findViewById(R.id.textViewErrorAccount);
- if (Character.isLetter(strAccountName.charAt(0)) == false) {
- textViewError.setText(R.string.create_account_account_name_error_start_letter);
- findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE);
- @@ -162,7 +163,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- }
- });
- - final EditText editTextPassword = (EditText)findViewById(R.id.editTextPassword);
- + final EditText editTextPassword = findViewById(R.id.editTextPassword);
- editTextPassword.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- @@ -178,7 +179,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- public void afterTextChanged(Editable s) {
- String strPassword = s.toString();
- - TextView textViewError = (TextView)findViewById(R.id.textViewErrorPasswrod);
- + TextView textViewError = findViewById(R.id.textViewErrorPasswrod);
- if (strPassword.length() < 12) {
- textViewError.setText(R.string.create_account_password_requirement);
- } else {
- @@ -194,7 +195,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- }
- });
- - EditText editTextPasswordConfirm = (EditText)findViewById(R.id.editTextPasswordConfirm);
- + EditText editTextPasswordConfirm = findViewById(R.id.editTextPasswordConfirm);
- editTextPasswordConfirm.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- @@ -211,7 +212,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- String strPassword = editTextPassword.getText().toString();
- String strPasswordConfirm = s.toString();
- - TextView textViewErrorInfo = (TextView)findViewById(R.id.textViewErrorInfo);
- + TextView textViewErrorInfo = findViewById(R.id.textViewErrorInfo);
- if (strPassword.compareTo(strPasswordConfirm) == 0) {
- findViewById(R.id.imageViewPasswordConfirmCheck).setVisibility(View.VISIBLE);
- textViewErrorInfo.setText("");
- @@ -270,7 +271,8 @@ public class CreateAccountActivity extends AppCompatActivity {
- }).observeOn(AndroidSchedulers.mainThread())
- .subscribe(integer -> {
- mProcessHud.dismiss();
- - Intent intent = new Intent(CreateAccountActivity.this, MainActivity.class);
- + Intent intent = new Intent(CreateAccountActivity.this, NewMainActivity.class);
- +// Intent intent = new Intent(CreateAccountActivity.this, MainActivity.class);
- intent.setFlags(FLAG_ACTIVITY_CLEAR_TASK | FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- }, throwable -> {
- @@ -288,7 +290,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- }
- private void processErrorCode(final int nErrorCode) {
- - final TextView textView = (TextView) findViewById(R.id.textViewErrorInfo);
- + final TextView textView = findViewById(R.id.textViewErrorInfo);
- switch (nErrorCode) {
- case ERROR_NETWORK_FAIL:
- textView.setText(R.string.create_account_activity_network_fail);
- @@ -327,7 +329,7 @@ public class CreateAccountActivity extends AppCompatActivity {
- }
- private void processExceptionMessage(final String strMessage) {
- - final TextView textView = (TextView) findViewById(R.id.textViewErrorInfo);
- + final TextView textView = findViewById(R.id.textViewErrorInfo);
- textView.setText(strMessage);
- }
- @@ -345,10 +347,10 @@ public class CreateAccountActivity extends AppCompatActivity {
- if (accountObect == null) {
- findViewById(R.id.imageViewAccountCheck).setVisibility(View.VISIBLE);
- } else {
- - EditText editTextAccount = (EditText)findViewById(R.id.editTextAccountName);
- + EditText editTextAccount = findViewById(R.id.editTextAccountName);
- String strAccountName = editTextAccount.getText().toString();
- if (strAccountName.compareTo(accountObect.name) == 0) {
- - TextView textViewError = (TextView) findViewById(R.id.textViewErrorAccount);
- + TextView textViewError = findViewById(R.id.textViewErrorAccount);
- textViewError.setText(R.string.create_account_activity_account_object_exist);
- findViewById(R.id.imageViewAccountCheck).setVisibility(View.INVISIBLE);
- }
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java b/evraz-wallet/app/src/main/java/com/ngse/ui/ImportActivty.java
- similarity index 97%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/ImportActivty.java
- index 0d8d876..36f34d2 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/ImportActivty.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/ImportActivty.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui;
- import android.content.Intent;
- import android.content.pm.PackageManager;
- @@ -20,6 +20,8 @@ import com.bitshares.bitshareswallet.wallet.common.ConvertUriToFilePath;
- import com.bitshares.bitshareswallet.wallet.common.ErrorCode;
- import com.kaopiz.kprogresshud.KProgressHUD;
- +import org.evrazcoin.evrazwallet.R;
- +
- import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
- import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
- @@ -53,7 +55,7 @@ public class ImportActivty extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- - setContentView(R.layout.activity_import_activty);
- + setContentView(R.layout.new_activity_import_activty);
- mToolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(mToolbar);
- @@ -127,7 +129,7 @@ public class ImportActivty extends AppCompatActivity {
- mnModel = getIntent().getIntExtra("model", 0);
- switch (mnModel) {
- case ACCOUNT_MODEL:
- - getSupportActionBar().setTitle(R.string.import_activity_account_model);
- + getSupportActionBar().setTitle(R.string.auth);
- break;
- case WALLET_MODEL_BIN_FILE:
- getSupportActionBar().setTitle(R.string.import_activity_wallet_model);
- @@ -221,7 +223,8 @@ public class ImportActivty extends AppCompatActivity {
- if (nRet == 0) {
- mProcessHud.dismiss();
- - Intent intent = new Intent(ImportActivty.this, MainActivity.class);
- + Intent intent = new Intent(ImportActivty.this, NewMainActivity.class);
- +// Intent intent = new Intent(ImportActivty.this, MainActivity.class);
- intent.setFlags(FLAG_ACTIVITY_CLEAR_TASK | FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent);
- } else {
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java b/evraz-wallet/app/src/main/java/com/ngse/ui/NewMainActivity.java
- similarity index 68%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/NewMainActivity.java
- index e1ab7b0..74b01c0 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/MainActivity.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/NewMainActivity.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui;
- import android.app.Activity;
- import android.arch.lifecycle.ViewModelProviders;
- @@ -8,23 +8,20 @@ import android.content.Context;
- import android.content.DialogInterface;
- import android.content.Intent;
- import android.content.SharedPreferences;
- -import android.content.pm.PackageInfo;
- -import android.content.pm.PackageManager;
- import android.content.res.Resources;
- import android.net.Uri;
- +import android.os.Bundle;
- import android.os.Handler;
- import android.support.annotation.NonNull;
- -import android.support.design.widget.BottomNavigationView;
- import android.support.design.widget.NavigationView;
- +import android.support.v4.app.FragmentManager;
- +import android.support.v4.app.FragmentTransaction;
- import android.support.v4.content.LocalBroadcastManager;
- -import android.support.v4.media.session.PlaybackStateCompat;
- import android.support.v4.view.GravityCompat;
- -import android.support.v4.view.ViewPager;
- import android.support.v4.widget.DrawerLayout;
- import android.support.v7.app.ActionBarDrawerToggle;
- import android.support.v7.app.AlertDialog;
- import android.support.v7.app.AppCompatActivity;
- -import android.os.Bundle;
- import android.support.v7.app.AppCompatDelegate;
- import android.support.v7.preference.PreferenceManager;
- import android.support.v7.widget.Toolbar;
- @@ -38,6 +35,10 @@ import android.widget.LinearLayout;
- import android.widget.TextView;
- import android.widget.Toast;
- +import com.bitshares.bitshareswallet.AboutActivity;
- +import com.bitshares.bitshareswallet.BitsharesApplication;
- +import com.bitshares.bitshareswallet.OnFragmentInteractionListener;
- +import com.bitshares.bitshareswallet.SettingsActivity;
- import com.bitshares.bitshareswallet.room.BitsharesAsset;
- import com.bitshares.bitshareswallet.room.BitsharesDao;
- import com.bitshares.bitshareswallet.room.BitsharesOperationHistory;
- @@ -49,14 +50,21 @@ import com.bitshares.bitshareswallet.wallet.account_object;
- import com.bitshares.bitshareswallet.wallet.fc.crypto.sha256_object;
- import com.bitshares.bitshareswallet.wallet.graphene.chain.signed_transaction;
- import com.bitshares.bitshareswallet.wallet.graphene.chain.utils;
- +import com.ngse.ui.main.MainWalletFragment;
- +import com.ngse.ui.main.trading.TradingScheduleFragment;
- +import com.ngse.ui.main.balanceitems.OpenOrdersFragment;
- +import com.ngse.ui.main.balanceitems.PortfolioFragment;
- +import com.ngse.ui.main.balanceitems.TransactionsFragment;
- +
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.util.List;
- import io.reactivex.Flowable;
- import io.reactivex.schedulers.Schedulers;
- -
- -public class MainActivity extends AppCompatActivity
- +public class NewMainActivity extends AppCompatActivity
- implements OnFragmentInteractionListener {
- static {
- @@ -68,16 +76,11 @@ public class MainActivity extends AppCompatActivity
- private Toolbar mToolbar;
- private DrawerLayout mDrawerLayout;
- private ActionBarDrawerToggle mActionBarDrawerToggle;
- - private NonScrollViewPager mViewPager;
- - private WalletFragment mWalletFragment;
- - private QuotationFragment mQuotationFragment;
- - private ExchangeFragment mExchangeFragment;
- - private BtsFragmentPageAdapter mMainFragmentPageAdapter;
- + private MainWalletFragment mWalletFragment;
- private TextView mTxtTitle;
- private LinearLayout mLayoutTitle;
- - private BottomNavigationView mBottomNavigation;
- - private Handler mHandler = new Handler();
- +
- private static final int REQUEST_CODE_SETTINGS = 1;
- @@ -101,6 +104,7 @@ public class MainActivity extends AppCompatActivity
- updateTitle();
- LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(Broadcast.CURRENCY_UPDATED));
- }
- +
- @Override
- protected void onNewIntent(Intent intent) {
- super.onNewIntent(intent);
- @@ -118,7 +122,7 @@ public class MainActivity extends AppCompatActivity
- );
- }
- - private void setTitleVisible(boolean visible){
- + public void setTitleVisible(boolean visible) {
- mLayoutTitle.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
- }
- @@ -127,7 +131,7 @@ public class MainActivity extends AppCompatActivity
- super.onCreate(savedInstanceState);
- rasingColorRevers = getResources().getConfiguration().locale.getCountry().equals("CN");
- - setContentView(R.layout.activity_main);
- + setContentView(R.layout.new_activity_main);
- mToolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(mToolbar);
- @@ -156,65 +160,29 @@ public class MainActivity extends AppCompatActivity
- mDrawerLayout.addDrawerListener(mActionBarDrawerToggle);
- mActionBarDrawerToggle.syncState();
- - mViewPager = (NonScrollViewPager) findViewById(R.id.viewPager);
- - mMainFragmentPageAdapter = new BtsFragmentPageAdapter(getSupportFragmentManager());
- + mWalletFragment = MainWalletFragment.newInstance();
- - mWalletFragment = WalletFragment.newInstance("","");
- - mQuotationFragment = QuotationFragment.newInstance();
- - mExchangeFragment = ExchangeFragment.newInstance("", "");
- - mMainFragmentPageAdapter.addFragment(mWalletFragment, "Wallet");
- - mMainFragmentPageAdapter.addFragment(mQuotationFragment, "Quotation");
- - mMainFragmentPageAdapter.addFragment(mExchangeFragment, "Exchange");
- - mViewPager.setAdapter(mMainFragmentPageAdapter);
- -
- - mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
- - @Override
- - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
- -
- - }
- -
- - @Override
- - public void onPageSelected(int position) {
- - if(position == 0) {
- - mBottomNavigation.setSelectedItemId(R.id.navigation_wallet);
- - } else if(position == 1) {
- - mBottomNavigation.setSelectedItemId(R.id.navigation_quotation);
- - } else if(position == 2) {
- - mBottomNavigation.setSelectedItemId(R.id.navigation_exchange);
- - }
- - setTitleVisible(position!=0);
- - mMainFragmentPageAdapter.updatePagePosition(position);
- - }
- -
- - @Override
- - public void onPageScrollStateChanged(int state) {
- -
- - }
- - });
- - NavigationView navigationView = (NavigationView)findViewById(R.id.navigation_view);
- - navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
- - @Override
- - public boolean onNavigationItemSelected(@NonNull MenuItem item) {
- + NavigationView navigationView = findViewById(R.id.navigation_view);
- + navigationView.setNavigationItemSelectedListener(item -> {
- switch (item.getItemId()) {
- case R.id.logout:
- processLogout();
- break;
- case R.id.settings:
- - Intent intentSettings = new Intent(MainActivity.this, SettingsActivity.class);
- + Intent intentSettings = new Intent(NewMainActivity.this, SettingsActivity.class);
- //startActivity(intent);
- startActivityForResult(intentSettings, REQUEST_CODE_SETTINGS);
- break;
- case R.id.about:
- - Intent intentAbout = new Intent(MainActivity.this, AboutActivity.class);
- + Intent intentAbout = new Intent(NewMainActivity.this, AboutActivity.class);
- startActivity(intentAbout);
- break;
- }
- mDrawerLayout.closeDrawer(GravityCompat.START);
- return false;
- - }
- });
- WalletViewModel walletViewModel = ViewModelProviders.of(this).get(WalletViewModel.class);
- @@ -250,7 +218,7 @@ public class MainActivity extends AppCompatActivity
- ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
- ClipData clipData = ClipData.newPlainText("account name", accountObject.name);
- clipboardManager.setPrimaryClip(clipData);
- - Toast toast = Toast.makeText(MainActivity.this, "Copy Successfully", Toast.LENGTH_SHORT);
- + Toast toast = Toast.makeText(NewMainActivity.this, "Copy Successfully", Toast.LENGTH_SHORT);
- toast.show();
- }
- });
- @@ -258,25 +226,6 @@ public class MainActivity extends AppCompatActivity
- }
- - mBottomNavigation = (BottomNavigationView) findViewById(R.id.navigation_bottom);
- - mBottomNavigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
- - @Override
- - public boolean onNavigationItemSelected(@NonNull MenuItem item) {
- - switch (item.getItemId()){
- - case R.id.navigation_wallet:
- - mViewPager.setCurrentItem(0, true);
- - return true;
- - case R.id.navigation_quotation:
- - mViewPager.setCurrentItem(1, true);
- - return true;
- - case R.id.navigation_exchange:
- - mViewPager.setCurrentItem(2, true);
- - return true;
- - }
- - return false;
- - }
- - });
- -
- QuotationViewModel viewModel = ViewModelProviders.of(this).get(QuotationViewModel.class);
- viewModel.getSelectedMarketTicker().observe(this,
- currencyPair -> {
- @@ -285,19 +234,10 @@ public class MainActivity extends AppCompatActivity
- utils.getAssetSymbolDisply(currencyPair.first))
- );
- });
- - }
- - @Override
- - protected void onPause() {
- - super.onPause();
- - mMainFragmentPageAdapter.updateShowing(false);
- + showWalletFragment();
- }
- - @Override
- - protected void onResume() {
- - super.onResume();
- - mMainFragmentPageAdapter.updateShowing(true);
- - }
- @Override
- public void onFragmentInteraction(Uri uri) {
- @@ -324,6 +264,7 @@ public class MainActivity extends AppCompatActivity
- imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
- }
- }
- +
- public static void showSoftKeyboard(View view, Context context) {
- if (view != null && context != null) {
- InputMethodManager imm = (InputMethodManager) context
- @@ -340,14 +281,15 @@ public class MainActivity extends AppCompatActivity
- }
- private void processLogout() {
- - AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
- + AlertDialog.Builder builder = new AlertDialog.Builder(NewMainActivity.this, R.style.CustomDialogTheme);
- builder.setPositiveButton(R.string.log_out_dialog_confirm_button, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- Flowable.just(0)
- .subscribeOn(Schedulers.io())
- .map(integer -> {
- - BitsharesDao bitsharesDao = BitsharesApplication.getInstance().getBitsharesDatabase().getBitsharesDao();;
- + BitsharesDao bitsharesDao = BitsharesApplication.getInstance().getBitsharesDatabase().getBitsharesDao();
- + ;
- List<BitsharesAsset> bitsharesAssetList = bitsharesDao.queryBalanceList();
- List<BitsharesOperationHistory> bitsharesOperationHistoryList = bitsharesDao.queryOperationHistoryList();
- bitsharesDao.deleteBalance(bitsharesAssetList);
- @@ -357,7 +299,7 @@ public class MainActivity extends AppCompatActivity
- }).subscribe();
- BitsharesWalletWraper.getInstance().reset();
- - Intent intent = new Intent(MainActivity.this, SignUpButtonActivity.class);
- + Intent intent = new Intent(NewMainActivity.this, SignUpButtonActivity.class);
- startActivity(intent);
- finish();
- }
- @@ -374,7 +316,7 @@ public class MainActivity extends AppCompatActivity
- }
- private void processChooseCurency() {
- - final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainActivity.this);
- + final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(NewMainActivity.this, R.style.CustomDialogTheme);
- dialogBuilder.setTitle(R.string.title_select_currency);
- Resources res = getResources();
- final String[] arrValues = res.getStringArray(R.array.quotation_currency_pair_values);
- @@ -395,20 +337,55 @@ public class MainActivity extends AppCompatActivity
- putString("quotation_currency_pair", arrValues[which])
- .apply();
- String strAsset[] = arrValues[which].split(":");
- - QuotationViewModel viewModel = ViewModelProviders.of(MainActivity.this).get(QuotationViewModel.class);
- + QuotationViewModel viewModel = ViewModelProviders.of(NewMainActivity.this).get(QuotationViewModel.class);
- viewModel.selectedMarketTicker(new Pair(strAsset[1], strAsset[0]));
- onCurrencyUpdate();
- }
- });
- - dialogBuilder.setPositiveButton(R.string.log_out_dialog_cancel_button, new DialogInterface.OnClickListener() {
- - @Override
- - public void onClick(DialogInterface dialog, int which) {
- - dialog.dismiss();
- + dialogBuilder.setPositiveButton(R.string.log_out_dialog_cancel_button, (dialog, which) -> dialog.dismiss());
- + dialogBuilder.show();
- }
- - });
- - dialogBuilder.show();
- + public void showWalletFragment() {
- + FragmentManager fragmentManager = getSupportFragmentManager();
- + FragmentTransaction ft = fragmentManager.beginTransaction();
- + ft.replace(R.id.fragmentFrameLayout, mWalletFragment, MainWalletFragment.TAG);
- + ft.commitAllowingStateLoss();
- + }
- +
- + public void showTransactionsFragment() {
- + FragmentManager fragmentManager = getSupportFragmentManager();
- + FragmentTransaction ft = fragmentManager.beginTransaction();
- + ft.replace(R.id.fragmentFrameLayout, TransactionsFragment.newInstance(), TransactionsFragment.TAG);
- + ft.addToBackStack(TransactionsFragment.TAG);
- + ft.commitAllowingStateLoss();
- + }
- +
- + public void showPortfolioFragment() {
- + FragmentManager fragmentManager = getSupportFragmentManager();
- + FragmentTransaction ft = fragmentManager.beginTransaction();
- + ft.replace(R.id.fragmentFrameLayout, PortfolioFragment.newInstance(), PortfolioFragment.TAG);
- + ft.addToBackStack(PortfolioFragment.TAG);
- + ft.commitAllowingStateLoss();
- }
- +
- + public void showOpenOrdersFragment() {
- + FragmentManager fragmentManager = getSupportFragmentManager();
- + FragmentTransaction ft = fragmentManager.beginTransaction();
- + ft.replace(R.id.fragmentFrameLayout, OpenOrdersFragment.newInstance(), OpenOrdersFragment.TAG);
- + ft.addToBackStack(OpenOrdersFragment.TAG);
- + ft.commitAllowingStateLoss();
- + }
- +
- + public void showTradingScheduleFragment() {
- + FragmentManager fragmentManager = getSupportFragmentManager();
- + FragmentTransaction ft = fragmentManager.beginTransaction();
- + ft.replace(R.id.fragmentFrameLayout, TradingScheduleFragment.newInstance(), TradingScheduleFragment.TAG);
- + ft.addToBackStack(TradingScheduleFragment.TAG);
- + ft.commitAllowingStateLoss();
- + }
- +
- +
- }
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/ui/SignUpButtonActivity.java b/evraz-wallet/app/src/main/java/com/ngse/ui/SignUpButtonActivity.java
- new file mode 100644
- index 0000000..7e44eee
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/SignUpButtonActivity.java
- @@ -0,0 +1,34 @@
- +package com.ngse.ui;
- +
- +import android.content.Intent;
- +import android.os.Bundle;
- +import android.support.v7.app.AppCompatActivity;
- +
- +
- +
- +import org.evrazcoin.evrazwallet.R;
- +
- +/**
- + * An example full-screen activity that shows and hides the system UI (i.e.
- + * status bar and navigation/system bar) with user interaction.
- + */
- +public class SignUpButtonActivity extends AppCompatActivity {
- + @Override
- + protected void onCreate(Bundle savedInstanceState) {
- + super.onCreate(savedInstanceState);
- +
- + setContentView(R.layout.new_activity_sign_up_button);
- + findViewById(R.id.sign_up_button).setOnClickListener(v -> {
- + Intent intent = new Intent(SignUpButtonActivity.this, SignUpInfoActivity.class);
- + startActivity(intent);
- + });
- +
- + findViewById(R.id.buttonLogin).setOnClickListener(v -> {
- + Intent intent = new Intent(SignUpButtonActivity.this, ImportActivty.class);
- + intent.putExtra("model", ImportActivty.ACCOUNT_MODEL);
- + startActivity(intent);
- + /* Intent intent = new Intent(SignUpButtonActivity.this, ModelSelectActivity.class);
- + startActivity(intent);*/
- + });
- + }
- +}
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/ui/SignUpInfoActivity.java b/evraz-wallet/app/src/main/java/com/ngse/ui/SignUpInfoActivity.java
- new file mode 100644
- index 0000000..23848f5
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/SignUpInfoActivity.java
- @@ -0,0 +1,32 @@
- +package com.ngse.ui;
- +
- +import android.content.Intent;
- +import android.os.Bundle;
- +import android.support.v7.app.AppCompatActivity;
- +import android.support.v7.widget.Toolbar;
- +
- +import org.evrazcoin.evrazwallet.R;
- +
- +
- +public class SignUpInfoActivity extends AppCompatActivity {
- + private Toolbar mToolbar;
- +
- + @Override
- + protected void onCreate(Bundle savedInstanceState) {
- + super.onCreate(savedInstanceState);
- +
- + setContentView(R.layout.new_activity_sign_up_info);
- + mToolbar = findViewById(R.id.toolbar);
- + setSupportActionBar(mToolbar);
- + mToolbar.setNavigationOnClickListener(v -> onBackPressed());
- + getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- + getSupportActionBar().setDisplayHomeAsUpEnabled(true);
- +
- + findViewById(R.id.sign_up_next).setOnClickListener(v -> {
- + Intent intent = new Intent(SignUpInfoActivity.this, CreateAccountActivity.class);
- + startActivity(intent);
- + });
- +
- +
- + }
- +}
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/ui/custom/CustomListPreference.java b/evraz-wallet/app/src/main/java/com/ngse/ui/custom/CustomListPreference.java
- new file mode 100644
- index 0000000..dd2894f
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/custom/CustomListPreference.java
- @@ -0,0 +1,37 @@
- +package com.ngse.ui.custom;
- +
- +import java.util.ArrayList;
- +
- +import android.content.Context;
- +import android.content.DialogInterface;
- +import android.content.SharedPreferences;
- +import android.content.res.TypedArray;
- +import android.graphics.Color;
- +
- +
- +import android.support.v7.preference.ListPreference;
- +import android.util.AttributeSet;
- +import android.view.ContextThemeWrapper;
- +
- +
- +public class CustomListPreference extends ListPreference {
- + private static int[] ATTRS = {android.R.attr.theme};
- + private ContextThemeWrapper mContextWrapper;
- +
- +
- + public CustomListPreference(Context context) {
- + this(context, null);
- + }
- +
- + public CustomListPreference(Context context, AttributeSet attrs) {
- + super(context, attrs);
- + TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);
- + mContextWrapper = new ContextThemeWrapper(context, a.getResourceId(0, 0));
- + a.recycle();
- + }
- +
- + @Override
- + public Context getContext() {
- + return mContextWrapper;
- + }
- +}
- \ No newline at end of file
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/WalletFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/BalanceFragment.java
- similarity index 55%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/WalletFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/BalanceFragment.java
- index e3533c7..32f0344 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/WalletFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/BalanceFragment.java
- @@ -1,104 +1,47 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main;
- import android.arch.lifecycle.ViewModelProviders;
- import android.content.Context;
- import android.content.DialogInterface;
- -import android.content.Intent;
- -import android.content.res.Resources;
- import android.net.Uri;
- import android.os.Bundle;
- -import android.os.Handler;
- -import android.support.design.widget.TabLayout;
- -import android.support.v4.app.Fragment;
- -import android.support.v4.view.ViewPager;
- import android.support.v7.app.AlertDialog;
- -import android.text.TextUtils;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.TextView;
- +import com.bitshares.bitshareswallet.BaseFragment;
- import com.bitshares.bitshareswallet.room.BitsharesBalanceAsset;
- import com.bitshares.bitshareswallet.viewmodel.WalletViewModel;
- +import com.ngse.ui.NewMainActivity;
- +
- +import org.evrazcoin.evrazwallet.R;
- import java.util.List;
- import java.util.Locale;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- +import butterknife.OnClick;
- -/**
- - * A simple {@link Fragment} subclass.
- - * Activities that contain this fragment must implement the
- - * {@link OnFragmentInteractionListener} interface
- - * to handle interaction events.
- - * Use the {@link WalletFragment#newInstance} factory method to
- - * create an instance of this fragment.
- - */
- -public class WalletFragment extends BaseFragment {
- - // TODO: Rename parameter arguments, choose names that match
- - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- - private static final String ARG_PARAM1 = "param1";
- - private static final String ARG_PARAM2 = "param2";
- -
- - // TODO: Rename and change types of parameters
- - private String mParam1;
- - private String mParam2;
- +public class BalanceFragment extends BaseFragment {
- + public static final String TAG = BalanceFragment.class.getName();
- private OnFragmentInteractionListener mListener;
- - private BtsFragmentPageAdapter mWalletFragmentPageAdapter;
- - private Handler mHandler = new Handler();
- - private SendFragment mSendFragment;
- -
- - @BindView(R.id.fw_viewPager) ViewPager mViewPager;
- - @BindView(R.id.tabLayout) TabLayout mTabLayout;
- - @BindView(R.id.textTotalBalance) TextView textViewBalances;
- - @BindView(R.id.textViewCurrency) TextView textViewCurency;
- -
- - public WalletFragment() {
- - // Required empty public constructor
- - }
- + @BindView(R.id.textTotalBalance)
- + TextView textViewBalances;
- + @BindView(R.id.textViewCurrency)
- + TextView textViewCurency;
- - public void onNewIntent(Intent intent){
- - String strAction = intent.getStringExtra("action");
- - if (TextUtils.isEmpty(strAction) == false) {
- - mViewPager.setCurrentItem(2);
- - String strName = intent.getStringExtra("name");
- - int nAmount = Integer.valueOf(intent.getStringExtra("amount"));
- - String strUnit = intent.getStringExtra("unit");
- - mSendFragment.processDonate(strName, nAmount, strUnit);
- - }
- - }
- - /**
- - * Use this factory method to create a new instance of
- - * this fragment using the provided parameters.
- - *
- - * @param param1 Parameter 1.
- - * @param param2 Parameter 2.
- - * @return A new instance of fragment WalletFragment.
- - */
- - // TODO: Rename and change types and number of parameters
- - public static WalletFragment newInstance(String param1, String param2) {
- - WalletFragment fragment = new WalletFragment();
- - Bundle args = new Bundle();
- - args.putString(ARG_PARAM1, param1);
- - args.putString(ARG_PARAM2, param2);
- - fragment.setArguments(args);
- - return fragment;
- + public static BalanceFragment newInstance() {
- + return new BalanceFragment();
- }
- - @Override
- - public void onCreate(Bundle savedInstanceState) {
- - super.onCreate(savedInstanceState);
- - if (getArguments() != null) {
- - mParam1 = getArguments().getString(ARG_PARAM1);
- - mParam2 = getArguments().getString(ARG_PARAM2);
- - }
- - }
- @Override
- public void onResume() {
- @@ -163,12 +106,10 @@ public class WalletFragment extends BaseFragment {
- String strTotalBalance = String.format(Locale.ENGLISH, "%d %s", totalBTS, "BTS");
- textViewBalances.setText(strTotalBalance);
- textViewCurency.setVisibility(View.VISIBLE);
- -
- - mWalletFragmentPageAdapter.notifyUpdate();
- }
- void processError() {
- - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.CustomDialogTheme);
- builder.setPositiveButton(R.string.connect_fail_dialog_retry, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- @@ -183,41 +124,27 @@ public class WalletFragment extends BaseFragment {
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- - View view = inflater.inflate(R.layout.fragment_wallet, container, false);
- + View view = inflater.inflate(R.layout.new_fragment_balance, container, false);
- ButterKnife.bind(this, view);
- - Resources res = getResources();
- - mWalletFragmentPageAdapter = new BtsFragmentPageAdapter(getFragmentManager());
- - mWalletFragmentPageAdapter.addFragment(BalancesFragment.newInstance("", ""), res.getString(R.string.tab_balances));
- - mWalletFragmentPageAdapter.addFragment(TransactionsFragment.newInstance("", ""), res.getString(R.string.tab_transactions));
- - mSendFragment = SendFragment.newInstance("", "");
- - mWalletFragmentPageAdapter.addFragment(mSendFragment, res.getString(R.string.tab_send));
- -
- - mViewPager.setAdapter(mWalletFragmentPageAdapter);
- - initPager(mViewPager, mWalletFragmentPageAdapter);
- -
- - mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
- - @Override
- - public void onTabSelected(TabLayout.Tab tab) {
- - mViewPager.setCurrentItem(tab.getPosition());
- - if (tab.getPosition() != 2) {
- - MainActivity.hideSoftKeyboard(mTabLayout, getActivity());
- - }
- + return view;
- }
- - @Override
- - public void onTabUnselected(TabLayout.Tab tab) {
- -
- + @OnClick(R.id.portfolio)
- + void portfolioClick() {
- + ((NewMainActivity) getActivity()).showPortfolioFragment();
- }
- - @Override
- - public void onTabReselected(TabLayout.Tab tab) {
- -
- + @OnClick(R.id.openOrders)
- + void openOrdersClick() {
- + ((NewMainActivity) getActivity()).showOpenOrdersFragment();
- }
- - });
- - mTabLayout.setupWithViewPager(mViewPager);
- - return view;
- +
- + @OnClick(R.id.transactions)
- + void transactionsClick() {
- + ((NewMainActivity) getActivity()).showTransactionsFragment();
- }
- +
- // TODO: Rename method, update argument and hook method into UI event
- public void onButtonPressed(Uri uri) {
- if (mListener != null) {
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/ui/main/ExchangeFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/ExchangeFragment.java
- new file mode 100644
- index 0000000..5e45275
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/ExchangeFragment.java
- @@ -0,0 +1,114 @@
- +package com.ngse.ui.main;
- +
- +import android.arch.lifecycle.ViewModelProviders;
- +import android.os.Bundle;
- +import android.support.v7.widget.LinearLayoutManager;
- +import android.support.v7.widget.RecyclerView;
- +import android.util.Pair;
- +import android.view.LayoutInflater;
- +import android.view.View;
- +import android.view.ViewGroup;
- +
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.market.MarketTicker;
- +import com.bitshares.bitshareswallet.viewmodel.QuotationViewModel;
- +import com.ngse.ui.NewMainActivity;
- +
- +import org.evrazcoin.evrazwallet.R;
- +
- +import butterknife.BindView;
- +import butterknife.ButterKnife;
- +
- +public class ExchangeFragment extends BaseFragment {
- + private static final String TAG = "QuotationFragment";
- +
- + private QuotationCurrencyPairAdapter quotationCurrencyPairAdapter;
- +
- + @BindView(R.id.recyclerView)
- + RecyclerView mRecyclerView;
- +
- +
- + public ExchangeFragment() {
- +
- + }
- +
- +
- + @Override
- + public void onCreate(Bundle savedInstanceState) {
- + super.onCreate(savedInstanceState);
- + }
- +
- + public static ExchangeFragment newInstance() {
- + ExchangeFragment fragment = new ExchangeFragment();
- + return fragment;
- + }
- +
- + @Override
- + public View onCreateView(LayoutInflater inflater, ViewGroup container,
- + Bundle savedInstanceState) {
- + View view = inflater.inflate(R.layout.new_fragment_exchange, container, false);
- + ButterKnife.bind(this, view);
- +
- + quotationCurrencyPairAdapter = new QuotationCurrencyPairAdapter(getActivity());
- + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
- + linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
- + mRecyclerView.setLayoutManager(linearLayoutManager);
- + mRecyclerView.setAdapter(quotationCurrencyPairAdapter);
- + mRecyclerView.setItemAnimator(null);
- +
- +
- + QuotationViewModel viewModel = ViewModelProviders.of(getActivity()).get(QuotationViewModel.class);
- + quotationCurrencyPairAdapter.setOnItemClickListenr(new QuotationCurrencyPairAdapter.OnItemClickListner() {
- + @Override
- + public void onItemClick(View view, int position) {
- + //mListener.notifyCurrencyPairChange();
- + if (quotationCurrencyPairAdapter.getSelectedMarketTicker() != null) {
- + MarketTicker marketTicker = quotationCurrencyPairAdapter.getSelectedMarketTicker().marketTicker;
- + viewModel.selectedMarketTicker(new Pair(marketTicker.base, marketTicker.quote));
- + ((NewMainActivity) getActivity()).showTradingScheduleFragment();
- + }
- +
- + }
- + });
- +
- + return view;
- + }
- +
- +
- + @Override
- + public void onShow() {
- + super.onShow();
- +
- + QuotationViewModel viewModel = ViewModelProviders.of(getActivity()).get(QuotationViewModel.class);
- + viewModel.getMarketTicker().observe(
- + this,
- + marketTickerListResource -> {
- + switch (marketTickerListResource.status) {
- + case ERROR:
- + break;
- + case LOADING:
- + if (marketTickerListResource.data != null && marketTickerListResource.data.size() != 0) {
- + quotationCurrencyPairAdapter.notifyDataUpdated(marketTickerListResource.data);
- + MarketTicker marketTicker = quotationCurrencyPairAdapter.getSelectedMarketTicker().marketTicker;
- + viewModel.selectedMarketTicker(new Pair(marketTicker.base, marketTicker.quote));
- + }
- + break;
- + case SUCCESS:
- + quotationCurrencyPairAdapter.notifyDataUpdated(marketTickerListResource.data);
- + MarketTicker marketTicker = quotationCurrencyPairAdapter.getSelectedMarketTicker().marketTicker;
- + viewModel.selectedMarketTicker(new Pair(marketTicker.base, marketTicker.quote));
- + break;
- + }
- + });
- +
- +
- + viewModel.getSelectedMarketTicker().observe(this, currencyPair -> quotationCurrencyPairAdapter.notifyDataSetChanged());
- + }
- +
- + @Override
- + public void onHide() {
- + super.onHide();
- + }
- +
- +
- +}
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/ui/main/MainWalletFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/MainWalletFragment.java
- new file mode 100644
- index 0000000..dc57e4c
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/MainWalletFragment.java
- @@ -0,0 +1,161 @@
- +package com.ngse.ui.main;
- +
- +import android.content.Context;
- +import android.content.Intent;
- +import android.content.res.Resources;
- +import android.net.Uri;
- +import android.os.Bundle;
- +import android.support.v4.app.Fragment;
- +import android.support.v4.view.ViewPager;
- +import android.text.TextUtils;
- +import android.view.LayoutInflater;
- +import android.view.View;
- +import android.view.ViewGroup;
- +import android.widget.RadioGroup;
- +
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.BtsFragmentPageAdapter;
- +import com.bitshares.bitshareswallet.TransactionsFragment;
- +
- +import org.evrazcoin.evrazwallet.R;
- +
- +import butterknife.BindView;
- +import butterknife.ButterKnife;
- +
- +
- +/**
- + * A simple {@link Fragment} subclass.
- + * Activities that contain this fragment must implement the
- + * {@link OnFragmentInteractionListener} interface
- + * to handle interaction events.
- + * Use the {@link MainWalletFragment#newInstance} factory method to
- + * create an instance of this fragment.
- + */
- +public class MainWalletFragment extends BaseFragment {
- + public static final String TAG = MainWalletFragment.class.getName();
- +
- +
- + private OnFragmentInteractionListener mListener;
- +
- + private BtsFragmentPageAdapter mWalletFragmentPageAdapter;
- +
- + private SendFragment mSendFragment;
- +
- + @BindView(R.id.fw_viewPager)
- + ViewPager mViewPager;
- + @BindView(R.id.viewPagerSwitcher)
- + RadioGroup viewPagerSwitcher;
- +
- +
- + public MainWalletFragment() {
- + // Required empty public constructor
- + }
- +
- + public void onNewIntent(Intent intent) {
- + String strAction = intent.getStringExtra("action");
- + if (TextUtils.isEmpty(strAction) == false) {
- +// mViewPager.setCurrentItem(1);
- + viewPagerSwitcher.check(R.id.sendButton);
- + String strName = intent.getStringExtra("name");
- + int nAmount = Integer.valueOf(intent.getStringExtra("amount"));
- + String strUnit = intent.getStringExtra("unit");
- + mSendFragment.processDonate(strName, nAmount, strUnit);
- + }
- + }
- +
- + public static MainWalletFragment newInstance() {
- + return new MainWalletFragment();
- + }
- +
- +
- + @Override
- + public void onResume() {
- + super.onResume();
- +
- +
- + }
- +
- + @Override
- + public void onShow() {
- + super.onShow();
- + }
- +
- + @Override
- + public void onHide() {
- + super.onHide();
- + }
- +
- +
- +
- +
- + @Override
- + public View onCreateView(LayoutInflater inflater, ViewGroup container,
- + Bundle savedInstanceState) {
- + View view = inflater.inflate(R.layout.new_fragment_wallet, container, false);
- + ButterKnife.bind(this, view);
- + Resources res = getResources();
- + mWalletFragmentPageAdapter = new BtsFragmentPageAdapter(getFragmentManager());
- + mWalletFragmentPageAdapter.addFragment(BalanceFragment.newInstance(), res.getString(R.string.tab_balances));
- + mSendFragment = SendFragment.newInstance("", "");
- + mWalletFragmentPageAdapter.addFragment(mSendFragment, res.getString(R.string.tab_send));
- + mWalletFragmentPageAdapter.addFragment(ExchangeFragment.newInstance(), res.getString(R.string.tab_transactions));
- +// mWalletFragmentPageAdapter.addFragment(TransactionsFragment.newInstance("", ""), res.getString(R.string.tab_transactions));
- +
- +
- + mViewPager.setAdapter(mWalletFragmentPageAdapter);
- + initPager(mViewPager, mWalletFragmentPageAdapter);
- + viewPagerSwitcher.setOnCheckedChangeListener((group, checkedId) -> {
- + switch (checkedId) {
- + case R.id.balanceButton:
- + mViewPager.setCurrentItem(0);
- + break;
- + case R.id.sendButton:
- + mViewPager.setCurrentItem(1);
- + break;
- + case R.id.exchangeButton:
- + mViewPager.setCurrentItem(2);
- + break;
- + }
- + });
- + return view;
- + }
- +
- + // TODO: Rename method, update argument and hook method into UI event
- + public void onButtonPressed(Uri uri) {
- + if (mListener != null) {
- + mListener.onFragmentInteraction(uri);
- + }
- + }
- +
- + @Override
- + public void onAttach(Context context) {
- + super.onAttach(context);
- + if (context instanceof OnFragmentInteractionListener) {
- + mListener = (OnFragmentInteractionListener) context;
- + } else {
- +// throw new RuntimeException(context.toString()
- +// + " must implement OnFragmentInteractionListener");
- + }
- + }
- +
- + @Override
- + public void onDetach() {
- + super.onDetach();
- + mListener = null;
- + }
- +
- + /**
- + * This interface must be implemented by activities that contain this
- + * fragment to allow an interaction in this fragment to be communicated
- + * to the activity and potentially other fragments contained in that
- + * activity.
- + * <p>
- + * See the Android Training lesson <a href=
- + * "http://developer.android.com/training/basics/fragments/communicating.html"
- + * >Communicating with Other Fragments</a> for more information.
- + */
- + public interface OnFragmentInteractionListener {
- + // TODO: Update argument type and name
- + void onFragmentInteraction(Uri uri);
- + }
- +}
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/QuotationCurrencyPairAdapter.java
- similarity index 92%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/QuotationCurrencyPairAdapter.java
- index 1ba06cd..c60510c 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/QuotationCurrencyPairAdapter.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/QuotationCurrencyPairAdapter.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main;
- import android.content.Context;
- import android.content.SharedPreferences;
- @@ -10,9 +10,13 @@ import android.view.ViewGroup;
- import android.widget.ImageView;
- import android.widget.TextView;
- +
- import com.bitshares.bitshareswallet.market.MarketTicker;
- import com.bitshares.bitshareswallet.room.BitsharesMarketTicker;
- import com.bitshares.bitshareswallet.wallet.graphene.chain.utils;
- +import com.ngse.ui.NewMainActivity;
- +
- +import org.evrazcoin.evrazwallet.R;
- import java.text.DecimalFormat;
- import java.util.ArrayList;
- @@ -25,9 +29,6 @@ import java.util.Locale;
- import java.util.Map;
- import java.util.Set;
- -/**
- - * Created by lorne on 22/09/2017.
- - */
- public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<QuotationCurrencyPairAdapter.ViewHolder> {
- public interface OnItemClickListner {
- @@ -36,7 +37,7 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- public class ViewHolder extends RecyclerView.ViewHolder {
- private View mView;
- - private View mViewSelected;
- +// private View mViewSelected;
- private ImageView mCurrencyIconView;
- private TextView mViewCurrencyPair;
- private TextView mViewPrice;
- @@ -45,7 +46,7 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- public ViewHolder(View itemView) {
- super(itemView);
- mView = itemView;
- - mViewSelected = mView.findViewById(R.id.viewSelected);
- +// mViewSelected = mView.findViewById(R.id.viewSelected);
- mCurrencyIconView = (ImageView) mView.findViewById(R.id.imageViewCurrency);
- mViewCurrencyPair = (TextView) mView.findViewById(R.id.textViewCurrencyPair);
- mViewPrice = (TextView) mView.findViewById(R.id.textViewPrice);
- @@ -68,6 +69,7 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- marrValues = context.getResources().getStringArray(R.array.quotation_currency_pair_values);
- currecnyPairSet.addAll(Arrays.asList(marrValues));
- + mapSymbol2Id.put("EVRAZ", R.mipmap.evraz);
- mapSymbol2Id.put("BTS", R.mipmap.bts);
- mapSymbol2Id.put("BTC", R.mipmap.btc);
- mapSymbol2Id.put("ETH", R.mipmap.eth);
- @@ -84,7 +86,7 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(parent.getContext())
- - .inflate(R.layout.recyclerview_item_currency_pair, parent, false);
- + .inflate(R.layout.new_recyclerview_item_currency_pair, parent, false);
- return new ViewHolder(view);
- }
- @@ -92,11 +94,11 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- public void onBindViewHolder(final ViewHolder holder, final int position) {
- BitsharesMarketTicker bitsharesMarketTicker = bitsharesMarketTickerList.get(position);
- - if (selected == position) {
- + /* if (selected == position) {
- holder.mViewSelected.setVisibility(View.VISIBLE);
- } else {
- holder.mViewSelected.setVisibility(View.INVISIBLE);
- - }
- + }*/
- MarketTicker marketTicker = bitsharesMarketTicker.marketTicker;
- String currencyPair = utils.getAssetSymbolDisply(marketTicker.quote) + " : " +
- @@ -122,10 +124,10 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- String strPercentChange;
- if (percent_change >= 0) {
- - if (!MainActivity.rasingColorRevers) {
- - holder.mView24h.setBackgroundResource(R.drawable.percent_change_background_green);
- + if (!NewMainActivity.rasingColorRevers) {
- + holder.mView24h.setBackgroundResource(R.drawable.oval_green_background);
- } else {
- - holder.mView24h.setBackgroundResource(R.drawable.percent_change_background_red);
- + holder.mView24h.setBackgroundResource(R.drawable.oval_red_background);
- }
- strPercentChange = String.format(
- Locale.ENGLISH,
- @@ -133,10 +135,10 @@ public class QuotationCurrencyPairAdapter extends RecyclerView.Adapter<Quotation
- percent_change
- );
- } else {
- - if (!MainActivity.rasingColorRevers) {
- - holder.mView24h.setBackgroundResource(R.drawable.percent_change_background_red);
- + if (!NewMainActivity.rasingColorRevers) {
- + holder.mView24h.setBackgroundResource(R.drawable.oval_red_background);
- } else {
- - holder.mView24h.setBackgroundResource(R.drawable.percent_change_background_green);
- + holder.mView24h.setBackgroundResource(R.drawable.oval_green_background);
- }
- strPercentChange = String.format(
- Locale.ENGLISH,
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/SendFragment.java
- similarity index 94%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/SendFragment.java
- index 24ebd9f..a995f65 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/SendFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/SendFragment.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main;
- import android.app.Activity;
- import android.arch.lifecycle.ViewModelProviders;
- @@ -25,6 +25,9 @@ import android.widget.Spinner;
- import android.widget.TextView;
- import android.widget.Toast;
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.BitsharesApplication;
- +import com.bitshares.bitshareswallet.OnFragmentInteractionListener;
- import com.bitshares.bitshareswallet.room.BitsharesAssetObject;
- import com.bitshares.bitshareswallet.room.BitsharesBalanceAsset;
- import com.bitshares.bitshareswallet.viewmodel.SendViewModel;
- @@ -39,6 +42,8 @@ import com.bitshares.bitshareswallet.wallet.graphene.chain.signed_transaction;
- import com.bituniverse.utils.NumericUtil;
- import com.kaopiz.kprogresshud.KProgressHUD;
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Locale;
- @@ -60,16 +65,11 @@ import io.reactivex.schedulers.Schedulers;
- * create an instance of this fragment.
- */
- public class SendFragment extends BaseFragment {
- - // TODO: Rename parameter arguments, choose names that match
- - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- - private static final String ARG_PARAM1 = "param1";
- - private static final String ARG_PARAM2 = "param2";
- +
- private KProgressHUD mProcessHud;
- private Spinner mSpinner;
- - // TODO: Rename and change types of parameters
- - private String mParam1;
- - private String mParam2;
- +
- private OnFragmentInteractionListener mListener;
- @@ -95,28 +95,14 @@ public class SendFragment extends BaseFragment {
- */
- // TODO: Rename and change types and number of parameters
- public static SendFragment newInstance(String param1, String param2) {
- - SendFragment fragment = new SendFragment();
- - Bundle args = new Bundle();
- - args.putString(ARG_PARAM1, param1);
- - args.putString(ARG_PARAM2, param2);
- - fragment.setArguments(args);
- - return fragment;
- - }
- -
- - @Override
- - public void onCreate(Bundle savedInstanceState) {
- - super.onCreate(savedInstanceState);
- - if (getArguments() != null) {
- - mParam1 = getArguments().getString(ARG_PARAM1);
- - mParam2 = getArguments().getString(ARG_PARAM2);
- - }
- + return new SendFragment();
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- - mView = inflater.inflate(R.layout.fragment_send, container, false);
- + mView = inflater.inflate(R.layout.new_fragment_send, container, false);
- ButterKnife.bind(this, mView);
- EditText editTextFrom = (EditText)mView.findViewById(R.id.editTextFrom);
- @@ -215,11 +201,11 @@ public class SendFragment extends BaseFragment {
- ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
- getActivity(),
- - android.R.layout.simple_spinner_item,
- + R.layout.new_custom_spinner_item,
- symbolList
- );
- - arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- + arrayAdapter.setDropDownViewResource(R.layout.new_spinner_style);
- mSpinner.setAdapter(arrayAdapter);
- }
- });
- @@ -502,12 +488,12 @@ public class SendFragment extends BaseFragment {
- ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
- getActivity(),
- - android.R.layout.simple_spinner_item,
- + R.layout.new_custom_spinner_item,
- listSymbols
- );
- if (mSpinner != null) {
- - arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- + arrayAdapter.setDropDownViewResource(R.layout.new_spinner_style);
- spinner.setAdapter(arrayAdapter);
- }
- }
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/OrdersFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/OpenOrdersFragment.java
- similarity index 66%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/OrdersFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/OpenOrdersFragment.java
- index 85a4349..00b92b8 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/OrdersFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/OpenOrdersFragment.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.balanceitems;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- @@ -15,11 +15,18 @@ import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import android.util.Log;
- import android.view.LayoutInflater;
- +import android.view.Menu;
- +import android.view.MenuInflater;
- +import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- +import android.widget.ImageView;
- import android.widget.TextView;
- import android.widget.Toast;
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.CancelOrderDialog;
- +import com.bitshares.bitshareswallet.TransactionSellBuyPasswordDialog;
- import com.bitshares.bitshareswallet.market.MarketStat;
- import com.bitshares.bitshareswallet.market.OpenOrder;
- import com.bitshares.bitshareswallet.wallet.BitsharesWalletWraper;
- @@ -28,14 +35,18 @@ import com.bitshares.bitshareswallet.wallet.exception.NetworkStatusException;
- import com.bitshares.bitshareswallet.wallet.graphene.chain.utils;
- import com.kaopiz.kprogresshud.KProgressHUD;
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.text.SimpleDateFormat;
- import java.util.List;
- import java.util.Locale;
- import java.util.concurrent.TimeUnit;
- -public class OrdersFragment extends BaseFragment
- +public class OpenOrdersFragment extends BaseFragment
- implements MarketStat.OnMarketStatUpdateListener {
- +
- + public static final String TAG = OpenOrdersFragment.class.getName();
- private static final long MARKET_STAT_INTERVAL_MILLIS = TimeUnit.SECONDS.toMillis(10);
- private RecyclerView listOrders;
- @@ -46,7 +57,7 @@ public class OrdersFragment extends BaseFragment
- private String baseAsset;
- private String quoteAsset;
- private KProgressHUD mProcessHud;
- - private Handler handler = new Handler();
- +// private MenuItem backMenuItem;
- private BroadcastReceiver currencyUpdateReceiver = new BroadcastReceiver() {
- @Override
- @@ -54,7 +65,7 @@ public class OrdersFragment extends BaseFragment
- marketStat.unsubscribe(baseAsset, quoteAsset);
- updateCurrency();
- marketStat.subscribe(baseAsset, quoteAsset, MarketStat.STAT_MARKET_OPEN_ORDER,
- - MARKET_STAT_INTERVAL_MILLIS, OrdersFragment.this);
- + MARKET_STAT_INTERVAL_MILLIS, OpenOrdersFragment.this);
- }
- };
- @@ -62,12 +73,27 @@ public class OrdersFragment extends BaseFragment
- marketStat.updateImmediately(baseAsset, quoteAsset);
- }
- - public OrdersFragment() {
- + public OpenOrdersFragment() {
- marketStat = new MarketStat();
- }
- - public static OrdersFragment newInstance() {
- - OrdersFragment fragment = new OrdersFragment();
- + /* @Override
- + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- + super.onCreateOptionsMenu(menu, inflater);
- + backMenuItem = menu.add(R.string.back)
- + .setIcon(R.drawable.abc_ic_ab_back_material)
- + .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
- + }
- +
- + @Override
- + public boolean onOptionsItemSelected(MenuItem item) {
- + if (item == backMenuItem)
- + getActivity().onBackPressed();
- + return super.onOptionsItemSelected(item);
- + }*/
- +
- + public static OpenOrdersFragment newInstance() {
- + OpenOrdersFragment fragment = new OpenOrdersFragment();
- return fragment;
- }
- @@ -80,7 +106,7 @@ public class OrdersFragment extends BaseFragment
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- - View view = inflater.inflate(R.layout.fragment_orders, container, false);
- + View view = inflater.inflate(R.layout.new_fragment_orders, container, false);
- adapterOrders = new OrderListAdapter();
- @@ -101,6 +127,12 @@ public class OrdersFragment extends BaseFragment
- return view;
- }
- + @Override
- + public void onResume() {
- + super.onResume();
- + onShow();
- + }
- +
- @Override
- public void onShow() {
- super.onShow();
- @@ -158,10 +190,11 @@ public class OrdersFragment extends BaseFragment
- class OrderListAdapter extends RecyclerView.Adapter<OrderViewHolder> {
- List<OpenOrder> listOrders;
- +
- @Override
- public OrderViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(
- - parent.getContext()).inflate(R.layout.view_my_order_item, parent, false);
- + parent.getContext()).inflate(R.layout.new_view_my_order_item, parent, false);
- return new OrderViewHolder(view);
- }
- @@ -182,61 +215,62 @@ public class OrdersFragment extends BaseFragment
- }
- class OrderViewHolder extends RecyclerView.ViewHolder {
- - TextView txtExpiration;
- - TextView txtCacel;
- +
- + ImageView imageCacel;
- TextView txtOperation;
- TextView txtPrice;
- - TextView txtSrcCoin;
- - TextView txtSrcCoinName;
- - TextView txtTargetCoin;
- - TextView txtTargetCoinName;
- +// TextView txtPriceUsd;
- OpenOrder order;
- public OrderViewHolder(View itemView) {
- super(itemView);
- + imageCacel = itemView.findViewById(R.id.voi_cacel);
- - txtExpiration = (TextView)itemView.findViewById(R.id.voi_txt_expiration);
- - txtCacel = (TextView)itemView.findViewById(R.id.voi_txt_cacel);
- txtOperation = (TextView) itemView.findViewById(R.id.voi_txt_operation);
- txtPrice = (TextView) itemView.findViewById(R.id.voi_txt_price);
- - txtSrcCoin = (TextView)itemView.findViewById(R.id.voi_txt_src_coin);
- - txtSrcCoinName = (TextView)itemView.findViewById(R.id.voi_txt_src_coin_name);
- - txtTargetCoin = (TextView)itemView.findViewById(R.id.voi_txt_target_coin);
- - txtTargetCoinName = (TextView)itemView.findViewById(R.id.voi_txt_target_coin_name);
- +// txtPriceUsd = (TextView) itemView.findViewById(R.id.voi_txt_price_usd);
- +
- - txtCacel.setOnClickListener(onCancelClickListener);
- + imageCacel.setOnClickListener(onCancelClickListener);
- }
- public void update(OpenOrder order) {
- +
- + String operation;
- + String firstAmount;
- + String secondAmount;
- +
- this.order = order;
- + String baseCurrency = utils.getAssetSymbolDisply(order.base.symbol);
- + String quoteCurrency = utils.getAssetSymbolDisply(order.quote.symbol);
- if (order.limitOrder.sell_price.quote.asset_id.equals(order.quote.id)) {
- - txtOperation.setText(R.string.label_buy);
- + operation = txtOperation.getContext().getString(R.string.label_buy);
- double buyAmount = utils.get_asset_amount(order.limitOrder.sell_price.quote.amount, order.quote);
- - txtTargetCoin.setText(String.format("%.6f",buyAmount));
- -
- + firstAmount = String.format(Locale.ENGLISH, "%.2f %s", buyAmount, quoteCurrency);
- double sellAmount = utils.get_asset_amount(order.limitOrder.sell_price.base.amount, order.base);
- - txtSrcCoin.setText(String.format("%.6f",sellAmount));
- + secondAmount = String.format(Locale.ENGLISH, "%.2f %s", sellAmount, baseCurrency);
- +
- + /* txtOperation.setText(R.string.label_buy);
- + txtTargetCoin.setText(String.format("%.6f", buyAmount));
- + txtSrcCoin.setText(String.format("%.6f", sellAmount));*/
- } else {
- - txtOperation.setText(R.string.label_sell);
- + operation = txtOperation.getContext().getString(R.string.label_sell);
- double buyAmount = utils.get_asset_amount(order.limitOrder.sell_price.quote.amount, order.base);
- - txtSrcCoin.setText(String.format("%.6f",buyAmount));
- -
- + secondAmount = String.format(Locale.ENGLISH, "%.2f %s", buyAmount, baseCurrency);
- double sellAmount = utils.get_asset_amount(order.limitOrder.sell_price.base.amount, order.quote);
- - txtTargetCoin.setText(String.format("%.6f",sellAmount));
- - }
- + firstAmount = String.format(Locale.ENGLISH, "%.2f %s", sellAmount, quoteCurrency);
- - txtPrice.setText(String.format(Locale.ENGLISH,
- - "%.6f %s/%s",
- - order.price,
- - utils.getAssetSymbolDisply(order.base.symbol),
- - utils.getAssetSymbolDisply(order.quote.symbol)
- - ));
- - //txtSrcCoinName.setText(order.base.symbol);
- - //txtTargetCoinName.setText(order.quote.symbol);
- - SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- - txtExpiration.setText(formatter.format(order.limitOrder.expiration));
- + /* txtOperation.setText(R.string.label_sell);
- + txtSrcCoin.setText(String.format("%.6f", buyAmount));
- + txtTargetCoin.setText(String.format("%.6f", sellAmount));*/
- + }
- + txtOperation.setText(txtOperation.getContext().getString(R.string.buy_string, operation, firstAmount, secondAmount));
- + txtPrice.setText(String.format(Locale.ENGLISH, "%.4f", order.price));
- +// txtPriceUsd.setText();
- + /* SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- + txtExpiration.setText(formatter.format(order.limitOrder.expiration));*/
- }
- private View.OnClickListener onCancelClickListener = new View.OnClickListener() {
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/PortfolioFragment.java
- similarity index 56%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/PortfolioFragment.java
- index 28e3ca0..8d48e90 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/BalancesFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/PortfolioFragment.java
- @@ -1,141 +1,67 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.balanceitems;
- import android.arch.lifecycle.ViewModelProviders;
- import android.content.Context;
- import android.net.Uri;
- import android.os.Bundle;
- -import android.support.v4.app.Fragment;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import android.view.LayoutInflater;
- +import android.view.Menu;
- +import android.view.MenuInflater;
- +import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.TextView;
- +import com.bitshares.bitshareswallet.BaseFragment;
- import com.bitshares.bitshareswallet.room.BitsharesBalanceAsset;
- import com.bitshares.bitshareswallet.viewmodel.WalletViewModel;
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.util.List;
- import java.util.Locale;
- +import butterknife.BindView;
- +import butterknife.ButterKnife;
- -/**
- - * A simple {@link Fragment} subclass.
- - * Activities that contain this fragment must implement the
- - * {@link BalancesFragment.OnFragmentInteractionListener} interface
- - * to handle interaction events.
- - * Use the {@link BalancesFragment#newInstance} factory method to
- - * create an instance of this fragment.
- - */
- -public class BalancesFragment extends BaseFragment {
- - // TODO: Rename parameter arguments, choose names that match
- - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- - private static final String ARG_PARAM1 = "param1";
- - private static final String ARG_PARAM2 = "param2";
- - // TODO: Rename and change types of parameters
- - private String mParam1;
- - private String mParam2;
- +public class PortfolioFragment extends BaseFragment {
- + public static final String TAG = PortfolioFragment.class.getName();
- private BalancesAdapter mBalancesAdapter;
- private OnFragmentInteractionListener mListener;
- + private MenuItem backMenuItem;
- - class BalanceItemViewHolder extends RecyclerView.ViewHolder {
- - public View view;
- - public TextView viewNumber;
- - public TextView viewUnit;
- - public TextView viewEqual;
- - public TextView viewConvertNumber;
- - public TextView viewConvertUnit;
- + @BindView(R.id.textUSDBalance)
- + TextView textUSDBalance;
- + @BindView(R.id.usdRateTitle)
- + TextView usdRateTitle;
- + @BindView(R.id.usdCostTitle)
- + TextView usdCostTitle;
- - public BalanceItemViewHolder(View itemView) {
- - super(itemView);
- - view = itemView;
- - viewNumber = (TextView) itemView.findViewById(R.id.textViewNumber);
- - viewUnit = (TextView) itemView.findViewById(R.id.textViewUnit);
- - viewEqual = (TextView) itemView.findViewById(R.id.textViewEqual);
- - viewConvertNumber = (TextView) itemView.findViewById(R.id.textViewNumber2);
- - viewConvertUnit = (TextView) itemView.findViewById(R.id.textViewUnit2);
- - }
- - }
- -
- - class BalancesAdapter extends RecyclerView.Adapter<BalanceItemViewHolder> {
- - private List<BitsharesBalanceAsset> bitsharesBalanceAssetList;
- @Override
- - public BalanceItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.recyclerview_item_balances, parent, false);
- - return new BalanceItemViewHolder(view);
- - }
- -
- - @Override
- - public void onBindViewHolder(BalanceItemViewHolder holder, int position) {
- - BitsharesBalanceAsset bitsharesBalanceAsset = bitsharesBalanceAssetList.get(position);
- - String strBalances = String.format(
- - Locale.ENGLISH,
- - "%.4f",
- - (float)bitsharesBalanceAsset.amount / bitsharesBalanceAsset.quote_precision
- - );
- -
- - holder.viewNumber.setText(strBalances);
- - holder.viewUnit.setText(bitsharesBalanceAsset.quote);
- - if (bitsharesBalanceAsset.quote.compareTo("BTS") != 0) {
- - int nResult = (int)Math.rint(bitsharesBalanceAsset.total / bitsharesBalanceAsset.base_precision);
- -
- - holder.viewEqual.setText("=");
- - holder.viewConvertNumber.setText(Integer.valueOf(nResult).toString());
- - holder.viewConvertUnit.setText("BTS");
- - }
- -
- + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- + super.onCreateOptionsMenu(menu, inflater);
- + backMenuItem = menu.add(R.string.back)
- + .setIcon(R.drawable.abc_ic_ab_back_material)
- + .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
- }
- @Override
- - public int getItemCount() {
- - if (bitsharesBalanceAssetList == null) {
- - return 0;
- - } else {
- - return bitsharesBalanceAssetList.size();
- - }
- + public boolean onOptionsItemSelected(MenuItem item) {
- + if (item == backMenuItem)
- + getActivity().onBackPressed();
- + return super.onOptionsItemSelected(item);
- }
- - public void notifyBalancesDataChanged(List<BitsharesBalanceAsset> bitsharesBalanceAssetList) {
- - this.bitsharesBalanceAssetList = bitsharesBalanceAssetList;
- -
- - notifyDataSetChanged();
- - }
- + public static PortfolioFragment newInstance() {
- + return new PortfolioFragment();
- }
- - public BalancesFragment() {
- - // Required empty public constructor
- - }
- -
- - /**
- - * Use this factory method to create a new instance of
- - * this fragment using the provided parameters.
- - *
- - * @param param1 Parameter 1.
- - * @param param2 Parameter 2.
- - * @return A new instance of fragment BalancesFragment.
- - */
- - // TODO: Rename and change types and number of parameters
- - public static BalancesFragment newInstance(String param1, String param2) {
- - BalancesFragment fragment = new BalancesFragment();
- - Bundle args = new Bundle();
- - args.putString(ARG_PARAM1, param1);
- - args.putString(ARG_PARAM2, param2);
- - fragment.setArguments(args);
- - return fragment;
- - }
- -
- - @Override
- - public void onCreate(Bundle savedInstanceState) {
- - super.onCreate(savedInstanceState);
- - if (getArguments() != null) {
- - mParam1 = getArguments().getString(ARG_PARAM1);
- - mParam2 = getArguments().getString(ARG_PARAM2);
- - }
- - }
- @Override
- public void onResume() {
- @@ -146,6 +72,7 @@ public class BalancesFragment extends BaseFragment {
- this, resourceBalanceList -> {
- switch (resourceBalanceList.status) {
- case SUCCESS:
- + processShowdata(resourceBalanceList.data);
- mBalancesAdapter.notifyBalancesDataChanged(resourceBalanceList.data);
- break;
- case LOADING:
- @@ -166,15 +93,41 @@ public class BalancesFragment extends BaseFragment {
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- - View view = inflater.inflate(R.layout.fragment_balances, container, false);
- - RecyclerView recyclerView = (RecyclerView)view.findViewById(R.id.recyclerView);
- + View view = inflater.inflate(R.layout.new_fragment_portfolio, container, false);
- + RecyclerView recyclerView = view.findViewById(R.id.recyclerView);
- recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
- mBalancesAdapter = new BalancesAdapter();
- recyclerView.setAdapter(mBalancesAdapter);
- + ButterKnife.bind(this, view);
- return view;
- }
- + void processShowdata(List<BitsharesBalanceAsset> bitsharesBalanceAssetList) {
- +// long totalBTS = 0;
- + long totalBalance = 0;
- + for (BitsharesBalanceAsset bitsharesBalanceAsset : bitsharesBalanceAssetList) {
- +// totalBTS += bitsharesBalanceAsset.total;
- + totalBalance += bitsharesBalanceAsset.balance;
- + }
- +
- + if (!bitsharesBalanceAssetList.isEmpty()) {
- + BitsharesBalanceAsset bitsharesBalanceAsset = bitsharesBalanceAssetList.get(0);
- + /* double exchangeRate = (double) totalBalance / bitsharesBalanceAsset.currency_precision / totalBTS * bitsharesBalanceAsset.base_precision;
- + totalBTS /= bitsharesBalanceAssetList.get(0).base_precision;*/
- + totalBalance /= bitsharesBalanceAssetList.get(0).currency_precision;
- +
- + String strTotalCurrency = getString(R.string.total_usd, totalBalance,
- + bitsharesBalanceAsset.currency);
- +
- +
- + textUSDBalance.setText(strTotalCurrency);
- + usdRateTitle.setText(getString(R.string.usd_rate, bitsharesBalanceAsset.currency));
- + usdCostTitle.setText(getString(R.string.usd_cost, bitsharesBalanceAsset.currency));
- + }
- +
- + }
- +
- // TODO: Rename method, update argument and hook method into UI event
- public void onButtonPressed(Uri uri) {
- if (mListener != null) {
- @@ -218,4 +171,67 @@ public class BalancesFragment extends BaseFragment {
- public void notifyUpdate() {
- }
- +
- + class BalanceItemViewHolder extends RecyclerView.ViewHolder {
- + public View view;
- + public TextView viewNumber;
- + public TextView viewUnit;
- + // public TextView viewEqual;
- + public TextView viewUSBBalance;
- + public TextView viewExchangeRate;
- +
- + public BalanceItemViewHolder(View itemView) {
- + super(itemView);
- + view = itemView;
- + viewNumber = (TextView) itemView.findViewById(R.id.textViewNumber);
- + viewUnit = (TextView) itemView.findViewById(R.id.textViewUnit);
- +// viewEqual = (TextView) itemView.findViewById(R.id.textViewEqual);
- + viewUSBBalance = (TextView) itemView.findViewById(R.id.textUSDBalance);
- + viewExchangeRate = (TextView) itemView.findViewById(R.id.textExchangeRate);
- + }
- + }
- +
- + class BalancesAdapter extends RecyclerView.Adapter<BalanceItemViewHolder> {
- + private List<BitsharesBalanceAsset> bitsharesBalanceAssetList;
- +
- + @Override
- + public BalanceItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.new_recyclerview_item_balances, parent, false);
- + return new BalanceItemViewHolder(view);
- + }
- +
- + @Override
- + public void onBindViewHolder(BalanceItemViewHolder holder, int position) {
- + BitsharesBalanceAsset bitsharesBalanceAsset = bitsharesBalanceAssetList.get(position);
- + float balance = (float) bitsharesBalanceAsset.amount / bitsharesBalanceAsset.quote_precision;
- + float usdBalance = (float) bitsharesBalanceAsset.balance / bitsharesBalanceAsset.currency_precision;
- + float usdExchangeRate = usdBalance / balance;
- + String strBalances = String.format(Locale.ENGLISH, "%.2f", balance);
- + String strUsdBalance = String.format(Locale.ENGLISH, "%.4f", usdBalance);
- + String strUsdExchangeRate = String.format(Locale.ENGLISH, "%.4f", usdExchangeRate);
- + holder.viewNumber.setText(strBalances);
- +
- + holder.viewUnit.setText(bitsharesBalanceAsset.quote);
- +
- + holder.viewExchangeRate.setText(strUsdExchangeRate);
- + holder.viewUSBBalance.setText(strUsdBalance);
- +
- + }
- +
- + @Override
- + public int getItemCount() {
- + if (bitsharesBalanceAssetList == null) {
- + return 0;
- + } else {
- + return bitsharesBalanceAssetList.size();
- + }
- + }
- +
- + public void notifyBalancesDataChanged(List<BitsharesBalanceAsset> bitsharesBalanceAssetList) {
- + this.bitsharesBalanceAssetList = bitsharesBalanceAssetList;
- +
- + notifyDataSetChanged();
- + }
- + }
- +
- }
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TranactionsAdapter.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/TranactionsAdapter.java
- similarity index 94%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TranactionsAdapter.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/TranactionsAdapter.java
- index 3b2ffa7..7f89b16 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TranactionsAdapter.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/TranactionsAdapter.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.balanceitems;
- import android.content.Context;
- import android.content.DialogInterface;
- @@ -21,11 +21,11 @@ import com.bitshares.bitshareswallet.wallet.graphene.chain.config;
- import com.bitshares.bitshareswallet.wallet.graphene.chain.memo_data;
- import com.bitshares.bitshareswallet.wallet.graphene.chain.operations;
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.util.Locale;
- -/**
- - * Created by lorne on 01/11/2017.
- - */
- +
- class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.TransactionsItemViewHolder> {
- class TransactionsItemViewHolder extends RecyclerView.ViewHolder {
- public View view;
- @@ -52,7 +52,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- @Override
- public TransactionsItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- - View view = mLayoutInflater.inflate(R.layout.recyclerview_item_transactions, parent, false);
- + View view = mLayoutInflater.inflate(R.layout.new_recyclerview_item_transactions, parent, false);
- return new TransactionsItemViewHolder(view);
- }
- @@ -151,7 +151,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- operations.account_create_operation operation = (operations.account_create_operation) operationType.operationContent;
- String strRegistarName = operationHistoryWrapper.mapId2AccountObject.get(operation.registrar).name;
- - String strTransferFormat = "<font color=\'#2d95ff\'>%s</font> registered the account <font color=\'#2d95ff\'>%s</font>";
- + String strTransferFormat = "<font color=\'#FFAB40\'>%s</font> registered the account <font color=\'#FFAB40\'>%s</font>";
- String strResult = String.format(
- Locale.ENGLISH,
- strTransferFormat,
- @@ -173,7 +173,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- String strTo = operationHistoryWrapper.mapId2AccountObject.get(operation.to).name;
- BitsharesAssetObject bitsharesAssetObject = operationHistoryWrapper.mapId2AssetObject.get(operation.amount.asset_id);
- - String strTransferFormat = "<font color=\'#2d95ff\'>%s</font> sent <font color=\'#000000\'>%s %s</font> to <font color=\'#2d95ff\'>%s</font>";
- + String strTransferFormat = "<font color=\'#FFAB40\'>%s</font> sent <font color=\'#ffffff\'>%s %s</font> to <font color=\'#FFAB40\'>%s</font>";
- String strResult = String.format(
- Locale.ENGLISH, strTransferFormat,
- @@ -190,7 +190,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- }
- private void processMemoUnlockClick() {
- - AlertDialog.Builder builder = new AlertDialog.Builder(transactionsFragment.getActivity());
- + AlertDialog.Builder builder = new AlertDialog.Builder(transactionsFragment.getActivity(), R.style.CustomDialogTheme);
- LayoutInflater layoutInflater = transactionsFragment.getActivity().getLayoutInflater();
- final View viewGroup = layoutInflater.inflate(R.layout.dialog_password_unlock, null);
- builder.setPositiveButton(
- @@ -251,7 +251,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- layoutTransaction.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- - AlertDialog.Builder builder = new AlertDialog.Builder(transactionsFragment.getActivity());
- + AlertDialog.Builder builder = new AlertDialog.Builder(transactionsFragment.getActivity(), R.style.CustomDialogTheme);
- builder.setMessage(strMemo);
- builder.show();
- }
- @@ -271,7 +271,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- holder.viewAction.setText("Create Order");
- operations.limit_order_create_operation operation = (operations.limit_order_create_operation) operationType.operationContent;
- - String strTransferFormat = "<font color=\'#000000\'>To buy %.5f %s</font> at %.5f %s/%s";
- + String strTransferFormat = "<font color=\'#ffffff\'>To buy %.5f %s</font> at %.5f %s/%s";
- String strResult = processOrderOperation(operation.amount_to_sell, operation.min_to_receive, strTransferFormat);
- @@ -285,7 +285,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- holder.viewAction.setText("Cancel Order");
- operations.limit_order_cancel_operation operation = (operations.limit_order_cancel_operation) operationType.operationContent;
- - String strTransferFormat = "<font color=\'#000000\'>Canceled order #%d</font>";
- + String strTransferFormat = "<font color=\'#ffffff\'>Canceled order #%d</font>";
- String strResult = String.format(
- Locale.ENGLISH,
- strTransferFormat,
- @@ -302,7 +302,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- holder.viewAction.setText("Update Order");
- operations.call_order_update_operation operation = (operations.call_order_update_operation) operationType.operationContent;
- - String strTransferFormat = "<font color=\'#000000\'>%s</font>";
- + String strTransferFormat = "<font color=\'#ffffff\'>%s</font>";
- String strResult = String.format(
- Locale.ENGLISH,
- @@ -320,7 +320,7 @@ class TranactionsAdapter extends RecyclerView.Adapter<TranactionsAdapter.Transac
- holder.viewAction.setText("Fill Order");
- operations.fill_order_operation operation = (operations.fill_order_operation) operationType.operationContent;
- - String strTransferFormat = "<font color=\'#000000\'>Bought %.5f %s</font> at %.5f %s/%s";
- + String strTransferFormat = "<font color=\'#ffffff\'>Bought %.5f %s</font> at %.5f %s/%s";
- String strResult = processOrderOperation(operation.pays, operation.receives, strTransferFormat);
- if (operation.receives.asset_id.equals(config.asset_object_base)) {
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionsFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/TransactionsFragment.java
- similarity index 68%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionsFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/TransactionsFragment.java
- index 090770d..4e39274 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionsFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/balanceitems/TransactionsFragment.java
- @@ -1,54 +1,52 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.balanceitems;
- import android.arch.lifecycle.ViewModelProviders;
- import android.content.Context;
- import android.net.Uri;
- import android.os.Bundle;
- -import android.support.v4.app.Fragment;
- import android.support.v7.widget.LinearLayoutManager;
- import android.support.v7.widget.RecyclerView;
- import android.view.LayoutInflater;
- +import android.view.Menu;
- +import android.view.MenuInflater;
- +import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- -import android.widget.ImageView;
- -import android.widget.TextView;
- +
- +import com.bitshares.bitshareswallet.BaseFragment;
- import com.bitshares.bitshareswallet.viewmodel.TransactionViewModel;
- +import org.evrazcoin.evrazwallet.R;
- +
- import butterknife.BindView;
- import butterknife.ButterKnife;
- -/**
- - * A simple {@link Fragment} subclass.
- - * Activities that contain this fragment must implement the
- - * {@link TransactionsFragment.OnFragmentInteractionListener} interface
- - * to handle interaction events.
- - * Use the {@link TransactionsFragment#newInstance} factory method to
- - * create an instance of this fragment.
- - */
- public class TransactionsFragment extends BaseFragment {
- - // TODO: Rename parameter arguments, choose names that match
- - // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
- - private static final String ARG_PARAM1 = "param1";
- - private static final String ARG_PARAM2 = "param2";
- -
- - // TODO: Rename and change types of parameters
- - private String mParam1;
- - private String mParam2;
- + public static final String TAG = TransactionsFragment.class.getName();
- private OnFragmentInteractionListener mListener;
- private TranactionsAdapter mTranactionsAdapter;
- - @BindView(R.id.recyclerView) RecyclerView mRecyclerView;
- - @BindView(R.id.layoutChartLoading) View mLoadingChartView;
- - @BindView(R.id.layoutLoadingError) View mLoadingErrorView;
- -
- + @BindView(R.id.recyclerView)
- + RecyclerView mRecyclerView;
- + @BindView(R.id.layoutChartLoading)
- + View mLoadingChartView;
- + @BindView(R.id.layoutLoadingError)
- + View mLoadingErrorView;
- + private MenuItem backMenuItem;
- private static final int SHOW_HISTORY_VIEW_LODING = 1;
- private static final int SHOW_HISTORY_VIEW_LODING_FAIL = 2;
- private static final int SHOW_HISTORY_VIEW_READY = 3;
- + @Override
- + public void onResume() {
- + super.onResume();
- + onShow();
- + }
- +
- @Override
- public void onShow() {
- super.onShow();
- @@ -59,7 +57,7 @@ public class TransactionsFragment extends BaseFragment {
- operationHistoryWrapperResource -> {
- switch (operationHistoryWrapperResource.status) {
- case ERROR:
- - changeShowedView(SHOW_HISTORY_VIEW_LODING_FAIL);
- +// changeShowedView(SHOW_HISTORY_VIEW_LODING_FAIL);
- break;
- case SUCCESS:
- changeShowedView(SHOW_HISTORY_VIEW_READY);
- @@ -77,42 +75,31 @@ public class TransactionsFragment extends BaseFragment {
- });
- }
- - public TransactionsFragment() {
- - // Required empty public constructor
- - }
- -
- - /**
- - * Use this factory method to create a new instance of
- - * this fragment using the provided parameters.
- - *
- - * @param param1 Parameter 1.
- - * @param param2 Parameter 2.
- - * @return A new instance of fragment TransactionsFragment.
- - */
- - // TODO: Rename and change types and number of parameters
- - public static TransactionsFragment newInstance(String param1, String param2) {
- - TransactionsFragment fragment = new TransactionsFragment();
- - Bundle args = new Bundle();
- - args.putString(ARG_PARAM1, param1);
- - args.putString(ARG_PARAM2, param2);
- - fragment.setArguments(args);
- - return fragment;
- + @Override
- + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- + super.onCreateOptionsMenu(menu, inflater);
- + backMenuItem = menu.add(R.string.back)
- + .setIcon(R.drawable.abc_ic_ab_back_material)
- + .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
- }
- @Override
- - public void onCreate(Bundle savedInstanceState) {
- - super.onCreate(savedInstanceState);
- - if (getArguments() != null) {
- - mParam1 = getArguments().getString(ARG_PARAM1);
- - mParam2 = getArguments().getString(ARG_PARAM2);
- + public boolean onOptionsItemSelected(MenuItem item) {
- + if (item == backMenuItem)
- + getActivity().onBackPressed();
- + return super.onOptionsItemSelected(item);
- }
- +
- + public static TransactionsFragment newInstance() {
- + return new TransactionsFragment();
- }
- +
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- - View view = inflater.inflate(R.layout.fragment_transactions, container, false);
- + View view = inflater.inflate(R.layout.new_fragment_transactions, container, false);
- ButterKnife.bind(this, view);
- mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
- @@ -161,10 +148,6 @@ public class TransactionsFragment extends BaseFragment {
- void onFragmentInteraction(Uri uri);
- }
- - @Override
- - public void notifyUpdate(){
- -
- - }
- private void changeShowedView(int nShowView) {
- switch (nShowView) {
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TradingOrdersFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TradingOrdersFragment.java
- new file mode 100644
- index 0000000..8974d9e
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TradingOrdersFragment.java
- @@ -0,0 +1,577 @@
- +package com.ngse.ui.main.trading;
- +
- +import android.content.BroadcastReceiver;
- +import android.content.Context;
- +import android.content.Intent;
- +import android.content.IntentFilter;
- +import android.content.SharedPreferences;
- +import android.net.Uri;
- +import android.os.Bundle;
- +import android.support.v4.content.LocalBroadcastManager;
- +import android.support.v7.preference.PreferenceManager;
- +import android.support.v7.widget.LinearLayoutManager;
- +import android.support.v7.widget.RecyclerView;
- +import android.view.LayoutInflater;
- +import android.view.View;
- +import android.view.ViewGroup;
- +
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.DensityUtil;
- +import com.bitshares.bitshareswallet.market.MarketStat;
- +import com.bitshares.bitshareswallet.wallet.Broadcast;
- +import com.bitshares.bitshareswallet.wallet.graphene.chain.utils;
- +
- +import org.evrazcoin.evrazwallet.R;
- +
- +import java.util.concurrent.TimeUnit;
- +
- +
- +public class TradingOrdersFragment extends BaseFragment
- + implements MarketStat.OnMarketStatUpdateListener
- + {//View.OnClickListener, TextWatcher , ConfirmOrderDialog.OnDialogInterationListener
- +
- + private static final long MARKET_STAT_INTERVAL_MILLIS = TimeUnit.SECONDS.toMillis(5);
- +// private static final String TRANSACTION_TYPE = "transaction_type";
- +
- +// private static int buyTimeSec = 5 * 365 * 24 * 60 * 60;
- +
- + private TransactionSellBuyRecyclerViewAdapter buyRecyclerViewAdapter;
- + private TransactionSellBuyRecyclerViewAdapter sellRecyclerViewAdapter;
- + private RecyclerView buyRecyclerView;
- + private RecyclerView sellRecyclerView;
- + private int maxOrderCount = 10;
- +
- + /*public static final int TRANSACTION_BUY = 1;
- + public static final int TRANSACTION_SELL = 2;
- + private int transactionType;*/
- + private MarketStat orderStat;
- + private String baseAsset;
- + private String quoteAsset;
- +// private double lowestSellPrice = -1;
- +// private double higgestBuyPrice = -1;
- + private OnFragmentInteractionListener mListener;
- +/*
- + private EditText qEditText;
- + private EditText pEditText;
- + private EditText tEditText;
- + private EditText fEditText;
- +
- + private TextView pTextLastView;
- + private TextView qTextLastView;
- + private TextView tTextLastView;
- +
- + private TextView balanceText;
- + private TextView askText;
- +
- + private TextView balanceTextBase;
- + private TextView askTextBase;
- + private TextView askTextInfo;
- +
- + private KProgressHUD mProcessHud;
- +
- + private asset_object btsAssetObj;
- + private asset_object baseAssetObj;
- + private asset_object quoteAssetObj;
- + private global_property_object globalPropertyObject;
- + private boolean isAssetObjIsInit;
- + private boolean isInitPriceValue;*/
- +
- + public TradingOrdersFragment() {
- + orderStat = new MarketStat();
- + }
- +
- + public static TradingOrdersFragment newInstance() {//int transactionType
- + /* TradingOrdersFragment fragment = new TradingOrdersFragment();
- + Bundle args = new Bundle();
- + args.putInt(TRANSACTION_TYPE, transactionType);
- + fragment.setArguments(args);*/
- + return new TradingOrdersFragment();
- + }
- +
- + private BroadcastReceiver currencyUpdateReceiver = new BroadcastReceiver() {
- + @Override
- + public void onReceive(Context context, Intent intent) {
- + orderStat.unsubscribe(baseAsset, quoteAsset);
- +
- + updateCurency();
- + orderStat.subscribe(baseAsset, quoteAsset, MarketStat.STAT_MARKET_ORDER_BOOK,
- + MARKET_STAT_INTERVAL_MILLIS, TradingOrdersFragment.this);
- + }
- + };
- +
- + @Override
- + public void onMarketStatUpdate(MarketStat.Stat stat) {
- + if (getView() == null || stat.orderBook == null) {
- + return;
- + }
- +
- + if (stat.orderBook.bids != null && !stat.orderBook.bids.isEmpty()) {
- + int maxCount = Math.min(stat.orderBook.bids.size(), maxOrderCount);
- + buyRecyclerViewAdapter.setList(stat.orderBook.bids.subList(0, maxCount));
- +
- +// higgestBuyPrice = stat.orderBook.bids.get(0).price;
- + } else {
- +// higgestBuyPrice = -1;
- + }
- +
- + if (stat.orderBook.asks != null && !stat.orderBook.asks.isEmpty()) {
- + int maxCount = Math.min(stat.orderBook.asks.size(), maxOrderCount);
- + sellRecyclerViewAdapter.setList(stat.orderBook.asks.subList(0, maxCount));
- +
- +// lowestSellPrice = stat.orderBook.asks.get(0).price;
- + } else {
- +// lowestSellPrice = -1;
- + }
- +
- +// initPriceValue();
- + }
- +
- +/* public void initPriceValue() {
- + DecimalFormat decimalFormat = new DecimalFormat("#.####");
- + if (!isInitPriceValue) {
- + isInitPriceValue = true;
- + if (transactionType == TRANSACTION_BUY && lowestSellPrice != -1) {
- + pEditText.setText(decimalFormat.format(lowestSellPrice));
- + } else if (transactionType == TRANSACTION_SELL && higgestBuyPrice != -1) {
- + pEditText.setText(decimalFormat.format(higgestBuyPrice));
- + }
- + }
- +
- + if (transactionType == TRANSACTION_BUY && lowestSellPrice != -1) {
- + askText.setText(decimalFormat.format(lowestSellPrice));
- + } else if (transactionType == TRANSACTION_SELL && higgestBuyPrice != -1) {
- + askText.setText(decimalFormat.format(higgestBuyPrice));
- + }
- + }*/
- +
- + /* @Override
- + public void onCreate(Bundle savedInstanceState) {
- + super.onCreate(savedInstanceState);
- + if (getArguments() != null) {
- + transactionType = getArguments().getInt(TRANSACTION_TYPE);
- + }
- + }
- +*/
- + @Override
- + public void onResume() {
- + super.onResume();
- + onShow();
- + }
- +
- + @Override
- + public void onShow() {
- + super.onShow();
- + updateCurency();
- +// initFee();
- + updateMaxOrderCount();
- + orderStat.subscribe(baseAsset, quoteAsset, MarketStat.STAT_MARKET_ORDER_BOOK,
- + MARKET_STAT_INTERVAL_MILLIS, this);
- +
- + IntentFilter intentFilter = new IntentFilter();
- + intentFilter.addAction(Broadcast.CURRENCY_UPDATED);
- + LocalBroadcastManager.getInstance(getContext())
- + .registerReceiver(currencyUpdateReceiver, intentFilter);
- +
- + /*SellBuyViewModel viewModel = ViewModelProviders.of(this).get(SellBuyViewModel.class);
- + if (isBuy()) {
- + viewModel.changeBalanceAsset(baseAsset);
- + } else {
- + viewModel.changeBalanceAsset(quoteAsset);
- + }*/
- +
- + /* viewModel.getAvaliableBalance().observe(this, bitsharesAssetResource -> {
- + if (bitsharesAssetResource.status == Status.SUCCESS) {
- + BitsharesAsset bitsharesAsset = bitsharesAssetResource.data;
- + if (bitsharesAsset != null) {
- + DecimalFormat decimalFormat = new DecimalFormat("#.####");
- + balanceText.setText(decimalFormat.format((double) bitsharesAsset.amount / bitsharesAsset.precision));
- + } else {
- + balanceText.setText("0");
- + }
- + }
- + });*/
- + }
- +
- + @Override
- + public void onHide() {
- + super.onHide();
- + orderStat.unsubscribe(baseAsset, quoteAsset);
- + LocalBroadcastManager.getInstance(getContext()).unregisterReceiver(currencyUpdateReceiver);
- + }
- +
- + @Override
- + public View onCreateView(LayoutInflater inflater, ViewGroup container,
- + Bundle savedInstanceState) {
- + View view = inflater.inflate(R.layout.new_fragment_buy_sell_orders, container, false);
- +
- + /*Button okButton = (Button) view.findViewById(R.id.okButton);
- + okButton.setOnClickListener(this);
- + if (isBuy()) {
- + okButton.setText(getResources().getString(R.string.title_buy));
- + } else {
- + okButton.setText(getResources().getString(R.string.title_sell));
- + }
- +*/
- + /* mProcessHud = KProgressHUD.create(getActivity())
- + .setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
- + .setLabel("Please Wait")
- + .setCancellable(false)
- + .setAnimationSpeed(2)
- + .setDimAmount(0.5f);*/
- +
- + /* Button restButton = (Button) view.findViewById(R.id.restButton);
- + restButton.setOnClickListener(this);
- +
- + qEditText = (EditText) view.findViewById(R.id.qEditText);
- + pEditText = (EditText) view.findViewById(R.id.pEditText);
- + pEditText.addTextChangedListener(this);
- + qEditText.addTextChangedListener(this);
- +
- + tEditText = (EditText) view.findViewById(R.id.tEditText);
- + fEditText = (EditText) view.findViewById(R.id.fEditText);
- + pTextLastView = (TextView) view.findViewById(R.id.pTextLastView);
- + qTextLastView = (TextView) view.findViewById(R.id.qTextLastView);
- + tTextLastView = (TextView) view.findViewById(R.id.tTextLastView);
- +
- + balanceText = (TextView) view.findViewById(R.id.balanceText);
- + askText = (TextView) view.findViewById(R.id.askText);
- +
- + balanceTextBase = (TextView) view.findViewById(R.id.balanceTextBase);
- + askTextBase = (TextView) view.findViewById(R.id.askTextBase);
- + askTextInfo = (TextView) view.findViewById(R.id.askTextInfo);*/
- +
- + buyRecyclerView = view.findViewById(R.id.buy_recycler);
- + buyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- + buyRecyclerViewAdapter = new TransactionSellBuyRecyclerViewAdapter();
- + buyRecyclerView.setAdapter(buyRecyclerViewAdapter);
- + buyRecyclerView.setItemAnimator(null);
- +
- + sellRecyclerView = view.findViewById(R.id.sell_recycler);
- + sellRecyclerViewAdapter = new TransactionSellBuyRecyclerViewAdapter();
- + sellRecyclerView.setAdapter(sellRecyclerViewAdapter);
- + sellRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- + sellRecyclerView.setItemAnimator(null);
- +
- + return view;
- + }
- +
- + // TODO: Rename method, update argument and hook method into UI event
- + public void onButtonPressed(Uri uri) {
- + if (mListener != null) {
- + mListener.onFragmentInteraction(uri);
- + }
- + }
- +
- + @Override
- + public void onAttach(Context context) {
- + super.onAttach(context);
- + if (context instanceof OnFragmentInteractionListener) {
- + mListener = (OnFragmentInteractionListener) context;
- + } else {
- +// throw new RuntimeException(context.toString()
- +// + " must implement OnFragmentInteractionListener");
- + }
- +
- +
- + }
- +
- + @Override
- + public void onDetach() {
- + super.onDetach();
- + mListener = null;
- + }
- +
- + /**
- + * This interface must be implemented by activities that contain this
- + * fragment to allow an interaction in this fragment to be communicated
- + * to the activity and potentially other fragments contained in that
- + * activity.
- + * <p>
- + * See the Android Training lesson <a href=
- + * "http://developer.android.com/training/basics/fragments/communicating.html"
- + * >Communicating with Other Fragments</a> for more information.
- + */
- + public interface OnFragmentInteractionListener {
- + // TODO: Update argument type and name
- + void onFragmentInteraction(Uri uri);
- + }
- +
- + /* @Override
- + public void onClick(View v) {
- + switch (v.getId()) {
- + case R.id.okButton:
- + ConfirmOrderDialog.ConfirmOrderData confirmOrderData = new ConfirmOrderDialog.ConfirmOrderData();
- + if (transactionType == TRANSACTION_BUY) {
- + confirmOrderData.setOperationName(getResources().getString(R.string.title_buy));
- + } else {
- + confirmOrderData.setOperationName(getResources().getString(R.string.title_sell));
- + }
- + confirmOrderData.setPrice(pEditText.getText().toString());
- + confirmOrderData.setQuantity(qEditText.getText().toString());
- + confirmOrderData.setTotal(tEditText.getText().toString());
- + confirmOrderData.setFree(fEditText.getText().toString());
- + confirmOrderData.setQuantityType(utils.getAssetSymbolDisply(quoteAsset));
- + confirmOrderData.setTotalType(utils.getAssetSymbolDisply(baseAsset));
- +
- + Calendar calendar = Calendar.getInstance();
- + calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) + 5);
- + calendar.getTime();
- + SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- + confirmOrderData.setTimeExpiration(formatter.format(calendar.getTimeInMillis()));
- + ConfirmOrderDialog confirmOrderDialog = new ConfirmOrderDialog(getActivity(), confirmOrderData);
- + confirmOrderDialog.setListener(this);
- + confirmOrderDialog.show();
- + break;
- + case R.id.restButton:
- + resetInputInfo();
- + break;
- + }
- + }*/
- +
- + /* public void resetInputInfo() {
- + qEditText.setText("");
- + pEditText.setText("");
- + tEditText.setText("");
- + fEditText.setText("");
- +
- + isInitPriceValue = false;
- + initPriceValue();
- + }*/
- +
- + /* @Override
- + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- +
- + }
- +
- + @Override
- + public void onTextChanged(CharSequence s, int start, int before, int count) {
- +
- + }
- +
- + @Override
- + public void afterTextChanged(Editable s) {
- + String qString = qEditText.getText().toString();
- + String pString = pEditText.getText().toString();
- + if (TextUtils.isEmpty(qString) || TextUtils.isEmpty(pString)) {
- + return;
- + }
- +
- + double qValue = NumericUtil.parseDouble(qString, -1.0D);
- + double pValue = NumericUtil.parseDouble(pString, -1.0D);
- + double total = qValue * pValue;
- +
- + DecimalFormat decimalFormat = new DecimalFormat("#.########");
- + tEditText.setText(decimalFormat.format(total));
- +
- + if (isBuy()) {
- + double fee = calculateBuyFee(quoteAssetObj, baseAssetObj, pValue, qValue);
- + fEditText.setText(decimalFormat.format(fee));
- + } else {
- + double fee = calculateSellFee(quoteAssetObj, baseAssetObj, pValue, qValue);
- + fEditText.setText(decimalFormat.format(fee));
- + }
- + }*/
- +
- + /* @Override
- + public void onConfirm() {
- + String qString = qEditText.getText().toString();
- + String pString = pEditText.getText().toString();
- + if (qString.equals("") || pString.equals("")) {
- + return;
- + }
- +
- + final double qValue;
- + final double pValue;
- + try {
- + qValue = Double.parseDouble(qString);
- + pValue = Double.parseDouble(pString);
- + } catch (Exception e) {
- + e.printStackTrace();
- + return;
- + }
- +
- + if (qValue <= 0 || pValue <= 0) {
- + return;
- + }
- +
- + if (!BitsharesWalletWraper.getInstance().is_locked()) {
- + if (transactionType == TRANSACTION_BUY) {
- + buy(pValue, qValue, buyTimeSec);
- + } else if (transactionType == TRANSACTION_SELL) {
- + sell(pValue, qValue, buyTimeSec);
- + }
- + } else {
- + TransactionSellBuyPasswordDialog builder = new TransactionSellBuyPasswordDialog(getActivity());
- + builder.setListener(new TransactionSellBuyPasswordDialog.OnDialogInterationListener() {
- + @Override
- + public void onConfirm(AlertDialog dialog, String passwordString) {
- + if (BitsharesWalletWraper.getInstance().unlock(passwordString) == 0) {
- + dialog.dismiss();
- + if (transactionType == TRANSACTION_BUY) {
- + buy(pValue, qValue, buyTimeSec);
- + } else if (transactionType == TRANSACTION_SELL) {
- + sell(pValue, qValue, buyTimeSec);
- + }
- + } else {
- + Toast.makeText(getContext(), getContext().getString(R.string.password_invalid), Toast.LENGTH_LONG).show();
- + }
- + }
- +
- + @Override
- + public void onReject(AlertDialog dialog) {
- + dialog.dismiss();
- + }
- + });
- + builder.show();
- + }
- + }
- +
- + @Override
- + public void onReject() {
- +
- + }*/
- +
- + /* private void initFee() {
- + isAssetObjIsInit = false;
- + new Thread(new Runnable() {
- + @Override
- + public void run() {
- + try {
- + btsAssetObj = BitsharesWalletWraper.getInstance().lookup_asset_symbols("BTS");
- + baseAssetObj = BitsharesWalletWraper.getInstance().lookup_asset_symbols(baseAsset);
- + quoteAssetObj = BitsharesWalletWraper.getInstance().lookup_asset_symbols(quoteAsset);
- + globalPropertyObject = BitsharesWalletWraper.getInstance().get_global_properties();
- + getActivity().runOnUiThread(new Runnable() {
- + @Override
- + public void run() {
- + isAssetObjIsInit = true;
- + }
- + });
- + } catch (Exception e) {
- + e.printStackTrace();
- + }
- + }
- + }).start();
- + }*/
- +
- + /* private void buy(final double rate, final double amount, final int timeSec) {
- + mProcessHud.show();
- + new Thread(new Runnable() {
- + @Override
- + public void run() {
- + try {
- + BitsharesWalletWraper.getInstance().buy(quoteAsset, baseAsset, rate, amount, timeSec);
- + getActivity().runOnUiThread(new Runnable() {
- + @Override
- + public void run() {
- + mProcessHud.dismiss();
- + }
- + });
- + } catch (Exception e) {
- + getActivity().runOnUiThread(new Runnable() {
- + @Override
- + public void run() {
- + mProcessHud.dismiss();
- + }
- + });
- + e.printStackTrace();
- + }
- + }
- + }).start();
- + }
- +
- + private void sell(final double rate, final double amount, final int timeSec) {
- + mProcessHud.show();
- + new Thread(new Runnable() {
- + @Override
- + public void run() {
- + try {
- + BitsharesWalletWraper.getInstance().sell(quoteAsset, baseAsset, rate, amount, timeSec);
- + getActivity().runOnUiThread(new Runnable() {
- + @Override
- + public void run() {
- + mProcessHud.dismiss();
- + }
- + });
- + } catch (Exception e) {
- + getActivity().runOnUiThread(new Runnable() {
- + @Override
- + public void run() {
- + mProcessHud.dismiss();
- + }
- + });
- + e.printStackTrace();
- + }
- + }
- + }).start();
- + }*/
- +
- + private void updateMaxOrderCount(){
- + int orderItemHeightDp = DensityUtil.dpToPx(getContext(), TransactionSellBuyRecyclerViewAdapter.ORDERITEMHEIGHTDP);
- + int buyRecyclerHeight = buyRecyclerView.getHeight();
- +
- + maxOrderCount = buyRecyclerHeight / orderItemHeightDp;
- + if (maxOrderCount <= 0) {
- + maxOrderCount = 8;
- + }
- + }
- +
- + private void updateCurency(){
- + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
- + String strAssetPair = prefs.getString("quotation_currency_pair", "BTS:USD");
- + String strAsset[] = strAssetPair.split(":");
- + baseAsset = strAsset[1];
- + quoteAsset = strAsset[0];
- +
- + String baseAssetDisplay = utils.getAssetSymbolDisply(baseAsset);
- + String quoteAssetDisplay = utils.getAssetSymbolDisply(quoteAsset);
- + /*pTextLastView.setText(baseAssetDisplay + "/" + quoteAssetDisplay);
- + qTextLastView.setText(quoteAssetDisplay);
- + tTextLastView.setText(baseAssetDisplay);
- + if (isBuy()) {
- + balanceTextBase.setText(baseAssetDisplay);
- + askTextBase.setText(baseAssetDisplay);
- + askTextInfo.setText(getString(R.string.label_lowest_ask));
- + } else {
- + balanceTextBase.setText(quoteAssetDisplay);
- + askTextBase.setText(quoteAssetDisplay);
- + askTextInfo.setText(getString(R.string.label_highest_bid));
- + }*/
- + }
- +
- + /* private boolean isBuy(){
- + return transactionType == TRANSACTION_BUY;
- + }*/
- +
- +/* private double calculateSellFee(asset_object symbolToSell, asset_object symbolToReceive, double rate,
- + double amount) {
- + if (!isAssetObjIsInit) {
- + return 0;
- + }
- + asset a = BitsharesWalletWraper.getInstance().calculate_sell_fee(symbolToSell, symbolToReceive,
- + rate, amount, globalPropertyObject);
- + if (a.asset_id.equals(btsAssetObj.id)) {
- + return utils.get_asset_amount(a.amount, btsAssetObj);
- + } else if (a.asset_id.equals(baseAssetObj.id)) {
- + return utils.get_asset_amount(a.amount, baseAssetObj);
- + } else {
- + return utils.get_asset_amount(a.amount, quoteAssetObj);
- + }
- + }
- +
- + private double calculateBuyFee(asset_object symbolToReceive, asset_object symbolToSell, double rate,
- + double amount) {
- + if (!isAssetObjIsInit) {
- + return 0;
- + }
- + asset a = BitsharesWalletWraper.getInstance().calculate_buy_fee(symbolToReceive, symbolToSell,
- + rate, amount, globalPropertyObject);
- + if (a.asset_id.equals(btsAssetObj.id)) {
- + return utils.get_asset_amount(a.amount, btsAssetObj);
- + } else if (a.asset_id.equals(baseAssetObj.id)) {
- + return utils.get_asset_amount(a.amount, baseAssetObj);
- + } else {
- + return utils.get_asset_amount(a.amount, quoteAssetObj);
- + }
- + }*/
- +}
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/QuotationFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TradingScheduleFragment.java
- similarity index 73%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/QuotationFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TradingScheduleFragment.java
- index 2bac1dd..7264030 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/QuotationFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TradingScheduleFragment.java
- @@ -1,21 +1,28 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.trading;
- import android.arch.lifecycle.ViewModelProviders;
- import android.content.Context;
- +import android.content.res.Resources;
- import android.graphics.Color;
- import android.graphics.Paint;
- +import android.net.Uri;
- import android.os.Bundle;
- import android.support.v4.content.ContextCompat;
- -import android.support.v7.widget.LinearLayoutManager;
- -import android.support.v7.widget.RecyclerView;
- -import android.util.Pair;
- +import android.support.v4.view.ViewPager;
- import android.view.LayoutInflater;
- +import android.view.Menu;
- +import android.view.MenuInflater;
- +import android.view.MenuItem;
- import android.view.View;
- import android.view.ViewGroup;
- +import android.widget.RadioGroup;
- import android.widget.TextView;
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.BtsFragmentPageAdapter;
- +import com.bitshares.bitshareswallet.MainActivity;
- +
- import com.bitshares.bitshareswallet.data.HistoryPrice;
- -import com.bitshares.bitshareswallet.market.MarketTicker;
- import com.bitshares.bitshareswallet.viewmodel.QuotationViewModel;
- import com.github.mikephil.charting.charts.CombinedChart;
- import com.github.mikephil.charting.components.AxisBase;
- @@ -33,6 +40,10 @@ import com.github.mikephil.charting.data.Entry;
- import com.github.mikephil.charting.formatter.IAxisValueFormatter;
- import com.github.mikephil.charting.highlight.Highlight;
- import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
- +import com.ngse.ui.NewMainActivity;
- +import com.ngse.ui.main.balanceitems.OpenOrdersFragment;
- +
- +import org.evrazcoin.evrazwallet.R;
- import java.text.DecimalFormat;
- import java.text.SimpleDateFormat;
- @@ -44,17 +55,28 @@ import java.util.Locale;
- import butterknife.BindView;
- import butterknife.ButterKnife;
- -public class QuotationFragment extends BaseFragment {
- - private static final String TAG = "QuotationFragment";
- - private QuotationCurrencyPairAdapter quotationCurrencyPairAdapter;
- - private OnFragmentInteractionListener mListener;
- +public class TradingScheduleFragment extends BaseFragment {
- + public static final String TAG = TradingScheduleFragment.class.getName();
- - @BindView(R.id.chart) CombinedChart mChart;
- - @BindView(R.id.recyclerView) RecyclerView mRecyclerView;
- - @BindView(R.id.layoutChartLoading) View mLoadingChartView;
- - @BindView(R.id.layoutLoadingError) View mLoadingErrorView;
- - @BindView(R.id.layoutSelected) View mviewLayoutSelected;
- +
- + private OnFragmentInteractionListener mListener;
- + private MenuItem backMenuItem;
- + private BtsFragmentPageAdapter mExchangeFragmentPageAdapter;
- +
- + @BindView(R.id.chart)
- + CombinedChart mChart;
- + @BindView(R.id.layoutChartLoading)
- + View mLoadingChartView;
- + @BindView(R.id.layoutLoadingError)
- + View mLoadingErrorView;
- + @BindView(R.id.layoutSelected)
- + View mviewLayoutSelected;
- +
- + @BindView(R.id.viewPager)
- + ViewPager mViewPager;
- + @BindView(R.id.viewPagerSwitcher)
- + RadioGroup viewPagerSwitcher;
- private static final int SHOW_CHART_VIEW_NO_DATA = 0;
- private static final int SHOW_CHART_VIEW_LODING = 1;
- @@ -62,45 +84,105 @@ public class QuotationFragment extends BaseFragment {
- private static final int SHOW_CHART_VIEW_READY = 3;
- private static final int SHOW_CHART_VIEW_NOT_SUPPORT = 4;
- - public QuotationFragment() {
- + public TradingScheduleFragment() {
- + // Required empty public constructor
- + }
- + @Override
- + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- + super.onCreateOptionsMenu(menu, inflater);
- + backMenuItem = menu.add(R.string.back)
- + .setIcon(R.drawable.abc_ic_ab_back_material)
- + .setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
- }
- @Override
- - public void onAttach(Context context) {
- - super.onAttach(context);
- + public boolean onOptionsItemSelected(MenuItem item) {
- + if (item == backMenuItem)
- + getActivity().onBackPressed();
- + return super.onOptionsItemSelected(item);
- + }
- - if (context instanceof OnFragmentInteractionListener) {
- - mListener = (OnFragmentInteractionListener) context;
- - } else {
- - throw new RuntimeException(context.toString()
- - + " must implement OnFragmentInteractionListener");
- + public static TradingScheduleFragment newInstance() {
- + return new TradingScheduleFragment();
- }
- +
- +
- + @Override
- + public void onResume() {
- + super.onResume();
- + onShow();
- + ((NewMainActivity) getActivity()).setTitleVisible(true);
- +
- }
- @Override
- - public void onCreate(Bundle savedInstanceState) {
- - super.onCreate(savedInstanceState);
- + public void onDestroyView() {
- + ((NewMainActivity) getActivity()).setTitleVisible(false);
- + super.onDestroyView();
- }
- - public static QuotationFragment newInstance() {
- - QuotationFragment fragment = new QuotationFragment();
- - return fragment;
- + @Override
- + public void onShow() {
- + super.onShow();
- + QuotationViewModel viewModel = ViewModelProviders.of(getActivity()).get(QuotationViewModel.class);
- + viewModel.getHistoryPrice().observe(this, historyPriceListResource -> {
- + switch (historyPriceListResource.status) {
- + case ERROR:
- + changeShowedView(SHOW_CHART_VIEW_LODING_FAIL);
- + break;
- + case LOADING:
- + changeShowedView(SHOW_CHART_VIEW_LODING);
- + break;
- + case SUCCESS:
- + changeShowedView(SHOW_CHART_VIEW_READY);
- + updateChartData(historyPriceListResource.data);
- + break;
- + }
- + });
- +
- }
- + @Override
- + public void onHide() {
- + super.onHide();
- + }
- +
- +
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- - View view = inflater.inflate(R.layout.fragment_quotation, container, false);
- + View view = inflater.inflate(R.layout.new_fragment_trading_schedule, container, false);
- ButterKnife.bind(this, view);
- -
- - quotationCurrencyPairAdapter = new QuotationCurrencyPairAdapter(getActivity());
- - LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
- - linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
- - mRecyclerView.setLayoutManager(linearLayoutManager);
- - mRecyclerView.setAdapter(quotationCurrencyPairAdapter);
- - mRecyclerView.setItemAnimator(null);
- -
- + Resources res = getResources();
- + mExchangeFragmentPageAdapter = new BtsFragmentPageAdapter(getFragmentManager());
- + mExchangeFragmentPageAdapter.addFragment(TransactionSellBuyFragment.newInstance(TransactionSellBuyFragment.TRANSACTION_BUY), "");
- + mExchangeFragmentPageAdapter.addFragment(TransactionSellBuyFragment.newInstance(TransactionSellBuyFragment.TRANSACTION_SELL), "");
- + mExchangeFragmentPageAdapter.addFragment(TradingOrdersFragment.newInstance(),"");
- + mExchangeFragmentPageAdapter.addFragment(OpenOrdersFragment.newInstance(), "");
- +// mWalletFragmentPageAdapter.addFragment(TransactionsFragment.newInstance("", ""), res.getString(R.string.tab_transactions));
- +
- +
- + mViewPager.setAdapter(mExchangeFragmentPageAdapter);
- + initPager(mViewPager, mExchangeFragmentPageAdapter);
- + viewPagerSwitcher.setOnCheckedChangeListener((group, checkedId) -> {
- + switch (checkedId) {
- + case R.id.buyButton:
- + mViewPager.setCurrentItem(0);
- + break;
- + case R.id.sellButton:
- + mViewPager.setCurrentItem(1);
- + break;
- + case R.id.ordersButton:
- + mViewPager.setCurrentItem(2);
- + break;
- + case R.id.myOrdersButton:
- + mViewPager.setCurrentItem(3);
- + break;
- + }
- + });
- + viewPagerSwitcher.check(R.id.buyButton);
- + /////////////////////
- initChart();
- mChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
- @@ -170,18 +252,6 @@ public class QuotationFragment extends BaseFragment {
- }
- });
- - QuotationViewModel viewModel = ViewModelProviders.of(getActivity()).get(QuotationViewModel.class);
- - quotationCurrencyPairAdapter.setOnItemClickListenr(new QuotationCurrencyPairAdapter.OnItemClickListner() {
- - @Override
- - public void onItemClick(View view, int position) {
- - //mListener.notifyCurrencyPairChange();
- - if (quotationCurrencyPairAdapter.getSelectedMarketTicker() != null) {
- - MarketTicker marketTicker = quotationCurrencyPairAdapter.getSelectedMarketTicker().marketTicker;
- - viewModel.selectedMarketTicker(new Pair(marketTicker.base, marketTicker.quote));
- - }
- -
- - }
- - });
- return view;
- }
- @@ -228,52 +298,43 @@ public class QuotationFragment extends BaseFragment {
- rightAxis.setAxisMinimum(0);
- }
- - @Override
- - public void onShow() {
- - super.onShow();
- -
- - QuotationViewModel viewModel = ViewModelProviders.of(getActivity()).get(QuotationViewModel.class);
- - viewModel.getMarketTicker().observe(
- - this,
- - marketTickerListResource -> {
- - switch (marketTickerListResource.status) {
- - case ERROR:
- - break;
- - case LOADING:
- - if (marketTickerListResource.data != null && marketTickerListResource.data.size() != 0) {
- - quotationCurrencyPairAdapter.notifyDataUpdated(marketTickerListResource.data);
- - MarketTicker marketTicker = quotationCurrencyPairAdapter.getSelectedMarketTicker().marketTicker;
- - viewModel.selectedMarketTicker(new Pair(marketTicker.base, marketTicker.quote));
- + // TODO: Rename method, update argument and hook method into UI event
- + public void onButtonPressed(Uri uri) {
- + if (mListener != null) {
- + mListener.onFragmentInteraction(uri);
- }
- - break;
- - case SUCCESS:
- - quotationCurrencyPairAdapter.notifyDataUpdated(marketTickerListResource.data);
- - MarketTicker marketTicker = quotationCurrencyPairAdapter.getSelectedMarketTicker().marketTicker;
- - viewModel.selectedMarketTicker(new Pair(marketTicker.base, marketTicker.quote));
- - break;
- }
- - });
- - viewModel.getHistoryPrice().observe(this, historyPriceListResource -> {
- - switch (historyPriceListResource.status) {
- - case ERROR:
- - changeShowedView(SHOW_CHART_VIEW_LODING_FAIL);
- - break;
- - case LOADING:
- - changeShowedView(SHOW_CHART_VIEW_LODING);
- - break;
- - case SUCCESS:
- - changeShowedView(SHOW_CHART_VIEW_READY);
- - updateChartData(historyPriceListResource.data);
- - break;
- + @Override
- + public void onAttach(Context context) {
- + super.onAttach(context);
- + if (context instanceof OnFragmentInteractionListener) {
- + mListener = (OnFragmentInteractionListener) context;
- + } else {
- +// throw new RuntimeException(context.toString()
- +// + " must implement OnFragmentInteractionListener");
- }
- - });
- - viewModel.getSelectedMarketTicker().observe(this, currencyPair -> quotationCurrencyPairAdapter.notifyDataSetChanged() );
- }
- @Override
- - public void onHide() {
- - super.onHide();
- + public void onDetach() {
- + super.onDetach();
- + mListener = null;
- + }
- +
- + /**
- + * This interface must be implemented by activities that contain this
- + * fragment to allow an interaction in this fragment to be communicated
- + * to the activity and potentially other fragments contained in that
- + * activity.
- + * <p>
- + * See the Android Training lesson <a href=
- + * "http://developer.android.com/training/basics/fragments/communicating.html"
- + * >Communicating with Other Fragments</a> for more information.
- + */
- + public interface OnFragmentInteractionListener {
- + // TODO: Update argument type and name
- + void onFragmentInteraction(Uri uri);
- }
- private void updateChartData(List<HistoryPrice> historyPriceList) {
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TransactionSellBuyFragment.java
- similarity index 95%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TransactionSellBuyFragment.java
- index 1ed8c02..c4c7c76 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyFragment.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TransactionSellBuyFragment.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.trading;
- import android.arch.lifecycle.ViewModelProviders;
- import android.content.BroadcastReceiver;
- @@ -24,6 +24,11 @@ import android.widget.EditText;
- import android.widget.TextView;
- import android.widget.Toast;
- +import com.bitshares.bitshareswallet.BaseFragment;
- +import com.bitshares.bitshareswallet.ConfirmOrderDialog;
- +import com.bitshares.bitshareswallet.DensityUtil;
- +import com.bitshares.bitshareswallet.TransactionSellBuyPasswordDialog;
- +import com.bitshares.bitshareswallet.TransactionSellBuyRecyclerViewAdapter;
- import com.bitshares.bitshareswallet.market.MarketStat;
- import com.bitshares.bitshareswallet.room.BitsharesAsset;
- import com.bitshares.bitshareswallet.viewmodel.SellBuyViewModel;
- @@ -37,6 +42,8 @@ import com.bituniverse.network.Status;
- import com.bituniverse.utils.NumericUtil;
- import com.kaopiz.kprogresshud.KProgressHUD;
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.text.DecimalFormat;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- @@ -53,12 +60,12 @@ public class TransactionSellBuyFragment extends BaseFragment
- private static final String TRANSACTION_TYPE = "transaction_type";
- private static int buyTimeSec = 5 * 365 * 24 * 60 * 60;
- -
- +/*
- private TransactionSellBuyRecyclerViewAdapter buyRecyclerViewAdapter;
- private TransactionSellBuyRecyclerViewAdapter sellRecyclerViewAdapter;
- private RecyclerView buyRecyclerView;
- private RecyclerView sellRecyclerView;
- - private int maxOrderCount = 10;
- + private int maxOrderCount = 10;*/
- public static final int TRANSACTION_BUY = 1;
- public static final int TRANSACTION_SELL = 2;
- @@ -125,8 +132,8 @@ public class TransactionSellBuyFragment extends BaseFragment
- }
- if (stat.orderBook.bids != null && !stat.orderBook.bids.isEmpty()) {
- - int maxCount = Math.min(stat.orderBook.bids.size(), maxOrderCount);
- - buyRecyclerViewAdapter.setList(stat.orderBook.bids.subList(0, maxCount));
- + /* int maxCount = Math.min(stat.orderBook.bids.size(), maxOrderCount);
- + buyRecyclerViewAdapter.setList(stat.orderBook.bids.subList(0, maxCount));*/
- higgestBuyPrice = stat.orderBook.bids.get(0).price;
- } else {
- @@ -134,8 +141,8 @@ public class TransactionSellBuyFragment extends BaseFragment
- }
- if (stat.orderBook.asks != null && !stat.orderBook.asks.isEmpty()) {
- - int maxCount = Math.min(stat.orderBook.asks.size(), maxOrderCount);
- - sellRecyclerViewAdapter.setList(stat.orderBook.asks.subList(0, maxCount));
- + /* int maxCount = Math.min(stat.orderBook.asks.size(), maxOrderCount);
- + sellRecyclerViewAdapter.setList(stat.orderBook.asks.subList(0, maxCount));*/
- lowestSellPrice = stat.orderBook.asks.get(0).price;
- } else {
- @@ -150,9 +157,9 @@ public class TransactionSellBuyFragment extends BaseFragment
- if (!isInitPriceValue) {
- isInitPriceValue = true;
- if (transactionType == TRANSACTION_BUY && lowestSellPrice != -1) {
- - pEditText.setText(decimalFormat.format(lowestSellPrice));
- + pEditText.setText(decimalFormat.format(lowestSellPrice).replace(",", "."));
- } else if (transactionType == TRANSACTION_SELL && higgestBuyPrice != -1) {
- - pEditText.setText(decimalFormat.format(higgestBuyPrice));
- + pEditText.setText(decimalFormat.format(higgestBuyPrice).replace(",", "."));
- }
- }
- @@ -171,12 +178,18 @@ public class TransactionSellBuyFragment extends BaseFragment
- }
- }
- + @Override
- + public void onResume() {
- + super.onResume();
- + onShow();
- + }
- +
- @Override
- public void onShow() {
- super.onShow();
- updateCurency();
- initFee();
- - updateMaxOrderCount();
- +// updateMaxOrderCount();
- orderStat.subscribe(baseAsset, quoteAsset, MarketStat.STAT_MARKET_ORDER_BOOK,
- MARKET_STAT_INTERVAL_MILLIS, this);
- @@ -215,7 +228,7 @@ public class TransactionSellBuyFragment extends BaseFragment
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- - View view = inflater.inflate(R.layout.fragment_buy_sell, container, false);
- + View view = inflater.inflate(R.layout.new_fragment_buy_sell, container, false);
- Button okButton = (Button) view.findViewById(R.id.okButton);
- okButton.setOnClickListener(this);
- @@ -252,6 +265,7 @@ public class TransactionSellBuyFragment extends BaseFragment
- balanceTextBase = (TextView) view.findViewById(R.id.balanceTextBase);
- askTextBase = (TextView) view.findViewById(R.id.askTextBase);
- askTextInfo = (TextView) view.findViewById(R.id.askTextInfo);
- +/*
- buyRecyclerView = (RecyclerView) view.findViewById(R.id.buy_recycler);
- buyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- @@ -264,6 +278,7 @@ public class TransactionSellBuyFragment extends BaseFragment
- sellRecyclerView.setAdapter(sellRecyclerViewAdapter);
- sellRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
- sellRecyclerView.setItemAnimator(null);
- +*/
- return view;
- }
- @@ -519,7 +534,7 @@ public class TransactionSellBuyFragment extends BaseFragment
- }).start();
- }
- - private void updateMaxOrderCount(){
- + /*private void updateMaxOrderCount(){
- int orderItemHeightDp = DensityUtil.dpToPx(getContext(), TransactionSellBuyRecyclerViewAdapter.ORDERITEMHEIGHTDP);
- int buyRecyclerHeight = buyRecyclerView.getHeight();
- @@ -527,7 +542,7 @@ public class TransactionSellBuyFragment extends BaseFragment
- if (maxOrderCount <= 0) {
- maxOrderCount = 8;
- }
- - }
- + }*/
- private void updateCurency() {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
- diff --git a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyRecyclerViewAdapter.java b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TransactionSellBuyRecyclerViewAdapter.java
- similarity index 92%
- rename from bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyRecyclerViewAdapter.java
- rename to evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TransactionSellBuyRecyclerViewAdapter.java
- index b727bb9..b2f97fd 100644
- --- a/bitshares_andriod_wallet/app/src/main/java/com/bitshares/bitshareswallet/TransactionSellBuyRecyclerViewAdapter.java
- +++ b/evraz-wallet/app/src/main/java/com/ngse/ui/main/trading/TransactionSellBuyRecyclerViewAdapter.java
- @@ -1,4 +1,4 @@
- -package com.bitshares.bitshareswallet;
- +package com.ngse.ui.main.trading;
- import android.support.v7.widget.RecyclerView;
- import android.view.LayoutInflater;
- @@ -8,7 +8,8 @@ import android.widget.TextView;
- import com.bitshares.bitshareswallet.market.Order;
- -import java.text.DecimalFormat;
- +import org.evrazcoin.evrazwallet.R;
- +
- import java.util.List;
- public class TransactionSellBuyRecyclerViewAdapter extends RecyclerView.Adapter<TransactionSellBuyRecyclerViewAdapter.ViewHolder> {
- @@ -30,7 +31,7 @@ public class TransactionSellBuyRecyclerViewAdapter extends RecyclerView.Adapter<
- @Override
- public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
- View view = LayoutInflater.from(parent.getContext())
- - .inflate(R.layout.view_order_item, parent, false);
- + .inflate(R.layout.new_view_order_item, parent, false);
- return new ViewHolder(view);
- }
- diff --git a/evraz-wallet/app/src/main/java/com/ngse/utility/DebugUtility.java b/evraz-wallet/app/src/main/java/com/ngse/utility/DebugUtility.java
- new file mode 100644
- index 0000000..40287f5
- --- /dev/null
- +++ b/evraz-wallet/app/src/main/java/com/ngse/utility/DebugUtility.java
- @@ -0,0 +1,118 @@
- +package com.ngse.utility;
- +
- +import android.content.Context;
- +import android.content.ContextWrapper;
- +import android.os.Environment;
- +import android.util.Log;
- +
- +import java.io.BufferedWriter;
- +import java.io.File;
- +import java.io.FileWriter;
- +import java.io.IOException;
- +import java.text.SimpleDateFormat;
- +import java.util.Calendar;
- +import java.util.Locale;
- +
- +/**
- + * Created by Kulykov Anton on 26.07.2018
- + */
- +
- +public class DebugUtility {
- + private static final boolean DEBUG = true;
- + private static final boolean DEBUG_FILE = false;
- + private static final String PRE_TAG = "TEST";
- + private static final String API_TAG = "API";
- + private static final String LOG_FOLDER = "logs";
- + public static SimpleDateFormat dateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
- + private static Object syncObject;
- +
- +
- + public static void logTest(String tag, String msg) {
- + tag = PRE_TAG + " " + tag;
- + Log.e(tag, msg);
- + }
- +
- + public static void logApi(String tag, String msg) {
- + tag = API_TAG + " " + tag;
- + if (msg == null)
- + msg = "";
- + Log.e(tag, msg);
- + }
- +
- + public static void logE(Context context, String tag, String msg) {
- + tag = PRE_TAG + " " + tag;
- + if (DEBUG_FILE) {
- + logToFile(context, tag, msg);
- + }
- + if (!DEBUG) {
- + return;
- + }
- + Log.e(tag, msg);
- + }
- +
- + private static void logToFile(Context context, String tag, String msg) {
- + if (context == null) {
- + return;
- + }
- + synchronized (getSyncObject()) {
- + String path = getTempPath(context, LOG_FOLDER);
- + if (!isSDCardEnabled(context, LOG_FOLDER)) {
- + return;
- + }
- + File logFile = new File(path + File.separator + "logNEW.txt");
- + if (!logFile.exists()) {
- + try {
- + logFile.createNewFile();
- + } catch (Exception e) {
- + e.printStackTrace();
- + }
- + }
- + try {
- + // BufferedWriter for performance, true to set append to file flag
- + BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
- + buf.append(dateTimeFormatter.format(Calendar.getInstance().getTime()) + " " + tag + " " + msg);
- + buf.newLine();
- + buf.close();
- + } catch (IOException e) {
- + e.printStackTrace();
- + }
- + }
- + }
- +
- + private static Object getSyncObject() {
- + if (syncObject == null)
- + syncObject = new Object();
- + return syncObject;
- + }
- +
- + public static String getTempPath(Context context, String folder) {
- + String path = getRootFolder(context) +
- + folder;
- +
- + return path;
- + }
- +
- + public static String getRootFolder(Context context) {
- + String packageNameString = context != null ? context.getApplicationContext().getPackageName() : "com.NGSE.Temp";
- + return getRootFolderWithoutPackage(context) + packageNameString + File.separator;
- + }
- +
- + public static String getRootFolderWithoutPackage(Context context) {
- + String state = Environment.getExternalStorageState();
- + boolean isTempStorageAccessibile = Environment.MEDIA_MOUNTED.equals(state);
- +
- + if (isTempStorageAccessibile || context == null) {
- + return Environment.getExternalStorageDirectory().getAbsolutePath() + "/Android/data/";
- + } else {
- + ContextWrapper cw = new ContextWrapper(context);
- + File directory = cw.getDir("media", Context.MODE_PRIVATE);
- + return directory.getAbsolutePath();
- + }
- + }
- +
- + public static boolean isSDCardEnabled(Context context, String folder) {
- + File tempFile = new File(getTempPath(context, folder));
- + tempFile.mkdirs();
- + return tempFile.canWrite();
- + }
- +}
- \ No newline at end of file
Add Comment
Please, Sign In to add comment