Java Code Examples for com.firebase.client.Firebase#setAndroidContext()

The following examples show how to use com.firebase.client.Firebase#setAndroidContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: forum.java    From Krishi-Seva with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_forum);
    Firebase.setAndroidContext(this);
    chatView = (ChatView) findViewById(R.id.chat_view);
  read();


    chatView.setOnSentMessageListener(new ChatView.OnSentMessageListener(){
        @Override
        public boolean sendMessage(ChatMessage chatMessage){
            Firebase ref = new Firebase("https://adaa-45b17.firebaseio.com/FORUMS/");
            foru person = new foru();

            person.setPost(chatMessage.getMessage());
            ref.push().setValue(person);

            return true;
        }
    });
}
 
Example 2
Source File: MainActivity.java    From cloud-cup-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Firebase.setAndroidContext(this);
    setContentView(R.layout.activity_main);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(Plus.SCOPE_PLUS_LOGIN)
            .build();

    firebase = new Firebase(Consts.FIREBASE_URL);
    username = (TextView) findViewById(R.id.username);
    userImage = (ImageView) findViewById(R.id.user_image);
    code = (EditText) findViewById(R.id.code);
    code.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            join();
            return true;
        }
    });
    code.requestFocus();
}
 
Example 3
Source File: MapsActivity.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);

    // Set up Google Maps
    SupportMapFragment mapFragment = (SupportMapFragment)
            getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    // Set up the API client for Places API
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Places.GEO_DATA_API)
            .build();
    mGoogleApiClient.connect();

    // Set up Firebase
    Firebase.setAndroidContext(this);
    mFirebase = new Firebase(FIREBASE_URL);
    mFirebase.child(FIREBASE_ROOT_NODE).addChildEventListener(this);
}
 
Example 4
Source File: createlisting.java    From Krishi-Seva with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_createlisting);
    ed = (EditText) findViewById(R.id.fname);
    ed2 = (EditText) findViewById(R.id.lname);
    ed3 = (EditText) findViewById(R.id.cname);
    Firebase.setAndroidContext(this);
}
 
Example 5
Source File: orders.java    From Krishi-Seva with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_orders);
    Firebase.setAndroidContext(this);
    read();

}
 
Example 6
Source File: MangoBlogger.java    From MangoBloggerAndroidApp with Mozilla Public License 2.0 5 votes vote down vote up
@Override
    public void onCreate() {
        super.onCreate();
        Firebase.setAndroidContext(this);


//        initGoogleAnalytics();
//        initGoogleTagManager();
    }
 
Example 7
Source File: MainActivity.java    From animation-samples with Apache License 2.0 5 votes vote down vote up
private void initFirebase() {
    Firebase.setAndroidContext(getApplicationContext());
    Config defaultConfig = Firebase.getDefaultConfig();
    if (!defaultConfig.isFrozen()) {
        defaultConfig.setPersistenceEnabled(true);
    }
}
 
Example 8
Source File: CloudManager.java    From thunderboard-android with Apache License 2.0 5 votes vote down vote up
@Inject
public CloudManager(
        @ForApplication Context context,
        @ForCloudData String baseDataUrl,
        @ForCloudDemo String baseDemoUrl,
        @ForCloudKeyFirebase String keyFirebase,
        PreferenceManager prefsManager) {
    this.context = context;
    this.baseDataUrl = baseDataUrl;
    this.baseDataThunderBoardUrl = baseDataUrl + "thunderboard/";
    this.baseDataSessionsUrl = baseDataUrl + "sessions/";
    this.baseDemoUrl = baseDemoUrl;
    this.baseDemoSessionsUrl = baseDemoUrl;
    this.keyFirebase = keyFirebase;
    this.prefsManager = prefsManager;

    // The Firebase library must be initialized once with an Android context.
    // This must happen before any Firebase app reference is created or used.
    Firebase.setAndroidContext(context);

    Timber.d("data url: %s", baseDataUrl);
    Timber.d("demo url: %s", baseDemoUrl);

    registerWifiUpdateReceiver();

    isRootDataSessionsAvailable = false;
}
 
Example 9
Source File: BaseApplication.java    From io16experiment-master with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    /* Initialize Firebase */
    Firebase.setAndroidContext(this);
}
 
Example 10
Source File: DrawingApplication.java    From AndroidDrawing with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Firebase.setAndroidContext(this);
    Firebase.getDefaultConfig().setPersistenceEnabled(true);
    //Firebase.getDefaultConfig().setLogLevel(Logger.Level.DEBUG);
    SyncedBoardManager.setContext(this);
}
 
Example 11
Source File: PerfTestFirebase.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
private void setupFirebase() {
    // handle multiple tests calling setup
    if (!Firebase.getDefaultConfig().isFrozen()) {
        Firebase.getDefaultConfig().setPersistenceEnabled(true);
    }
    Firebase.setAndroidContext(getTargetContext());
    Firebase.goOffline();

    rootFirebaseRef = new Firebase("https://luminous-inferno-2264.firebaseio.com");
}
 
Example 12
Source File: HNewsApplication.java    From yahnac with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    context = this;
    Firebase.setAndroidContext(this);
    SimpleChromeCustomTabs.initialize(this);

    Inject.using(new DefaultDependenciesFactory(this));

    startup();
}
 
Example 13
Source File: ChatApplication.java    From AndroidChat with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Firebase.setAndroidContext(this);
}
 
Example 14
Source File: LoginDemoApplication.java    From firebase-login-demo-android with MIT License 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Firebase.setAndroidContext(this);
    FacebookSdk.sdkInitialize(this);
}
 
