Fix compatibility issues for 19-23 SDK

This commit is contained in:
Tanguy Herbron 2018-08-04 03:35:35 +02:00
parent cf8cc29329
commit ae3ab48c58
9 changed files with 91 additions and 88 deletions

View File

@ -87,7 +87,7 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
lineChartButton = view.findViewById(R.id.lineChartButton);
candleStickChartButton = view.findViewById(R.id.candleStickChartButton);
barChart = view.findViewById(R.id.chartVolumeView);
preferencesManager = new PreferencesManager(getContext());
preferencesManager = new PreferencesManager(getActivity().getBaseContext());
displayLineChart = true;
@ -129,7 +129,7 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
{
timeIntervalSpinner = view.findViewById(R.id.timeIntervalSinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getContext(),
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(getActivity().getBaseContext(),
R.array.time_interval_string_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@ -160,31 +160,31 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
switch (index)
{
case 0:
currency.updateHistoryMinutes(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryMinutes(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 1:
currency.updateHistoryMinutes(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryMinutes(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 2:
currency.updateHistoryMinutes(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryMinutes(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 3:
currency.updateHistoryHours(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryHours(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 4:
currency.updateHistoryHours(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryHours(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 5:
currency.updateHistoryHours(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryHours(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 6:
currency.updateHistoryDays(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryDays(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 7:
currency.updateHistoryDays(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryDays(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
case 8:
currency.updateHistoryDays(getContext(), preferencesManager.getDefaultCurrency());
currency.updateHistoryDays(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency());
break;
}
}
@ -252,8 +252,8 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
updateFluctuation(start, end);
((TextView) view.findViewById(R.id.txtViewPriceStart)).setText(PlaceholderManager.getValueString(numberConformer(start), getContext()));
((TextView) view.findViewById(R.id.txtViewPriceNow)).setText(PlaceholderManager.getValueString(numberConformer(end), getContext()));
((TextView) view.findViewById(R.id.txtViewPriceStart)).setText(PlaceholderManager.getValueString(numberConformer(start), getActivity().getBaseContext()));
((TextView) view.findViewById(R.id.txtViewPriceNow)).setText(PlaceholderManager.getValueString(numberConformer(end), getActivity().getBaseContext()));
for(int i = 1; i < dataChartList.size(); i++)
{
@ -270,9 +270,9 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
}
}
((TextView) view.findViewById(R.id.totalVolume)).setText(PlaceholderManager.getValueString(numberConformer(totalVolume), getContext()));
((TextView) view.findViewById(R.id.highestPrice)).setText(PlaceholderManager.getValueString(numberConformer(highestPrice), getContext()));
((TextView) view.findViewById(R.id.lowestPrice)).setText(PlaceholderManager.getValueString(numberConformer(lowestPrice), getContext()));
((TextView) view.findViewById(R.id.totalVolume)).setText(PlaceholderManager.getValueString(numberConformer(totalVolume), getActivity().getBaseContext()));
((TextView) view.findViewById(R.id.highestPrice)).setText(PlaceholderManager.getValueString(numberConformer(highestPrice), getActivity().getBaseContext()));
((TextView) view.findViewById(R.id.lowestPrice)).setText(PlaceholderManager.getValueString(numberConformer(lowestPrice), getActivity().getBaseContext()));
}
private void updateFluctuation(float start, float end)
@ -457,9 +457,9 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
date = getDateFromTimestamp(dataChartList.get(index).getTimestamp() * 1000);
}
volumePlaceholder = PlaceholderManager.getVolumeString(numberConformer(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getY()), getContext());
pricePlaceholder = PlaceholderManager.getPriceString(numberConformer((lineChart.getHighlighted())[0].getY()), getContext());
timestampPlaceholder = PlaceholderManager.getTimestampString(date, getContext());
volumePlaceholder = PlaceholderManager.getVolumeString(numberConformer(barChart.getData().getDataSets().get(0).getEntryForIndex(index).getY()), getActivity().getBaseContext());
pricePlaceholder = PlaceholderManager.getPriceString(numberConformer((lineChart.getHighlighted())[0].getY()), getActivity().getBaseContext());
timestampPlaceholder = PlaceholderManager.getTimestampString(date, getActivity().getBaseContext());
((TextView) view.findViewById(R.id.volumeHightlight)).setText(volumePlaceholder);
view.findViewById(R.id.volumeHightlight).setVisibility(View.VISIBLE);
@ -545,14 +545,14 @@ public class Charts extends Fragment implements CurrencyInfoUpdateNotifierInterf
dataSet = new CandleDataSet(values, "");
dataSet.setDrawIcons(false);
dataSet.setDrawValues(false);
dataSet.setDecreasingColor(MoodlBox.getColor(R.color.decreaseCandle, getContext()));
dataSet.setDecreasingColor(MoodlBox.getColor(R.color.decreaseCandle, getActivity().getBaseContext()));
dataSet.setShowCandleBar(true);
dataSet.setShadowColorSameAsCandle(true);
dataSet.setDecreasingPaintStyle(Paint.Style.FILL);
dataSet.setIncreasingColor(MoodlBox.getColor(R.color.increaseCandle, getContext()));
dataSet.setIncreasingColor(MoodlBox.getColor(R.color.increaseCandle, getActivity().getBaseContext()));
dataSet.setIncreasingPaintStyle(Paint.Style.STROKE);
dataSet.setNeutralColor(MoodlBox.getColor(R.color.increaseCandle, getContext()));
dataSet.setHighLightColor(MoodlBox.getColor(R.color.colorAccent, getContext()));
dataSet.setNeutralColor(MoodlBox.getColor(R.color.increaseCandle, getActivity().getBaseContext()));
dataSet.setHighLightColor(MoodlBox.getColor(R.color.colorAccent, getActivity().getBaseContext()));
dataSet.setDrawHorizontalHighlightIndicator(false);
return new CandleData(dataSet);

View File

@ -44,7 +44,7 @@ public class Informations extends Fragment {
isTickerUpdated = false;
currency = getActivity().getIntent().getParcelableExtra("currency");
preferencesManager = new PreferencesManager(getContext());
preferencesManager = new PreferencesManager(getActivity().getBaseContext());
updateInfoTab();
@ -53,7 +53,7 @@ public class Informations extends Fragment {
private void updateInfoTab()
{
currency.updateSnapshot(getContext(), new Currency.CurrencyCallBack() {
currency.updateSnapshot(getActivity().getBaseContext(), new Currency.CurrencyCallBack() {
@Override
public void onSuccess(final Currency currency) {
isSnapshotUpdated = true;
@ -61,7 +61,7 @@ public class Informations extends Fragment {
}
});
currency.updateTicker(getContext(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
currency.updateTicker(getActivity().getBaseContext(), preferencesManager.getDefaultCurrency(), new Currency.CurrencyCallBack() {
@Override
public void onSuccess(Currency currency) {
isTickerUpdated = true;
@ -120,12 +120,12 @@ public class Informations extends Fragment {
((TextView) view.findViewById(R.id.txtViewDescription))
.setMovementMethod(LinkMovementMethod.getInstance());
((TextView) view.findViewById(R.id.txtViewPercentageCoinEmited))
.setText(PlaceholderManager.getEmitedPercentageString(numberConformer(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100), getContext()));
.setText(PlaceholderManager.getEmitedPercentageString(numberConformer(currency.getMinedCoinSupply() / currency.getMaxCoinSupply() * 100), getActivity().getBaseContext()));
if(currency.getMarketCapitalization() != 0)
{
((TextView) view.findViewById(R.id.txtViewMarketCapitalization))
.setText(PlaceholderManager.getValueString(numberConformer(currency.getMarketCapitalization()), getContext()));
.setText(PlaceholderManager.getValueString(numberConformer(currency.getMarketCapitalization()), getActivity().getBaseContext()));
view.findViewById(R.id.linearMarketCap).setVisibility(View.VISIBLE);
}

View File

@ -51,10 +51,10 @@ public class Transactions extends Fragment {
{
view = inflater.inflate(R.layout.fragment_transactions_detailsactivity, container, false);
PreferencesManager preferencesManager = new PreferencesManager(getContext());
PreferencesManager preferencesManager = new PreferencesManager(getActivity().getBaseContext());
currency = getActivity().getIntent().getParcelableExtra("currency");
databaseManager = new DatabaseManager(getContext());
databaseManager = new DatabaseManager(getActivity().getBaseContext());
//binanceManager = new BinanceManager(preferencesManager.getBinancePublicKey(), preferencesManager.getBinancePrivateKey());
tradeLayout = view.findViewById(R.id.listTrades);
transactionLayout = view.findViewById(R.id.listTransactions);
@ -72,7 +72,7 @@ public class Transactions extends Fragment {
private void loadingIndicatorGenerator()
{
loadingFooter = LayoutInflater.from(getContext()).inflate(R.layout.listview_loading_indicator, null, false);
loadingFooter = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.listview_loading_indicator, null, false);
Drawable drawable = ((ProgressBar) loadingFooter.findViewById(R.id.progressIndicator)).getIndeterminateDrawable();
drawable.mutate();
@ -108,7 +108,7 @@ public class Transactions extends Fragment {
});
}
tradeListAdapter = new TradeListAdapter(getContext(), trades);
tradeListAdapter = new TradeListAdapter(getActivity().getBaseContext(), trades);
tradeLayout.setAdapter(tradeListAdapter);
tradeLayout.setTextFilterEnabled(false);
@ -180,7 +180,7 @@ public class Transactions extends Fragment {
private void drawTransactionList(ArrayList<Transaction> transactions)
{
TransactionListAdapter transactionListAdapter = new TransactionListAdapter(getContext(), transactions);
TransactionListAdapter transactionListAdapter = new TransactionListAdapter(getActivity().getBaseContext(), transactions);
transactionLayout.setAdapter(transactionListAdapter);
transactionLayout.setTextFilterEnabled(false);

View File

@ -69,11 +69,11 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
{
view = inflater.inflate(R.layout.fragment_marketcap_homeactivity, container, false);
preferencesManager = new PreferencesManager(getContext());
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getContext());
preferencesManager = new PreferencesManager(getActivity().getBaseContext());
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getActivity().getBaseContext());
coinmarketCapAPIManager.addListener(this);
cryptocompareApiManager = CryptocompareApiManager.getInstance(getContext());
cryptocompareApiManager = CryptocompareApiManager.getInstance(getActivity().getBaseContext());
cryptocompareApiManager.addListener(this);
if(!cryptocompareApiManager.isDetailsUpToDate())
@ -258,13 +258,13 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
if(iconUrl != null)
{
MoodlBox.getBitmapFromURL(iconUrl, localCurrency.getSymbol(), getResources(), getContext(), new MoodlboxNotifierInterface() {
MoodlBox.getBitmapFromURL(iconUrl, localCurrency.getSymbol(), getResources(), getActivity().getBaseContext(), new MoodlboxNotifierInterface() {
@Override
public void onBitmapDownloaded(Bitmap bitmapIcon) {
Palette.Builder builder = Palette.from(bitmapIcon);
coinmarketCapAPIManager.getTopCurrencies().get(index).setIcon(bitmapIcon);
coinmarketCapAPIManager.getTopCurrencies().get(index).setChartColor(builder.generate().getDominantColor(getColor(R.color.default_color, getContext())));
coinmarketCapAPIManager.getTopCurrencies().get(index).setChartColor(builder.generate().getDominantColor(getColor(R.color.default_color, getActivity().getBaseContext())));
countIcons();
@ -387,13 +387,13 @@ public class MarketCapitalization extends Fragment implements CryptocompareNotif
private void updateDetails(double marketCap, double volume, String title, double percentage)
{
((TextView) view.findViewById(R.id.textViewMarketCap))
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(marketCap), getContext()));
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(marketCap), getActivity().getBaseContext()));
((TextView) view.findViewById(R.id.textViewVolume))
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(volume), getContext()));
.setText(PlaceholderManager.getValueString(MoodlBox.numberConformer(volume), getActivity().getBaseContext()));
((TextView) view.findViewById(R.id.textViewTitle))
.setText(title);
((TextView) view.findViewById(R.id.textViewDominancePercentage))
.setText(PlaceholderManager.getPercentageString(MoodlBox.numberConformer(percentage), getContext()));
.setText(PlaceholderManager.getPercentageString(MoodlBox.numberConformer(percentage), getActivity().getBaseContext()));
}
private SpannableString generateCenterSpannableText() {

View File

@ -54,14 +54,14 @@ public class Overview extends Fragment implements CoinmarketcapNotifierInterface
{
View fragmentView = inflater.inflate(R.layout.fragment_overview_homeactivity, container, false);
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getContext());
cryptocompareApiManager = CryptocompareApiManager.getInstance(getContext());
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getActivity().getBaseContext());
cryptocompareApiManager = CryptocompareApiManager.getInstance(getActivity().getBaseContext());
coinmarketCapAPIManager.addListener(this);
fragmentView.findViewById(R.id.toolbar).bringToFront();
preferenceManager = new PreferencesManager(getContext());
preferenceManager = new PreferencesManager(getActivity().getBaseContext());
listLayout = fragmentView.findViewById(R.id.linearLayoutOverview);
@ -137,7 +137,7 @@ public class Overview extends Fragment implements CoinmarketcapNotifierInterface
private void loadingIndicatorGenerator()
{
loadingFooter = LayoutInflater.from(getContext()).inflate(R.layout.listview_loading_indicator, null, false);
loadingFooter = LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.listview_loading_indicator, null, false);
listLayout.addFooterView(loadingFooter);
}
@ -192,7 +192,7 @@ public class Overview extends Fragment implements CoinmarketcapNotifierInterface
if(iconUrl != null)
{
MoodlBox.getBitmapFromURL(iconUrl, currency.getSymbol(), getResources(), getContext(), new MoodlboxNotifierInterface() {
MoodlBox.getBitmapFromURL(iconUrl, currency.getSymbol(), getResources(), getActivity().getBaseContext(), new MoodlboxNotifierInterface() {
@Override
public void onBitmapDownloaded(Bitmap bitmap) {
currency.setIcon(bitmap);
@ -203,7 +203,7 @@ public class Overview extends Fragment implements CoinmarketcapNotifierInterface
}
else
{
Drawable drawable = getDrawable(R.drawable.ic_panorama_fish_eye_24dp, getContext());
Drawable drawable = getDrawable(R.drawable.ic_panorama_fish_eye_24dp, getActivity().getBaseContext());
Bitmap icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
@ -233,7 +233,7 @@ public class Overview extends Fragment implements CoinmarketcapNotifierInterface
public void run() {
if(overviewListAdapter == null)
{
overviewListAdapter = new OverviewListAdapter(getContext(), currencyList, getActivity());
overviewListAdapter = new OverviewListAdapter(getActivity().getBaseContext(), currencyList, getActivity());
listLayout.setAdapter(overviewListAdapter);
listLayout.setTextFilterEnabled(false);

View File

@ -103,7 +103,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
View fragmentView = inflater.inflate(R.layout.fragment_summary_homeactivity, container, false);
preferencesManager = new PreferencesManager(getActivity());
balanceManager = new BalanceManager(getContext());
balanceManager = new BalanceManager(getActivity());
coinmarketCapAPIManager = CoinmarketCapAPIManager.getInstance(getActivity());
cryptocompareApiManager = CryptocompareApiManager.getInstance(getActivity());
@ -264,10 +264,10 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
Random random = new Random();
LinearLayout splashLayout = (LinearLayout) LayoutInflater.from(getContext()).inflate(R.layout.splash_screen, null, true);
LinearLayout splashLayout = (LinearLayout) LayoutInflater.from(getActivity().getBaseContext()).inflate(R.layout.splash_screen, null, true);
LinearLayout animatedLayout = splashLayout.findViewById(R.id.animatedViewsLayout);
File cacheDir = new File(getContext().getCacheDir().getAbsolutePath());
File cacheDir = new File(getActivity().getBaseContext().getCacheDir().getAbsolutePath());
File[] cacheFiles = cacheDir.listFiles();
if(cacheFiles.length > 4)
@ -287,7 +287,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(ContextCompat.getColor(getContext(), R.color.white));
paint.setColor(ContextCompat.getColor(getActivity().getBaseContext(), R.color.white));
Canvas canvas = new Canvas(result);
canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint);
@ -691,11 +691,11 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
{
Palette.Builder builder = Palette.from(currency.getIcon());
currency.setChartColor(builder.generate().getDominantColor(getColor(R.color.default_color, getContext())));
currency.setChartColor(builder.generate().getDominantColor(getColor(R.color.default_color, getActivity().getBaseContext())));
}
else
{
currency.setChartColor(getColor(R.color.default_color, getContext()));
currency.setChartColor(getColor(R.color.default_color, getActivity().getBaseContext()));
}
}
@ -812,7 +812,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
if(iconUrl != null)
{
MoodlBox.getBitmapFromURL(iconUrl, localCurrency.getSymbol(), getResources(), getContext(), new MoodlboxNotifierInterface() {
MoodlBox.getBitmapFromURL(iconUrl, localCurrency.getSymbol(), getResources(), getActivity().getBaseContext(), new MoodlboxNotifierInterface() {
@Override
public void onBitmapDownloaded(Bitmap bitmapIcon) {
localCurrency.setIcon(bitmapIcon);
@ -822,7 +822,7 @@ public class Summary extends Fragment implements BalanceSwitchManagerInterface,
}
else
{
Drawable drawable = getDrawable(R.drawable.ic_panorama_fish_eye_24dp, getContext());
Drawable drawable = getDrawable(R.drawable.ic_panorama_fish_eye_24dp, getActivity().getBaseContext());
Bitmap icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

View File

@ -73,9 +73,9 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
refreshLayout = view.findViewById(R.id.swiperefreshwatchlist);
dragLinearLayout = view.findViewById(R.id.linearLayoutWatchlist);
cryptocompareApiManager = CryptocompareApiManager.getInstance(getContext());
preferencesManager = new PreferencesManager(getContext());
databaseManager = new DatabaseManager(getContext());
cryptocompareApiManager = CryptocompareApiManager.getInstance(getActivity().getBaseContext());
preferencesManager = new PreferencesManager(getActivity().getBaseContext());
databaseManager = new DatabaseManager(getActivity().getBaseContext());
lastTimestamp = 0;
defaultCurrency = preferencesManager.getDefaultCurrency();
@ -97,7 +97,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
editModeEnabled = false;
watchlistManager = new WatchlistManager(getContext());
watchlistManager = new WatchlistManager(getActivity().getBaseContext());
updateWatchlist(true);
@ -171,7 +171,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
private void disableEdition()
{
editButton.setBackground(MoodlBox.getDrawable(R.drawable.check_to_edit, getContext()));
editButton.setBackground(MoodlBox.getDrawable(R.drawable.check_to_edit, getActivity().getBaseContext()));
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
@ -196,7 +196,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
private void enableEdition()
{
editButton.setBackground(MoodlBox.getDrawable(R.drawable.edit_to_check, getContext()));
editButton.setBackground(MoodlBox.getDrawable(R.drawable.edit_to_check, getActivity().getBaseContext()));
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
@ -357,7 +357,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
for(Currency currency : watchlistManager.getWatchlist())
{
View addedView = new CurrencyCardview(getContext(), currency, getActivity());
View addedView = new CurrencyCardview(getActivity().getBaseContext(), currency, getActivity());
dragLinearLayout.addDragView(addedView, addedView.findViewById(R.id.dragCardWatchlist));
}
@ -386,11 +386,11 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
{
Palette.Builder builder = Palette.from(currency.getIcon());
currency.setChartColor(builder.generate().getDominantColor(getColor(R.color.default_color, getContext())));
currency.setChartColor(builder.generate().getDominantColor(getColor(R.color.default_color, getActivity().getBaseContext())));
}
else
{
currency.setChartColor(getColor(R.color.default_color, getContext()));
currency.setChartColor(getColor(R.color.default_color, getActivity().getBaseContext()));
}
}
@ -450,7 +450,7 @@ public class Watchlist extends Fragment implements CryptocompareNotifierInterfac
if(iconUrl != null)
{
MoodlBox.getBitmapFromURL(iconUrl, currency.getSymbol(), getResources(), getContext(), new MoodlboxNotifierInterface() {
MoodlBox.getBitmapFromURL(iconUrl, currency.getSymbol(), getResources(), getActivity().getBaseContext(), new MoodlboxNotifierInterface() {
@Override
public void onBitmapDownloaded(Bitmap bitmapIcon) {
currency.setIcon(bitmapIcon);

View File

@ -61,6 +61,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.annotation.Target;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyStore;
@ -253,7 +254,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public boolean onPreferenceClick(Preference preference) {
boolean isChecked = ((SwitchPreference) findPreference("enable_hitbtc")).isChecked();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getBaseContext());
SharedPreferences.Editor editor = preferences.edit();
@ -269,7 +270,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public boolean onPreferenceClick(Preference preference) {
boolean isChecked = ((SwitchPreference) findPreference("enable_binance")).isChecked();
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getBaseContext());
SharedPreferences.Editor editor = preferences.edit();
@ -296,7 +297,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
private void startFingerprintProtocol()
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getContext());
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getActivity().getBaseContext());
FingerprintDialogFragment newFragment = FingerprintDialogFragment.newInstance();
SwitchPreference touchdIdSwitch = (SwitchPreference) findPreference("enable_fingerprint");
@ -311,7 +312,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
touchdIdSwitch.setEnabled(false);
}
if(ActivityCompat.checkSelfPermission(this.getContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)
if(ActivityCompat.checkSelfPermission(this.getActivity().getBaseContext(), Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED)
{
touchdIdSwitch.setEnabled(false);
}
@ -337,7 +338,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
{
cryptoObject = new FingerprintManager.CryptoObject(cipher);
FingerprintHandler helper = new FingerprintHandler(this.getContext(), newFragment);
FingerprintHandler helper = new FingerprintHandler(this.getActivity().getBaseContext(), newFragment);
helper.startAuth(fingerprintManager, cryptoObject);
}
}
@ -353,6 +354,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
}
@TargetApi(23)
private void generateKey() throws FingerprintException
{
try {
@ -378,6 +380,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
}
}
@TargetApi(23)
public boolean initCipher()
{
try {
@ -436,7 +439,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
developperCategory.getPreference(0).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
File cacheDir = getContext().getCacheDir();
File cacheDir = getActivity().getBaseContext().getCacheDir();
File[] cachedFiles = cacheDir.listFiles();
for(int i = 0; i < cachedFiles.length; i++)
@ -456,8 +459,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
public boolean onPreferenceClick(Preference preference) {
Context context = getContext();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
Context context = getActivity().getBaseContext();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainPreferenceFragment.this.getActivity());
View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_export_data, null, true);
dialogBuilder.setView(dialogView);
@ -512,7 +515,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss", Locale.getDefault());
Date currentDate = new Date();
String fileName = "Bakup_" + formatter.format(currentDate) + ".moodl";
DatabaseManager databaseManager = new DatabaseManager(getContext());
DatabaseManager databaseManager = new DatabaseManager(getActivity().getBaseContext());
if(enterPasswordCheckbox.isChecked())
{
@ -538,7 +541,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
if(backupManualEntriesCheckbox.isChecked())
{
backupJson.put("transactions",
databaseManager.getDatabaseBackup(getContext(),
databaseManager.getDatabaseBackup(getActivity().getBaseContext(),
DatabaseManager.TABLE_MANUAL_CURRENCIES,
enterPasswordCheckbox.isChecked()));
}
@ -546,7 +549,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
if(backupWatchlistCheckbox.isChecked())
{
backupJson.put("watchlist",
databaseManager.getDatabaseBackup(getContext(),
databaseManager.getDatabaseBackup(getActivity().getBaseContext(),
DatabaseManager.TABLE_WATCHLIST,
enterPasswordCheckbox.isChecked()));
}
@ -554,7 +557,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
if(backupKeysCheckbox.isChecked())
{
backupJson.put("apiKeys",
databaseManager.getDatabaseBackup(getContext(),
databaseManager.getDatabaseBackup(getActivity().getBaseContext(),
DatabaseManager.TABLE_EXCHANGE_KEYS,
enterPasswordCheckbox.isChecked()));
}
@ -590,8 +593,8 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
public boolean onPreferenceClick(Preference preference) {
Context context = getContext();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
Context context = getActivity().getBaseContext();
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(MainPreferenceFragment.this.getActivity());
View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_import_data, null, true);
dialogBuilder.setView(dialogView);
@ -716,7 +719,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
if(enterPasswordCheckbox.isChecked())
{
checker = DataCrypter.decrypt(getContext(), backupJson.getString("encodeChecker"));
checker = DataCrypter.decrypt(getActivity().getBaseContext(), backupJson.getString("encodeChecker"));
}
else
{
@ -740,7 +743,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
{
JSONObject transactionObject = transactionsArray.getJSONObject(i);
databaseManager.addRowTransaction(transactionObject, getContext(), enterPasswordCheckbox.isChecked());
databaseManager.addRowTransaction(transactionObject, getActivity().getBaseContext(), enterPasswordCheckbox.isChecked());
}
}
}
@ -760,7 +763,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
{
JSONObject watchlistObject = watchlistArray.getJSONObject(i);
databaseManager.addRowWatchlist(watchlistObject, getContext(), enterPasswordCheckbox.isChecked());
databaseManager.addRowWatchlist(watchlistObject, getActivity().getBaseContext(), enterPasswordCheckbox.isChecked());
}
}
}
@ -780,7 +783,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
{
JSONObject apiKeysObject = apiArray.getJSONObject(i);
databaseManager.addRowApiKeys(apiKeysObject, getContext(), enterPasswordCheckbox.isChecked());
databaseManager.addRowApiKeys(apiKeysObject, getActivity().getBaseContext(), enterPasswordCheckbox.isChecked());
}
}
}
@ -818,7 +821,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent exchangeListIntent = new Intent(getContext(), ExchangeListActivity.class);
Intent exchangeListIntent = new Intent(getActivity().getBaseContext(), ExchangeListActivity.class);
startActivity(exchangeListIntent);
return false;
@ -834,7 +837,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
{
if(mustEncrypt)
{
backupJson.put("encodeChecker", DataCrypter.encrypt(getContext(), "NaukVerification"));
backupJson.put("encodeChecker", DataCrypter.encrypt(getActivity().getBaseContext(), "NaukVerification"));
}
else
{
@ -861,7 +864,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
int result;
List<String> listPermissionsNeeded = new ArrayList<>();
for (String p : permissions) {
result = ContextCompat.checkSelfPermission(getContext(), p);
result = ContextCompat.checkSelfPermission(getActivity().getBaseContext(), p);
if (result != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(p);
}

View File

@ -68,7 +68,7 @@ public class BinanceManager extends Exchange {
if(Double.parseDouble(assets.get(i).getFree()) > 0 || Double.parseDouble(assets.get(i).getLocked()) > 0)
{
//balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
if(!assets.get(i).getAsset().equals("VET"))
if(!assets.get(i).getAsset().equals("VEN"))
{
balance.add(new Currency(assets.get(i).getAsset(), Double.parseDouble(assets.get(i).getFree()) + Double.parseDouble(assets.get(i).getLocked())));
}