49 lines
1.4 KiB
Java
49 lines
1.4 KiB
Java
package com.psmreborn.pkgj;
|
|
|
|
import android.app.Activity;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.widget.AdapterView;
|
|
import android.widget.ArrayAdapter;
|
|
import android.widget.ListView;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
public class MainActivity extends Activity {
|
|
private ArrayAdapter<Game> titleAdapter;
|
|
private ArrayList<Game> games = null;
|
|
|
|
public void addGame(Game game){
|
|
this.games.add(game);
|
|
}
|
|
|
|
public void updateGames(){
|
|
this.titleAdapter.notifyDataSetChanged();
|
|
}
|
|
@Override
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
setContentView(R.layout.activity_main);
|
|
|
|
this.games = new ArrayList<Game>();
|
|
|
|
titleAdapter = new ArrayAdapter<Game>(this.getApplicationContext(), R.layout.list_item, R.id.list_content, this.games);
|
|
ListView lstView = (ListView)this.findViewById(R.id.gameList);
|
|
lstView.setAdapter(titleAdapter);
|
|
|
|
(new NoPayStationParser(this, false)).execute();
|
|
|
|
lstView.setOnItemClickListener(new AdapterView.OnItemClickListener(){
|
|
@Override
|
|
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
Game item = (Game)adapterView.getItemAtPosition(i);
|
|
(new PsmGameDownloader(MainActivity.this, item)).execute();
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
|
|
}
|