MyTetra Share
Делитесь знаниями!
CrimeLab.java
22.04.2017
10:15
Раздел: Android - books - AndroidProgramming2e - 13 Панель инструментов
CrimeLab.java
package com.bignerdranch.android.criminalintent; 
 
import android.content.Context; 
 
import java.util.ArrayList; 
import java.util.List; 
import java.util.UUID; 
 
public class CrimeLab { 
    private static CrimeLab sCrimeLab; 
 
    private ArrayList<Crime> mCrimes; 
 
    public static CrimeLab get(Context context) { 
        if (sCrimeLab == null) { 
            sCrimeLab = new CrimeLab(context); 
        } 
        return sCrimeLab; 
    } 
 
    private CrimeLab(Context context) { 
        mCrimes = new ArrayList<>(); 
    } 
 
    public void addCrime(Crime c) { 
        mCrimes.add(c); 
    } 
 
    public List<Crime> getCrimes() { 
        return mCrimes; 
    } 
 
    public Crime getCrime(UUID id) { 
        for (Crime crime : mCrimes) { 
            if (crime.getId().equals(id)) { 
                return crime; 
            } 
        } 
        return null; 
    } 
} 

 
MyTetra Share v.0.52
Яндекс индекс цитирования