我想在同一个活动中添加两个不同请求的额外内容

时间:2017-11-03 16:28:20

标签: android

当我发送两个不同URL的两个请求时,我需要在同一个活动上添加额外内容,但是我启动了这个Activity两次,因此第一个请求Activity(附加内容不同)被第二个请求替换

源代码是这样的:

request.checkPlayerName(buscar, new ApiRequest.CheckPlayerCallback() {
    @Override
    public void onSuccess(String name, long summonerLevel, int profileIconId, long id) {
        pbLoader.setVisibility(View.INVISIBLE);
        Intent intent = new Intent(getApplicationContext(), EstadisticasActivity.class);
        Bundle extras = new Bundle();
        extras.putString("NAME", name);
        extras.putLong("SUMMONERLEVEL", summonerLevel);
        extras.putInt("PROFILEICONID", profileIconId);
        extras.putLong("ID", id);
        intent.putExtras(extras);
        startActivity(intent);
    }

    @Override
    public void dontExist(String message) {
        pbLoader.setVisibility(View.INVISIBLE);
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onError(String message) {
        pbLoader.setVisibility(View.INVISIBLE);
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
    }
});

request.checkPlayerLeague(new ApiRequest.CheckLeagueCallback() {
    @Override
    public void onSuccess(String tier, int leaguePoints, String rank) {
        Intent intent = new Intent(getApplicationContext(), EstadisticasActivity.class);
        Bundle extras = new Bundle();
        extras.putString("TIER", tier);
        extras.putInt("LEAGUEPOINTS", leaguePoints);
        extras.putString("RANK", rank);
        intent.putExtras(extras);
        //startActivity(intent);
    }

    @Override
    public void onError(String message) {
        Toast.makeText(getApplicationContext(), message, Toast.LENGTH_SHORT).show();
    }
});

0 个答案:

没有答案