Android Open Source - photogallery Visible Fragment






From Project

Back to project page photogallery.

License

The source code is released under:

Apache License

If you think the Android project photogallery 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.donnemartin.android.photogallery;
// w w w . j a v a 2 s. co m
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v4.app.Fragment;
import android.util.Log;

public abstract class VisibleFragment extends Fragment {
    // Dynamic broadcast receiver.
    // Generic fragment that hides foreground notifications

    public static final String TAG = "VisibleFragment";

    // The receiver is typically defined as an inner instance like a
    // button click listener
    // We need mOnShowNotification for onResume and onPause, so save it
    private BroadcastReceiver mOnShowNotification = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // if we receive this, we're visible, so cancel
            // the notification
            Log.i(TAG, "canceling notification");
            setResultCode(Activity.RESULT_CANCELED);
        }
    };

    @Override
    public void onResume() {
        super.onResume();

        // Can also create this in XML as an <intent-filter>
        IntentFilter filter =
            new IntentFilter(PollService.ACTION_SHOW_NOTIFICATION);
        getActivity().registerReceiver(mOnShowNotification,
                                       filter,
                                       PollService.PERM_PRIVATE,
                                       null);
    }

    @Override
    public void onPause() {
        super.onPause();
        getActivity().unregisterReceiver(mOnShowNotification);
    }
}




Java Source Code List

com.donnemartin.android.photogallery.Creds.java
com.donnemartin.android.photogallery.FlickrConn.java
com.donnemartin.android.photogallery.GalleryItem.java
com.donnemartin.android.photogallery.NotificationReceiver.java
com.donnemartin.android.photogallery.PhotoGalleryActivity.java
com.donnemartin.android.photogallery.PhotoGalleryFragment.java
com.donnemartin.android.photogallery.PhotoPageActivity.java
com.donnemartin.android.photogallery.PhotoPageFragment.java
com.donnemartin.android.photogallery.PollService.java
com.donnemartin.android.photogallery.SingleFragmentActivity.java
com.donnemartin.android.photogallery.StartupReceiver.java
com.donnemartin.android.photogallery.ThumbnailDownloader.java
com.donnemartin.android.photogallery.VisibleFragment.java