Program: 15183
Project: 15183
Buggy source:
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  Bundle extras=getIntent().getExtras();
  if (WordPress.wpDB == null)   WordPress.wpDB=new WordPressDB(this);
  if (WordPress.currentBlog == null) {
    try {
      WordPress.currentBlog=new Blog(WordPress.wpDB.getLastBlogID(this),this);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  Display display=((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (height > width) {
    width=height;
  }
  if (width > 480) {
    isLargeScreen=true;
  }
  categories=new JSONArray();
  String action=getIntent().getAction();
  WordPress.richPostContent=null;
  if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
    isAction=true;
    isNew=true;
    Vector<?> accounts=WordPress.wpDB.getAccounts(this);
    if (accounts.size() > 0) {
      final String blogNames[]=new String[accounts.size()];
      final int accountIDs[]=new int[accounts.size()];
      for (int i=0; i < accounts.size(); i++) {
        HashMap<?,?> curHash=(HashMap<?,?>)accounts.get(i);
        try {
          blogNames[i]=EscapeUtils.unescapeHtml(curHash.get("String_Node_Str").toString());
        }
 catch (        Exception e) {
          blogNames[i]=curHash.get("String_Node_Str").toString();
        }
        accountIDs[i]=(Integer)curHash.get("String_Node_Str");
        try {
          blog=new Blog(accountIDs[i],EditPost.this);
        }
 catch (        Exception e) {
          Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
          finish();
        }
      }
      if (accounts.size() != 1) {
        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        builder.setCancelable(false);
        builder.setTitle(getResources().getText(R.string.select_a_blog));
        builder.setItems(blogNames,new DialogInterface.OnClickListener(){
          public void onClick(          DialogInterface dialog,          int item){
            id=accountIDs[item];
            try {
              blog=new Blog(id,EditPost.this);
            }
 catch (            Exception e) {
              Toast.makeText(EditPost.this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
              finish();
            }
            WordPress.currentBlog=blog;
            WordPress.wpDB.updateLastBlogID(WordPress.currentBlog.getId());
            accountName=blogNames[item];
            setTitle(EscapeUtils.unescapeHtml(accountName) + "String_Node_Str" + getResources().getText((isPage) ? R.string.new_page : R.string.new_post));
          }
        }
);
        AlertDialog alert=builder.create();
        alert.show();
      }
 else {
        id=accountIDs[0];
        try {
          blog=new Blog(id,EditPost.this);
        }
 catch (        Exception e) {
          Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
          finish();
        }
        WordPress.currentBlog=blog;
        WordPress.wpDB.updateLastBlogID(WordPress.currentBlog.getId());
        accountName=blogNames[0];
        setTitle(EscapeUtils.unescapeHtml(accountName) + "String_Node_Str" + getResources().getText((isPage) ? R.string.new_page : R.string.new_post));
      }
    }
 else {
      Intent i=new Intent(this,Dashboard.class);
      Toast.makeText(getApplicationContext(),getResources().getText(R.string.no_account),Toast.LENGTH_LONG).show();
      startActivity(i);
      finish();
      return;
    }
  }
 else {
    if (extras != null) {
      id=WordPress.currentBlog.getId();
      try {
        blog=new Blog(id,this);
      }
 catch (      Exception e) {
        Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
        finish();
      }
      accountName=EscapeUtils.unescapeHtml(extras.getString("String_Node_Str"));
      postID=extras.getLong("String_Node_Str");
      localDraft=extras.getBoolean("String_Node_Str",false);
      isPage=extras.getBoolean("String_Node_Str",false);
      isNew=extras.getBoolean("String_Node_Str",false);
      option=extras.getString("String_Node_Str");
      if (extras.getBoolean("String_Node_Str")) {
        id=extras.getInt("String_Node_Str");
        try {
          blog=new Blog(id,this);
          WordPress.currentBlog=blog;
        }
 catch (        Exception e) {
          Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_LONG).show();
          finish();
          return;
        }
      }
      if (!isNew) {
        try {
          post=new Post(id,postID,isPage,this);
          if (post == null) {
            Toast.makeText(this,getResources().getText(R.string.post_not_found),Toast.LENGTH_LONG).show();
            finish();
            return;
          }
 else {
            WordPress.currentPost=post;
          }
        }
 catch (        Exception e) {
          finish();
        }
      }
    }
    if (isNew) {
      setTitle(EscapeUtils.unescapeHtml(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText((isPage) ? R.string.new_page : R.string.new_post));
    }
 else {
      setTitle(EscapeUtils.unescapeHtml(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText((isPage) ? R.string.edit_page : R.string.edit_post));
    }
  }
  if (isPage) {
    setContentView(R.layout.edit_page);
  }
 else {
    setContentView(R.layout.edit);
    if (blog.getPostFormats().equals("String_Node_Str")) {
      Vector<Object> args=new Vector<Object>();
      args.add(blog);
      args.add(this);
      new ApiHelper.getPostFormatsTask().execute(args);
      postFormatTitles=getResources().getStringArray(R.array.post_formats_array);
      String defaultPostFormatTitles[]={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
      postFormats=defaultPostFormatTitles;
    }
 else {
      try {
        JSONObject jsonPostFormats=new JSONObject(blog.getPostFormats());
        postFormats=new String[jsonPostFormats.length()];
        postFormatTitles=new String[jsonPostFormats.length()];
        Iterator<?> it=jsonPostFormats.keys();
        int i=0;
        while (it.hasNext()) {
          String key=(String)it.next();
          String val=(String)jsonPostFormats.get(key);
          postFormats[i]=key;
          postFormatTitles[i]=val;
          i++;
        }
        java.util.Arrays.sort(postFormats);
        java.util.Arrays.sort(postFormatTitles);
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
    }
    Spinner pfSpinner=(Spinner)findViewById(R.id.postFormat);
    ArrayAdapter<String> pfAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,postFormatTitles);
    pfAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    pfSpinner.setAdapter(pfAdapter);
    String activePostFormat="String_Node_Str";
    if (!isNew) {
      if (!post.getWP_post_format().equals("String_Node_Str"))       activePostFormat=post.getWP_post_format();
    }
    for (int i=0; i < postFormats.length; i++) {
      if (postFormats[i].equals(activePostFormat))       pfSpinner.setSelection(i);
    }
    if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action))     setContent();
  }
  String[] items=new String[]{getResources().getString(R.string.publish_post),getResources().getString(R.string.draft),getResources().getString(R.string.pending_review),getResources().getString(R.string.post_private),getResources().getString(R.string.local_draft)};
  Spinner spinner=(Spinner)findViewById(R.id.status);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> arg0,    View arg1,    int arg2,    long arg3){
      evaluateSaveButtonText();
    }
    @Override public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
  boolean hasLocationProvider=false;
  LocationManager locationManager=(LocationManager)getSystemService(LOCATION_SERVICE);
  List<String> providers=locationManager.getProviders(true);
  for (  String providerName : providers) {
    if (providerName.equals(LocationManager.GPS_PROVIDER) || providerName.equals(LocationManager.NETWORK_PROVIDER)) {
      hasLocationProvider=true;
    }
  }
  if (hasLocationProvider && blog.isLocation() && !isPage) {
    enableLBSButtons();
  }
  if (isNew) {
    if (option != null) {
      Intent i=new Intent(EditPost.this,EditContent.class);
      i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
      i.putExtra("String_Node_Str",option);
      startActivityForResult(i,0);
    }
  }
 else {
    EditText titleET=(EditText)findViewById(R.id.title);
    WPEditText contentET=(WPEditText)findViewById(R.id.postContent);
    EditText passwordET=(EditText)findViewById(R.id.post_password);
    titleET.setText(post.getTitle());
    if (post.isUploaded()) {
      items=new String[]{getResources().getString(R.string.publish_post),getResources().getString(R.string.draft),getResources().getString(R.string.pending_review),getResources().getString(R.string.post_private)};
      adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
      spinner.setAdapter(adapter);
    }
    String contentHTML;
    if (!post.getMt_text_more().equals("String_Node_Str")) {
      if (post.isLocalDraft())       contentHTML=post.getDescription() + "String_Node_Str" + post.getMt_text_more();
 else       contentHTML=post.getDescription() + "String_Node_Str" + post.getMt_text_more();
    }
 else {
      contentHTML=post.getDescription();
    }
    try {
      if (post.isLocalDraft()) {
        contentET.setText(WPHtml.fromHtml(contentHTML.replaceAll("String_Node_Str","String_Node_Str"),EditPost.this,post));
      }
 else {
        contentET.setText(contentHTML.replaceAll("String_Node_Str","String_Node_Str"));
      }
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
    long pubDate=post.getDate_created_gmt();
    if (pubDate != 0) {
      try {
        int flags=0;
        flags|=android.text.format.DateUtils.FORMAT_SHOW_DATE;
        flags|=android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
        flags|=android.text.format.DateUtils.FORMAT_SHOW_YEAR;
        flags|=android.text.format.DateUtils.FORMAT_SHOW_TIME;
        String formattedDate=DateUtils.formatDateTime(EditPost.this,pubDate,flags);
        TextView tvPubDate=(TextView)findViewById(R.id.pubDate);
        tvPubDate.setText(formattedDate);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    if (post.getWP_password() != null)     passwordET.setText(post.getWP_password());
    if (post.getPost_status() != null) {
      String status=post.getPost_status();
      if (status.equals("String_Node_Str")) {
        spinner.setSelection(0,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(1,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(2,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(3,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(4,true);
      }
      evaluateSaveButtonText();
    }
    if (!isPage) {
      if (post.getCategories() != null) {
        categories=post.getCategories();
        if (!categories.equals("String_Node_Str")) {
          for (int i=0; i < categories.length(); i++) {
            try {
              selectedCategories.add(categories.getString(i));
            }
 catch (            JSONException e) {
              e.printStackTrace();
            }
          }
          TextView tvCategories=(TextView)findViewById(R.id.selectedCategories);
          tvCategories.setText(getResources().getText(R.string.selected_categories) + "String_Node_Str" + getCategoriesCSV());
        }
      }
      Double latitude=post.getLatitude();
      Double longitude=post.getLongitude();
      if (latitude != 0.0) {
        new getAddressTask().execute(latitude,longitude);
      }
    }
    String tags=post.getMt_keywords();
    if (!tags.equals("String_Node_Str")) {
      EditText tagsET=(EditText)findViewById(R.id.tags);
      tagsET.setText(tags);
    }
  }
  if (!isPage) {
    Button selectCategories=(Button)findViewById(R.id.selectCategories);
    selectCategories.setOnClickListener(new Button.OnClickListener(){
      public void onClick(      View v){
        Bundle bundle=new Bundle();
        bundle.putInt("String_Node_Str",id);
        if (categories.length() > 0) {
          bundle.putString("String_Node_Str",getCategoriesCSV());
        }
        Intent i=new Intent(EditPost.this,SelectCategories.class);
        i.putExtras(bundle);
        startActivityForResult(i,1);
      }
    }
);
  }
  final WPEditText content=(WPEditText)findViewById(R.id.postContent);
  content.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View view,    boolean hasFocus){
      if (hasFocus) {
        Intent i=new Intent(EditPost.this,EditContent.class);
        if (isNew || localDraft)         i.putExtra("String_Node_Str",true);
 else         i.putExtra("String_Node_Str",false);
        WordPress.richPostContent=content.getText();
        i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivityForResult(i,0);
      }
    }
  }
);
  final Button saveButton=(Button)findViewById(R.id.post);
  saveButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      boolean result=savePost();
      if (result) {
        if (post.isUploaded() || !post.getPost_status().equals("String_Node_Str"))         post.upload();
        finish();
      }
    }
  }
);
  Button pubDate=(Button)findViewById(R.id.pubDateButton);
  pubDate.setOnClickListener(new TextView.OnClickListener(){
    public void onClick(    View v){
      Calendar c=Calendar.getInstance();
      mYear=c.get(Calendar.YEAR);
      mMonth=c.get(Calendar.MONTH);
      mDay=c.get(Calendar.DAY_OF_MONTH);
      mHour=c.get(Calendar.HOUR_OF_DAY);
      mMinute=c.get(Calendar.MINUTE);
      showDialog(ID_DIALOG_DATE);
    }
  }
);
}

Fixed version (ground truth):
@Override public void onCreate(Bundle icicle){
  super.onCreate(icicle);
  Bundle extras=getIntent().getExtras();
  if (WordPress.wpDB == null)   WordPress.wpDB=new WordPressDB(this);
  if (WordPress.currentBlog == null) {
    try {
      WordPress.currentBlog=new Blog(WordPress.wpDB.getLastBlogID(this),this);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
  Display display=((WindowManager)getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
  int width=display.getWidth();
  int height=display.getHeight();
  if (height > width) {
    width=height;
  }
  if (width > 480) {
    isLargeScreen=true;
  }
  categories=new JSONArray();
  String action=getIntent().getAction();
  if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
    WordPress.richPostContent=null;
    isAction=true;
    isNew=true;
    Vector<?> accounts=WordPress.wpDB.getAccounts(this);
    if (accounts.size() > 0) {
      final String blogNames[]=new String[accounts.size()];
      final int accountIDs[]=new int[accounts.size()];
      for (int i=0; i < accounts.size(); i++) {
        HashMap<?,?> curHash=(HashMap<?,?>)accounts.get(i);
        try {
          blogNames[i]=EscapeUtils.unescapeHtml(curHash.get("String_Node_Str").toString());
        }
 catch (        Exception e) {
          blogNames[i]=curHash.get("String_Node_Str").toString();
        }
        accountIDs[i]=(Integer)curHash.get("String_Node_Str");
        try {
          blog=new Blog(accountIDs[i],EditPost.this);
        }
 catch (        Exception e) {
          Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
          finish();
        }
      }
      if (accounts.size() != 1) {
        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        builder.setCancelable(false);
        builder.setTitle(getResources().getText(R.string.select_a_blog));
        builder.setItems(blogNames,new DialogInterface.OnClickListener(){
          public void onClick(          DialogInterface dialog,          int item){
            id=accountIDs[item];
            try {
              blog=new Blog(id,EditPost.this);
            }
 catch (            Exception e) {
              Toast.makeText(EditPost.this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
              finish();
            }
            WordPress.currentBlog=blog;
            WordPress.wpDB.updateLastBlogID(WordPress.currentBlog.getId());
            accountName=blogNames[item];
            setTitle(EscapeUtils.unescapeHtml(accountName) + "String_Node_Str" + getResources().getText((isPage) ? R.string.new_page : R.string.new_post));
          }
        }
);
        AlertDialog alert=builder.create();
        alert.show();
      }
 else {
        id=accountIDs[0];
        try {
          blog=new Blog(id,EditPost.this);
        }
 catch (        Exception e) {
          Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
          finish();
        }
        WordPress.currentBlog=blog;
        WordPress.wpDB.updateLastBlogID(WordPress.currentBlog.getId());
        accountName=blogNames[0];
        setTitle(EscapeUtils.unescapeHtml(accountName) + "String_Node_Str" + getResources().getText((isPage) ? R.string.new_page : R.string.new_post));
      }
    }
 else {
      Intent i=new Intent(this,Dashboard.class);
      Toast.makeText(getApplicationContext(),getResources().getText(R.string.no_account),Toast.LENGTH_LONG).show();
      startActivity(i);
      finish();
      return;
    }
  }
 else {
    if (extras != null) {
      id=WordPress.currentBlog.getId();
      try {
        blog=new Blog(id,this);
      }
 catch (      Exception e) {
        Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_SHORT).show();
        finish();
      }
      accountName=EscapeUtils.unescapeHtml(extras.getString("String_Node_Str"));
      postID=extras.getLong("String_Node_Str");
      localDraft=extras.getBoolean("String_Node_Str",false);
      isPage=extras.getBoolean("String_Node_Str",false);
      isNew=extras.getBoolean("String_Node_Str",false);
      option=extras.getString("String_Node_Str");
      if (extras.getBoolean("String_Node_Str")) {
        id=extras.getInt("String_Node_Str");
        try {
          blog=new Blog(id,this);
          WordPress.currentBlog=blog;
        }
 catch (        Exception e) {
          Toast.makeText(this,getResources().getText(R.string.blog_not_found),Toast.LENGTH_LONG).show();
          finish();
          return;
        }
      }
      if (!isNew) {
        try {
          post=new Post(id,postID,isPage,this);
          if (post == null) {
            Toast.makeText(this,getResources().getText(R.string.post_not_found),Toast.LENGTH_LONG).show();
            finish();
            return;
          }
 else {
            WordPress.currentPost=post;
          }
        }
 catch (        Exception e) {
          finish();
        }
      }
    }
    if (isNew) {
      setTitle(EscapeUtils.unescapeHtml(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText((isPage) ? R.string.new_page : R.string.new_post));
    }
 else {
      setTitle(EscapeUtils.unescapeHtml(WordPress.currentBlog.getBlogName()) + "String_Node_Str" + getResources().getText((isPage) ? R.string.edit_page : R.string.edit_post));
    }
  }
  if (isPage) {
    setContentView(R.layout.edit_page);
  }
 else {
    setContentView(R.layout.edit);
    if (blog.getPostFormats().equals("String_Node_Str")) {
      Vector<Object> args=new Vector<Object>();
      args.add(blog);
      args.add(this);
      new ApiHelper.getPostFormatsTask().execute(args);
      postFormatTitles=getResources().getStringArray(R.array.post_formats_array);
      String defaultPostFormatTitles[]={"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str"};
      postFormats=defaultPostFormatTitles;
    }
 else {
      try {
        JSONObject jsonPostFormats=new JSONObject(blog.getPostFormats());
        postFormats=new String[jsonPostFormats.length()];
        postFormatTitles=new String[jsonPostFormats.length()];
        Iterator<?> it=jsonPostFormats.keys();
        int i=0;
        while (it.hasNext()) {
          String key=(String)it.next();
          String val=(String)jsonPostFormats.get(key);
          postFormats[i]=key;
          postFormatTitles[i]=val;
          i++;
        }
        java.util.Arrays.sort(postFormats);
        java.util.Arrays.sort(postFormatTitles);
      }
 catch (      JSONException e) {
        e.printStackTrace();
      }
    }
    Spinner pfSpinner=(Spinner)findViewById(R.id.postFormat);
    ArrayAdapter<String> pfAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,postFormatTitles);
    pfAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    pfSpinner.setAdapter(pfAdapter);
    String activePostFormat="String_Node_Str";
    if (!isNew) {
      if (!post.getWP_post_format().equals("String_Node_Str"))       activePostFormat=post.getWP_post_format();
    }
    for (int i=0; i < postFormats.length; i++) {
      if (postFormats[i].equals(activePostFormat))       pfSpinner.setSelection(i);
    }
    if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action))     setContent();
  }
  String[] items=new String[]{getResources().getString(R.string.publish_post),getResources().getString(R.string.draft),getResources().getString(R.string.pending_review),getResources().getString(R.string.post_private),getResources().getString(R.string.local_draft)};
  Spinner spinner=(Spinner)findViewById(R.id.status);
  ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  spinner.setAdapter(adapter);
  spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
    @Override public void onItemSelected(    AdapterView<?> arg0,    View arg1,    int arg2,    long arg3){
      evaluateSaveButtonText();
    }
    @Override public void onNothingSelected(    AdapterView<?> arg0){
    }
  }
);
  boolean hasLocationProvider=false;
  LocationManager locationManager=(LocationManager)getSystemService(LOCATION_SERVICE);
  List<String> providers=locationManager.getProviders(true);
  for (  String providerName : providers) {
    if (providerName.equals(LocationManager.GPS_PROVIDER) || providerName.equals(LocationManager.NETWORK_PROVIDER)) {
      hasLocationProvider=true;
    }
  }
  if (hasLocationProvider && blog.isLocation() && !isPage) {
    enableLBSButtons();
  }
  if (isNew) {
    if (option != null) {
      Intent i=new Intent(EditPost.this,EditContent.class);
      i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
      i.putExtra("String_Node_Str",option);
      startActivityForResult(i,0);
    }
  }
 else {
    EditText titleET=(EditText)findViewById(R.id.title);
    WPEditText contentET=(WPEditText)findViewById(R.id.postContent);
    EditText passwordET=(EditText)findViewById(R.id.post_password);
    titleET.setText(post.getTitle());
    if (post.isUploaded()) {
      items=new String[]{getResources().getString(R.string.publish_post),getResources().getString(R.string.draft),getResources().getString(R.string.pending_review),getResources().getString(R.string.post_private)};
      adapter=new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,items);
      spinner.setAdapter(adapter);
    }
    String contentHTML;
    if (!post.getMt_text_more().equals("String_Node_Str")) {
      if (post.isLocalDraft())       contentHTML=post.getDescription() + "String_Node_Str" + post.getMt_text_more();
 else       contentHTML=post.getDescription() + "String_Node_Str" + post.getMt_text_more();
    }
 else {
      contentHTML=post.getDescription();
    }
    try {
      if (post.isLocalDraft()) {
        contentET.setText(WPHtml.fromHtml(contentHTML.replaceAll("String_Node_Str","String_Node_Str"),EditPost.this,post));
      }
 else {
        contentET.setText(contentHTML.replaceAll("String_Node_Str","String_Node_Str"));
      }
    }
 catch (    Exception e1) {
      e1.printStackTrace();
    }
    long pubDate=post.getDate_created_gmt();
    if (pubDate != 0) {
      try {
        int flags=0;
        flags|=android.text.format.DateUtils.FORMAT_SHOW_DATE;
        flags|=android.text.format.DateUtils.FORMAT_ABBREV_MONTH;
        flags|=android.text.format.DateUtils.FORMAT_SHOW_YEAR;
        flags|=android.text.format.DateUtils.FORMAT_SHOW_TIME;
        String formattedDate=DateUtils.formatDateTime(EditPost.this,pubDate,flags);
        TextView tvPubDate=(TextView)findViewById(R.id.pubDate);
        tvPubDate.setText(formattedDate);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
    if (post.getWP_password() != null)     passwordET.setText(post.getWP_password());
    if (post.getPost_status() != null) {
      String status=post.getPost_status();
      if (status.equals("String_Node_Str")) {
        spinner.setSelection(0,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(1,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(2,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(3,true);
      }
 else       if (status.equals("String_Node_Str")) {
        spinner.setSelection(4,true);
      }
      evaluateSaveButtonText();
    }
    if (!isPage) {
      if (post.getCategories() != null) {
        categories=post.getCategories();
        if (!categories.equals("String_Node_Str")) {
          for (int i=0; i < categories.length(); i++) {
            try {
              selectedCategories.add(categories.getString(i));
            }
 catch (            JSONException e) {
              e.printStackTrace();
            }
          }
          TextView tvCategories=(TextView)findViewById(R.id.selectedCategories);
          tvCategories.setText(getResources().getText(R.string.selected_categories) + "String_Node_Str" + getCategoriesCSV());
        }
      }
      Double latitude=post.getLatitude();
      Double longitude=post.getLongitude();
      if (latitude != 0.0) {
        new getAddressTask().execute(latitude,longitude);
      }
    }
    String tags=post.getMt_keywords();
    if (!tags.equals("String_Node_Str")) {
      EditText tagsET=(EditText)findViewById(R.id.tags);
      tagsET.setText(tags);
    }
  }
  if (!isPage) {
    Button selectCategories=(Button)findViewById(R.id.selectCategories);
    selectCategories.setOnClickListener(new Button.OnClickListener(){
      public void onClick(      View v){
        Bundle bundle=new Bundle();
        bundle.putInt("String_Node_Str",id);
        if (categories.length() > 0) {
          bundle.putString("String_Node_Str",getCategoriesCSV());
        }
        Intent i=new Intent(EditPost.this,SelectCategories.class);
        i.putExtras(bundle);
        startActivityForResult(i,1);
      }
    }
);
  }
  final WPEditText content=(WPEditText)findViewById(R.id.postContent);
  content.setOnFocusChangeListener(new View.OnFocusChangeListener(){
    @Override public void onFocusChange(    View view,    boolean hasFocus){
      if (hasFocus) {
        Intent i=new Intent(EditPost.this,EditContent.class);
        if (isNew || localDraft)         i.putExtra("String_Node_Str",true);
 else         i.putExtra("String_Node_Str",false);
        WordPress.richPostContent=content.getText();
        i.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivityForResult(i,0);
      }
    }
  }
);
  final Button saveButton=(Button)findViewById(R.id.post);
  saveButton.setOnClickListener(new Button.OnClickListener(){
    public void onClick(    View v){
      boolean result=savePost();
      if (result) {
        if (post.isUploaded() || !post.getPost_status().equals("String_Node_Str"))         post.upload();
        finish();
      }
    }
  }
);
  Button pubDate=(Button)findViewById(R.id.pubDateButton);
  pubDate.setOnClickListener(new TextView.OnClickListener(){
    public void onClick(    View v){
      Calendar c=Calendar.getInstance();
      mYear=c.get(Calendar.YEAR);
      mMonth=c.get(Calendar.MONTH);
      mDay=c.get(Calendar.DAY_OF_MONTH);
      mHour=c.get(Calendar.HOUR_OF_DAY);
      mMinute=c.get(Calendar.MINUTE);
      showDialog(ID_DIALOG_DATE);
    }
  }
);
}