Java 类com.parse.FunctionCallback 实例源码

项目:flowlist    文件:LoginActivity.java   
private void requestSessionToken(String authorizationCode) {
    HashMap<String, Object> params = new HashMap<>();
    params.put("authorizationCode", authorizationCode);
    ParseCloud.callFunctionInBackground("requestSessionToken", params, new FunctionCallback<String>() {
        @Override
        public void done(String sessionToken, ParseException e) {
            if (e == null) {
                Log.d("cloud", "Got back: " + sessionToken);
                becomeUser(sessionToken);
            } else {
                Toast.makeText(LoginActivity.this, "Login failed", Toast.LENGTH_LONG).show();
                Log.d("error", e.toString());
            }
        }
    });
}
项目:androidClient    文件:RestaurantDealAdapter.java   
public void upVote() {
    if (dealModel != null) {
        Map<String,String> params = new HashMap<>();
        final Activity restaurantActivity = activity;
        params.put("objectId", dealModel.getId());
        params.put("deviceId", Device.getDeviceId(activity));
        ParseCloud.callFunctionInBackground("upVote", params, new FunctionCallback<String>() {
            public void done(String results, ParseException e) {
                if (results != null) {
                    Toast.makeText(restaurantActivity, results, Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(restaurantActivity, e.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
项目:androidClient    文件:RestaurantDealAdapter.java   
public void downVote() {
    if (dealModel != null) {
        Map<String, String> params = new HashMap<>();
        final Activity restaurantActivity = activity;
        params.put("objectId", dealModel.getId());
        params.put("deviceId", Device.getDeviceId(activity));
        ParseCloud.callFunctionInBackground("downVote", params, new FunctionCallback<String>() {
            public void done(String results, ParseException e) {
                if (results != null) {
                    Toast.makeText(restaurantActivity, results, Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(restaurantActivity, e.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
项目:androidClient    文件:RestaurantDealAdapter.java   
public void undoUpVote() {
    if (dealModel != null) {
        Map<String,String> params = new HashMap<>();
        final Activity restaurantActivity = activity;
        params.put("objectId", dealModel.getId());
        params.put("deviceId", Device.getDeviceId(activity));
        ParseCloud.callFunctionInBackground("undoUpVote", params, new FunctionCallback<String>() {
            public void done(String results, ParseException e) {
                if (results != null) {
                    Toast.makeText(restaurantActivity, results, Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(restaurantActivity, e.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
项目:androidClient    文件:RestaurantDealAdapter.java   
public void undoDownVote() {
    if (dealModel != null) {
        Map<String,String> params = new HashMap<>();
        final Activity restaurantActivity = activity;
        params.put("objectId", dealModel.getId());
        params.put("deviceId", Device.getDeviceId(activity));
        ParseCloud.callFunctionInBackground("undoDownVote", params, new FunctionCallback<String>() {
            public void done(String results, ParseException e) {
                if (results != null){
                    Toast.makeText(restaurantActivity, results, Toast.LENGTH_LONG).show();
                } else {
                    Toast.makeText(restaurantActivity, e.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
项目:cat-chat-android    文件:InboxActivity.java   
@Override
public void onClick(View view) {
    if (view.getId() == R.id.resend_verification_email) {
        HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("userid", ParseUser.getCurrentUser().getObjectId());

        ParseCloud.callFunctionInBackground("resendVerificationEmail", map, new FunctionCallback<Object>() {
            @Override
            public void done(Object o, ParseException e) {
                if (e == null) {
                    Toast.makeText(InboxActivity.this, getString(R.string.email_verification_sent), Toast.LENGTH_SHORT).show();
                } else {
                    Toast.makeText(InboxActivity.this, getString(R.string.failed_to_send_email_verification) + " " + e.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        });
    }
}
项目:avatars    文件:ParseAdapter.java   
@Override
public List<Profile> getProfile(Email... emails) {
    HashMap<String, Email> params = new HashMap<String, Email>();
    int counter = 1;
    for(Email email : emails) {
        params.put("email" + counter, email);
        counter++;
    }

    ParseCloud.callFunctionInBackground("hello", params, new FunctionCallback<Profile>() {
        public void done(Profile fetchedProfile, ParseException e) {
            if (e == null) {
                if(ParseAdapter.profileList == null) {
                    ParseAdapter.profileList.add(fetchedProfile);
                }
            }
        }
    });

    return ParseAdapter.profileList;
}
项目:FashionSpot    文件:FeedFragment.java   
private void loadFeedItems() {
    Map<String, String> params = new HashMap<>();
    ParseCloud.callFunctionInBackground("loadFeed", params, new FunctionCallback<List<Design>>() {
        @Override
        public void done(List<Design> designs, ParseException e) {
            if (e == null) {
                mAdapter.addAll(designs);
            } else {
                e.printStackTrace();
            }

            progressBar.setVisibility(View.INVISIBLE);
        }
    });
}
项目:FashionSpot    文件:SearchFragment.java   
private void fetchUsers() {
    Map<String, String> map = new HashMap<String, String>();
    ParseCloud.callFunctionInBackground("loadFindPeople", map, new FunctionCallback<List<User>>() {
        @Override
        public void done(List<User> users, ParseException e) {
            if (e == null) {
                mAdapter.addAll(users);
            } else {
                e.printStackTrace();
            }
            progressBar.setVisibility(View.INVISIBLE);
        }
    });
}
项目:Social-Networking-App-where-you-smiling-is-liking-the-post    文件:SignupActivity.java   
public void resend_fun(View v)
{
 if(busy==0)
 {
     busy =1;
     HashMap<String, String> ha = new HashMap<String, String>();
     ha.put("number", number);
     ha.put("message", "Cloak Verification Code: "+verification_code);
    ParseCloud.callFunctionInBackground("send_sms", ha, new FunctionCallback<String>() {
          public void done(String result, ParseException e) {
              busy =0;
            if (e == null) {
                Toast.makeText(con, "Successfully sent.", Toast.LENGTH_LONG).show();
              Log.d("%%%%%%%%%%%%%%%%%%%%%%", result);
            }
            else{
                Log.d("%%%%%%%%%%%%%%%%%%%%%%", e.getMessage());

            }
          }
        });
 }
 else
 {
     Toast.makeText(con, "Please wait. Already sending another request.", Toast.LENGTH_LONG).show();
 }
}
项目:AndroidClient    文件:LCDetailsActivity.java   
protected void getLCDetailsData() {
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("userId", ParseUser.getCurrentUser().getObjectId());

    params.put("parentGoalId", goal.getParentGoal().getObjectId());
    params.put("goalId", goal.getObjectId());

    showLoadingView();

    ParseCloud.callFunctionInBackground("goalDetailView", params,
            new FunctionCallback<HashMap<String, Object>>() {

                @SuppressWarnings("unchecked")
                @Override
                public void done(HashMap<String, Object> result, ParseException exception) {
                    if (exception == null) {
                        final ObjectMapper mapper = new ObjectMapper();
                        mapper.setSerializationInclusion(Include.NON_NULL);

                        mLendingCircleDetail = mapper.convertValue(result.get("goalDetails"),
                                LCDetail.class);
                        posts.addAll((List<Post>) result.get("posts"));
                        aposts.notifyDataSetChanged();

                        HideLoadingView();
                        setUpCircle();
                        lvLCDetails.setAdapter(aposts);
                    } else {
                        Toast.makeText(LCDetailsActivity.this, R.string.parse_error_querying,
                                Toast.LENGTH_LONG).show();
                        Log.d("debug", exception.getLocalizedMessage());
                    }

                }
            });
}
项目:AndroidClient    文件:LCDetailsActivity.java   
@Override
public void onSavePost(String inputText) {
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("userId", ParseUser.getCurrentUser().getObjectId());

    // parent goal id
    params.put("goalId", goal.getParentGoal().getObjectId());
    params.put("content", inputText);
    // params.put("type", inputText);
    // params.put("toUserId", goal.getObjectId());

    ParseCloud.callFunctionInBackground("createPost", params,
            new FunctionCallback<HashMap<String, Object>>() {

                @Override
                public void done(HashMap<String, Object> result, ParseException exception) {
                    if (exception == null) {
                        final ObjectMapper mapper = new ObjectMapper();
                        mapper.setSerializationInclusion(Include.NON_NULL);
                        Log.d("debug", result.toString());
                        // add it to adapter
                        boolean success = (Boolean) result.get("success");
                        if (success) {
                            Post post = (Post) result.get("post");
                            aposts.insert(post, 0);
                        }
                    }
                }
            });
}
项目:AndroidClient    文件:LCDetailsActivity.java   
@Override
public void onSaveComment(String postId, String inputText) {
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("userId", ParseUser.getCurrentUser().getObjectId());

    params.put("postId", postId);
    params.put("content", inputText);
    // params.put("type", inputText);
    // params.put("toUserId", goal.getObjectId());

    ParseCloud.callFunctionInBackground("createComment", params,
            new FunctionCallback<HashMap<String, Object>>() {

                @Override
                public void done(HashMap<String, Object> result, ParseException exception) {
                    if (exception == null) {
                        final ObjectMapper mapper = new ObjectMapper();
                        mapper.setSerializationInclusion(Include.NON_NULL);
                        Log.d("debug", result.toString());
                        // add it to adapter
                        boolean success = (Boolean) result.get("success");
                        if (success) {
                            Post post = (Post) result.get("comment");
                            post.setUser(currentUser);
                            aposts.remove(post);
                            aposts.insert(post, 0);
                        }
                    }
                }
            });
}
项目:AndroidClient    文件:LiquidAssetsFragment.java   
private void setupData() {
    tvEmptyLiquidAssets.setVisibility(View.INVISIBLE);
    rlLiquidAssets.setVisibility(View.INVISIBLE);
    pbLoadingLiquidAssets.setVisibility(View.VISIBLE);

    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("userId", User.getCurrentUser().getObjectId());

    Calendar today = Calendar.getInstance();
    params.put("day", today.get(Calendar.DAY_OF_MONTH));
    params.put("month", today.get(Calendar.MONTH) + 1); // Thanks Java...
    params.put("year", today.get(Calendar.YEAR));

    ParseCloud.callFunctionInBackground("stackedBarChartDetailView", params,
            new FunctionCallback<HashMap<String, Object>>() {

                @Override
                public void done(HashMap<String, Object> result, ParseException exception) {
                    if (exception != null) {
                        Log.d("LiquidAssetsFragment", "error on querying transactions",
                                exception);
                        return;
                    }

                    final ObjectMapper mapper = new ObjectMapper();
                    mapper.setSerializationInclusion(Include.NON_NULL);

                    final TransactionsDashboard dashboard = mapper.convertValue(result,
                            TransactionsDashboard.class);
                    mChart = dashboard.getChart();

                    Boolean hasData = mChart.getHasData();

                    if (!hasData) {
                        return;
                    }

                    setupSummary(dashboard);
                    setupChart(dashboard.getChart());

                    mTransactionsAdapter = new
                            TransactionsExpandableListAdapter(
                                    dashboard.getTransactionsByDate(),
                                    getActivity());

                    elvTransactions.setAdapter(mTransactionsAdapter);
                    elvTransactions.setEmptyView(tvEmptyTransactions);
                    elvTransactions.setGroupIndicator(null);

                    for (int i = 0; i <
                    mTransactionsAdapter.getGroupCount(); i++) {
                        elvTransactions.expandGroup(i);
                    }

                    pbLoadingLiquidAssets.setVisibility(View.INVISIBLE);

                    if (isSummaryEmpty()) {
                        tvEmptyLiquidAssets.setVisibility(View.VISIBLE);
                    } else {
                        rlLiquidAssets.setVisibility(View.VISIBLE);
                    }
                }
            });
}
项目:AndroidClient    文件:DashboardFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_dashboard, container, false);

    setupViews(view);

    setupListeners();

    showMonthlySpentChartProgressBar();

    ParseCloud.callFunctionInBackground("dashboardView", new HashMap<String, Object>(),
            new FunctionCallback<HashMap<String, Object>>() {

                @Override
                public void done(HashMap<String, Object> result, ParseException exception) {

                    if (exception == null) {
                        // TODO: Handle case of no data points to plot

                        final ObjectMapper mapper = new ObjectMapper();
                        mapper.setSerializationInclusion(Include.NON_NULL);

                        Log.d("DEBUG", result.toString());

                        final MainDashboard mainDashboardData = mapper.convertValue(result,
                                MainDashboard.class);
                        final CashSpentChart cashSpentChart = mainDashboardData
                                .getCashSpentChart();

                        BigDecimal totalCash = mainDashboardData.getTotalCash();

                        // Update total cash on Action Bar
                        ActionBar actionBar = getActivity().getActionBar();

                        actionBar.setSubtitle(
                                getResources().getString(
                                        R.string.dashboard_subtitle_cash_available,
                                        CurrencyUtils.getCurrencyValueFormatted(totalCash)));

                        List<BigDecimal> data = cashSpentChart.getData();
                        List<String> xLabels = cashSpentChart.getxLabels();

                        Log.d("DEBUG", "Data points: " + data.toString());
                        Log.d("DEBUG", "xLabels: " + xLabels.toString());
                        Log.d("DEBUG", "# of goals: "
                                + String.valueOf(mainDashboardData.getGoals().size()));

                        setupChart(rlMonthlySpentChart, data, xLabels);
                    } else {
                        // TODO: better handle if parse throws and exception
                        Toast.makeText(getActivity(), getString(R.string.parse_error_querying),
                                Toast.LENGTH_LONG).show();
                        // Hide progress Bar
                        hideMonthlySpentChartProgressBar();
                    }

                }
            });

    return view;
}
项目:AndroidClient    文件:DashboardFragment.java   
private void refreshChart() {
    showProgressBar();

    ParseCloud.callFunctionInBackground("dashboardView", new HashMap<String, Object>(),
            new FunctionCallback<HashMap<String, Object>>() {

                @Override
                public void done(HashMap<String, Object> result, ParseException exception) {

                    if (exception == null) {
                        // TODO: Handle case of no data points to plot

                        final ObjectMapper mapper = new ObjectMapper();
                        mapper.setSerializationInclusion(Include.NON_NULL);

                        Log.d("DEBUG", result.toString());

                        final MainDashboard mainDashboardData = mapper.convertValue(result,
                                MainDashboard.class);
                        final CashSpentChart cashSpentChart = mainDashboardData
                                .getCashSpentChart();

                        BigDecimal totalCash = mainDashboardData.getTotalCash();

                        // Update total cash on Action Bar
                        ActionBar actionBar = getActivity().getActionBar();

                        actionBar.setSubtitle(
                                getResources().getString(
                                        R.string.dashboard_subtitle_cash_available,
                                        CurrencyUtils.getCurrencyValueFormatted(totalCash)));

                        List<BigDecimal> data = cashSpentChart.getData();
                        List<String> xLabels = cashSpentChart.getxLabels();

                        Log.d("DEBUG", "Data points: " + data.toString());
                        Log.d("DEBUG", "xLabels: " + xLabels.toString());
                        Log.d("DEBUG", "# of goals: "
                                + String.valueOf(mainDashboardData.getGoals().size()));

                        setupChart(rlMonthlySpentChart, data, xLabels);

                    } else {
                        // TODO: better handle if parse throws and exception
                        Toast.makeText(getActivity(), getString(R.string.parse_error_querying),
                                Toast.LENGTH_LONG).show();
                    }
                    hideProgressBar();
                }
            });
}