Android Open Source - doubanbook4android Serch Input Activity






From Project

Back to project page doubanbook4android.

License

The source code is released under:

Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECI...

If you think the Android project doubanbook4android 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 com.study.doubanbook_for_android.activity;
//  w  ww.  j a v  a 2 s.c o m
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.study.doubanbook_for_android.R;
import com.study.doubanbook_for_android.business.DoubanBusiness;

public class SerchInputActivity extends BaseActivity {

  EditText search_et;
  Button search_btn;
  TextView clear_tv;
  private Context context;
  private Button authBtn;
  private TextView readerSearch;
  private TextView bookSearch;
  private static final int SEARCH_BOOK = 0;// search book flag
  private static final int SEARCH_READER = 1;// search reader flag

  private int flag = SEARCH_BOOK;// search flag

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.a_serch_input);

    context = this;
    findViews();
    initWidgets();
    initListners();

    // auto auth
    DoubanBusiness db = new DoubanBusiness(context);
    db.auth();
  }

  @Override
  void findViews() {
    super.findViews();
    search_et = (EditText) this.findViewById(R.id.serchContent_et);
    search_btn = (Button) this.findViewById(R.id.search_btn);
    clear_tv = (TextView) this.findViewById(R.id.clear_tv);
    authBtn = (Button) this.findViewById(R.id.authBtn);
    bookSearch = (TextView) this.findViewById(R.id.bookSearch_tv);
    readerSearch = (TextView) this.findViewById(R.id.readerSearch_tv);

  }

  @Override
  void initWidgets() {
    super.initWidgets();
    clear_tv.setVisibility(View.GONE);
    // bookSearch.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);// ???
    readerSearch.setTextColor(Color.GRAY);
  }

  @Override
  void initListners() {
    super.initListners();

    search_btn.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        System.out.println(flag);
        if (flag == SEARCH_BOOK) {
          Intent intent = new Intent();
          intent.setClass(context, BookListsActivity.class);
          String s = getText(search_et);
          intent.putExtra("searchContent", s);
          startActivity(intent);
        } else if (flag == SEARCH_READER) {
          Intent intent = new Intent();
          intent.setClass(context, UserListActivity.class);
          String s = getText(search_et);
          intent.putExtra("searchContent", s);
          startActivity(intent);
        }
      }
    });
    search_et.addTextChangedListener(new TextWatcher() {

      @Override
      public void onTextChanged(CharSequence s, int start, int before,
          int count) {
        String str = getText(search_et);
        if (!str.toString().equals("")) {
          clear_tv.setVisibility(View.VISIBLE);
        } else {
          clear_tv.setVisibility(View.GONE);
        }
      }

      @Override
      public void beforeTextChanged(CharSequence s, int start, int count,
          int after) {

      }

      @Override
      public void afterTextChanged(Editable s) {

      }
    });
    clear_tv.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        search_et.setText("");
      }
    });

    bookSearch.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        // bookSearch.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//
        // ???
        // readerSearch.getPaint().setFlags(Paint.););
        bookSearch.setTextColor(Color.BLACK);
        readerSearch.setTextColor(Color.GRAY);
        search_et.setHint(getResources().getString(
            R.string.search_book_hint));
        flag = SEARCH_BOOK;
        System.out.println(flag);
      }
    });

    readerSearch.setOnClickListener(new OnClickListener() {

      @Override
      public void onClick(View v) {
        // readerSearch.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);//
        // ???
        // readerSearch.getPaint().setFlags(Paint.););

        bookSearch.setTextColor(Color.GRAY);
        readerSearch.setTextColor(Color.BLACK);
        search_et.setHint(getResources().getString(
            R.string.search_reader_hint));
        flag = SEARCH_READER;
        System.out.println(flag);
      }
    });

  }

  boolean test = false;
}




Java Source Code List

.UserListAdapter.java
com.study.doubanbook_for_android.activity.BaseActivity.java
com.study.doubanbook_for_android.activity.BaseP2RActivity.java
com.study.doubanbook_for_android.activity.BookDetailActivity.java
com.study.doubanbook_for_android.activity.BookListsActivity.java
com.study.doubanbook_for_android.activity.BookNoteListActivity.java
com.study.doubanbook_for_android.activity.CollectDetailActivity.java
com.study.doubanbook_for_android.activity.NoteAndUserDetailActivity.java
com.study.doubanbook_for_android.activity.SerchInputActivity.java
com.study.doubanbook_for_android.activity.TextActivity1.java
com.study.doubanbook_for_android.activity.UserDetailActivity.java
com.study.doubanbook_for_android.activity.UserListActivity.java
com.study.doubanbook_for_android.activity.UserNoteActivity.java
com.study.doubanbook_for_android.adapter.BookAdapter.java
com.study.doubanbook_for_android.adapter.CommentAdapter.java
com.study.doubanbook_for_android.adapter.UserNoteAdapter.java
com.study.doubanbook_for_android.api.NetUtils.java
com.study.doubanbook_for_android.api.SSLSocketFactoryEx.java
com.study.doubanbook_for_android.api.WrongMsg.java
com.study.doubanbook_for_android.auth.AccessToken.java
com.study.doubanbook_for_android.auth.DoubanDialogError.java
com.study.doubanbook_for_android.auth.DoubanDialog.java
com.study.doubanbook_for_android.auth.DoubanException.java
com.study.doubanbook_for_android.auth.DoubanOAuthListener.java
com.study.doubanbook_for_android.auth.DoubanParameters.java
com.study.doubanbook_for_android.auth.DoubanRequest.java
com.study.doubanbook_for_android.auth.Douban.java
com.study.doubanbook_for_android.auth.KeepToken.java
com.study.doubanbook_for_android.auth.SimpleDoubanOAuthListener.java
com.study.doubanbook_for_android.auth.Token.java
com.study.doubanbook_for_android.business.DoubanBusiness.java
com.study.doubanbook_for_android.callback.AsynCallback.java
com.study.doubanbook_for_android.imagedownloader.FileCache.java
com.study.doubanbook_for_android.imagedownloader.INetImageDownloader.java
com.study.doubanbook_for_android.imagedownloader.ImageCache.java
com.study.doubanbook_for_android.imagedownloader.ImageDownloaderListener.java
com.study.doubanbook_for_android.imagedownloader.ImageDownloader.java
com.study.doubanbook_for_android.model.Annotations.java
com.study.doubanbook_for_android.model.AuthorUser.java
com.study.doubanbook_for_android.model.BookItem.java
com.study.doubanbook_for_android.model.CollectBookMsg.java
com.study.doubanbook_for_android.model.CollectSuccessResult.java
com.study.doubanbook_for_android.model.CommentItem.java
com.study.doubanbook_for_android.model.Comment.java
com.study.doubanbook_for_android.model.CurrenUserCollection.java
com.study.doubanbook_for_android.model.GeneralNoteResult.java
com.study.doubanbook_for_android.model.GeneralResult.java
com.study.doubanbook_for_android.model.GeneralUserResult.java
com.study.doubanbook_for_android.model.ImageItem.java
com.study.doubanbook_for_android.model.Rating.java
com.study.doubanbook_for_android.model.RequestGrantScope.java
com.study.doubanbook_for_android.model.TagItem.java
com.study.doubanbook_for_android.model.URLMananeger.java
com.study.doubanbook_for_android.utils.EncodeUtils.java
com.study.doubanbook_for_android.utils.JsonParser.java
com.study.doubanbook_for_android.utils.JsonUtil.java
com.study.doubanbook_for_android.utils.UriUtils.java