[go: nahoru, domu]

Skip to content

Commit

Permalink
add local draft / remote post example
Browse files Browse the repository at this point in the history
  • Loading branch information
maxme committed Feb 13, 2015
1 parent d33a9be commit 1d7067e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class EditorExampleActivity extends ActionBarActivity implements EditorFr
public static final String EDITOR_PARAM = "EDITOR_PARAM";
public static final String TITLE_PARAM = "TITLE_PARAM";
public static final String CONTENT_PARAM = "CONTENT_PARAM";
public static final String DRAFT_PARAM = "DRAFT_PARAM";
public static final int USE_NEW_EDITOR = 1;
public static final int USE_LEGACY_EDITOR = 2;

Expand Down Expand Up @@ -52,15 +53,16 @@ public void onAddMediaButtonClicked() {
@Override
public void onEditorFragmentInitialized() {
// arbitrary setup
mEditorFragment.setLocalDraft(false);
mEditorFragment.setFeaturedImageSupported(true);
mEditorFragment.setBlogSettingMaxImageWidth("600");

// set title and content
// get title and content and draft switch
String title = getIntent().getStringExtra(TITLE_PARAM);
String content = getIntent().getStringExtra(CONTENT_PARAM);
boolean isLocalDraft = getIntent().getBooleanExtra(DRAFT_PARAM, true);
mEditorFragment.setTitle(title);
mEditorFragment.setContent(content);
mEditorFragment.setLocalDraft(isLocalDraft);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,29 @@ protected void onCreate(Bundle savedInstanceState) {
}
});

Button legacyEditorPost1 = (Button) findViewById(R.id.legacy_editor_post_1);
legacyEditorPost1.setOnClickListener(new OnClickListener() {
Button legacyEditorPost1Local = (Button) findViewById(R.id.legacy_editor_post_1_local);
legacyEditorPost1Local.setOnClickListener(new OnClickListener() {
@Override public void onClick(View v) {
Intent intent = new Intent(MainExampleActivity.this, EditorExampleActivity.class);
Bundle bundle = new Bundle();
bundle.putString(EditorExampleActivity.TITLE_PARAM, getString(R.string.example_post_1_title));
bundle.putString(EditorExampleActivity.CONTENT_PARAM, getString(R.string.example_post_1_content));
bundle.putInt(EditorExampleActivity.EDITOR_PARAM, EditorExampleActivity.USE_LEGACY_EDITOR);
bundle.putBoolean(EditorExampleActivity.DRAFT_PARAM, true);
intent.putExtras(bundle);
startActivity(intent);
}
});

Button legacyEditorPost1Remote = (Button) findViewById(R.id.legacy_editor_post_1_remote);
legacyEditorPost1Remote.setOnClickListener(new OnClickListener() {
@Override public void onClick(View v) {
Intent intent = new Intent(MainExampleActivity.this, EditorExampleActivity.class);
Bundle bundle = new Bundle();
bundle.putString(EditorExampleActivity.TITLE_PARAM, getString(R.string.example_post_1_title));
bundle.putString(EditorExampleActivity.CONTENT_PARAM, getString(R.string.example_post_1_content));
bundle.putInt(EditorExampleActivity.EDITOR_PARAM, EditorExampleActivity.USE_LEGACY_EDITOR);
bundle.putBoolean(EditorExampleActivity.DRAFT_PARAM, false);
intent.putExtras(bundle);
startActivity(intent);
}
Expand Down
14 changes: 12 additions & 2 deletions example/src/main/res/layout/activity_example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Legacy Editor - Post 1"
android:id="@+id/legacy_editor_post_1"
android:text="Legacy Editor - Post 1 - Local Draft"
android:id="@+id/legacy_editor_post_1_local"
android:layout_marginTop="32dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/new_editor_post_1"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Legacy Editor - Post 1 - Remote"
android:id="@+id/legacy_editor_post_1_remote"
android:layout_marginTop="32dp"
android:layout_centerHorizontal="true"
android:layout_below="@id/legacy_editor_post_1_local"/>


</RelativeLayout>

0 comments on commit 1d7067e

Please sign in to comment.