Search in sources :

Example 16 with IntentFilter

use of android.content.IntentFilter in project Talon-for-Twitter by klinker24.

the class MainActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    UpdateUtils.checkUpdate(this);
    MainActivity.sendHandler = new Handler();
    context = this;
    sContext = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    DrawerActivity.settings = AppSettings.getInstance(context);
    try {
        requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    } catch (Exception e) {
    }
    sharedPrefs.edit().putBoolean("refresh_me", getIntent().getBooleanExtra("from_notification", false)).commit();
    setUpTheme();
    setUpWindow();
    setContentView(R.layout.main_activity);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    setUpDrawer(0, getResources().getString(R.string.timeline));
    MainActivity.sendLayout = (LinearLayout) findViewById(R.id.send_layout);
    MainActivity.sendHandler.postDelayed(showSend, 1000);
    MainActivity.sendButton = (ImageButton) findViewById(R.id.send_button);
    MainActivity.sendButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Intent compose = new Intent(context, ComposeActivity.class);
            startActivity(compose);
        }
    });
    actionBar = getActionBar();
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
    }
    mSectionsPagerAdapter = new TimelinePagerAdapter(getFragmentManager(), context, sharedPrefs, getIntent().getBooleanExtra("from_launcher", false));
    int currAccount = sharedPrefs.getInt("current_account", 1);
    int defaultPage = sharedPrefs.getInt("default_timeline_page_" + currAccount, 0);
    actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(defaultPage));
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        public void onPageScrollStateChanged(int state) {
        }

        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (!actionBar.isShowing()) {
                actionBar.show();
                if (translucent) {
                    statusBar.setVisibility(View.VISIBLE);
                }
            }
            MainActivity.sendHandler.post(showSend);
        }

        public void onPageSelected(int position) {
            String title = "" + mSectionsPagerAdapter.getPageTitle(position);
            MainDrawerArrayAdapter.setCurrent(context, position);
            drawerList.invalidateViews();
            actionBar.setTitle(title);
        }
    });
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mViewPager.setCurrentItem(defaultPage);
    MainDrawerArrayAdapter.setCurrent(this, defaultPage);
    drawerList.invalidateViews();
    if (getIntent().getBooleanExtra("from_launcher", false)) {
        actionBar.setTitle(mSectionsPagerAdapter.getPageTitle(getIntent().getIntExtra("launcher_page", 0)));
    }
    mViewPager.setOffscreenPageLimit(TimelinePagerAdapter.MAX_EXTRA_PAGES);
    if (getIntent().getBooleanExtra("tutorial", false) && !sharedPrefs.getBoolean("done_tutorial", false)) {
        getIntent().putExtra("tutorial", false);
        sharedPrefs.edit().putBoolean("done_tutorial", true).commit();
        registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "close drawer");
                    mDrawerLayout.closeDrawer(Gravity.LEFT);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_CLOSE_DRAWER));
        registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "open drawer");
                    mDrawerLayout.openDrawer(Gravity.LEFT);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_OPEN_DRAWER));
        registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "page left");
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() - 1, true);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_PAGE_LEFT));
        registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                try {
                    Log.v("tutorial_activity", "page right");
                    mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);
                    unregisterReceiver(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, new IntentFilter(TutorialActivity.ACTION_PAGE_RIGHT));
        startActivity(new Intent(context, TutorialActivity.class));
        overridePendingTransition(0, 0);
    }
    setLauncherPage();
    if (getIntent().getBooleanExtra("from_drawer", false)) {
        mViewPager.setCurrentItem(getIntent().getIntExtra("page_to_open", 1));
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) ComposeActivity(com.klinker.android.twitter.activities.compose.ComposeActivity) Handler(android.os.Handler) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) TimelinePagerAdapter(com.klinker.android.twitter.adapters.TimelinePagerAdapter) BroadcastReceiver(android.content.BroadcastReceiver) View(android.view.View) ViewPager(android.support.v4.view.ViewPager) TutorialActivity(com.klinker.android.twitter.activities.setup.TutorialActivity)

Example 17 with IntentFilter

use of android.content.IntentFilter in project Shuttle by timusus.

the class PlayerActivity method onStart.

@Override
protected void onStart() {
    super.onStart();
    mStatusListener = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            final String action = intent.getAction();
            if (action != null) {
                switch(action) {
                    case MusicService.InternalIntents.META_CHANGED:
                        updateTrackInfo();
                        setPauseButtonImage();
                        queueNextRefresh(1);
                        break;
                    case MusicService.InternalIntents.PLAY_STATE_CHANGED:
                        setPauseButtonImage();
                        break;
                    case MusicService.InternalIntents.REPEAT_CHANGED:
                        setRepeatButtonImage();
                        break;
                    case MusicService.InternalIntents.SHUFFLE_CHANGED:
                        setShuffleButtonImage();
                        break;
                }
            }
        }
    };
    final IntentFilter filter = new IntentFilter();
    filter.addAction(MusicService.InternalIntents.PLAY_STATE_CHANGED);
    filter.addAction(MusicService.InternalIntents.META_CHANGED);
    filter.addAction(MusicService.InternalIntents.SHUFFLE_CHANGED);
    filter.addAction(MusicService.InternalIntents.REPEAT_CHANGED);
    registerReceiver(mStatusListener, new IntentFilter(filter));
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver)

Example 18 with IntentFilter

use of android.content.IntentFilter in project Shuttle by timusus.

the class QCircleActivity method registerIntentReceiver.

private void registerIntentReceiver() {
    IntentFilter filter = new IntentFilter();
    // Add QCircle intent to the intent filter
    filter.addAction(ACTION_ACCESSORY_COVER_EVENT);
    // Register a broadcast receiver with the system
    mContext.registerReceiver(mIntentReceiver, filter);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 19 with IntentFilter

use of android.content.IntentFilter in project Shuttle by timusus.

the class AlbumFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    IntentFilter filter = new IntentFilter();
    filter.addAction("restartLoader");
    getActivity().registerReceiver(receiver, filter);
    refreshAdapterItems();
}
Also used : IntentFilter(android.content.IntentFilter)

Example 20 with IntentFilter

use of android.content.IntentFilter in project Shuttle by timusus.

the class EqualizerService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    IntentFilter audioFilter = new IntentFilter();
    audioFilter.addAction(ACTION_OPEN_EQUALIZER_SESSION);
    audioFilter.addAction(ACTION_CLOSE_EQUALIZER_SESSION);
    registerReceiver(mAudioSessionReceiver, audioFilter);
    saveDefaults();
}
Also used : IntentFilter(android.content.IntentFilter)

Aggregations

IntentFilter (android.content.IntentFilter)1505 Intent (android.content.Intent)516 Context (android.content.Context)305 BroadcastReceiver (android.content.BroadcastReceiver)285 PendingIntent (android.app.PendingIntent)155 RemoteException (android.os.RemoteException)80 Handler (android.os.Handler)65 ComponentName (android.content.ComponentName)55 PowerManager (android.os.PowerManager)50 View (android.view.View)50 Uri (android.net.Uri)42 Test (org.junit.Test)42 ArrayList (java.util.ArrayList)39 TextView (android.widget.TextView)37 HandlerThread (android.os.HandlerThread)34 ResolveInfo (android.content.pm.ResolveInfo)30 File (java.io.File)30 PackageManager (android.content.pm.PackageManager)28 Point (android.graphics.Point)28 IOException (java.io.IOException)28