Preparation for Entries pages
- Actionbar implementation - Entries pages implementation - New icons for pages
This commit is contained in:
parent
7e5a2ad568
commit
e4ecba5254
15 changed files with 62 additions and 10 deletions
app/src/main
java/info/nerull7/mysqlbrowser
res
drawable-hdpi
drawable-mdpi
drawable-xhdpi
drawable-xxhdpi
menu
values
|
@ -3,19 +3,24 @@ package info.nerull7.mysqlbrowser;
|
|||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import java.util.zip.Inflater;
|
||||
|
||||
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");
|
||||
Bundle bundle = getIntent().getExtras();
|
||||
bundle.putInt("Page", 0);
|
||||
String titleName = bundle.getString("DatabaseName")+"->"+bundle.getString("TableName");
|
||||
setTitle(titleName);
|
||||
|
||||
EntriesFragment entriesFragment = new EntriesFragment();
|
||||
entriesFragment.setArguments(getIntent().getExtras());
|
||||
entriesFragment.setArguments(bundle);
|
||||
if (savedInstanceState == null) {
|
||||
getFragmentManager().beginTransaction()
|
||||
.add(R.id.container, entriesFragment)
|
||||
|
@ -23,4 +28,22 @@ public class EntriesActivity extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()){
|
||||
case R.id.action_previous:
|
||||
case R.id.action_next:
|
||||
// item.setEnabled(!item.isEnabled());
|
||||
// item.setVisible(!item.isVisible());
|
||||
break;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.entries_activity_actions, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nerull7.mysqlbrowser;
|
||||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
|
@ -21,14 +22,16 @@ import java.util.List;
|
|||
* Created by nerull7 on 15.07.14.
|
||||
*/
|
||||
public class EntriesFragment extends Fragment {
|
||||
private String databaseName;
|
||||
private String tableName;
|
||||
private TableLayout entriesTable;
|
||||
private ScrollView entriesScrollView;
|
||||
private FrameLayout headerFrame;
|
||||
private int entriesLimit;
|
||||
private RelativeLayout rootView;
|
||||
|
||||
private String databaseName;
|
||||
private String tableName;
|
||||
private int entriesLimit;
|
||||
private int page;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
|
@ -40,10 +43,17 @@ public class EntriesFragment extends Fragment {
|
|||
headerFrame = (FrameLayout) rootView.findViewById(R.id.headerFrame);
|
||||
entriesLimit = getActivity().getSharedPreferences(SettingsFragment.PREFERENCE_FILE, Context.MODE_PRIVATE).getInt(SettingsFragment.ENTRIES_PAGE_LIMIT, SettingsFragment.ENTRIES_PAGE_LIMIT_DEF);
|
||||
this.rootView = (RelativeLayout) rootView;
|
||||
page = getArguments().getInt("Page");
|
||||
setupTable();
|
||||
// setupActionBar();
|
||||
return rootView;
|
||||
}
|
||||
|
||||
// private void setupActionBar() {
|
||||
// ActionBar actionBar = getActivity().getActionBar();
|
||||
// actionBar.
|
||||
// }
|
||||
|
||||
private void setupTable(){
|
||||
List<String> fieldList = Static.databaseConnector.getFields(tableName);
|
||||
|
||||
|
@ -81,7 +91,7 @@ public class EntriesFragment extends Fragment {
|
|||
headerFrame.addView(fakeHeaderView);
|
||||
|
||||
// Now we get Rows
|
||||
List<List<String>> rows = Static.databaseConnector.getRows(tableName, entriesLimit);
|
||||
List<List<String>> rows = Static.databaseConnector.getRows(tableName, entriesLimit, page);
|
||||
if(rows!=null) {
|
||||
for (int i = 0; i < rows.size(); i++) {
|
||||
List<String> elements = rows.get(i);
|
||||
|
|
|
@ -14,5 +14,5 @@ public interface DatabaseConnector {
|
|||
|
||||
List<String> getFields(String table);
|
||||
|
||||
List<List<String>> getRows(String table, int count);
|
||||
List<List<String>> getRows(String table, int count, int page);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ public class FakeDatabaseConnector implements DatabaseConnector {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<List<String>> getRows(String table, int count){
|
||||
public List<List<String>> getRows(String table, int count, int page){
|
||||
if(database==null) return null; // if database is not chosen return null
|
||||
List<List<String>> stringListList = new ArrayList<List<String>>();
|
||||
|
||||
|
|
|
@ -178,7 +178,8 @@ public class RealDatabaseConnector implements DatabaseConnector {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<List<String>> getRows(String table, int count){
|
||||
return getMatrix(actionUrlBuilder("getrows")+"&d="+database+"&t="+table+"&s="+0+"&l="+count); //FIXME
|
||||
public List<List<String>> getRows(String table, int count, int page){
|
||||
int limitStart = page * count;
|
||||
return getMatrix(actionUrlBuilder("getrows")+"&d="+database+"&t="+table+"&s="+limitStart+"&l="+count); //FIXME
|
||||
}
|
||||
}
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_action_arrow_back.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_action_arrow_back.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 406 B |
BIN
app/src/main/res/drawable-hdpi/ic_action_arrow_forward.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_action_arrow_forward.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 379 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_arrow_back.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_action_arrow_back.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 277 B |
BIN
app/src/main/res/drawable-mdpi/ic_action_arrow_forward.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_action_arrow_forward.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 248 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_arrow_back.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_action_arrow_back.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 514 B |
BIN
app/src/main/res/drawable-xhdpi/ic_action_arrow_forward.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_action_arrow_forward.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 459 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_arrow_back.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_action_arrow_back.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 802 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_action_arrow_forward.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_action_arrow_forward.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 801 B |
16
app/src/main/res/menu/entries_activity_actions.xml
Normal file
16
app/src/main/res/menu/entries_activity_actions.xml
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_previous"
|
||||
android:icon="@drawable/ic_action_arrow_back"
|
||||
android:title="@string/action_previous"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_next"
|
||||
android:icon="@drawable/ic_action_arrow_forward"
|
||||
android:title="@string/action_next"
|
||||
android:showAsAction="always"/>
|
||||
|
||||
</menu>
|
|
@ -25,5 +25,7 @@
|
|||
<string name="error_no_tables">No tables in this database</string>
|
||||
<string name="error_no_entries">No entries in this table</string>
|
||||
<string name="error_no_databases">No available databases</string>
|
||||
<string name="action_previous">Previous</string>
|
||||
<string name="action_next">Next</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue