Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Cannot resolve symbol rename reference usageStats & appIcon #9

@rohitsrms

Description

@rohitsrms

/*

  • Copyright (C) 2014 The Android Open Source Project
  • Licensed under the Apache License, Version 2.0 (the "License");
  • you may not use this file except in compliance with the License.
  • You may obtain a copy of the License at
  •  http://www.apache.org/licenses/LICENSE-2.0
    
  • Unless required by applicable law or agreed to in writing, software
  • distributed under the License is distributed on an "AS IS" BASIS,
  • WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  • See the License for the specific language governing permissions and
  • limitations under the License.
    */

package com.example.android.appusagestatistics;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**

  • Provide views to RecyclerView with the directory entries.
    */
    public class UsageListAdapter extends RecyclerView.Adapter<UsageListAdapter.ViewHolder> {

    private List mCustomUsageStatsList = new ArrayList<>();
    private DateFormat mDateFormat = new SimpleDateFormat();

    /**

    • Provide a reference to the type of views that you are using (custom ViewHolder)
      */
      public static class ViewHolder extends RecyclerView.ViewHolder {
      private final TextView mPackageName;
      private final TextView mLastTimeUsed;
      private final ImageView mAppIcon;

      public ViewHolder(View v) {
      super(v);
      mPackageName = (TextView) v.findViewById(R.id.textview_package_name);
      mLastTimeUsed = (TextView) v.findViewById(R.id.textview_last_time_used);
      mAppIcon = (ImageView) v.findViewById(R.id.app_icon);
      }

      public TextView getLastTimeUsed() {
      return mLastTimeUsed;
      }

      public TextView getPackageName() {
      return mPackageName;
      }

      public ImageView getAppIcon() {
      return mAppIcon;
      }
      }

    public UsageListAdapter() {
    }

    @OverRide
    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    View v = LayoutInflater.from(viewGroup.getContext())
    .inflate(R.layout.usage_row, viewGroup, false);
    return new ViewHolder(v);
    }

    @OverRide
    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
    viewHolder.getPackageName().setText(
    mCustomUsageStatsList.get(position).usageStats.getPackageName());
    long lastTimeUsed = mCustomUsageStatsList.get(position).usageStats.getLastTimeUsed();
    viewHolder.getLastTimeUsed().setText(mDateFormat.format(new Date(lastTimeUsed)));
    viewHolder.getAppIcon().setImageDrawable(mCustomUsageStatsList.get(position).appIcon);
    }

    @OverRide
    public int getItemCount() {
    return mCustomUsageStatsList.size();
    }

    public void setCustomUsageStatsList(List customUsageStats) {
    mCustomUsageStatsList = customUsageStats;
    }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions