Android Open Source - TheGamesDB-Android-app Search Activity






From Project

Back to project page TheGamesDB-Android-app.

License

The source code is released under:

GNU General Public License

If you think the Android project TheGamesDB-Android-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package dragni.tgb.thegamesdb.views;
//  www .j ava2 s  .  co  m
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.example.thegamesdb.R;

public class SearchActivity extends SherlockActivity {
  
  private String searchQuery;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);  
        
        setSearchBarEnterAction();  
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getSupportMenuInflater().inflate(R.menu.search, menu);
        return true;
    }
    
    private void setSearchBarEnterAction() {
    final EditText searchBar = (EditText) findViewById(R.id.searchBar);
    searchBar.setOnEditorActionListener(new OnEditorActionListener() {

        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
          if (actionId == EditorInfo.IME_ACTION_DONE) {
            searchQuery = searchBar.getText().toString();
            cleanSearchQuery();
            sendSearchRequest();
            return true;
          } else {
            return false;
          }
       }
    });
    }
    
    private void cleanSearchQuery() {
      searchQuery = searchQuery.replace(" ", "+");
    }
    
    private void sendSearchRequest() {
      Intent intent = new Intent(this, GameListActivity.class);
      intent.putExtra("searchQuery", searchQuery);
      startActivity(intent);
    }
    
}




Java Source Code List

dragni.tgb.thegamesdb.entity.GameList.java
dragni.tgb.thegamesdb.entity.Game.java
dragni.tgb.thegamesdb.entity.ImageList.java
dragni.tgb.thegamesdb.entity.Image.java
dragni.tgb.thegamesdb.logic.GameSearcher.java
dragni.tgb.thegamesdb.util.GameListSorter.java
dragni.tgb.thegamesdb.util.SearchType.java
dragni.tgb.thegamesdb.util.UrlMaker.java
dragni.tgb.thegamesdb.views.FragmentGameImages.java
dragni.tgb.thegamesdb.views.FragmentGameInformation.java
dragni.tgb.thegamesdb.views.FragmentGameVideos.java
dragni.tgb.thegamesdb.views.GameListActivity.java
dragni.tgb.thegamesdb.views.GameOverviewActivity.java
dragni.tgb.thegamesdb.views.ImageAdapter.java
dragni.tgb.thegamesdb.views.ImageZoomActivity.java
dragni.tgb.thegamesdb.views.ListAdapter.java
dragni.tgb.thegamesdb.views.SearchActivity.java
dragni.tgb.thegamesdb.views.ViewPagerAdapter.java