本文整理汇总了Java中com.parse.ParseQuery.setCachePolicy方法的典型用法代码示例。如果您正苦于以下问题:Java ParseQuery.setCachePolicy方法的具体用法?Java ParseQuery.setCachePolicy怎么用?Java ParseQuery.setCachePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.parse.ParseQuery
的用法示例。
在下文中一共展示了ParseQuery.setCachePolicy方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMessage
import com.parse.ParseQuery; //导入方法依赖的package包/类
/**
* Request a single message in a conversation to be updated.
*/
private void updateMessage(@NonNull String conversationId, @NonNull String messageId) {
ParseQuery<ParseObject> query = new ParseQuery<>(MessagesTable.NAME);
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ONLY);
query.include(MessagesTable.Fields.IMAGE);
Log.d(TAG, "Updating message: " + messageId);
mParseHelper.get(query, messageId)
.map(in -> ParseUtils.from(in, mParseHelper))
.toList()
.subscribe(messages -> {
for (ExampleMessage message : messages) {
mUpdatePublisher.onNext(new Update<>(conversationId, Update.Action.UPDATED, null, message));
}
});
}
示例2: fetchMyListings
import com.parse.ParseQuery; //导入方法依赖的package包/类
private void fetchMyListings() {
ParseQuery<ParseObject> query = new ParseQuery<>(
ParseTables.Listings.LISTINGS);
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.whereEqualTo(ParseTables.Listings.OWNER_NAME, ParseUser.getCurrentUser().getString(ParseTables.Users.NAME));
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(final List<ParseObject> parseObjects, ParseException e) {
if (e == null) {
doneFetching(parseObjects);
} else {
loader.setVisibility(View.GONE);
Toast.makeText(getActivity(), "Please connect to the Internet", Toast.LENGTH_SHORT).show();
}
}
});
}
示例3: getAllUsers
import com.parse.ParseQuery; //导入方法依赖的package包/类
@NonNull
@Override
public Observable<List<ExampleUser>> getAllUsers(UserQueries.GetAllUsersQuery query) {
final ParseQuery<ParseUser> parseQuery = new ParseQuery<>("_User");
parseQuery.whereNotEqualTo("objectId", mParseHelper.getCurrentUser().getObjectId());
parseQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ONLY);
return mParseHelper.find(parseQuery)
.flatMap(Observable::from)
.map(ParseUtils::fromParseUser)
.toList()
.subscribeOn(Schedulers.io());
}
示例4: getSingleUser
import com.parse.ParseQuery; //导入方法依赖的package包/类
@NonNull
@Override
public Observable<ExampleUser> getSingleUser(UserQueries.GetUserQuery query) {
ParseQuery<ParseUser> parseQuery = new ParseQuery<>("_User");
parseQuery.whereEqualTo("objectId", query.getUserId());
parseQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ONLY);
return mParseHelper.find(parseQuery)
.flatMap(Observable::from)
.map(ParseUtils::fromParseUser)
.subscribeOn(Schedulers.io());
}
示例5: fetchData
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void fetchData(){
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>(
"Events");
query.orderByAscending(ParseTables.Events.CREATED_AT);
if(check_my_events){
query.whereEqualTo(ParseTables.Events.CREATED_BY, ParseUser.getCurrentUser().getString("NAME"));
}
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
doneFetching(parseObjects);
}
});
}
示例6: getNotes
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void getNotes() {
clear_lists();
ParseQuery<ParseObject> query = new ParseQuery<>(
"Notes");
query.orderByDescending("createdAt");
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
for (ParseObject notes : parseObjects) {
notesBranchName.add((String) notes.get("branchName"));
notesSubjectName.add((String) notes.get("subjectName"));
notesCollegeName.add((String) notes.get("collegeName"));
notesTopicName.add((String) notes.get("topicName"));
uploadedBy.add((String) notes.get("userName"));
notesFirstImage.add((ArrayList<ParseFile>) notes.get("notesImages"));
}
notesCustomGridViewAdapter = new NotesCustomGridViewAdapter(getActivity(), notesCollegeName,
notesBranchName, notesTopicName, notesSubjectName, notesFirstImage, uploadedBy);
mRecyclerView.setAdapter(notesCustomGridViewAdapter);
}
});
}
示例7: performSearch
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void performSearch(final String s) {
if(s.equals("")) {
Toast.makeText(getActivity(),"Please Enter Something",Toast.LENGTH_SHORT).show();
return;
}
ParseQuery<ParseObject> query = new ParseQuery<>(
"Notes");
clear_lists();
query.whereContains("topicName",s);
query.orderByDescending("createdAt");
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> parseObjects, ParseException e) {
// Log.d("Search notes","result size : "+String.valueOf( parseObjects.size())+" "+s);
for (ParseObject notes : parseObjects) {
notesBranchName.add((String) notes.get("branchName"));
notesSubjectName.add((String) notes.get("subjectName"));
notesCollegeName.add((String) notes.get("collegeName"));
notesTopicName.add((String) notes.get("topicName"));
uploadedBy.add((String) notes.get("userName"));
notesFirstImage.add((ArrayList<ParseFile>) notes.get("notesImages"));
}
notesCustomGridViewAdapter = new NotesCustomGridViewAdapter(getActivity(), notesCollegeName,
notesBranchName, notesTopicName, notesSubjectName, notesFirstImage, uploadedBy);
mRecyclerView.setAdapter(notesCustomGridViewAdapter);
// notesCustomGridViewAdapter.notifyDataSetChanged();
}
});
}
示例8: doneFetchingUserInterests
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void doneFetchingUserInterests(ArrayList<ParseObject> currentUserInterestsList) {
existingElement.clear();
if (currentUserInterestsList != null && !currentUserInterestsList.isEmpty())
{
for (int c = 0; c < currentUserInterestsList.size(); c++) {
if (!currentUserInterestsList.get(c).equals("") || !(currentUserInterestsList.get(c) == null)) {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.include(ParseTables.Users.INTERESTS);
query.include(ParseTables.Users.INSTITUTE);
query.whereEqualTo(ParseTables.Users.INTERESTS, currentUserInterestsList.get(c));
query.findInBackground(new FindCallback<ParseUser>() {
public void done(final List<ParseUser> objects, ParseException e) {
if (e == null) {
doneFetchingPeople(objects);
} else {
// Something went wrong.
}
}
});
}
}
} else
{
progressBar.setVisibility(View.GONE);
}
}
示例9: onCreateView
import com.parse.ParseQuery; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.fragment_feed, container, false);
int p = getActivity().getResources().getColor(R.color.colorPrimary);
int s = getActivity().getResources().getColor(R.color.colorPrimaryDark);
ApplicationWrapper.setCustomTheme((ActionBarActivity) getActivity(), p, s);
searchEditText = (EditText) rootView.findViewById(R.id.feed_search);
searchEditText.setOnKeyListener(this);
recyclerView = (RecyclerView) rootView.findViewById(R.id.feed_recycler_view);
searchButton = (ImageButton) rootView.findViewById(R.id.searchblahblah);
searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
searchEditText.setFocusableInTouchMode(true);
searchEditText.requestFocus();
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
}
});
context = getActivity();
RecyclerView.LayoutManager mVerticalLayoutManager = new LinearLayoutManager(getActivity(),
LinearLayoutManager.VERTICAL, false);
StaggeredGridLayoutManager mGridLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
mGridLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_MOVE_ITEMS_BETWEEN_SPANS);
recyclerView.setLayoutManager(mVerticalLayoutManager);
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT){
recyclerView.setLayoutManager(mVerticalLayoutManager);
}
else {
recyclerView.setLayoutManager(mGridLayoutManager);
}
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swipeRefreshLayoutfeed);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (Utilities.isNetworkAvailable(getActivity())) {
getFeed();
}
else {
swipeRefreshLayout.setRefreshing(false);
Toast.makeText(getActivity(), "Please connect to the Internet", Toast.LENGTH_SHORT).show();
}
}
});
ParseUser currentUser = ParseUser.getCurrentUser();
ParseQuery<ParseObject> query = ParseQuery.getQuery("Interests");
query.whereEqualTo("users", currentUser);
query.setCachePolicy(ParseQuery.CachePolicy.CACHE_ELSE_NETWORK);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(final List<ParseObject> parseObjects, ParseException e) {
if (e != null) {
e.printStackTrace();
return;
}
// if(Utilities.isNetworkAvailable(getActivity())){
// ParseObject.unpinAllInBackground("feed_interests", new DeleteCallback() {
// @Override
// public void done(ParseException e) {
// Log.d(TAG,"pinning");
// ParseObject.pinAllInBackground("feed_interests", parseObjects);
// }
// });
// }
for (ParseObject parseObject : parseObjects) {
interestList.add(parseObject.getString("name"));
}
getFeed();
}
});
return rootView;
}
示例10: loaddata
import com.parse.ParseQuery; //导入方法依赖的package包/类
private void loaddata() {
listOfPeople.clear();
currentuser = User.getUsername();
currentuseremail = User.getString(ParseTables.Users.EMAIL);
if(ParseUser.getCurrentUser().get(ParseTables.Users.INSTITUTE)!=null)
{
// currentuserinstituition = ParseUser.getCurrentUser().getParseObject(ParseTables.Users.INSTITUTE).getString(ParseTables.College.NAME);
}
else{
currentuserinstituition = " - " ;
}
currentusername = User.getString(ParseTables.Users.NAME);
currentuserqualification = User.getString(ParseTables.Users.QUALIFICATIONS);
userlocation = User.getParseGeoPoint(ParseTables.Users.LOCATION);
// ArrayList<ParseObject> interests = (ArrayList<ParseObject>) User.get(ParseTables.Users.INTERESTS);
// ^^ can't fetch array list in back ground, therefore using a query with .include(ParseTables.Users.INTERESTS)
ParseQuery<ParseUser> currentuserInterestsQuery = ParseUser.getQuery();
currentuserInterestsQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
currentuserInterestsQuery.whereEqualTo("username", currentuser);
currentuserInterestsQuery.include(ParseTables.Users.INTERESTS);
currentuserInterestsQuery.include(ParseTables.Users.INSTITUTE);
currentuserInterestsQuery.getFirstInBackground(new GetCallback<ParseUser>() {
public void done(final ParseUser user, ParseException e) {
if (user == null) {
if (ApplicationWrapper.LOG_DEBUG) Log.d("query", "failed.");
} else {
final ArrayList<ParseObject> currentUserInterestsList = (ArrayList<ParseObject>) User.get(ParseTables.Users.INTERESTS);
if (currentuserinterests == null)
{
currentuserinterests = "";
}
doneFetchingUserInterests(currentUserInterestsList);
// The query was successful.
}
}
});
}
示例11: loaddataAfterSearch
import com.parse.ParseQuery; //导入方法依赖的package包/类
private void loaddataAfterSearch(final String textSearch) {
listOfPeople.clear();
q = new MyAdapter3(getActivity(), 0, listOfPeople);
q.notifyDataSetChanged();
lv.setAdapter(q);
currentuser = User.getUsername();
currentuseremail = User.getString(ParseTables.Users.EMAIL);
if(ParseUser.getCurrentUser().get(ParseTables.Users.INSTITUTE)!=null)
{
// currentuserinstituition = ParseUser.getCurrentUser().getParseObject(ParseTables.Users.INSTITUTE).getString(ParseTables.College.NAME);
}
else{
currentuserinstituition = " - " ;
}
currentusername = User.getString(ParseTables.Users.NAME);
currentuserqualification = User.getString(ParseTables.Users.QUALIFICATIONS);
userlocation = User.getParseGeoPoint(ParseTables.Users.LOCATION);
// ArrayList<ParseObject> interests = (ArrayList<ParseObject>) User.get(ParseTables.Users.INTERESTS);
// ^^ can't fetch array list in back ground, therefore using a query with .include(ParseTables.Users.INTERESTS)
ParseQuery<ParseUser> currentuserInterestsQuery = ParseUser.getQuery();
currentuserInterestsQuery.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
currentuserInterestsQuery.whereEqualTo("username", currentuser);
currentuserInterestsQuery.include(ParseTables.Users.INTERESTS);
currentuserInterestsQuery.include(ParseTables.Users.INSTITUTE);
currentuserInterestsQuery.getFirstInBackground(new GetCallback<ParseUser>() {
public void done(final ParseUser user, ParseException e) {
if (user == null) {
if (ApplicationWrapper.LOG_DEBUG) Log.d("query", "failed.");
} else {
final ArrayList<ParseObject> currentUserInterestsList = (ArrayList<ParseObject>) User.get(ParseTables.Users.INTERESTS);
if (currentuserinterests == null)
{
currentuserinterests = "";
}
doneFetchingUserInterestsForSearch(currentUserInterestsList, textSearch);
// The query was successful.
}
}
});
}
示例12: doneFetchingUserInterestsForSearch
import com.parse.ParseQuery; //导入方法依赖的package包/类
public void doneFetchingUserInterestsForSearch(ArrayList<ParseObject> currentUserInterestsList, String textSearch) {
existingElement.clear();
if (!currentUserInterestsList.isEmpty())
{
for (int c = 0; c < currentUserInterestsList.size(); c++) {
if (!currentUserInterestsList.get(c).equals("") || !(currentUserInterestsList.get(c) == null)) {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.setCachePolicy(ParseQuery.CachePolicy.NETWORK_ELSE_CACHE);
query.whereEqualTo(ParseTables.Users.INTERESTS, currentUserInterestsList.get(c));
query.whereMatches(ParseTables.Users.NAME, "(" + textSearch + ")", "i");
query.include(ParseTables.Users.INTERESTS);
query.include(ParseTables.Users.INSTITUTE);
query.findInBackground(new FindCallback<ParseUser>() {
public void done(final List<ParseUser> objects, ParseException e) {
if (e == null) {
doneFetchingPeople(objects);
} else {
// Something went wrong.
}
}
});
}
}
} else
{
progressBar.setVisibility(View.GONE);
}
}