Commit 0d89253f authored by DEEPAK VERMA's avatar DEEPAK VERMA

Parsing and putting done.

Save and Discard button have to add.
parent 520ed45a
...@@ -132,16 +132,18 @@ public class ReminderEditActivity extends AppCompatActivity { ...@@ -132,16 +132,18 @@ public class ReminderEditActivity extends AppCompatActivity {
// Get reminder using reminder id // Get reminder using reminder id
rb = new ReminderDatabase(this); rb = new ReminderDatabase(this);
Intent intent = getIntent();
/*Intent intent = getIntent();
if(intent.getType().equals("text/"+Utility.FILE_EXTENSION)){ if(intent.getType().equals("text/"+Utility.FILE_EXTENSION)){
mReceivedReminder.setTitle(intent.getStringExtra("mTitle")); mReceivedReminder.setTitle(intent.getStringExtra("mTitle"));
System.out.println("**********************************"); System.out.println("**********************************");
System.out.println(mReceivedReminder.getTitle()); System.out.println(mReceivedReminder.getTitle());
System.out.println("**********************************"); System.out.println("**********************************");
} }
else { else {*/
// Get reminder id from intent
mReceivedReminder = rb.getReminder(mReceivedID); mReceivedReminder = rb.getReminder(mReceivedID);
} //}
// Get values from reminder // Get values from reminder
mTitle = mReceivedReminder.getTitle(); mTitle = mReceivedReminder.getTitle();
......
...@@ -7,14 +7,21 @@ import android.content.Context; ...@@ -7,14 +7,21 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStream; import java.io.InputStream;
public class ReminderReceiveActivity extends AppCompatActivity { public class ReminderReceiveActivity extends AppCompatActivity {
private Toolbar mToolbar; private Toolbar mToolbar;
private EditText mTitleText;
private TextView mDateText, mTimeText, mRepeatText, mRepeatNoText, mRepeatTypeText;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -28,24 +35,50 @@ public class ReminderReceiveActivity extends AppCompatActivity { ...@@ -28,24 +35,50 @@ public class ReminderReceiveActivity extends AppCompatActivity {
//Get the file from intent //Get the file from intent
Intent intent = getIntent(); Intent intent = getIntent();
Uri fileUri = intent.getData(); Uri fileUri = intent.getData();
StringBuilder reminderJson=new StringBuilder();
if (intent.getType().equals("text/"+Utility.FILE_EXTENSION)) { if (intent.getType().equals("text/"+Utility.FILE_EXTENSION)) {
try { try {
InputStream in = getContentResolver().openInputStream(fileUri); InputStream in = getContentResolver().openInputStream(fileUri);
int i; int i;
StringBuilder sb = new StringBuilder();
while ((i=in.read()) != -1) while ((i=in.read()) != -1)
sb.append((char)i); reminderJson.append((char)i);
System.out.println("******************************************************************"); //System.out.println("******************************************************************");
System.out.println(sb.toString()); //System.out.println(sb.toString());
System.out.println("******************************************************************"); //System.out.println("******************************************************************");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
Intent senderIntent = new Intent(context, ReminderEditActivity.class); try {
JSONObject obj = new JSONObject(reminderJson.toString());
//Reminder talkingReminder=new Reminder();
mTitleText = (EditText) findViewById(R.id.reminder_title);
mDateText = (TextView) findViewById(R.id.set_date);
mTimeText = (TextView) findViewById(R.id.set_time);
mRepeatText = (TextView) findViewById(R.id.set_repeat);
mRepeatNoText = (TextView) findViewById(R.id.set_repeat_no);
mRepeatTypeText = (TextView) findViewById(R.id.set_repeat_type);
mTitleText.setText(obj.getString("mTitle"));
mDateText.setText(obj.getString("mDate"));
mTimeText.setText(obj.getString("mTime"));
mRepeatText.setText("Every "+obj.getString("mRepeatNo")+" "+ obj.getString("mRepeatType")+"(s)");
mRepeatNoText.setText(obj.getString("mRepeatNo"));
mRepeatTypeText.setText(obj.getString("mRepeatType"));
}
catch (Throwable t){
t.printStackTrace();
}
/*Intent senderIntent = new Intent(context, ReminderEditActivity.class);
senderIntent.putExtra("received", true); senderIntent.putExtra("received", true);
senderIntent.putExtra("mTitle", "First Receive Reminder test"); senderIntent.putExtra("mTitle", "First Receive Reminder test");
startActivity(senderIntent); startActivity(senderIntent);*/
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment