Search in sources :

Example 1 with QueryWordFragment

use of com.zhan_dui.dictionary.fragments.QueryWordFragment in project little-bear-dictionary by daimajia.

the class GeneralActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    ThemeUtils.onActivityCreateSetTheme(this);
    super.onCreate(savedInstanceState);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mContext = this;
    setBehindContentView(R.layout.sliding_menu);
    setContentView(R.layout.activity_main);
    mSlidingMenu = getSlidingMenu();
    mSlidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
    mSlidingMenu.setFadeDegree(0.35f);
    mSlidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
    mSlidingMenu.setMode(SlidingMenu.LEFT);
    mMenuView = mSlidingMenu.getMenu();
    // start finding ui widget
    mSearch = (Button) mMenuView.findViewById(R.id.search);
    mSetting = (Button) mMenuView.findViewById(R.id.setting);
    mOfflineManage = (Button) mMenuView.findViewById(R.id.offline_manage);
    mSetting = (Button) mMenuView.findViewById(R.id.setting);
    mAbout = (Button) mMenuView.findViewById(R.id.about);
    mRate = (Button) mMenuView.findViewById(R.id.star);
    mWords = (Button) mMenuView.findViewById(R.id.words);
    mSetting.setOnClickListener(this);
    mOfflineManage.setOnClickListener(this);
    mSearch.setOnClickListener(this);
    mAbout.setOnClickListener(this);
    mRate.setOnClickListener(this);
    mAbout.setOnClickListener(this);
    mWords.setOnClickListener(this);
    mSlidingMenu.setOnClosedListener(this);
    // SlidingMenu init;
    getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, new QueryWordFragment(), mTag).commit();
    mCurrentShowID = R.id.search;
    if (isBaseDictionaryExist() == false) {
        AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
        builder.setTitle(R.string.tips);
        builder.setMessage(R.string.init);
        builder.setPositiveButton(R.string.init_start, new StartMovingBaseDictionaryListener(mContext));
        builder.setNegativeButton(R.string.init_not_now, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                GeneralActivity.this.finish();
            }
        });
        builder.show();
    }
    UMFeedbackService.enableNewReplyNotification(this, NotificationType.AlertDialog);
    Boolean first = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean(Constants.PREFER_FIRST, true);
    if (first) {
        Intent intent = new Intent(this, GuideActivity.class);
        startActivity(intent);
    }
}
Also used : QueryWordFragment(com.zhan_dui.dictionary.fragments.QueryWordFragment) AlertDialog(org.holoeverywhere.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) StartMovingBaseDictionaryListener(com.zhan_dui.dictionary.listeners.StartMovingBaseDictionaryListener) SuppressLint(android.annotation.SuppressLint)

Example 2 with QueryWordFragment

use of com.zhan_dui.dictionary.fragments.QueryWordFragment in project little-bear-dictionary by daimajia.

the class GeneralActivity method onKeyDown.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    SearchView searchView = null;
    switch(keyCode) {
        case KeyEvent.KEYCODE_SEARCH:
            if (mSlidingMenu.isMenuShowing()) {
                mSlidingMenu.toggle();
            }
            if (mCurrentShowID != R.id.search) {
                removerCurrentAndReplaceFragment(R.id.search, new QueryWordFragment(), false);
            }
            searchView = (SearchView) findViewById(android.R.id.inputArea);
            if (searchView != null)
                searchView.setIconified(false);
            return true;
        case KeyEvent.KEYCODE_MENU:
            mSlidingMenu.toggle();
            break;
        case KeyEvent.KEYCODE_BACK:
            if (mSlidingMenu.isMenuShowing()) {
                mSlidingMenu.toggle();
                return true;
            }
            searchView = (SearchView) findViewById(android.R.id.inputArea);
            if (searchView != null && searchView.isIconified() == false) {
                searchView.clearFocus();
                searchView.setIconified(true);
                return true;
            }
            boolean askQuite = PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean("quitetip", true);
            if (askQuite == true) {
                AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
                builder.setTitle(R.string.tips);
                builder.setMessage(R.string.quite_tips);
                builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        finish();
                    }
                });
                builder.setNeutralButton(R.string.give_suggestion, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        UMFeedbackService.openUmengFeedbackSDK(GeneralActivity.this);
                    }
                });
                builder.setNegativeButton(R.string.cancel, null);
                builder.show();
            }
            break;
        default:
    }
    return super.onKeyDown(keyCode, event);
}
Also used : QueryWordFragment(com.zhan_dui.dictionary.fragments.QueryWordFragment) AlertDialog(org.holoeverywhere.app.AlertDialog) SearchView(com.actionbarsherlock.widget.SearchView) DialogInterface(android.content.DialogInterface) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)2 DialogInterface (android.content.DialogInterface)2 QueryWordFragment (com.zhan_dui.dictionary.fragments.QueryWordFragment)2 AlertDialog (org.holoeverywhere.app.AlertDialog)2 Intent (android.content.Intent)1 SearchView (com.actionbarsherlock.widget.SearchView)1 StartMovingBaseDictionaryListener (com.zhan_dui.dictionary.listeners.StartMovingBaseDictionaryListener)1