Commit eafb4d7d authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

individual extras to bundle

parent 2c829959
......@@ -3,6 +3,7 @@ package com.example.instilostandfound;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
......@@ -12,20 +13,19 @@ import android.widget.TextView;
public class ItemDetails extends AppCompatActivity implements View.OnClickListener {
String category, name, key;
int type;
Bundle details_bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_item_details);
Intent intent = getIntent();
category = intent.getStringExtra("category");
name = intent.getStringExtra("name");
key = intent.getStringExtra("key");
type = intent.getIntExtra("type",-1);
details_bundle = intent.getExtras();
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);
name_row.setText(name);
name_row.setText(details_bundle.getString("name"));
findViewById(R.id.edit_post).setOnClickListener(this);
findViewById(R.id.resolve_post).setOnClickListener(this);
......@@ -35,17 +35,16 @@ int type;
public void onClick(View v) {
switch (v.getId()){
case R.id.edit_post:
if(type == 0){
if(details_bundle.getInt("type") == 0){
Intent intent = new Intent(ItemDetails.this, LostItem.class);
intent.putExtra("key", key);
intent.putExtras(details_bundle);
startActivity(intent);
}
else if(type == 1){
else if(details_bundle.getInt("type") == 1){
Intent intent = new Intent(ItemDetails.this, FoundItem.class);
intent.putExtra("key", key);
intent.putExtras(details_bundle);
startActivity(intent);
}
Log.d("..................", "hiiiiiiiiiii");
break;
case R.id.resolve_post:
break;
......
......@@ -31,7 +31,7 @@ public class MyPosts extends AppCompatActivity {
intent.putExtra("category", "Electronics");
intent.putExtra("name", "Phone");
intent.putExtra("key", "123");
intent.putExtra("type", 1);
intent.putExtra("type", 0);
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