![JAR search and dependency download from the Maven repository](/logo.png)
src.com.android.egg.neko.NekoDialog Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of android-all Show documentation
Show all versions of android-all Show documentation
A library jar that provides APIs for Applications written for the Google Android Platform.
/*
* Copyright (C) 2020 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.android.egg.neko;
import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.egg.R;
import java.util.ArrayList;
public class NekoDialog extends Dialog {
private final Adapter mAdapter;
public NekoDialog(@NonNull Context context) {
super(context, android.R.style.Theme_Material_Dialog_NoActionBar);
RecyclerView view = new RecyclerView(getContext());
mAdapter = new Adapter(getContext());
view.setLayoutManager(new GridLayoutManager(getContext(), 2));
view.setAdapter(mAdapter);
final float dp = context.getResources().getDisplayMetrics().density;
final int pad = (int)(16*dp);
view.setPadding(pad, pad, pad, pad);
setContentView(view);
}
private void onFoodSelected(Food food) {
PrefState prefs = new PrefState(getContext());
int currentState = prefs.getFoodState();
if (currentState == 0 && food.getType() != 0) {
NekoService.registerJob(getContext(), food.getInterval(getContext()));
}
// MetricsLogger.histogram(getContext(), "egg_neko_offered_food", food.getType());
prefs.setFoodState(food.getType());
dismiss();
}
private class Adapter extends RecyclerView.Adapter {
private final Context mContext;
private final ArrayList mFoods = new ArrayList<>();
public Adapter(Context context) {
mContext = context;
int[] foods = context.getResources().getIntArray(R.array.food_names);
// skip food 0, you can't choose it
for (int i=1; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy