com.firebase.client.Firebase Java Examples

The following examples show how to use com.firebase.client.Firebase. 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: MainActivity.java    From io16experiment-master with Apache License 2.0 6 votes vote down vote up
/**
 * Generate an anonymous account to identify this user. The UID will be transmitted as part of the payload for all
 * connected devices.
 */
private void generateAnonymousAccount() {
    LogUtils.LOGE("***> generate anon account", "here");
    Firebase ref = new Firebase(Constants.FIREBASE_URL);
    ref.authAnonymously(new Firebase.AuthResultHandler() {
        @Override
        public void onAuthenticated(AuthData authData) {
            // we've authenticated this session with your Firebase app
            LogUtils.LOGE("***> onAuthenticated", authData.getUid());
            PreferencesUtils.setString(mActivity, R.string.key_firebase_uid, authData.getUid());
            createUserInFirebaseHelper(authData.getUid());
        }
        @Override
        public void onAuthenticationError(FirebaseError firebaseError) {
            // there was an error
        }
    });
}
 
Example #2
Source File: FireBaseActivity.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Random r = new Random();
    mUsername = "AhoyUser" + r.nextInt(1000);

    setContentView(R.layout.day30_activity_firebase);

    mButtonSend = (ImageButton) findViewById(R.id.button_send);
    mMessage = (EditText) findViewById(R.id.message);
    mListView = (ListView) findViewById(R.id.list_view);
    mListView.setBackgroundColor(Color.parseColor("#26B895"));

    mFirebase = new Firebase(AHOY_CHAT_URL).child("chat");

    queryData();

    mButtonSend.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            sendMessage();
        }
    });
}
 
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: ClimbSessionDetailFragment.java    From climb-tracker with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Analytics.
    ClimbTrackerApplication application = (ClimbTrackerApplication) getActivity().getApplication();
    mTracker = application.getDefaultTracker();

    // track pageview
    mTracker.setScreenName(LOG_TAG);
    mTracker.send(new HitBuilders.ScreenViewBuilder().build());

    mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url));
    AuthData authData = mFirebaseRef.getAuth();
    mFirebaseRef = mFirebaseRef.child("users")
            .child(authData.getUid())
            .child("climbs");


    long time = getArguments().getLong(ARG_FIRST_CLIMB_TIME);
    mSession = new ClimbSession( new Date(time) );

    long lastTime = getArguments().getLong(ARG_LAST_CLIMB_TIME);

    mListAdapter = new ClimbListAdapter(mFirebaseRef.limitToFirst(50).orderByChild("date").startAt(time).endAt(lastTime), R.layout.climb_item, getActivity());
}
 
Example #5
Source File: ClimbSessionListFragment.java    From climb-tracker with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url));

    mFirebaseRef.addAuthStateListener(new Firebase.AuthStateListener() {
        @Override
        public void onAuthStateChanged(AuthData authData) {
            if (authData != null) {
                Firebase ref = mFirebaseRef.child("users").child(authData.getUid());
                ref.keepSynced(true);
                mListAdapter = new ClimbSessionListAdapter(ref.child("climbs").limitToLast(CLIMB_LIMIT).orderByChild("date"), R.layout.climbsession_item, getActivity());
                setListAdapter(mListAdapter);
            }
        }
    });

}
 
Example #6
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 #7
Source File: MainActivity.java    From io16experiment-master with Apache License 2.0 6 votes vote down vote up
public static void resetDevice() {
    // Delete entries from Firebase
    String firebaseUid = PreferencesUtils.getString(mActivity, R.string.key_firebase_uid, "");

    LogUtils.LOGE("***> reset device", firebaseUid);
    Firebase deviceRef = new Firebase(Constants.FIREBASE_URL_DEVICES).child(firebaseUid);
    deviceRef.removeValue();

    Firebase userRef = new Firebase(Constants.FIREBASE_URL_USERS).child(firebaseUid);
    userRef.removeValue();

    PreferencesUtils.setString(mActivity, R.string.key_firebase_uid, "");
    PreferencesUtils.setInt(mActivity, R.string.key_device_number, 0);
    PreferencesUtils.setBoolean(mActivity, R.string.key_is_connected, false);
    PreferencesUtils.setInt(mActivity, R.string.key_total_devices, 0);
    PreferencesUtils.setBoolean(mActivity, R.string.key_message_received, false);

    hide();

    PreferencesUtils.setBoolean(mActivity, R.string.key_device_reset_done, true);

    Intent intent = new Intent(mActivity, MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    mActivity.startActivity(intent);
    mActivity.finish();
}
 
Example #8
Source File: BoardListActivity.java    From AndroidDrawing with MIT License 6 votes vote down vote up
private void createBoard() {
    // create a new board
    final Firebase newBoardRef = mBoardsRef.push();
    Map<String, Object> newBoardValues = new HashMap<>();
    newBoardValues.put("createdAt", ServerValue.TIMESTAMP);
    android.graphics.Point size = new android.graphics.Point();
    getWindowManager().getDefaultDisplay().getSize(size);
    newBoardValues.put("width", size.x);
    newBoardValues.put("height", size.y);
    newBoardRef.setValue(newBoardValues, new Firebase.CompletionListener() {
        @Override
        public void onComplete(FirebaseError firebaseError, Firebase ref) {
            if (firebaseError != null) {
                Log.e(TAG, firebaseError.toString());
                throw firebaseError.toException();
            } else {
                // once the board is created, start a DrawingActivity on it
                openBoard(newBoardRef.getKey());
            }
        }
    });
}
 
Example #9
Source File: DataPresenter.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a data presenter.
 *
 * @param dataView The view which will display the data.
 * @param configUrl The firebase endpoint url.
 */
DataPresenter(@NonNull DataView<T> dataView, @NonNull String configUrl) {
    mFirebase = new Firebase(configUrl);
    mData = new ArrayList<>();
    mDataView = dataView;

    mValueEventListener = new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mData.clear();
            for (DataSnapshot data : dataSnapshot.getChildren()) {
                // Data parsing is being done within the extending classes.
                mData.add(parseData(data));
            }
            mDataView.showData(mData);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            Log.d(TAG, "onCancelled: " + firebaseError.getMessage());
            // Deliberately swallow the firebase error here.
            mDataView.showError();
        }
    };
}
 
Example #10
Source File: createlisting.java    From Krishi-Seva with MIT License 6 votes vote down vote up
public void c(View view) {
    String amount = ed.getText().toString();
    String kg = ed2.getText().toString();
    String loc = ed3.getText().toString();
    if(selected.equals(""))
    {
        new SweetAlertDialog(this, SweetAlertDialog.ERROR_TYPE)
                .setTitleText("Oops...")
                .setContentText("You Did Not Enter The Amount")
                .show();
    }
    else
    {
       String  url="https://adaa-45b17.firebaseio.com/ORDERS";
        Firebase ref = new Firebase(url);
        ordering order = new ordering();

      order.setAmount(amount);
        order.setKgs(kg);
        order.setCrop(selected);
        order.setLat("9.9312");
        order.setLongg("76.2673");
        order.setLoc(loc);
        ref.push().setValue(order);
    }
}
 
Example #11
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 #12
Source File: FirebaseListFragment.java    From MangoBloggerAndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_recycler_view, container ,false);

        recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
//        mShimmerView = (ListShimmerView) view.findViewById(R.id.shimmer_view);
        mProgressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
//        mShimmerView.setVisibility(View.VISIBLE);
        final GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(), 1);

        recyclerView.setLayoutManager(gridLayoutManager);
        recyclerView.addItemDecoration(new GridSpacingItemDecoration(1, 20, true));


        mBlogList = new ArrayList<>();
        FirebaseDatabase.getInstance().setPersistenceEnabled(true);
        mFirebaseRef = new Firebase(mUrl); /* connect to firebase*/


        return view;
    }
 
Example #13
Source File: forum.java    From Krishi-Seva with MIT License 5 votes vote down vote up
public void read()
{

    final Firebase ref = new Firebase("https://adaa-45b17.firebaseio.com/FORUMS/");
    //Value event listener for realtime data update

    ref.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot usersSnapshot) {

            for (DataSnapshot userSnapshot : usersSnapshot.getChildren()) {
                foru user = userSnapshot.getValue(foru.class);

               String post = user.getPost().toString();
                chatView.addMessage(new ChatMessage(post, System.currentTimeMillis(), ChatMessage.Type.RECEIVED));

            }

        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            System.out.println("The read failed: " + firebaseError.getMessage());
        }
    });

}
 
Example #14
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 #15
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 #16
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 #17
Source File: HNewsApi.java    From yahnac with Apache License 2.0 5 votes vote down vote up
private Firebase getStoryFirebase(Story.FILTER FILTER) {
    switch (FILTER) {
        case show:
            return new Firebase("https://hacker-news.firebaseio.com/v0/showstories");
        case ask:
            return new Firebase("https://hacker-news.firebaseio.com/v0/askstories");
        case jobs:
            return new Firebase("https://hacker-news.firebaseio.com/v0/jobstories");
        default:
            return new Firebase("https://hacker-news.firebaseio.com/v0/topstories");
    }
}
 
Example #18
Source File: SimpleLogin.java    From firebase-simple-login-java with MIT License 5 votes vote down vote up
private SimpleLogin(Firebase ref, String apiHost, Context context, SimpleLoginOptions options) {
  super();
  this.ref = ref;
  this.apiHost = apiHost;
  this.namespace = FirebaseUtils.namespaceFromRef(ref);
  this.androidContext = context;
  this.options = options;
}
 
Example #19
Source File: DrawingActivity.java    From AndroidDrawing with MIT License 5 votes vote down vote up
/**
 * Called when the activity is first created.
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Intent intent = getIntent();
    final String url = intent.getStringExtra("FIREBASE_URL");
    final String boardId = intent.getStringExtra("BOARD_ID");
    Log.i(TAG, "Adding DrawingView on "+url+" for boardId "+boardId);
    mFirebaseRef = new Firebase(url);
    mBoardId = boardId;
    mMetadataRef = mFirebaseRef.child("boardmetas").child(boardId);
    mSegmentsRef = mFirebaseRef.child("boardsegments").child(mBoardId);
    mMetadataRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            if (mDrawingView != null) {
                ((ViewGroup) mDrawingView.getParent()).removeView(mDrawingView);
                mDrawingView.cleanup();
                mDrawingView = null;
            }
            Map<String, Object> boardValues = (Map<String, Object>) dataSnapshot.getValue();
            if (boardValues != null && boardValues.get("width") != null && boardValues.get("height") != null) {
                mBoardWidth = ((Long) boardValues.get("width")).intValue();
                mBoardHeight = ((Long) boardValues.get("height")).intValue();

                mDrawingView = new DrawingView(DrawingActivity.this, mFirebaseRef.child("boardsegments").child(boardId), mBoardWidth, mBoardHeight);
                setContentView(mDrawingView);
            }
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            // No-op
        }
    });
}
 
Example #20
Source File: PerfTestFirebase.java    From android-database-performance with Apache License 2.0 5 votes vote down vote up
@Override
protected void doIndexedStringEntityQueries() throws Exception {
    // Firebase does not support defining indexes locally, only in the cloud component
    // We measure the local datastore query time anyhow, but WITHOUT INDEXES.

    // set up node for entities
    Firebase entityRef = rootFirebaseRef.child("indexedStringEntity");

    for (int i = 0; i < RUNS; i++) {
        log("----Run " + (i + 1) + " of " + RUNS);
        indexedStringEntityQueriesRun(entityRef, getBatchSize());
    }
}
 
Example #21
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 #22
Source File: MobileDataLayerListenerService.java    From climb-tracker with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Wearable.API)
            .addApi(LocationServices.API)
            .build();
    mGoogleApiClient.connect();

    mFirebaseRef = new Firebase(getResources().getString(R.string.firebase_url));
}
 
Example #23
Source File: DrawingActivity.java    From AndroidDrawing with MIT License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == COLOR_MENU_ID) {
        new ColorPickerDialog(this, this, 0xFFFF0000).show();
        return true;
    } else if (item.getItemId() == CLEAR_MENU_ID) {
        mDrawingView.cleanup();
        mSegmentsRef.removeValue(new Firebase.CompletionListener() {
            @Override
            public void onComplete(FirebaseError firebaseError, Firebase firebase) {
                if (firebaseError != null) {
                    throw firebaseError.toException();
                }
                mDrawingView = new DrawingView(DrawingActivity.this, mFirebaseRef.child("boardsegments").child(mBoardId), mBoardWidth, mBoardHeight);
                setContentView(mDrawingView);
                //mDrawingView.clear();
            }
        });

        return true;
    } else if (item.getItemId() == PIN_MENU_ID) {
        SyncedBoardManager.toggle(mFirebaseRef.child("boardsegments"), mBoardId);
        item.setChecked(SyncedBoardManager.isSynced(mBoardId));
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}
 
Example #24
Source File: MainActivity.java    From cloud-cup-android with Apache License 2.0 5 votes vote down vote up
public void join() {
    Intent intent = new Intent(this, BlankGameActivity.class);

    String codeValue = code.getText().toString();

    String playerName;
    String imageUrl;
    if(mGoogleApiClient.isConnected()) {
        // Get data of current signed-in user
        Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
        playerName = currentPerson.getName().getGivenName();
        imageUrl = getUserImageUrl(currentPerson);

    } else {
        Random rand = new Random();
        playerName = "Anonymous " + rand.nextInt(10);
        imageUrl = "";
    }

    // Register player data in Firebase
    Firebase ref = firebase.child("room/" + codeValue + "/players");
    Firebase pushRef = ref.push();
    Map<String, Object> user = new HashMap<String, Object>();
    user.put("name", playerName);
    user.put("imageUrl", imageUrl);
    user.put("score", 0);
    pushRef.setValue(user);
    String key = pushRef.getKey();

    // Add intent data
    intent.putExtra("playerId", key);
    intent.putExtra("playerName", playerName);
    intent.putExtra("code", codeValue);

    // Start the intent
    startActivity(intent);
}
 
Example #25
Source File: SyncedBoardManager.java    From AndroidDrawing with MIT License 5 votes vote down vote up
public static void toggle(Firebase boardsRef, String boardId) {
    SharedPreferences preferences = mContext.getSharedPreferences(PREFS_NAME, 0);
    Set<String> syncedBoards = new HashSet<>(preferences.getStringSet(PREF_NAME, new HashSet<String>()));
    if (syncedBoards.contains(boardId)) {
        syncedBoards.remove(boardId);
        boardsRef.child(boardId).keepSynced(false);
    }
    else {
        syncedBoards.add(boardId);
        boardsRef.child(boardId).keepSynced(true);
    }
    preferences.edit().putStringSet(PREF_NAME, syncedBoards).commit();
    Log.i(TAG, "Board " + boardId + " is now " + (syncedBoards.contains(boardId) ? "" : "not ") + "synced");
}
 
Example #26
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 #27
Source File: FirebaseDB.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_BOOLEAN,
  defaultValue = "False")
@SimpleProperty(userVisible = false,
  description = "If true, variables will retain their values when off-line and the App " +
  "exits. Values will be uploaded to Firebase the next time the App is " +
  "run while connected to the network. This is useful for applications " +
  "which will gather data while not connected to the network. Note: " +
  "AppendValue and RemoveFirst will not work correctly when off-line, " +
  "they require a network connection.<br/><br/> " +
  "<i>Note</i>: If you set Persist on any Firebase component, on any " +
  "screen, it makes all Firebase components on all screens persistent. " +
  "This is a limitation of the low level Firebase library. Also be " +
  "aware that if you want to set persist to true, you should do so " +
  "before connecting the Companion for incremental development.")
public void Persist(boolean value) {
  Log.i(LOG_TAG, "Persist Called: Value = " + value);
  if (persist != value) {     // We are making a change
    if (isInitialized) {
      throw new RuntimeException("You cannot change the Persist value of Firebase " +
        "after Application Initialization, this includes the Companion");
    }
    Config config = Firebase.getDefaultConfig();
    config.setPersistenceEnabled(value);
    Firebase.setDefaultConfig(config);
    persist = value;
    resetListener();
  }
}
 
Example #28
Source File: MainActivity.java    From AndroidChat with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Make sure we have a mUsername
    setupUsername();

    setTitle("Chatting as " + mUsername);

    // Setup our Firebase mFirebaseRef
    mFirebaseRef = new Firebase(FIREBASE_URL).child("chat");

    // Setup our input methods. Enter key on the keyboard or pushing the send button
    EditText inputText = (EditText) findViewById(R.id.messageInput);
    inputText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
            if (actionId == EditorInfo.IME_NULL && keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
                sendMessage();
            }
            return true;
        }
    });

    findViewById(R.id.sendButton).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            sendMessage();
        }
    });

}
 
Example #29
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 #30
Source File: orders.java    From Krishi-Seva with MIT License 5 votes vote down vote up
public void read()
{
    final Firebase ref = new Firebase("https://adaa-45b17.firebaseio.com/ORDERS");
    //Value event listener for realtime data update


    ref.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot usersSnapshot) {

            for (DataSnapshot userSnapshot : usersSnapshot.getChildren()) {
                ordering forums = userSnapshot.getValue(ordering.class);
                String amount = forums.getAmount().toString();
                String crop = forums.getCrop().toString();
                String lat = forums.getLat();
                String longg = forums.getLongg();
                String kgs= forums.getKgs();
                String l= forums.getLoc();
                location.add(l);
                amountt.add(amount);
                cropp.add(crop);
                latt.add(lat);
                longgg.add(longg);
                kg.add(kgs);

            }
            cardpop();
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            System.out.println("The read failed: " + firebaseError.getMessage());
        }
    });

}