Fixed the ShareLinkActivity

pull/14/head
Sam Bosley 14 years ago
parent 03041b146f
commit c6e0f746b8

@ -205,6 +205,12 @@ public class AstridActivity extends FragmentActivity
transaction.replace(R.id.tasklist_fragment_container, newFragment, transaction.replace(R.id.tasklist_fragment_container, newFragment,
TaskListFragment.TAG_TASKLIST_FRAGMENT); TaskListFragment.TAG_TASKLIST_FRAGMENT);
transaction.commit(); transaction.commit();
runOnUiThread(new Runnable() {
@Override
public void run() {
getSupportFragmentManager().executePendingTransactions();
}
});
} catch (Exception e) { } catch (Exception e) {
// Don't worry about it // Don't worry about it
} }

@ -6,33 +6,69 @@ package com.todoroo.astrid.activity;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.astrid.data.Task; import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.service.TaskService;
/** /**
* @author joshuagross * @author joshuagross
* *
* Create a new task based on incoming links from the "share" menu * Create a new task based on incoming links from the "share" menu
*/ */
public final class ShareLinkActivity extends TaskListFragment { public final class ShareLinkActivity extends TaskListActivity {
@Autowired
private TaskService taskService;
private String subject;
private boolean handled;
private static final String TOKEN_LINK_HANDLED = "linkHandled"; //$NON-NLS-1$
public ShareLinkActivity () { public ShareLinkActivity () {
super(); super();
DependencyInjectionService.getInstance().inject(this);
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Intent callerIntent = getActivity().getIntent(); Intent callerIntent = getIntent();
String subject = callerIntent.getStringExtra(Intent.EXTRA_SUBJECT); subject = callerIntent.getStringExtra(Intent.EXTRA_SUBJECT);
if(subject == null) if(subject == null)
subject = ""; //$NON-NLS-1$ subject = ""; //$NON-NLS-1$
Task task = quickAddTask(subject, false); }
task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT));
taskService.save(task); @Override
Intent intent = new Intent(getActivity(), TaskEditActivity.class); protected void onPostResume() {
intent.putExtra(TaskEditFragment.TOKEN_ID, task.getId()); super.onPostResume();
intent.putExtra(TOKEN_FILTER, filter); TaskListFragment tlf = getTaskListFragment();
startActivityForResult(intent, ACTIVITY_EDIT_TASK); if (tlf == null) {
return; // Uh ohs!
}
if (!handled) {
Intent callerIntent = getIntent();
Task task = tlf.quickAddTask(subject, false);
task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT));
taskService.save(task);
handled = true;
onTaskListItemClicked(task.getId());
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(TOKEN_LINK_HANDLED, handled);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
handled = savedInstanceState.getBoolean(TOKEN_LINK_HANDLED);
} }
} }

Loading…
Cancel
Save