Android Open Source - misound Wrapper Activity






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;
//from w w w .  j  a  v a 2  s. c  o  m
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import com.umeng.analytics.MobclickAgent;
import com.xiaomi.mitv.idata.client.app.AppData;
import com.xiaomi.mitv.idata.util.Counter;
import com.xiaomi.mitv.soundbarapp.diagnosis.DiagnosisFragment;
import com.xiaomi.mitv.soundbarapp.eq.UserEQControlFragment;
import com.xiaomi.mitv.soundbarapp.faq.FaqFragment;
import com.xiaomi.mitv.soundbarapp.eq.EQSettingsFragment;
import com.xiaomi.mitv.soundbarapp.fragment.BaseFragment;
import com.xiaomi.mitv.soundbarapp.fragment.FeedbackFragment;
import com.xiaomi.mitv.soundbarapp.fragment.SettingsFragment;
import com.xiaomi.mitv.soundbarapp.player.PlayListFragment;

/**
 * Created by chenxuetong on 8/21/14.
 */
public class WrapperActivity extends FragmentActivity {
    public static final String FRAGMENT_UPGRADE = "upgrade";
    public static final String FRAGMENT_SETTINGS = "settings";
    public static final String FRAGMENT_EQ = "eq";
    public static final String FRAGMENT_FAQ = "faq";
    public static final String FRAGMENT_FEEDBACK = "feedback";
    public static final String FRAGMENT_DIAGNOSIS = "diagnosis";
    public static final String FRAGMENT_USER_EQ = "user_eq";
    public static final String FRAGMENT_PLAYLIST = "play_list";

    private BaseFragment mFragement;

    public static void go(Activity from, String fragment, boolean sourceReady){
        Intent i = new Intent(from, WrapperActivity.class);
        i.putExtra("fragment", fragment);
        i.putExtra("have_source", sourceReady);
        i.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
        from.startActivity(i);
    }

    public static void go(Activity from, String fragment){
        go(from,fragment,true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent i = getIntent();
        if(i != null){
            String fragment = i.getStringExtra("fragment");
            if(FRAGMENT_SETTINGS.equals(fragment)){
                boolean sourceReaday = i.getBooleanExtra("have_source", true);
                onSettings(sourceReaday);
            }
            if(FRAGMENT_FAQ.equals(fragment)){
                onFaq();
            }
            if(FRAGMENT_FEEDBACK.equals(fragment)){
                onFeedback();
            }
            if(FRAGMENT_DIAGNOSIS.equals(fragment)){
                onExamine();
            }
            if(FRAGMENT_EQ.equals(fragment)){
                onEQ();
            }
            if(FRAGMENT_USER_EQ.equals(fragment)){
                onUserEQ();
            }
            if(FRAGMENT_PLAYLIST.equals(fragment)){
                onPlayList();
            }
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        MobclickAgent.onResume(this);
    }

    @Override
    protected void onPause() {
        super.onPause();
        MobclickAgent.onResume(this);
    }

    private void onPlayList() {
        mFragement = PlayListFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_PLAYLIST)
                .commitAllowingStateLoss();
    }

    private void onUserEQ() {
        mFragement = UserEQControlFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_UPGRADE)
                .commitAllowingStateLoss();
    }

    @Override
    public void onBackPressed() {
        if(mFragement != null && mFragement.onBackPressed()){
            return;
        }
        finish();
    }

    private void onEQ() {
        mFragement = EQSettingsFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_EQ)
                .commitAllowingStateLoss();
        reportFeatureAccess(FRAGMENT_EQ);
    }

    public void onSettings(boolean sourceReday) {
        SettingsFragment sf = SettingsFragment.newInstance();
        sf.setHaveSource(sourceReday);
        mFragement = sf;
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_SETTINGS)
                .commitAllowingStateLoss();
        reportFeatureAccess(FRAGMENT_SETTINGS);
    }


    public void onFaq() {
        mFragement = FaqFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_FAQ)
                .commitAllowingStateLoss();
        reportFeatureAccess(FRAGMENT_FAQ);
    }

    public void onExamine() {
        DiagnosisFragment.OnListener listener = new DiagnosisFragment.OnListener() {
            @Override
            public void goBack() {
                finish();
            }

            @Override
            public void goFeedback() {
                getFragmentManager().popBackStack();//quit myself
                onFeedback();
            }

            @Override
            public void goFaq() {
                onFaq();
            }
        };

        mFragement = DiagnosisFragment.newInstance(listener);
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_DIAGNOSIS)
                .commitAllowingStateLoss();
        reportFeatureAccess(FRAGMENT_DIAGNOSIS);
    }

    public void onFeedback() {
        mFragement = FeedbackFragment.newInstance();
        getSupportFragmentManager().beginTransaction()
                .add(android.R.id.content, mFragement, FRAGMENT_FEEDBACK)
                .commitAllowingStateLoss();
        reportFeatureAccess(FRAGMENT_FEEDBACK);
    }

    private void showAlert(String title, String msg, final boolean exit) {
        new AlertDialog.Builder(this)
                .setTitle(title)
                .setMessage(msg)
                .setNegativeButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                })
                .create()
                .show();
    }

    private void reportFeatureAccess(String feature) {
        if (TextUtils.isEmpty(feature)) return;
        Counter.count(this, AppData.appID, AppData.appKey, feature, 1);
    }
}




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