Skip to content

Commit

Permalink
further bugfix tries
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejgaciarz committed Jul 16, 2018
1 parent da753e8 commit 749d5fb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ public List<Recipe> getRecipes(String JSON){

JsonParser jsonParser = new JsonParser();

Object object;

object = jsonParser.parse(JSON);
Object object = jsonParser.parse(JSON);

JsonObject jsonObject = (JsonObject) object;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@ public ListAdapter(Activity activity, List<Recipe> recipes) {
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.recipes = recipes;
}
int x= 0;
@Override
public View getView(int position, View convertView, ViewGroup parent){

View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_row, null);
vi = inflater.inflate(R.layout.list_row, parent,false);
//vi = inflater.inflate(R.layout.list_row, null);

TextView dishName = (TextView)vi.findViewById(R.id.dishName);
TextView dishDesc = (TextView)vi.findViewById(R.id.dishDescription);
ImageView dishImage =(ImageView) vi.findViewById(R.id.dishImage);

Recipe curRecipe = this.recipes.get(position);
Recipe recipe = recipes.get(position);


//load
dishName.setText(curRecipe.getLabel());
dishDesc.setText(curRecipe.getInstructionURL());
Picasso.get().load(curRecipe.getImageURL()).into(dishImage);
dishName.setText(recipe.getLabel());
dishDesc.setText(recipe.getInstructionURL());
Picasso.get().load(recipe.getImageURL()).into(dishImage);


return vi;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,23 @@
public class ResultActivity extends AppCompatActivity {


ListView list;
ListAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_result);



Bundle extras = getIntent().getExtras();
if (extras != null) {
String json = extras.getString("searchValues");

List<Recipe> recipes = new JSONObjectWrapper().getRecipes(json);

list = findViewById(R.id.list);
ListView list;

adapter = new ListAdapter(this, recipes);
list = (ListView) findViewById(R.id.list);

ListAdapter adapter = new ListAdapter(this, recipes);

if(adapter!=null){
list.setAdapter(adapter);
Expand All @@ -62,7 +60,9 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

Toast.makeText(getApplicationContext(),
"Click ListItem Number " + position, Toast.LENGTH_LONG)
.show();
}
});
}
Expand Down

0 comments on commit 749d5fb

Please sign in to comment.