Example 15
Source File: HelloAndroidActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Called when the activity is first created.
 * 
 * @param savedInstanceState
 *            If the activity is being re-initialized after previously being
 *            shut down then this Bundle contains the data it most recently
 *            supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it
 *            is null.</b>
 */
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_main);
	
	// Retrieve components
	final ListView listView = (ListView)findViewById(R.id.messagesListView);
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
	listView.setAdapter(adapter);

	final EditText msgText = (EditText)findViewById(R.id.msgEditText);
	Button sendButton = (Button)findViewById(R.id.sendButton);
	
	// setting context to firebase
	Firebase.setAndroidContext(this);
    myFirebaseRef = new Firebase("https://anaware.firebaseio.com/");
    myFirebaseRef.child("message").addValueEventListener(new ValueEventListener() {
	        public void onDataChange(DataSnapshot snapshot) {
	        	if (snapshot.getValue() != null) {
	        		Map<String, Object> newPost = (Map<String, Object>) snapshot.getValue();
	        		list.clear();
	        		for (String post : newPost.keySet())
	        		{
	        			list.add(post + "\r\n" + newPost.get(post));
	        		}
	        		((BaseAdapter) listView.getAdapter()).notifyDataSetChanged(); 
	        	}
	        }
	        
        	public void onCancelled(FirebaseError error) {
        		// TODO
        	}
        });
    
	// Add events
	sendButton.setOnClickListener(new OnClickListener() {
		public void onClick(View v) {
			if (!msgText.getText().toString().equals("")) {
			    myFirebaseRef.child("message").child((new Date()).toString()).setValue(msgText.getText().toString());
			    msgText.setText("");
			}
		}
	});
}
 
Example 16
Source File: CommentsActivity.java    From Hews with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set theme
    prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String theme = SharedPrefsManager.getTheme(prefs);
    switch (theme) {
        case SharedPrefsManager.THEME_SEPIA:
            setTheme(R.style.AppTheme_Sepia);
            break;
        case SharedPrefsManager.THEME_DARK:
            setTheme(R.style.AppTheme_Dark);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                getWindow().setStatusBarColor(getResources().getColor(R.color.grey_900));
            }
            break;
        case SharedPrefsManager.THEME_AMOLED_BLACK:
            setTheme(R.style.AppTheme_AMOLEDBlack);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                getWindow().setStatusBarColor(getResources().getColor(android.R.color.black));
            }
            break;
    }
    setContentView(R.layout.activity_comments);
    Firebase.setAndroidContext(this);
    appbar = (AppBarLayout) findViewById(R.id.appbar);
    appbar.addOnOffsetChangedListener(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle("Comments");
        actionBar.setHomeButtonEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mWindow = new PopupFloatingWindow(this, toolbar);
    mFab = (FloatingScrollDownButton) findViewById(R.id.fab);
    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
    layoutReply = (LinearLayout) findViewById(R.id.layout_reply);
    btnReplySend = (FloatingActionButton) findViewById(R.id.btn_reply_send);
    etReply = (EditText) findViewById(R.id.et_reply);

    Intent intent = getIntent();
    CommentsFragment commentsFragment = null;
    Parcelable postParcel = intent.getParcelableExtra(Constants.KEY_POST_PARCEL);
    if (postParcel != null) {
        commentsFragment = CommentsFragment.newInstance(postParcel,
            intent.getBooleanExtra(Constants.KEY_IS_BOOKMARKED, false));
        Post post = Parcels.unwrap(postParcel);
        //FIXME how the url could be null?!
        mUrl = (post.getUrl() != null ? post.getUrl() : "https://news.ycombinator.com/");
        mPostId = post.getId();
    } else {
        final Uri data = intent.getData();
        if (data != null && data.getQueryParameter("id") != null) {
            long storyId = Long.parseLong(data.getQueryParameter("id"));
            commentsFragment = CommentsFragment.newInstance(storyId);
            mPostId = storyId;
        }
    }

    if (savedInstanceState == null) {
        if (commentsFragment != null) {
            getFragmentManager().beginTransaction()
                .add(R.id.container, commentsFragment, Constants.FRAGMENT_TAG_COMMENT)
                .commit();
        }
    }

    mDataManager = new DataManager();
    mCompositeSubscription = new CompositeSubscription();
}
 
Example 17
Source File: ClimbTrackerApplication.java    From climb-tracker with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    Firebase.getDefaultConfig().setPersistenceEnabled(true);
    Firebase.setAndroidContext(this);
}
 
Example 18
Source File: HomeActivity.java    From MangoBloggerAndroidApp with Mozilla Public License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    loadGTMContainer();
    setContentView(R.layout.activity_home);
    if (savedInstanceState == null) {
        pendingIntroAnimation = true;
    }

    Fabric.with(this, new Crashlytics());
    Firebase.setAndroidContext(this);

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);
    mFirebaseAnalytics.setMinimumSessionDuration(20000);
    // firebase remote configuration
    mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
    firebaseRemoteConfigSettings();
    fetchFirebaseRemoteConfig();

    Bundle bundle = new Bundle();
    String id = "MangoBlogger";
    String name = "Google analytics";
    bundle.putString(FirebaseAnalytics.Param.ITEM_ID, id);
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, name);
    bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "image");
    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);

    mNavigation = (BottomNavigationView) findViewById(R.id.navigation);
    mNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbarLogo = (ImageView) findViewById(R.id.app_logo);
    setupToolbar();
    setUpDrawer();



    attachFragment(HomeFragment.newInstance(), false);



}