Commit bd34f7fb authored by MUTTINENI NAVYA's avatar MUTTINENI NAVYA

myPosts and ItemDetails activities added

parent 0d1f8020
...@@ -9,8 +9,11 @@ ...@@ -9,8 +9,11 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity android:name=".Navigation" <activity android:name=".ItemDetails"></activity>
android:theme="@style/AppTheme.NoActionBar"/> <activity android:name=".MyPosts" />
<activity
android:name=".Navigation"
android:theme="@style/AppTheme.NoActionBar" />
<activity <activity
android:name=".FoundItem" android:name=".FoundItem"
android:label="@string/title_activity_found_item" android:label="@string/title_activity_found_item"
......
package com.example.instilostandfound;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
public class ItemDetails extends AppCompatActivity implements View.OnClickListener {
String category, name, key;
int type;
@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);
TextView cat_row = (TextView) findViewById(R.id.category);
cat_row.setText(category);
TextView name_row = (TextView) findViewById(R.id.name);
name_row.setText(name);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.edit_post:
if(type == 0){
Intent intent = new Intent(ItemDetails.this, LostItem.class);
intent.putExtra("key", key);
startActivity(intent);
}
else if(type == 1){
Intent intent = new Intent(ItemDetails.this, FoundItem.class);
intent.putExtra("key", key);
startActivity(intent);
}
Log.d("..................", "hiiiiiiiiiii");
break;
case R.id.resolve_post:
break;
}
}
}
package com.example.instilostandfound;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
public class MyPosts extends AppCompatActivity {
String items[] = new String[] {"apple", "banana"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_posts);
ListView listView = (ListView) findViewById(R.id.listview);
ArrayAdapter<String> adaptor = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, items);
listView.setAdapter(adaptor);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(MyPosts.this, items[position], Toast.LENGTH_SHORT).show();
Intent intent = new Intent(MyPosts.this, ItemDetails.class);
intent.putExtra("category", "Electronics");
intent.putExtra("name", "Phone");
intent.putExtra("key", "123");
intent.putExtra("type", 1);
startActivity(intent);
}
});
}
}
...@@ -15,9 +15,10 @@ import android.widget.Toast; ...@@ -15,9 +15,10 @@ import android.widget.Toast;
import com.google.android.material.navigation.NavigationView; import com.google.android.material.navigation.NavigationView;
public class Navigation extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener{ public class Navigation extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
private String username = null; private String username = null;
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -43,18 +44,18 @@ private String username = null; ...@@ -43,18 +44,18 @@ private String username = null;
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MainActivity()).commit(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MainActivity()).commit();
}*/ }*/
} }
@Override @Override
public void onBackPressed(){ public void onBackPressed() {
if(drawerLayout.isDrawerOpen(GravityCompat.START)){ if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
drawerLayout.closeDrawer(GravityCompat.START); drawerLayout.closeDrawer(GravityCompat.START);
} } else
else
super.onBackPressed(); super.onBackPressed();
} }
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
switch ((menuItem.getItemId())){ switch ((menuItem.getItemId())) {
case R.id.post_found: case R.id.post_found:
Intent intent = new Intent(Navigation.this, FoundItem.class); Intent intent = new Intent(Navigation.this, FoundItem.class);
intent.putExtra("username", username); intent.putExtra("username", username);
...@@ -70,7 +71,8 @@ private String username = null; ...@@ -70,7 +71,8 @@ private String username = null;
startActivity(getIntent()); startActivity(getIntent());
break; break;
case R.id.my_posts: case R.id.my_posts:
// Redirect to myposts "FRAGMENT" intent = new Intent(this, MyPosts.class);
startActivity(intent);
break; break;
case R.id.logout: case R.id.logout:
finish(); finish();
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ItemDetails">
<TableLayout
android:id="@+id/item_details_table"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:layout_editor_absoluteX="50dp"
tools:layout_editor_absoluteY="50dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Category" />
<TextView
android:id="@+id/category"
android:layout_width="171dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:text="Name" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:text="" />
</TableRow>
</TableLayout>
<Button
android:id="@+id/edit_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginBottom="24dp"
android:text="Edit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/resolve_post"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:layout_marginRight="32dp"
android:layout_marginBottom="24dp"
android:text="Resolve Post"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyPosts">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/listview">
</ListView>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="sections">
<item>Name</item>
<item>Place Found</item>
</string-array>
</resources>
\ No newline at end of file
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