From 492b5668f743794c8b5296e94ac753580d6eb674 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Tue, 15 Jul 2014 09:19:05 +0200 Subject: [PATCH] Welcome EntriesActivity --- app/src/main/AndroidManifest.xml | 4 ++ .../nerull7/mysqlbrowser/EntriesActivity.java | 55 +++++++++++++++++++ .../nerull7/mysqlbrowser/EntriesFragment.java | 19 +++++++ .../nerull7/mysqlbrowser/TableFragment.java | 8 ++- app/src/main/res/layout/activity_entries.xml | 7 +++ app/src/main/res/layout/fragment_entries.xml | 16 ++++++ app/src/main/res/menu/entries.xml | 8 +++ app/src/main/res/values/strings.xml | 1 + 8 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/info/nerull7/mysqlbrowser/EntriesActivity.java create mode 100644 app/src/main/java/info/nerull7/mysqlbrowser/EntriesFragment.java create mode 100644 app/src/main/res/layout/activity_entries.xml create mode 100644 app/src/main/res/layout/fragment_entries.xml create mode 100644 app/src/main/res/menu/entries.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bfa8501..55fc68d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -24,6 +24,10 @@ android:name=".TableActivity" android:label="@string/title_activity_table" > + + diff --git a/app/src/main/java/info/nerull7/mysqlbrowser/EntriesActivity.java b/app/src/main/java/info/nerull7/mysqlbrowser/EntriesActivity.java new file mode 100644 index 0000000..df4390b --- /dev/null +++ b/app/src/main/java/info/nerull7/mysqlbrowser/EntriesActivity.java @@ -0,0 +1,55 @@ +package info.nerull7.mysqlbrowser; + +import android.app.Activity; +import android.app.ActionBar; +import android.app.Fragment; +import android.os.Bundle; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.os.Build; + +import info.nerull7.mysqlbrowser.R; + +public class EntriesActivity extends Activity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_entries); + String titleName = getIntent().getStringExtra("DatabaseName")+"->"+getIntent().getStringExtra("TableName"); + setTitle(titleName); + + EntriesFragment entriesFragment = new EntriesFragment(); + entriesFragment.setArguments(getIntent().getExtras()); + if (savedInstanceState == null) { + getFragmentManager().beginTransaction() + .add(R.id.container, entriesFragment) + .commit(); + } + } + + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.entries, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + if (id == R.id.action_settings) { + return true; + } + return super.onOptionsItemSelected(item); + } + +} diff --git a/app/src/main/java/info/nerull7/mysqlbrowser/EntriesFragment.java b/app/src/main/java/info/nerull7/mysqlbrowser/EntriesFragment.java new file mode 100644 index 0000000..be84df5 --- /dev/null +++ b/app/src/main/java/info/nerull7/mysqlbrowser/EntriesFragment.java @@ -0,0 +1,19 @@ +package info.nerull7.mysqlbrowser; + +import android.app.Fragment; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +/** + * Created by nerull7 on 15.07.14. + */ +public class EntriesFragment extends Fragment { + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.fragment_entries, container, false); + return rootView; + } +} diff --git a/app/src/main/java/info/nerull7/mysqlbrowser/TableFragment.java b/app/src/main/java/info/nerull7/mysqlbrowser/TableFragment.java index 21f4a9e..23a141f 100644 --- a/app/src/main/java/info/nerull7/mysqlbrowser/TableFragment.java +++ b/app/src/main/java/info/nerull7/mysqlbrowser/TableFragment.java @@ -1,6 +1,7 @@ package info.nerull7.mysqlbrowser; import android.app.Fragment; +import android.content.Intent; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -37,6 +38,11 @@ public class TableFragment extends Fragment implements AdapterView.OnItemClickLi @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { - + String choosenTable = (String) listAdapter.getItem(position); + listAdapter.getItem(position); + Intent intent = new Intent(getActivity(), EntriesActivity.class); + intent.putExtra("DatabaseName",databaseName); + intent.putExtra("TableName",choosenTable); + startActivity(intent); } } diff --git a/app/src/main/res/layout/activity_entries.xml b/app/src/main/res/layout/activity_entries.xml new file mode 100644 index 0000000..afd0e25 --- /dev/null +++ b/app/src/main/res/layout/activity_entries.xml @@ -0,0 +1,7 @@ + diff --git a/app/src/main/res/layout/fragment_entries.xml b/app/src/main/res/layout/fragment_entries.xml new file mode 100644 index 0000000..c52f930 --- /dev/null +++ b/app/src/main/res/layout/fragment_entries.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/app/src/main/res/menu/entries.xml b/app/src/main/res/menu/entries.xml new file mode 100644 index 0000000..695e129 --- /dev/null +++ b/app/src/main/res/menu/entries.xml @@ -0,0 +1,8 @@ + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de5ac24..3d56b95 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,5 +14,6 @@ OK Error TableActivity + EntriesActivity