Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0304cc2590 |
5 changed files with 245 additions and 92 deletions
app/src/main/java/info/nerull7/mysqlbrowser
|
@ -30,6 +30,8 @@ public class DatabaseFragment extends Fragment implements AdapterView.OnItemClic
|
||||||
private RelativeLayout rootView;
|
private RelativeLayout rootView;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
|
private String chosenDatabase;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
|
||||||
//Inflate the layout for this fragment
|
//Inflate the layout for this fragment
|
||||||
|
@ -38,35 +40,48 @@ public class DatabaseFragment extends Fragment implements AdapterView.OnItemClic
|
||||||
this.rootView = (RelativeLayout) rootView;
|
this.rootView = (RelativeLayout) rootView;
|
||||||
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
||||||
|
|
||||||
Static.asyncDatabaseConnector.setListReturnListener(this);
|
// Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||||
Static.asyncDatabaseConnector.getDatabases();
|
// Static.asyncDatabaseConnector.getDatabases();
|
||||||
|
|
||||||
|
listAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, Static.databases);
|
||||||
|
databasesListView.setAdapter(listAdapter);
|
||||||
|
databasesListView.setOnItemClickListener(this);
|
||||||
|
progressBar.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||||
String chosenDatabase = (String) listAdapter.getItem(position);
|
chosenDatabase = (String) listAdapter.getItem(position);
|
||||||
listAdapter.getItem(position);
|
listAdapter.getItem(position);
|
||||||
Intent intent = new Intent(getActivity(), TableActivity.class);
|
|
||||||
intent.putExtra(Static.DATABASE_NAME_ARG,chosenDatabase);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
Static.asyncDatabaseConnector.setDatabaseInUse(chosenDatabase);
|
Static.asyncDatabaseConnector.setDatabaseInUse(chosenDatabase);
|
||||||
startActivity(intent);
|
Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||||
|
Static.asyncDatabaseConnector.getTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListReturn(List<String> databases) {
|
public void onListReturn(List<String> tables) {
|
||||||
if(databases!= null) {
|
// if(databases!= null) {
|
||||||
listAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, databases);
|
// listAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, databases);
|
||||||
databasesListView.setAdapter(listAdapter);
|
// databasesListView.setAdapter(listAdapter);
|
||||||
databasesListView.setOnItemClickListener(this);
|
// databasesListView.setOnItemClickListener(this);
|
||||||
} else {
|
// } else {
|
||||||
TextView errorMessage = new TextView(getActivity());
|
// TextView errorMessage = new TextView(getActivity());
|
||||||
errorMessage.setText(R.string.error_no_databases);
|
// errorMessage.setText(R.string.error_no_databases);
|
||||||
errorMessage.setTypeface(null, Typeface.ITALIC);
|
// errorMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
errorMessage.setClickable(false);
|
// errorMessage.setClickable(false);
|
||||||
rootView.addView(errorMessage);
|
// rootView.addView(errorMessage);
|
||||||
rootView.removeView(databasesListView);
|
// rootView.removeView(databasesListView);
|
||||||
|
// }
|
||||||
|
// progressBar.setVisibility(View.INVISIBLE);
|
||||||
|
if(tables!=null) {
|
||||||
|
Static.tables = tables;
|
||||||
}
|
}
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
Intent intent = new Intent(getActivity(), TableActivity.class);
|
||||||
|
intent.putExtra(Static.DATABASE_NAME_ARG, chosenDatabase);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,62 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
||||||
initArguments();
|
initArguments();
|
||||||
initViewItems(rootView);
|
initViewItems(rootView);
|
||||||
|
|
||||||
Static.asyncDatabaseConnector.setIntegerReturnListener(this);
|
// Static.asyncDatabaseConnector.setIntegerReturnListener(this);
|
||||||
Static.asyncDatabaseConnector.setListReturnListener(this);
|
// Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||||
Static.asyncDatabaseConnector.setMatrixReturnListener(this);
|
// Static.asyncDatabaseConnector.setMatrixReturnListener(this);
|
||||||
Static.asyncDatabaseConnector.getFields(tableName);
|
// Static.asyncDatabaseConnector.getFields(tableName);
|
||||||
Static.asyncDatabaseConnector.getEntriesCount(tableName);
|
// Static.asyncDatabaseConnector.getEntriesCount(tableName);
|
||||||
|
|
||||||
|
pageCount = Static.pageCount/entriesLimit;
|
||||||
|
if( Static.pageCount%entriesLimit > 0)
|
||||||
|
pageCount++;
|
||||||
|
|
||||||
|
if(pageCount>1)
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
|
// First we need header
|
||||||
|
headerRow = new TableRow(getActivity());
|
||||||
|
headerRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
|
||||||
|
for(int i =0;i<Static.header.size();i++){
|
||||||
|
TextView textView = new TextView(getActivity());
|
||||||
|
textView.setText(Static.header.get(i));
|
||||||
|
textView.setTypeface(null, Typeface.BOLD);
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
textView.setBackgroundResource(R.drawable.background_header);
|
||||||
|
textView.setPadding(HEADER_PADDING_LEFT, HEADER_PADDING_TOP, HEADER_PADDING_RIGHT, HEADER_PADDING_BOTTOM);
|
||||||
|
headerRow.addView(textView);
|
||||||
|
}
|
||||||
|
headerFrame.addView(headerRow);
|
||||||
|
|
||||||
|
// now data
|
||||||
|
if(Static.entries!=null) {
|
||||||
|
for (int i = 0; i < Static.entries.size(); i++) {
|
||||||
|
List<String> elements = Static.entries.get(i);
|
||||||
|
TableRow newRow = new TableRow(getActivity());
|
||||||
|
for (int j = 0; j < elements.size(); j++) { // elements.size can be the same as in header so maybe some one number or not
|
||||||
|
TextView textView = new TextView(getActivity());
|
||||||
|
textView.setText(elements.get(j));
|
||||||
|
textView.setLayoutParams(layoutParams);
|
||||||
|
textView.setPadding(ENTRIES_PADDING_LEFT, ENTRIES_PADDING_TOP, ENTRIES_PADDING_RIGHT, ENTRIES_PADDING_BOTTOM);
|
||||||
|
textView.setBackgroundResource(R.drawable.background_element);
|
||||||
|
newRow.addView(textView);
|
||||||
|
}
|
||||||
|
entriesTable.addView(newRow);
|
||||||
|
|
||||||
|
syncWidths();
|
||||||
|
fakeScroll();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
TextView errorMessage = new TextView(getActivity());
|
||||||
|
errorMessage.setText(R.string.error_no_entries);
|
||||||
|
errorMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
|
errorMessage.setClickable(false);
|
||||||
|
entriesScrollView.removeView(entriesTable);
|
||||||
|
headerFrame.setVisibility(View.VISIBLE);
|
||||||
|
entriesScrollView.addView(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
|
@ -153,54 +204,54 @@ public class EntriesFragment extends Fragment implements AsyncDatabaseConnector.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMatrixReturn(List<List<String>> rows) {
|
public void onMatrixReturn(List<List<String>> rows) {
|
||||||
// Now we get Rows
|
// // Now we get Rows
|
||||||
if(rows!=null) {
|
// if(rows!=null) {
|
||||||
for (int i = 0; i < rows.size(); i++) {
|
// for (int i = 0; i < rows.size(); i++) {
|
||||||
List<String> elements = rows.get(i);
|
// List<String> elements = rows.get(i);
|
||||||
TableRow newRow = new TableRow(getActivity());
|
// TableRow newRow = new TableRow(getActivity());
|
||||||
for (int j = 0; j < elements.size(); j++) { // elements.size can be the same as in header so maybe some one number or not
|
// for (int j = 0; j < elements.size(); j++) { // elements.size can be the same as in header so maybe some one number or not
|
||||||
TextView textView = new TextView(getActivity());
|
// TextView textView = new TextView(getActivity());
|
||||||
textView.setText(elements.get(j));
|
// textView.setText(elements.get(j));
|
||||||
textView.setLayoutParams(layoutParams);
|
// textView.setLayoutParams(layoutParams);
|
||||||
textView.setPadding(ENTRIES_PADDING_LEFT, ENTRIES_PADDING_TOP, ENTRIES_PADDING_RIGHT, ENTRIES_PADDING_BOTTOM);
|
// textView.setPadding(ENTRIES_PADDING_LEFT, ENTRIES_PADDING_TOP, ENTRIES_PADDING_RIGHT, ENTRIES_PADDING_BOTTOM);
|
||||||
textView.setBackgroundResource(R.drawable.background_element);
|
// textView.setBackgroundResource(R.drawable.background_element);
|
||||||
newRow.addView(textView);
|
// newRow.addView(textView);
|
||||||
}
|
// }
|
||||||
entriesTable.addView(newRow);
|
// entriesTable.addView(newRow);
|
||||||
|
//
|
||||||
syncWidths();
|
// syncWidths();
|
||||||
fakeScroll();
|
// fakeScroll();
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
TextView errorMessage = new TextView(getActivity());
|
// TextView errorMessage = new TextView(getActivity());
|
||||||
errorMessage.setText(R.string.error_no_entries);
|
// errorMessage.setText(R.string.error_no_entries);
|
||||||
errorMessage.setTypeface(null, Typeface.ITALIC);
|
// errorMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
errorMessage.setClickable(false);
|
// errorMessage.setClickable(false);
|
||||||
entriesScrollView.removeView(entriesTable);
|
// entriesScrollView.removeView(entriesTable);
|
||||||
headerFrame.setVisibility(View.VISIBLE);
|
// headerFrame.setVisibility(View.VISIBLE);
|
||||||
entriesScrollView.addView(errorMessage);
|
// entriesScrollView.addView(errorMessage);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
setLoading(false);
|
// setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onListReturn(List<String> fieldList) {
|
public void onListReturn(List<String> fieldList) {
|
||||||
// First we need header
|
// // First we need header
|
||||||
headerRow = new TableRow(getActivity());
|
// headerRow = new TableRow(getActivity());
|
||||||
headerRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
|
// headerRow.setLayoutParams(new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT));
|
||||||
for(int i =0;i<fieldList.size();i++){
|
// for(int i =0;i<fieldList.size();i++){
|
||||||
TextView textView = new TextView(getActivity());
|
// TextView textView = new TextView(getActivity());
|
||||||
textView.setText(fieldList.get(i));
|
// textView.setText(fieldList.get(i));
|
||||||
textView.setTypeface(null, Typeface.BOLD);
|
// textView.setTypeface(null, Typeface.BOLD);
|
||||||
textView.setLayoutParams(layoutParams);
|
// textView.setLayoutParams(layoutParams);
|
||||||
textView.setBackgroundResource(R.drawable.background_header);
|
// textView.setBackgroundResource(R.drawable.background_header);
|
||||||
textView.setPadding(HEADER_PADDING_LEFT, HEADER_PADDING_TOP, HEADER_PADDING_RIGHT, HEADER_PADDING_BOTTOM);
|
// textView.setPadding(HEADER_PADDING_LEFT, HEADER_PADDING_TOP, HEADER_PADDING_RIGHT, HEADER_PADDING_BOTTOM);
|
||||||
headerRow.addView(textView);
|
// headerRow.addView(textView);
|
||||||
}
|
// }
|
||||||
headerFrame.addView(headerRow);
|
// headerFrame.addView(headerRow);
|
||||||
|
//
|
||||||
Static.asyncDatabaseConnector.getRows(tableName, entriesLimit, page);
|
// Static.asyncDatabaseConnector.getRows(tableName, entriesLimit, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -13,12 +14,15 @@ import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
import javax.crypto.IllegalBlockSizeException;
|
import javax.crypto.IllegalBlockSizeException;
|
||||||
|
@ -29,7 +33,7 @@ import info.nerull7.mysqlbrowser.db.AsyncDatabaseConnector;
|
||||||
/**
|
/**
|
||||||
* Created by nerull7 on 07.07.14.
|
* Created by nerull7 on 07.07.14.
|
||||||
*/
|
*/
|
||||||
public class LoginFragment extends Fragment implements View.OnClickListener, AsyncDatabaseConnector.BooleanReturnListener {
|
public class LoginFragment extends Fragment implements View.OnClickListener, AsyncDatabaseConnector.BooleanReturnListener, AsyncDatabaseConnector.ListReturnListener {
|
||||||
private EditText urlTextbox;
|
private EditText urlTextbox;
|
||||||
private EditText loginTextbox;
|
private EditText loginTextbox;
|
||||||
private EditText passwordTextbox;
|
private EditText passwordTextbox;
|
||||||
|
@ -94,8 +98,8 @@ public class LoginFragment extends Fragment implements View.OnClickListener, Asy
|
||||||
public void onBooleanReturn(boolean result) {
|
public void onBooleanReturn(boolean result) {
|
||||||
if(result) {
|
if(result) {
|
||||||
Static.asyncDatabaseConnector = asyncDatabaseConnector;
|
Static.asyncDatabaseConnector = asyncDatabaseConnector;
|
||||||
Intent intent = new Intent(getActivity(), DatabaseActivity.class);
|
Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||||
startActivity(intent);
|
Static.asyncDatabaseConnector.getDatabases();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
@ -115,4 +119,25 @@ public class LoginFragment extends Fragment implements View.OnClickListener, Asy
|
||||||
loginButton.setEnabled(true); // Now we can click button again
|
loginButton.setEnabled(true); // Now we can click button again
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
progressBar.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListReturn(List<String> databases) {
|
||||||
|
if(databases!= null) {
|
||||||
|
Static.databases = databases;
|
||||||
|
|
||||||
|
Intent intent = new Intent(getActivity(), DatabaseActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
// listAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, databases);
|
||||||
|
// databasesListView.setAdapter(listAdapter);
|
||||||
|
// databasesListView.setOnItemClickListener(this);
|
||||||
|
// } else {
|
||||||
|
// TextView errorMessage = new TextView(getActivity());
|
||||||
|
// errorMessage.setText(R.string.error_no_databases);
|
||||||
|
// errorMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
|
// errorMessage.setClickable(false);
|
||||||
|
// rootView.addView(errorMessage);
|
||||||
|
// rootView.removeView(databasesListView);
|
||||||
|
// }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package info.nerull7.mysqlbrowser;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import info.nerull7.mysqlbrowser.db.AsyncDatabaseConnector;
|
import info.nerull7.mysqlbrowser.db.AsyncDatabaseConnector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +15,11 @@ public class Static {
|
||||||
public static final String TABLE_NAME_ARG = "TableName";
|
public static final String TABLE_NAME_ARG = "TableName";
|
||||||
|
|
||||||
public static AsyncDatabaseConnector asyncDatabaseConnector = null;
|
public static AsyncDatabaseConnector asyncDatabaseConnector = null;
|
||||||
|
static List<String> tables;
|
||||||
|
static List<String> databases;
|
||||||
|
static List<String> header;
|
||||||
|
static List<List<String>> entries;
|
||||||
|
static int pageCount;
|
||||||
|
|
||||||
public static void startSettings(Context context){
|
public static void startSettings(Context context){
|
||||||
Intent intent = new Intent(context, SettingsActivity.class);
|
Intent intent = new Intent(context, SettingsActivity.class);
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Fragment;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -23,13 +24,16 @@ import info.nerull7.mysqlbrowser.db.AsyncDatabaseConnector;
|
||||||
/**
|
/**
|
||||||
* Created by nerull7 on 14.07.14.
|
* Created by nerull7 on 14.07.14.
|
||||||
*/
|
*/
|
||||||
public class TableFragment extends Fragment implements AdapterView.OnItemClickListener, AsyncDatabaseConnector.ListReturnListener{
|
public class TableFragment extends Fragment implements AdapterView.OnItemClickListener, AsyncDatabaseConnector.ListReturnListener, AsyncDatabaseConnector.IntegerReturnListener, AsyncDatabaseConnector.MatrixReturnListener {
|
||||||
private String databaseName;
|
private String databaseName;
|
||||||
private ListView tablesList;
|
private ListView tablesList;
|
||||||
private ListAdapter listAdapter;
|
private ListAdapter listAdapter;
|
||||||
private RelativeLayout rootView;
|
private RelativeLayout rootView;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
|
|
||||||
|
private int listenerCalled;
|
||||||
|
private String chosenTable;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
@ -38,25 +42,12 @@ public class TableFragment extends Fragment implements AdapterView.OnItemClickLi
|
||||||
tablesList = (ListView) rootView.findViewById(R.id.tableList);
|
tablesList = (ListView) rootView.findViewById(R.id.tableList);
|
||||||
this.rootView = (RelativeLayout) rootView;
|
this.rootView = (RelativeLayout) rootView;
|
||||||
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
progressBar = (ProgressBar) rootView.findViewById(R.id.loginProgressBar);
|
||||||
Static.asyncDatabaseConnector.setListReturnListener(this);
|
listenerCalled = 0;
|
||||||
Static.asyncDatabaseConnector.getTables();
|
// Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||||
return rootView;
|
// Static.asyncDatabaseConnector.getTables();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if(Static.tables != null) {
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
listAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, Static.tables);
|
||||||
String chosenTable = (String) listAdapter.getItem(position);
|
|
||||||
listAdapter.getItem(position);
|
|
||||||
Intent intent = new Intent(getActivity(), EntriesActivity.class);
|
|
||||||
intent.putExtra(Static.DATABASE_NAME_ARG,databaseName);
|
|
||||||
intent.putExtra(Static.TABLE_NAME_ARG,chosenTable);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onListReturn(List<String> tables) {
|
|
||||||
if(tables != null) {
|
|
||||||
listAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, tables);
|
|
||||||
tablesList.setAdapter(listAdapter);
|
tablesList.setAdapter(listAdapter);
|
||||||
tablesList.setOnItemClickListener(this);
|
tablesList.setOnItemClickListener(this);
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,9 +55,73 @@ public class TableFragment extends Fragment implements AdapterView.OnItemClickLi
|
||||||
errorMessage.setText(R.string.error_no_tables);
|
errorMessage.setText(R.string.error_no_tables);
|
||||||
errorMessage.setTypeface(null, Typeface.ITALIC);
|
errorMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
errorMessage.setClickable(false);
|
errorMessage.setClickable(false);
|
||||||
rootView.addView(errorMessage);
|
this.rootView.addView(errorMessage);
|
||||||
rootView.removeView(tablesList);
|
this.rootView.removeView(tablesList);
|
||||||
}
|
}
|
||||||
progressBar.setVisibility(View.INVISIBLE);
|
progressBar.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
return rootView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||||
|
chosenTable = (String) listAdapter.getItem(position);
|
||||||
|
listAdapter.getItem(position);
|
||||||
|
|
||||||
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
Static.asyncDatabaseConnector.setIntegerReturnListener(this);
|
||||||
|
Static.asyncDatabaseConnector.setListReturnListener(this);
|
||||||
|
Static.asyncDatabaseConnector.setMatrixReturnListener(this);
|
||||||
|
|
||||||
|
int entriesLimit = PreferenceManager.getDefaultSharedPreferences(getActivity()).getInt(SettingsFragment.ENTRIES_PAGE_LIMIT, SettingsFragment.ENTRIES_PAGE_LIMIT_DEF);
|
||||||
|
|
||||||
|
Static.asyncDatabaseConnector.getRows(chosenTable, entriesLimit, 1);
|
||||||
|
Static.asyncDatabaseConnector.getFields(chosenTable);
|
||||||
|
Static.asyncDatabaseConnector.getEntriesCount(chosenTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onListReturn(List<String> header) {
|
||||||
|
// if(tables != null) {
|
||||||
|
// listAdapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1, tables);
|
||||||
|
// tablesList.setAdapter(listAdapter);
|
||||||
|
// tablesList.setOnItemClickListener(this);
|
||||||
|
// } else {
|
||||||
|
// TextView errorMessage = new TextView(getActivity());
|
||||||
|
// errorMessage.setText(R.string.error_no_tables);
|
||||||
|
// errorMessage.setTypeface(null, Typeface.ITALIC);
|
||||||
|
// errorMessage.setClickable(false);
|
||||||
|
// rootView.addView(errorMessage);
|
||||||
|
// rootView.removeView(tablesList);
|
||||||
|
// }
|
||||||
|
// progressBar.setVisibility(View.INVISIBLE);
|
||||||
|
Static.header = header;
|
||||||
|
listenerCalled++;
|
||||||
|
if(listenerCalled==3)
|
||||||
|
startEntriesActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onIntegerReturn(int result) {
|
||||||
|
Static.pageCount = result;
|
||||||
|
listenerCalled++;
|
||||||
|
if(listenerCalled==3)
|
||||||
|
startEntriesActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onMatrixReturn(List<List<String>> data) {
|
||||||
|
Static.entries = data;
|
||||||
|
listenerCalled++;
|
||||||
|
if(listenerCalled==3)
|
||||||
|
startEntriesActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void startEntriesActivity() {
|
||||||
|
Intent intent = new Intent(getActivity(), EntriesActivity.class);
|
||||||
|
intent.putExtra(Static.DATABASE_NAME_ARG,databaseName);
|
||||||
|
intent.putExtra(Static.TABLE_NAME_ARG,chosenTable);
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue