From 122a487f29d549e75a33757b94efd29718cbd245 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Tue, 29 May 2018 11:43:27 +0200 Subject: [PATCH] Fix deprecated methods --- .../moodl/Activities/CurrencyDetailsActivity.java | 7 ++++--- .../DataManagers/CurrencyData/CurrencyCardview.java | 13 +++++++------ app/src/main/res/values/strings.xml | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java b/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java index 5e5fe8b..ed880ee 100644 --- a/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java +++ b/app/src/main/java/com/nauk/moodl/Activities/CurrencyDetailsActivity.java @@ -65,6 +65,7 @@ import com.nauk.moodl.R; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import static com.nauk.moodl.MoodlBox.numberConformer; import static com.nauk.moodl.MoodlBox.getDateFromTimestamp; @@ -130,7 +131,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_currency_details); - currency = getIntent().getParcelableExtra("currency"); + currency = getIntent().getParcelableExtra(getBaseContext().getString(R.string.currency)); viewPager = findViewById(R.id.vfCurrencyDetails); final DetailsActivityPagerAdapter adapter = new DetailsActivityPagerAdapter(getSupportFragmentManager(), 3); @@ -174,7 +175,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { setTitle(" " + currency.getName() + " | " + numberConformer(currency.getBalance())); } - getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | + Objects.requireNonNull(getSupportActionBar()).setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_USE_LOGO); Bitmap result = Bitmap.createBitmap(150, 150, currency.getIcon().getConfig()); @@ -187,7 +188,7 @@ public class CurrencyDetailsActivity extends AppCompatActivity { canvas.drawCircle(result.getHeight()/2, result.getWidth()/2, 75, paint); canvas.drawBitmap(Bitmap.createScaledBitmap(currency.getIcon(), 100, 100, false), result.getHeight()/2 - 50, result.getWidth()/2 - 50, null); - getSupportActionBar().setIcon(new BitmapDrawable(Bitmap.createScaledBitmap(result, 120, 120, false))); + getSupportActionBar().setIcon(new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(result, 120, 120, false))); } } /*for(int i = 0; i < dataChartList.size(); i++) diff --git a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java index 6e48e3f..3fa7b55 100644 --- a/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java +++ b/app/src/main/java/com/nauk/moodl/DataManagers/CurrencyData/CurrencyCardview.java @@ -9,6 +9,7 @@ import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.CardView; import android.util.Log; import android.view.LayoutInflater; @@ -186,7 +187,7 @@ public class CurrencyCardview extends CardView { @Override public void onClick(View view) { Intent intent = new Intent(context.getApplicationContext(), CurrencyDetailsActivity.class); - intent.putExtra("currency", currency); + intent.putExtra(getContext().getString(R.string.currency), currency); context.getApplicationContext().startActivity(intent); } }); @@ -321,7 +322,7 @@ public class CurrencyCardview extends CardView { values.add(new Entry(i, (float) dataChartList.get(i).getOpen())); } - dataSet = new LineDataSet(values, "History"); + dataSet = new LineDataSet(values, ""); dataSet.setDrawIcons(false); dataSet.setColor(currency.getChartColor()); dataSet.setLineWidth(1); @@ -341,16 +342,16 @@ public class CurrencyCardview extends CardView { if(currency.getDayFluctuationPercentage() >= 0) { ((TextView) findViewById(R.id.currencyFluctuationPercentageTextView)) - .setTextColor(getResources().getColor(R.color.increase)); + .setTextColor(ContextCompat.getColor(getContext(), R.color.increase)); ((TextView) findViewById(R.id.currencyFluctuationTextView)) - .setTextColor(getResources().getColor(R.color.increase)); + .setTextColor(ContextCompat.getColor(getContext(), R.color.increase)); } else { ((TextView) findViewById(R.id.currencyFluctuationPercentageTextView)) - .setTextColor(getResources().getColor(R.color.decrease)); + .setTextColor(ContextCompat.getColor(getContext(), R.color.decrease)); ((TextView) findViewById(R.id.currencyFluctuationTextView)) - .setTextColor(getResources().getColor(R.color.decrease)); + .setTextColor(ContextCompat.getColor(getContext(), R.color.decrease)); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9bb20b6..c157b62 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4,7 +4,7 @@ Moodl_debugVolley Settings - + currency General