-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
00d3195
commit d526d88
Showing
9 changed files
with
167 additions
and
0 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
61 changes: 61 additions & 0 deletions
61
app/src/main/java/org/mmaug/InfoCenter/activities/AddContactActivity.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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package org.mmaug.InfoCenter.activities; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.text.TextUtils; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
import butterknife.Bind; | ||
import butterknife.ButterKnife; | ||
import mmaug.org.yaybay.R; | ||
import org.mmaug.InfoCenter.model.News; | ||
import org.mmaug.InfoCenter.rest.client.RESTClient; | ||
import retrofit.Callback; | ||
import retrofit.RetrofitError; | ||
import retrofit.client.Response; | ||
|
||
/** | ||
* @author SH ([email protected]) | ||
*/ | ||
public class AddContactActivity extends AppCompatActivity { | ||
@Bind(R.id.edt_title) EditText edtTitle; | ||
@Bind(R.id.edt_fb_url) EditText edtFbUrl; | ||
@Bind(R.id.edt_contact_number) EditText edtContactNumber; | ||
@Bind(R.id.edt_detail) EditText edtDetail; | ||
@Bind(R.id.edt_donation_location) EditText edtLocation; | ||
|
||
@Override public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_add_contact); | ||
ButterKnife.bind(this); | ||
} | ||
|
||
public void onSubmit(View view) { | ||
if (TextUtils.isEmpty(edtTitle.getText()) | ||
|| TextUtils.isEmpty(edtFbUrl.getText()) | ||
|| TextUtils.isEmpty(edtContactNumber.getText())) { | ||
Toast.makeText(this, "Please write at least contact number", Toast.LENGTH_LONG).show(); | ||
} else { | ||
Toast.makeText(getApplicationContext(), "Loading...", Toast.LENGTH_SHORT).show(); | ||
String title = edtTitle.getText().toString(); | ||
String fb = edtFbUrl.getText().toString(); | ||
String content = edtDetail.getText().toString(); | ||
String ph = edtContactNumber.getText().toString(); | ||
String location = edtLocation.getText().toString(); | ||
|
||
RESTClient.getInstance() | ||
.getService() | ||
.submitContact(title, content, fb, location, ph, new Callback<News>() { | ||
@Override public void success(News news, Response response) { | ||
Toast.makeText(getApplicationContext(), "Submitted", Toast.LENGTH_SHORT).show(); | ||
finish(); | ||
} | ||
|
||
@Override public void failure(RetrofitError error) { | ||
|
||
} | ||
}); | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<EditText | ||
android:id="@+id/edt_title" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/hint_title" | ||
android:minLines="3" /> | ||
|
||
<EditText | ||
android:id="@+id/edt_fb_url" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/hint_fb_url" | ||
android:inputType="textUri" /> | ||
|
||
<EditText | ||
android:id="@+id/edt_contact_number" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/hint_contact_numbers" | ||
android:minLines="3" /> | ||
|
||
<EditText | ||
android:id="@+id/edt_detail" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/hint_detail" | ||
android:minLines="5" /> | ||
|
||
<EditText | ||
android:id="@+id/edt_donation_location" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:hint="@string/hint_location" | ||
android:minLines="5" /> | ||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="right" | ||
android:onClick="onSubmit" | ||
android:text="@string/btn_submit" /> | ||
|
||
</LinearLayout> | ||
</ScrollView> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
<item | ||
android:id="@+id/action_add" | ||
android:title="Add Contact" | ||
app:showAsAction="always" /> | ||
</menu> |
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