Add Server and Volume fragments
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.rcarrillocruz.android.openstackdroid;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ServerDetailsFragment extends Fragment {
|
||||
|
||||
public static final String[] SERVER_DETAILS = {
|
||||
"LOLSERVER1",
|
||||
"SADASD",
|
||||
"ERWER"
|
||||
};
|
||||
|
||||
public static ServerDetailsFragment newInstance(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
ServerDetailsFragment f = new ServerDetailsFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("position", position);
|
||||
f.setArguments(args);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public int getShownIndex() {
|
||||
// TODO Auto-generated method stub
|
||||
return getArguments().getInt("position", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
ScrollView scroller = new ScrollView(getActivity());
|
||||
TextView text = new TextView(getActivity());
|
||||
int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||
4, getActivity().getResources().getDisplayMetrics());
|
||||
text.setPadding(padding, padding, padding, padding);
|
||||
scroller.addView(text);
|
||||
text.setText(SERVER_DETAILS[getShownIndex()]);
|
||||
|
||||
return scroller;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.rcarrillocruz.android.openstackdroid;
|
||||
|
||||
import android.app.FragmentTransaction;
|
||||
import android.app.ListFragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class ServerListFragment extends ListFragment {
|
||||
String[] servers = new String[] {
|
||||
"webserver",
|
||||
"oracle",
|
||||
"proxy"
|
||||
};
|
||||
int mCurCheckPosition = 0;
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1, servers));
|
||||
|
||||
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
showDetails(position);
|
||||
}
|
||||
|
||||
private void showDetails(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
mCurCheckPosition = position;
|
||||
getListView().setItemChecked(position, true);
|
||||
|
||||
ServerDetailsFragment sdf = (ServerDetailsFragment) ((CloudBrowserActivity) getActivity()).getmServerDetailsFragment();
|
||||
|
||||
if (sdf == null || sdf.getShownIndex() != position)
|
||||
sdf = ServerDetailsFragment.newInstance(position);
|
||||
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.item_details, sdf);
|
||||
//ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
ft.commit();
|
||||
|
||||
/* mCurCheckPosition = position;
|
||||
getListView().setItemChecked(position, true);
|
||||
|
||||
ServerDetailsFragment df = (ServerDetailsFragment) getFragmentManager().findFragmentById(R.id.item_details);
|
||||
|
||||
if (df == null || df.getShownIndex() != position) {
|
||||
df = ServerDetailsFragment.newInstance(position);
|
||||
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.item_details, df);
|
||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
ft.commit();
|
||||
} */
|
||||
|
||||
((CloudBrowserActivity) getActivity()).showDetailsLayout();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.rcarrillocruz.android.openstackdroid;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class VolumeDetailsFragment extends Fragment {
|
||||
|
||||
public static final String[] VOLUME_DETAILS = {
|
||||
"10G",
|
||||
"2G",
|
||||
"40G"
|
||||
};
|
||||
|
||||
public static VolumeDetailsFragment newInstance(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
VolumeDetailsFragment f = new VolumeDetailsFragment();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("position", position);
|
||||
f.setArguments(args);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public int getShownIndex() {
|
||||
// TODO Auto-generated method stub
|
||||
return getArguments().getInt("position", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
|
||||
ScrollView scroller = new ScrollView(getActivity());
|
||||
TextView text = new TextView(getActivity());
|
||||
int padding = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||
4, getActivity().getResources().getDisplayMetrics());
|
||||
text.setPadding(padding, padding, padding, padding);
|
||||
scroller.addView(text);
|
||||
text.setText(VOLUME_DETAILS[getShownIndex()]);
|
||||
|
||||
return scroller;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.rcarrillocruz.android.openstackdroid;
|
||||
|
||||
import android.app.ListFragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
public class VolumeFragment extends ListFragment {
|
||||
String[] volumes = new String[] {
|
||||
"/static",
|
||||
"/photos",
|
||||
"/icons"
|
||||
};
|
||||
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity().getBaseContext(), android.R.layout.simple_list_item_multiple_choice, volumes);
|
||||
|
||||
setListAdapter(adapter);
|
||||
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.rcarrillocruz.android.openstackdroid;
|
||||
|
||||
import android.app.FragmentTransaction;
|
||||
import android.app.ListFragment;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
|
||||
public class VolumeListFragment extends ListFragment {
|
||||
String[] volumes = new String[] {
|
||||
"/var",
|
||||
"/static",
|
||||
"/opt"
|
||||
};
|
||||
int mCurCheckPosition = 0;
|
||||
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
// TODO Auto-generated method stub
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
setListAdapter(new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_activated_1, volumes));
|
||||
|
||||
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
|
||||
|
||||
}
|
||||
|
||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||
// TODO Auto-generated method stub
|
||||
((CloudBrowserActivity) getActivity()).setDetailEnabled(true);
|
||||
|
||||
showDetails(position);
|
||||
}
|
||||
|
||||
private void showDetails(int position) {
|
||||
// TODO Auto-generated method stub
|
||||
mCurCheckPosition = position;
|
||||
getListView().setItemChecked(position, true);
|
||||
|
||||
VolumeDetailsFragment vdf = (VolumeDetailsFragment) ((CloudBrowserActivity) getActivity()).getmVolumeDetailsFragment();
|
||||
|
||||
if (vdf == null || vdf.getShownIndex() != position)
|
||||
vdf = VolumeDetailsFragment.newInstance(position);
|
||||
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.item_details, vdf);
|
||||
//ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
ft.commit();
|
||||
|
||||
/*VolumeDetailsFragment df = (VolumeDetailsFragment) getFragmentManager().findFragmentById(R.id.item_details);
|
||||
|
||||
if (df == null || df.getShownIndex() != position) {
|
||||
df = VolumeDetailsFragment.newInstance(position);
|
||||
|
||||
FragmentTransaction ft = getFragmentManager().beginTransaction();
|
||||
ft.replace(R.id.item_details, df);
|
||||
ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
|
||||
ft.commit();
|
||||
}*/
|
||||
|
||||
((CloudBrowserActivity) getActivity()).showDetailsLayout();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user