Add element implementation-ish
This commit is contained in:
parent
f4382ca249
commit
78d840db29
8 changed files with 163 additions and 11 deletions
app/src/main
java/info/nerull7/mysqlbrowser
res
|
@ -11,10 +11,17 @@ public class ElementActivity extends Activity {
|
|||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_database);
|
||||
setContentView(R.layout.activity_element);
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
String titleName = bundle.getString(Static.TABLE_NAME_ARG);
|
||||
setTitle(titleName);
|
||||
|
||||
ElementFragment elementFragment = new ElementFragment();
|
||||
elementFragment.setArguments(bundle);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
getFragmentManager().beginTransaction()
|
||||
.add(R.id.container, new ElementFragment())
|
||||
.add(R.id.container, elementFragment)
|
||||
.commit();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
package info.nerull7.mysqlbrowser;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by nerull7 on 2014-08-06.
|
||||
*/
|
||||
public class ElementArrayAdapter extends ArrayAdapter<String> {
|
||||
private Context context;
|
||||
private List<String> values;
|
||||
private int layout;
|
||||
|
||||
public ElementArrayAdapter(Context context, int resource, List<String> objects) {
|
||||
super(context, resource, objects);
|
||||
this.context = context;
|
||||
values = objects;
|
||||
layout = resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
View rowView = layoutInflater.inflate(layout, parent, false);
|
||||
|
||||
TextView textView = (TextView) rowView.findViewById(R.id.textFieldName);
|
||||
textView.setText(values.get(position));
|
||||
|
||||
return rowView;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,70 @@
|
|||
package info.nerull7.mysqlbrowser;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.nerull7.mysqlbrowser.db.AsyncDatabaseConnector;
|
||||
|
||||
/**
|
||||
* Created by nerull7 on 2014-08-06.
|
||||
*/
|
||||
public class ElementFragment extends Fragment {
|
||||
public class ElementFragment extends Fragment implements AsyncDatabaseConnector.ListReturnListener {
|
||||
private String databaseName;
|
||||
private String tableName;
|
||||
private ListAdapter listAdapter;
|
||||
|
||||
private ProgressBar progressBar;
|
||||
private ListView listView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
//Inflate the layout for this fragment
|
||||
View rootView = inflater.inflate(R.layout.fragment_element, container, false);
|
||||
progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
|
||||
listView = (ListView) rootView.findViewById(R.id.listView);
|
||||
|
||||
initArguments();
|
||||
|
||||
Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||
Static.asyncDatabaseConnector.getFields(tableName);
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
private void initArguments() {
|
||||
databaseName = getArguments().getString(Static.DATABASE_NAME_ARG);
|
||||
tableName = getArguments().getString(Static.TABLE_NAME_ARG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
inflater.inflate(R.menu.element, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListReturn(List<String> fields) {
|
||||
listAdapter = new ElementArrayAdapter(getActivity(), R.layout.list_item_element_simple, fields);
|
||||
listView.setAdapter(listAdapter);
|
||||
// databasesListView.setAdapter(listAdapter);
|
||||
// databasesListView.setOnItemClickListener(this);
|
||||
progressBar.setVisibility(View.INVISIBLE);
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nerull7.mysqlbrowser;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
|
@ -147,7 +148,10 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
|||
}
|
||||
|
||||
private void addNewElement(){
|
||||
//TODO Implement this method
|
||||
Intent intent = new Intent(getActivity(), ElementActivity.class);
|
||||
intent.putExtra(Static.DATABASE_NAME_ARG,databaseName);
|
||||
intent.putExtra(Static.TABLE_NAME_ARG,tableName);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,5 +2,22 @@
|
|||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
<ProgressBar
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:indeterminate="true"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/progressBar"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_alignParentTop="false"
|
||||
android:layout_marginTop="-7dp" />
|
||||
|
||||
<ListView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/listView"
|
||||
android:layout_below="@+id/progressBar"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
</RelativeLayout>
|
23
app/src/main/res/layout/list_item_element_simple.xml
Normal file
23
app/src/main/res/layout/list_item_element_simple.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent" android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="New Text"
|
||||
android:id="@+id/textFieldName"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<EditText
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/editFieldValue"
|
||||
android:layout_below="@+id/textFieldName"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
</RelativeLayout>
|
|
@ -1,8 +1,10 @@
|
|||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="info.nerull7.mysqlbrowser.ElementActivity" >
|
||||
<item android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
android:showAsAction="never" />
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item android:id="@+id/action_save"
|
||||
android:title="@string/action_save"
|
||||
android:showAsAction="always"
|
||||
android:icon="@drawable/ic_action_save"/>
|
||||
|
||||
</menu>
|
||||
|
|
|
@ -33,5 +33,6 @@
|
|||
<string name="no_connection">No Internet Connection</string>
|
||||
<string name="action_add">Add new</string>
|
||||
<string name="title_activity_element">ElementActivity</string>
|
||||
<string name="action_save">Save</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue