Android Open Source - misound Main Entry Fragment






From Project

Back to project page misound.

License

The source code is released under:

Apache License

If you think the Android project misound 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.xiaomi.mitv.soundbarapp.fragment;
/*from  w w w . j  av  a  2 s  .co  m*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.xiaomi.mitv.soundbarapp.R;
import com.xiaomi.mitv.soundbarapp.WrapperActivity;
import com.xiaomi.mitv.soundbarapp.player.PlayerFragment;
import com.xiaomi.mitv.soundbarapp.upgrade.UpgradeFragment;

/**
 * Created by chenxuetong on 9/28/14.
 */
public class MainEntryFragment extends BaseFragment implements View.OnClickListener {
    public static final String UPGRADE_TAG = "upgarde";
    public static final String PLAYER_TAG = "player";

    private View mEQEntry;
    private View mSettings;
    private View mDiagnosis;
    protected boolean mBarSourceReady;
    private boolean mSettingEnabled = true;
    private boolean mEqEnabled = true;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.new_main_entries_with_player, container, false);
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        mSettings = findViewbyId(R.id.main_entry_settings);
        mSettings.setOnClickListener(this);
        mEQEntry = findViewbyId(R.id.main_entry_eq);
        mEQEntry.setOnClickListener(this);
        mDiagnosis = findViewbyId(R.id.main_entry_diagnose);
        mDiagnosis.setOnClickListener(this);
        mEQEntry.setEnabled(mEqEnabled);
        mSettings.setEnabled(mSettingEnabled);

        Fragment f = getFragmentManager().findFragmentByTag(UPGRADE_TAG);
        if(f==null) {
            Fragment upgrade = new UpgradeFragment();
            getFragmentManager().beginTransaction()
                    .replace(R.id.main_entry_upgrade, upgrade, UPGRADE_TAG)
                    .commit();
        }

        f = getFragmentManager().findFragmentByTag(PLAYER_TAG);
        if(f==null){
            PlayerFragment pf = new PlayerFragment();
            FragmentActivity activity = getActivity();
            if(activity instanceof PlayerFragment.OnPlayerStateListener){
                pf.setStateListener((PlayerFragment.OnPlayerStateListener)activity);
            }

            getFragmentManager().beginTransaction()
                    .add(R.id.main_player_container, pf, PLAYER_TAG)
                    .commit();
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.main_entry_upgrade:
                break;
            case R.id.main_entry_settings:
                showSettings();
                break;
            case R.id.main_entry_eq:
                showEq();
                break;
            case R.id.main_entry_diagnose:
                WrapperActivity.go(getActivity(), WrapperActivity.FRAGMENT_DIAGNOSIS);
                break;
        }
    }

    public void setSourceReady(boolean ready){
        mBarSourceReady = ready;
    }

    public void showSettings(){
        if(mSettings.isEnabled()) {
            WrapperActivity.go(getActivity(), WrapperActivity.FRAGMENT_SETTINGS, mBarSourceReady);
        }
    }

    public void showEq(){
        if(mEQEntry.isEnabled()) {
            if (mBarSourceReady) {
                WrapperActivity.go(getActivity(), WrapperActivity.FRAGMENT_EQ);
            } else {
                Toast.makeText(getActivity(), "???????????", Toast.LENGTH_LONG).show();
            }
        }
    }
    public void enableSettings(boolean enabled) {
        mSettingEnabled = enabled;
        if(mSettings != null) {
            mSettings.setEnabled(enabled);
        }
    }

    public void enableEq(boolean enabled) {
        mEqEnabled = enabled;
        if(mEQEntry != null) {
            mEQEntry.setEnabled(enabled);
        }
    }
}




Java Source Code List

com.xiaomi.mitv.soundbar.DefaultMisoundDevice.java
com.xiaomi.mitv.soundbarapp.BarInfoUtils.java
com.xiaomi.mitv.soundbarapp.ConnectingActivity.java
com.xiaomi.mitv.soundbarapp.MainActivity2.java
com.xiaomi.mitv.soundbarapp.SoundBarApplication.java
com.xiaomi.mitv.soundbarapp.TestActivity.java
com.xiaomi.mitv.soundbarapp.TypefaceManager.java
com.xiaomi.mitv.soundbarapp.WrapperActivity.java
com.xiaomi.mitv.soundbarapp.diagnosis.DiagnosisFragment.java
com.xiaomi.mitv.soundbarapp.diagnosis.Engine.java
com.xiaomi.mitv.soundbarapp.diagnosis.ViewWrapper.java
com.xiaomi.mitv.soundbarapp.diagnosis.data.Entry.java
com.xiaomi.mitv.soundbarapp.diagnosis.data.Node.java
com.xiaomi.mitv.soundbarapp.diagnosis.data.OrderedList.java
com.xiaomi.mitv.soundbarapp.diagnosis.data.QAElement.java
com.xiaomi.mitv.soundbarapp.eq.EQManager.java
com.xiaomi.mitv.soundbarapp.eq.EQSettingsFragment.java
com.xiaomi.mitv.soundbarapp.eq.EQStyleResource.java
com.xiaomi.mitv.soundbarapp.eq.EQStyle.java
com.xiaomi.mitv.soundbarapp.eq.UserEQControlFragment.java
com.xiaomi.mitv.soundbarapp.faq.FaqDataStore.java
com.xiaomi.mitv.soundbarapp.faq.FaqFragment.java
com.xiaomi.mitv.soundbarapp.fragment.A2dpDlg.java
com.xiaomi.mitv.soundbarapp.fragment.BaseFragment.java
com.xiaomi.mitv.soundbarapp.fragment.FeedbackFragment.java
com.xiaomi.mitv.soundbarapp.fragment.MainEntryFragment.java
com.xiaomi.mitv.soundbarapp.fragment.PanelFragment.java
com.xiaomi.mitv.soundbarapp.fragment.SettingsFragment.java
com.xiaomi.mitv.soundbarapp.player.MediaButtonIntentReceiver.java
com.xiaomi.mitv.soundbarapp.player.MusicUtils.java
com.xiaomi.mitv.soundbarapp.player.PlayListFragment.java
com.xiaomi.mitv.soundbarapp.player.PlayerFragment.java
com.xiaomi.mitv.soundbarapp.player.PlayerService.java
com.xiaomi.mitv.soundbarapp.player.Player.java
com.xiaomi.mitv.soundbarapp.provider.DataProvider.java
com.xiaomi.mitv.soundbarapp.upgrade.FirmwareManager.java
com.xiaomi.mitv.soundbarapp.upgrade.FirmwareZipFile.java
com.xiaomi.mitv.soundbarapp.upgrade.UpdateActivity.java
com.xiaomi.mitv.soundbarapp.upgrade.UpgradeFragment.java
com.xiaomi.mitv.soundbarapp.upgrade.VersionSelectFragment.java
com.xiaomi.mitv.soundbarapp.util.ConfirmActivityDlg.java
com.xiaomi.mitv.soundbarapp.util.Worker.java
com.xiaomi.mitv.widget.GainView.java
com.xiaomi.mitv.widget.GifView.java
com.xiaomi.mitv.widget.LetterIndexSilderBar.java
com.xiaomi.mitv.widget.MiSwitch.java
com.xiaomi.mitv.widget.RoundAnimationView.java
com.xiaomi.mitv.widget.RoundProgressBar.java
com.xiaomi.mitv.widget.RoundSeekBar.java