Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
ext {
supportLibraryVersion = '25.3.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.databinding.DataBindingUtil;
import android.widget.Toast;

import in.tosc.digitaloceanapp.R;
import in.tosc.digitaloceanapp.activities.DropletCreateActivity;
import in.tosc.digitaloceanapp.databinding.FragmentAdditionalDetailsBinding;
import in.tosc.doandroidlib.DigitalOcean;
import in.tosc.doandroidlib.api.DigitalOceanClient;
import in.tosc.doandroidlib.objects.Droplet;
Expand All @@ -31,11 +30,7 @@
public class AdditionalDetailsFragment extends Fragment {

public static final String TAG = "AdditionalFragment";
CheckBox cbPrivateNetworking;
CheckBox cbBackups;
CheckBox cbIpv6;
EditText etDropletName;
Button btnCreateDroplet;
private FragmentAdditionalDetailsBinding binding;

public AdditionalDetailsFragment() {
// Required empty public constructor
Expand All @@ -46,17 +41,14 @@ public AdditionalDetailsFragment() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_additional_details, container, false);
cbPrivateNetworking = (CheckBox) view.findViewById(R.id.networkingCheckBox);
cbBackups = (CheckBox) view.findViewById(R.id.backupsCheckBox);
cbIpv6 = (CheckBox) view.findViewById(R.id.ipv6CheckBox);
etDropletName = (EditText) view.findViewById(R.id.etDropletName);
btnCreateDroplet = (Button) view.findViewById(R.id.btnCreateDroplet);
binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_additional_details, container, false);

setAdditionalOptions();
btnCreateDroplet.setOnClickListener(new View.OnClickListener() {
binding.btnCreateDroplet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String dropletName = etDropletName.getText().toString();
String dropletName = binding.etDropletName.getText().toString();
if (dropletName.equals("")) {
Toast.makeText(getContext(), "Droplet Name is Required", Toast.LENGTH_SHORT).show();
} else {
Expand Down Expand Up @@ -96,12 +88,14 @@ public void onFailure(Call<Droplet> call, Throwable t) {
}
}
});
return view;

return binding.getRoot();
}


public void setAdditionalOptions() {
cbPrivateNetworking.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
binding.networkingCheckBox.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Expand All @@ -112,7 +106,8 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
}
});
cbIpv6.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
binding.ipv6CheckBox.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Expand All @@ -123,7 +118,8 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
}
});
cbBackups.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
binding.backupsCheckBox.setOnCheckedChangeListener(
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package in.tosc.digitaloceanapp.fragments;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.databinding.DataBindingUtil;
import android.view.ViewGroup;

import in.tosc.digitaloceanapp.R;
import in.tosc.digitaloceanapp.adapters.DataCenterAdapter;
import in.tosc.digitaloceanapp.databinding.FragmentSelectDataCenterBinding;
import in.tosc.doandroidlib.DigitalOcean;
import in.tosc.doandroidlib.api.DigitalOceanClient;
import in.tosc.doandroidlib.objects.Regions;
Expand Down Expand Up @@ -39,17 +39,18 @@ public DataCenterFragment() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_select_data_center, container, false);
final RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.datacenter_recycler);
recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 2));
final FragmentSelectDataCenterBinding binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_select_data_center, container, false);

binding.datacenterRecycler.setLayoutManager(new GridLayoutManager(getActivity(), 2));
DigitalOceanClient doClient = DigitalOcean.getDOClient(getContext().getSharedPreferences("DO", MODE_PRIVATE).getString("authToken", null));
recyclerView.setAdapter(dataCenterAdapter);
binding.datacenterRecycler.setAdapter(dataCenterAdapter);
doClient.getRegions().enqueue(new Callback<Regions>() {
@Override
public void onResponse(Call<Regions> call, Response<Regions> response) {
Regions regions = response.body();
DataCenterAdapter dataCenterAdapter = new DataCenterAdapter(regions, getActivity());
recyclerView.setAdapter(dataCenterAdapter);
binding.datacenterRecycler.setAdapter(dataCenterAdapter);
dataCenterAdapter.notifyDataSetChanged();
Log.i(TAG, "onResponse: " + regions.getRegions().size() + " Regions Fetched Successfully!");
}
Expand All @@ -60,7 +61,7 @@ public void onFailure(Call<Regions> call, Throwable t) {
}
});

return view;
return binding.getRoot();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.databinding.DataBindingUtil;
import android.view.ViewGroup;

import in.tosc.digitaloceanapp.databinding.FragmentImageBinding;
import java.util.List;

