Buggy code:
@ ContentView ( layout . activity_rss ) public class RSSActivity extends RoboActivity { public static final String TAG = RSSActivity . class . getSimpleName ( ) ; public static final int MODE_WORLD_READABLE = 1 ; private final String BASE_URL = "http:////219.223.190.211" ; private AsyncHttpClient httpHelper = new AsyncHttpClient ( 80 ) ; @ InjectView ( id . cities ) private EditText mCities ; @ InjectView ( id . add_btn ) private Button mAddBtn ; @ InjectView ( id . del_btn ) private Button del_btn ; private RSSActivity . BadgeAdapter cityListAdapter ; private ArrayList < String > city = new ArrayList < String > ( ) ; private static JSONObject jUS = new JSONObject ( ) ; private boolean isLongClick = false ; private SharedPreferences sharedPreferences ; private Editor editor ; private Intent intent = new Intent ( ) ; private JSONObject jObj = new JSONObject ( ) ; private RSSActivity . RSSReceiver rssReceiver ; protected void onCreate ( Bundle savedInstanceState ) { } @ SuppressLint ( { "WorldReadableFiles" , "NewApi" } ) private void initComponent ( ) throws IOException , JSONException { sharedPreferences = this . getSharedPreferences ( "user_info" , RSSActivity . MODE_WORLD_READABLE ) ; editor = sharedPreferences . edit ( ) ; downFile ( ) ; loadCityFile ( ) ; rssReceiver = new RSSActivity . RSSReceiver ( ) ; IntentFilter intentFilter = new IntentFilter ( ) ; intentFilter . addAction ( "com.example.communication.RSSRECEIVER" ) ; registerReceiver ( rssReceiver , intentFilter ) ; Set < String > set = sharedPreferences . getStringSet ( "cities" , null ) ; if ( set != null ) { city = new ArrayList < String > ( set ) ; int len = city . size ( ) ; RSSActivity . jUS = new JSONObject ( ) ; if ( len != 0 ) { for ( int i = 0 ; i < len ; i ++ ) { JSONObject jTmp = new JSONObject ( ) ; jTmp . put ( "to" , city . get ( i ) ) ; jTmp . put ( "from" , city . get ( i ) ) ; jTmp . put ( "id" , jObj . getString ( city . get ( i ) ) ) ; String jOS = jTmp . toString ( ) ; Log . d ( "notify" , jOS ) ; HttpPost httpRequest = new HttpPost ( ( ( BASE_URL ) + "//citytop" ) ) ; List < BasicNameValuePair > params = new ArrayList < BasicNameValuePair > ( ) ; params . add ( new BasicNameValuePair ( "data" , jOS ) ) ; httpRequest . setEntity ( new org . apache . http . client . entity . UrlEncodedFormEntity ( params , HTTP . UTF_8 ) ) ; HttpResponse httpResponse = new DefaultHttpClient ( ) . execute ( httpRequest ) ; if ( ( httpResponse . getStatusLine ( ) . getStatusCode ( ) ) == ( HttpStatus . SC_OK ) ) { Header header = httpResponse . getLastHeader ( "new" ) ; Log . d ( ( ( RSSActivity . TAG ) + "nihao" ) , header . toString ( ) ) ; RSSActivity . jUS . put ( city . get ( i ) , header . getValue ( ) ) ; } } } } ListView gridview = ( ( ListView ) ( findViewById ( list_rsscities ) ) ) ; cityListAdapter = new RSSActivity . BadgeAdapter ( city , this ) ; gridview . setAdapter ( cityListAdapter ) ; mAddBtn . setOnClickListener ( new Button . OnClickListener ( ) { @ Override public void onClick ( View v ) { String newcity = mCities . getText ( ) . toString ( ) ; <START_BUG> if ( ( ! ( newcity . endsWith ( "<seq2seq4repair_space>" ) ) ) && ( ! ( newcity . isEmpty ( ) ) ) ) { <END_BUG> city . add ( newcity ) ; cityListAdapter . city = city ; cityListAdapter . notifyDataSetChanged ( ) ; try { jObj . put ( newcity , "" ) ; RSSActivity . jUS . put ( newcity , "0" ) ; downCityFile ( jObj ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } Set < String > set = new HashSet < String > ( ) ; set . addAll ( city ) ; editor . putStringSet ( "cities" , set ) ; editor . commit ( ) ; } } } ) ; gridview . setOnItemClickListener ( new OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > parent , View view , int position , long id ) { if ( ! ( isLongClick ) ) { try { getHttpResponse ( position ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } } } ) ; gridview . setOnItemLongClickListener ( new OnItemLongClickListener ( ) { @ Override public boolean onItemLongClick ( AdapterView < ? > parent , View view , final int position , long id ) { if ( ! ( isLongClick ) ) { isLongClick = true ; del_btn . setVisibility ( VISIBLE ) ; del_btn . setOnClickListener ( new OnClickListener ( ) { @ Override public void onClick ( View v ) { del_btn . setVisibility ( GONE ) ; isLongClick = false ; jObj . remove ( city . get ( position ) ) ; RSSActivity . jUS . remove ( city . get ( position ) ) ; try { downCityFile ( jObj ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } city . remove ( position ) ; Set < String > set = new HashSet < String > ( ) ; set . addAll ( city ) ; editor . putStringSet ( "cities" , set ) ;

Fix:
if ( ( ( ! ( newcity . endsWith ( "<seq2seq4repair_space>" ) ) ) && ( ! ( newcity . isEmpty ( ) ) ) ) && ( ! ( city . contains ( newcity ) ) ) ) {