Updated on 2026-08-14

This commit is contained in:
Tangem 2018-10-26 19:42:56 +03:00
parent 61ef397705
commit 96c04894eb
5 changed files with 16 additions and 14 deletions

View file

@ -3,8 +3,8 @@ package com.tangem;
import android.app.Application;
import android.support.v7.app.AppCompatDelegate;
import com.tangem.di.AppComponent;
import com.tangem.di.DaggerAppComponent;
import com.tangem.di.DaggerNetworkComponent;
import com.tangem.di.NetworkComponent;
public class App extends Application {
@ -21,7 +21,7 @@ public class App extends Application {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
private static AppComponent component;
private static NetworkComponent networkComponent;
@Override
public void onCreate() {
@ -29,7 +29,7 @@ public class App extends Application {
// initialize the singleton
sInstance = this;
component = DaggerAppComponent.create();
networkComponent = DaggerNetworkComponent.create();
}
/**
@ -39,8 +39,8 @@ public class App extends Application {
return sInstance;
}
public static AppComponent getComponent() {
return component;
public static NetworkComponent getNetworkComponent() {
return networkComponent;
}
}

View file

@ -46,7 +46,7 @@ public class ServerApiHelper {
}
public void estimateFee(int blockCount) {
EstimatefeeApi estimatefeeApi = App.getComponent().getRetrofitEstimatefee().create(EstimatefeeApi.class);
EstimatefeeApi estimatefeeApi = App.getNetworkComponent().getRetrofitEstimatefee().create(EstimatefeeApi.class);
Call<String> call;
switch (blockCount) {
@ -114,7 +114,7 @@ public class ServerApiHelper {
}
public void infura(String method, int id, String wallet, String contract, String tx) {
InfuraApi infuraApi = App.getComponent().getRetrofitInfura().create(InfuraApi.class);
InfuraApi infuraApi = App.getNetworkComponent().getRetrofitInfura().create(InfuraApi.class);
InfuraBody infuraBody;
switch (method) {
@ -179,7 +179,7 @@ public class ServerApiHelper {
}
public void cardVerifyAndGetInfo(TangemCard card) {
TangemApi tangemApi = App.getComponent().getRetrofitTangem().create(TangemApi.class);
TangemApi tangemApi = App.getNetworkComponent().getRetrofitTangem().create(TangemApi.class);
List<CardVerifyAndGetInfo.Request.Item> requests = new ArrayList<>();
requests.add(new CardVerifyAndGetInfo.Request.Item(Util.bytesToHex(card.getCID()), Util.bytesToHex(card.getCardPublicKey())));
@ -224,7 +224,7 @@ public class ServerApiHelper {
}
public void requestArtwork(String artworkId, Date updateDate, TangemCard card) {
TangemApi tangemApi = App.getComponent().getRetrofitTangem().create(TangemApi.class);
TangemApi tangemApi = App.getNetworkComponent().getRetrofitTangem().create(TangemApi.class);
Call<ResponseBody> call = tangemApi.getArtwork(artworkId, Util.bytesToHex(card.getCID()), Util.bytesToHex(card.getCardPublicKey()));
call.enqueue(new Callback<ResponseBody>() {
@ -267,7 +267,7 @@ public class ServerApiHelper {
@SuppressLint("CheckResult")
public void rateInfoData(String cryptoId) {
CoinmarketApi coinmarketApi = App.getComponent().getRetrofitCoinmarketcap().create(CoinmarketApi.class);
CoinmarketApi coinmarketApi = App.getNetworkComponent().getRetrofitCoinmarketcap().create(CoinmarketApi.class);
coinmarketApi.getRateInfoList()
.subscribeOn(Schedulers.io())
@ -302,7 +302,7 @@ public class ServerApiHelper {
}
public void requestLastVersion() {
UpdateVersionApi updateVersionApi = App.getComponent().getRetrofitGithubusercontent().create(UpdateVersionApi.class);
UpdateVersionApi updateVersionApi = App.getNetworkComponent().getRetrofitGithubusercontent().create(UpdateVersionApi.class);
Call<ResponseBody> call = updateVersionApi.getLastVersion();
call.enqueue(new Callback<ResponseBody>() {

View file

@ -111,7 +111,7 @@ public class ServerApiHelperElectrum {
Collections.addAll(result, electrumRequest);
try {
Socket socket = App.getComponent().getSocket();
Socket socket = App.getNetworkComponent().getSocket();
socket.connect(new InetSocketAddress(InetAddress.getByName(host), port));
Log.i(TAG, host + " " + port);
try {

View file

@ -12,7 +12,7 @@ import retrofit2.Retrofit;
@Singleton
@Component(modules = {NetworkModule.class})
public interface AppComponent {
public interface NetworkComponent {
@Named(Server.ApiInfura.URL_INFURA)
Retrofit getRetrofitInfura();

View file

@ -53,6 +53,8 @@ class MainActivity : AppCompatActivity(), NfcAdapter.ReaderCallback, CardProtoco
const val EXTRA_LAST_DISCOVERED_TAG = "extra_last_tag"
fun callingIntent(context: Context) = Intent(context, MainActivity::class.java)
fun commonInit(context: Context) {
if (PINStorage.needInit())
PINStorage.Init(context)