import in.tosc.digitaloceanapp.R;
Expand All @@ -27,7 +28,6 @@ public class SelectImageFragment extends Fragment {

public static List<Image> imageList;
ImageAdapter imageAdapter;
RecyclerView imageRecyclerView;

public SelectImageFragment() {

Expand All @@ -43,18 +43,19 @@ public void onCreate(Bundle savedInstanceState) {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_image, container, false);
final FragmentImageBinding binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_image, container, false);

DigitalOceanClient doClient = DigitalOcean.getDOClient(getContext().getSharedPreferences("DO", MODE_PRIVATE).getString("authToken", null));
imageRecyclerView = (RecyclerView) view.findViewById(R.id.imageRecyclerVIew);
imageRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 3));
imageRecyclerView.setAdapter(imageAdapter);
binding.imageRecyclerVIew.setLayoutManager(new GridLayoutManager(getContext(), 3));
binding.imageRecyclerVIew.setAdapter(imageAdapter);

doClient.getImages(1, 100, "distribution").enqueue(new Callback<Images>() {
@Override
public void onResponse(Call<Images> call, Response<Images> response) {
imageList = response.body().getImages();
imageAdapter = new ImageAdapter(imageList, getContext());
imageRecyclerView.setAdapter(imageAdapter);
binding.imageRecyclerVIew.setAdapter(imageAdapter);
Log.e("Droplets fetched", String.valueOf(imageList.size()));
}

Expand All @@ -63,6 +64,7 @@ public void onFailure(Call<Images> call, Throwable t) {
Log.e("Failed getting images", t.getLocalizedMessage());
}
});
return view;

return binding.getRoot();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import in.tosc.digitaloceanapp.databinding.FragmentSizeBinding;
import android.view.ViewGroup;

import android.databinding.DataBindingUtil;
import java.util.List;

import in.tosc.digitaloceanapp.R;
Expand All @@ -31,24 +32,23 @@
public class SelectSizeFragment extends Fragment{

private List<Size> sizeList;
private RecyclerView recyclerView;
private SelectSizeAdapter selectSizeAdapter;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable final ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_size, container, false);
final FragmentSizeBinding binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_size, container, false);

DigitalOceanClient doClient = DigitalOcean.getDOClient(getContext().getSharedPreferences("DO", MODE_PRIVATE).getString("authToken",null));
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView_size);
recyclerView.setLayoutManager(new GridLayoutManager(getContext(),1));
recyclerView.setAdapter(selectSizeAdapter);
binding.recyclerViewSize.setLayoutManager(new GridLayoutManager(getContext(),1));
binding.recyclerViewSize.setAdapter(selectSizeAdapter);
doClient.getSizes().enqueue(new Callback<Sizes>() {
@Override
public void onResponse(Call<Sizes> call, Response<Sizes> response) {
sizeList = response.body().getSizes();
selectSizeAdapter = new SelectSizeAdapter(sizeList, getContext());
recyclerView.setAdapter(selectSizeAdapter);
binding.recyclerViewSize.setAdapter(selectSizeAdapter);
Log.e("Sizes fetched", String.valueOf(sizeList.size()));
}

Expand All @@ -57,7 +57,8 @@ public void onFailure(Call<Sizes> call, Throwable t) {
Log.e("Failed getting sizes",t.getLocalizedMessage());
}
});
return view;

return binding.getRoot();

}
}
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_additional_details.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
>
Expand Down Expand Up @@ -93,4 +93,5 @@
android:theme="@style/resize"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</RelativeLayout>
</layout>
7 changes: 4 additions & 3 deletions app/src/main/res/layout/fragment_image.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.RecyclerView
android:id="@+id/imageRecyclerVIew"
android:name="in.tosc.digitaloceanapp.fragments.SelectImageFragment"
android:layout_width="match_parent"
Expand All @@ -11,4 +12,4 @@
app:layoutManager="LinearLayoutManager"
tools:context="in.tosc.digitaloceanapp.fragments.SelectImageFragment"
tools:listitem="@layout/fragment_image" />
</layout>
7 changes: 4 additions & 3 deletions app/src/main/res/layout/fragment_select_data_center.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- TODO: Update blank fragment layout -->
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v7.widget.RecyclerView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/datacenter_recycler"
xmlns:android="http://schemas.android.com/apk/res/android">
</android.support.v7.widget.RecyclerView>
android:id="@+id/datacenter_recycler">
</android.support.v7.widget.RecyclerView>
</layout>
9 changes: 5 additions & 4 deletions app/src/main/res/layout/fragment_size.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView_size"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.tosc.digitaloceanapp.fragments.SelectSizeFragment">

</android.support.v7.widget.RecyclerView>
</android.support.v7.widget.RecyclerView>
</layout>