Java Code Examples for com.parse.ParseObject#getCreatedAt()

The following examples show how to use com.parse.ParseObject#getCreatedAt() . 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: NewsAdapter.java    From Gazetti_Newspaper_Reader with MIT License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        LayoutInflater inflater = ctx.getLayoutInflater();
        convertView = inflater.inflate(R.layout.headline_list_row, parent, false);

        holder = new ViewHolder();
        holder.textViewItem = (TextView) convertView.findViewById(R.id.headline);
        convertView.setTag(holder);

    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    ParseObject object = articleObjectList.get(position);
    // Add the title view
    holder.textViewItem.setText(object.getString("title"));

    // get PubDate
    Date createdAtDate = object.getCreatedAt();
    long createdAtDateInMillis = createdAtDate.getTime();
    //Log.d(TAG, "createdAtDateInMillis " + createdAtDateInMillis);

    String diff = getTimeAgo(createdAtDateInMillis);
    //Log.d(TAG, "diff " + diff);

    // Add title, link to Map
    linkMap.put(object.getString("title"), object.getString("link"));
    pubDateMap.put(object.getString("title"), diff);
    //Log.d(TAG, "Added " + pubDateMap.get(object.getString("title")));

    // PubDate

    return convertView;

}
 
Example 2
Source File: WebsiteListFragment.java    From Gazetti_Newspaper_Reader with MIT License 4 votes vote down vote up
private void getNewListItems() {

        mListViewContainer.setRefreshing(true);
        ParseQuery<ParseObject> queryGetNewItems = ParseQuery.getQuery(dbToSearch);
        queryGetNewItems.whereEqualTo("newspaper_id", npIdString);
        queryGetNewItems.whereEqualTo("cat_id", catIdString);
        queryGetNewItems.orderByDescending("createdAt");

        if (retainedList.size() > 0) {
            ParseObject topObject = retainedList.get(0);
            Date topObjectCreatedAt = topObject.getCreatedAt();
            queryGetNewItems.whereGreaterThan("createdAt", topObjectCreatedAt);
        }

        if (firstRun) {
            queryGetNewItems.setLimit(15);
        }
        //TODO: Try-catch with message
        queryGetNewItems.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> articleObjectList, ParseException exception) {

                if(exception == null){

                    retainedList.addAll(0, articleObjectList);

                    newsAdapter.notifyDataSetChanged();

                    dateLastUpdatedString = "Last Updated: "
                            + (DateUtils.formatDateTime(context, System.currentTimeMillis(), //
                            DateUtils.FORMAT_SHOW_TIME //
                                    | DateUtils.FORMAT_SHOW_WEEKDAY //
                                    | DateUtils.FORMAT_SHOW_DATE //
                                    | DateUtils.FORMAT_ABBREV_WEEKDAY //
                                    | DateUtils.FORMAT_NO_NOON //
                                    | DateUtils.FORMAT_NO_MIDNIGHT)); //
                    headerTextView.setText(dateLastUpdatedString);
                    mListViewContainer.setRefreshing(false);

                    if (mTwoPane) {
                        mListView.performItemClick(newsAdapter.getView(mActivatedPosition - 1, null, null),
                                mActivatedPosition, mActivatedPosition);

                    }
                    firstRun = false;
                } else {
                    Crashlytics.log("Wrong while fetching - " + exception.getMessage());
                    headerTextView.setText("Something went wrong!");
                }
            }

        });
    }