Commit eafb4d7d authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

individual extras to bundle

parent 2c829959
...@@ -3,6 +3,7 @@ package com.example.instilostandfound; ...@@ -3,6 +3,7 @@ package com.example.instilostandfound;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
...@@ -12,20 +13,19 @@ import android.widget.TextView; ...@@ -12,20 +13,19 @@ import android.widget.TextView;
public class ItemDetails extends AppCompatActivity implements View.OnClickListener { public class ItemDetails extends AppCompatActivity implements View.OnClickListener {
String category, name, key; String category, name, key;
int type; int type;
Bundle details_bundle;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_details); setContentView(R.layout.activity_item_details);
Intent intent = getIntent(); Intent intent = getIntent();
category = intent.getStringExtra("category"); details_bundle = intent.getExtras();
name = intent.getStringExtra("name");
key = intent.getStringExtra("key");
type = intent.getIntExtra("type",-1);
TextView cat_row = (TextView) findViewById(R.id.category); TextView cat_row = (TextView) findViewById(R.id.category);
cat_row.setText(category); cat_row.setText(details_bundle.getString("category"));
TextView name_row = (TextView) findViewById(R.id.name); TextView name_row = (TextView) findViewById(R.id.name);
name_row.setText(name); name_row.setText(details_bundle.getString("name"));
findViewById(R.id.edit_post).setOnClickListener(this); findViewById(R.id.edit_post).setOnClickListener(this);
findViewById(R.id.resolve_post).setOnClickListener(this); findViewById(R.id.resolve_post).setOnClickListener(this);
...@@ -35,17 +35,16 @@ int type; ...@@ -35,17 +35,16 @@ int type;
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()){ switch (v.getId()){
case R.id.edit_post: case R.id.edit_post:
if(type == 0){ if(details_bundle.getInt("type") == 0){
Intent intent = new Intent(ItemDetails.this, LostItem.class); Intent intent = new Intent(ItemDetails.this, LostItem.class);
intent.putExtra("key", key); intent.putExtras(details_bundle);
startActivity(intent); startActivity(intent);
} }
else if(type == 1){ else if(details_bundle.getInt("type") == 1){
Intent intent = new Intent(ItemDetails.this, FoundItem.class); Intent intent = new Intent(ItemDetails.this, FoundItem.class);
intent.putExtra("key", key); intent.putExtras(details_bundle);
startActivity(intent); startActivity(intent);
} }
Log.d("..................", "hiiiiiiiiiii");
break; break;
case R.id.resolve_post: case R.id.resolve_post:
break; break;
......
...@@ -31,7 +31,7 @@ public class MyPosts extends AppCompatActivity { ...@@ -31,7 +31,7 @@ public class MyPosts extends AppCompatActivity {
intent.putExtra("category", "Electronics"); intent.putExtra("category", "Electronics");
intent.putExtra("name", "Phone"); intent.putExtra("name", "Phone");
intent.putExtra("key", "123"); intent.putExtra("key", "123");
intent.putExtra("type", 1); intent.putExtra("type", 0);
startActivity(intent); startActivity(intent);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment