-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
incorporate activities managements into controllers
- Loading branch information
1 parent
73812bb
commit 5333a26
Showing
4 changed files
with
76 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 34 additions & 29 deletions
63
app/src/main/java/org/pacemaker/controllers/CreateActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,68 @@ | ||
package org.pacemaker.controllers; | ||
|
||
import android.content.Intent; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.widget.Toast; | ||
import org.pacemaker.R; | ||
import org.pacemaker.http.Response; | ||
import org.pacemaker.main.PacemakerApp; | ||
import org.pacemaker.models.MyActivity; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.widget.NumberPicker; | ||
import android.widget.TextView; | ||
import org.pacemaker.main.PacemakerApp; | ||
import org.pacemaker.models.MyActivity; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.pacemaker.R; | ||
|
||
public class CreateActivity extends AppCompatActivity | ||
{ | ||
public class CreateActivity extends android.app.Activity implements Response<MyActivity> { | ||
private PacemakerApp app; | ||
|
||
private Button createActivityButton; | ||
private TextView activityType; | ||
private TextView activityLocation; | ||
private Button createActivityButton; | ||
private TextView activityType; | ||
private TextView activityLocation; | ||
private NumberPicker distancePicker; | ||
|
||
private ArrayList<MyActivity> activities = new ArrayList<MyActivity>(); | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) | ||
{ | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_create); | ||
|
||
app = (PacemakerApp) getApplication(); | ||
|
||
createActivityButton = (Button) findViewById(R.id.createActivityButton); | ||
activityType = (TextView) findViewById(R.id.activityType); | ||
activityLocation = (TextView) findViewById(R.id.activityLocation); | ||
distancePicker = (NumberPicker) findViewById(R.id.numberPicker); | ||
createActivityButton = (Button) findViewById(R.id.createActivityButton); | ||
activityType = (TextView) findViewById(R.id.activityType); | ||
activityLocation = (TextView) findViewById(R.id.activityLocation); | ||
distancePicker = (NumberPicker) findViewById(R.id.numberPicker); | ||
|
||
distancePicker.setMinValue(0); | ||
distancePicker.setMaxValue(20); | ||
|
||
Log.v("Pacemaker", "got the CreateActivity button"); | ||
} | ||
|
||
public void createActivityButtonPressed (View view) | ||
{ | ||
public void createActivityButtonPressed(View view) { | ||
double distance = distancePicker.getValue(); | ||
MyActivity activity = new MyActivity (activityType.getText().toString(), activityLocation.getText().toString(), distance); | ||
MyActivity activity = new MyActivity(activityType.getText().toString(), activityLocation.getText().toString(), distance); | ||
|
||
app.createActivity(this, activity, this); | ||
} | ||
|
||
@Override | ||
public void setResponse(List<MyActivity> aList) { | ||
} | ||
|
||
app.createActivity(activity); | ||
Log.v("Pacemaker", "CreateActivity Button Pressed with " + distance); | ||
@Override | ||
public void setResponse(MyActivity anObject) { | ||
} | ||
|
||
@Override | ||
public void errorOccurred(Exception e) { | ||
Toast toast = Toast.makeText(this, "Failed to create Activity", Toast.LENGTH_SHORT); | ||
toast.show(); | ||
} | ||
|
||
public void listActivityButtonPressed (View view) | ||
{ | ||
Log.v("Pacemaker", "List Activityies Button Pressed"); | ||
Intent intent = new Intent(this, ActivitiesList.class); | ||
startActivity (intent); | ||
Log.v("Pacemaker", "List Activities Button Pressed"); | ||
startActivity (new Intent(this, ActivitiesList.class)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters