From 5a62e305f6beef4306f82e5fb04da72ae7b752d2 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 18 Jul 2016 17:32:19 +1000 Subject: [PATCH] [Android] Re,pve Prompt.java --- Android/src/emu/project64/dialog/Prompt.java | 159 ------------------- 1 file changed, 159 deletions(-) delete mode 100644 Android/src/emu/project64/dialog/Prompt.java diff --git a/Android/src/emu/project64/dialog/Prompt.java b/Android/src/emu/project64/dialog/Prompt.java deleted file mode 100644 index c1d417714..000000000 --- a/Android/src/emu/project64/dialog/Prompt.java +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -* * -* Project64 - A Nintendo 64 emulator. * -* http://www.pj64-emu.com/ * -* Copyright (C) 2012 Project64. All rights reserved. * -* * -* License: * -* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html * -* * -****************************************************************************/ -package emu.project64.dialog; - -import java.io.File; -import java.util.List; - -import emu.project64.R; - -import android.content.Context; -import android.text.TextUtils; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -/** - * A utility class that generates dialogs to prompt the user for information. - */ -public final class Prompt -{ - /** - * An interface that simplifies the population of list items. - * - * @param The type of the data to be wrapped. - * @see Prompt#createAdapter(Context, List, int, int, ListItemPopulator) - */ - public interface ListItemPopulator - { - public void onPopulateListItem( T item, int position, View view ); - } - - /** - * An interface that simplifies the population of list items having two text fields and an icon. - * - * @param The type of the data to be wrapped. - * @see Prompt#createAdapter(Context, List, ListItemTwoTextIconPopulator) - */ - public interface ListItemTwoTextIconPopulator - { - public void onPopulateListItem( T item, int position, TextView text1, TextView text2, - ImageView icon ); - } - - /** - * Create a {@link ListAdapter} where each list item has a specified layout. - * - * @param The type of the data to be wrapped. - * @param context The current context. - * @param items The data source for the list items. - * @param layoutResId The layout resource to be used for each list item. - * @param textResId The {@link TextView} resource within the layout to be populated by default. - * @param populator The object to populate the fields in each list item. - * - * @return An adapter that can be used to create list dialogs. - */ - public static ArrayAdapter createAdapter( Context context, List items, - final int layoutResId, final int textResId, final ListItemPopulator populator ) - { - return new ArrayAdapter( context, layoutResId, textResId, items ) - { - @Override - public View getView( int position, View convertView, ViewGroup parent ) - { - View row; - if( convertView == null ) - { - LayoutInflater inflater = (LayoutInflater) getContext().getSystemService( - Context.LAYOUT_INFLATER_SERVICE ); - row = (View) inflater.inflate( layoutResId, null ); - } - else - { - row = (View) convertView; - } - - populator.onPopulateListItem( getItem( position ), position, row ); - return row; - } - }; - } - - /** - * Create a {@link ListAdapter} where each list item has two text fields and an icon. - * - * @param The type of the data to be wrapped. - * @param context The activity context. - * @param items The data source for list items. - * @param populator The object to populate the fields in each list item. - * - * @return An adapter that can be used to create list dialogs. - */ - public static ArrayAdapter createAdapter( Context context, List items, - final ListItemTwoTextIconPopulator populator ) - { - return createAdapter( context, items, R.layout.list_item_two_text_icon, R.id.text1, - new ListItemPopulator() - { - @Override - public void onPopulateListItem( T item, int position, View view ) - { - TextView text1 = (TextView) view.findViewById( R.id.text1 ); - TextView text2 = (TextView) view.findViewById( R.id.text2 ); - ImageView icon = (ImageView) view.findViewById( R.id.icon ); - populator.onPopulateListItem( item, position, text1, text2, icon ); - } - } ); - } - - public static ArrayAdapter createFilenameAdapter( Context context, List paths, - final List names ) - { - return createAdapter( context, paths, new ListItemTwoTextIconPopulator() - { - @Override - public void onPopulateListItem( String path, int position, TextView text1, - TextView text2, ImageView icon ) - { - if( !TextUtils.isEmpty( path ) ) - { - String name = names.get( position ).toString(); - if( name.equals( ".." ) ) - { - text1.setText( R.string.pathPreference_parentFolder ); - icon.setVisibility( View.VISIBLE ); - icon.setImageResource( R.drawable.ic_arrow_u ); - } - else - { - File file = new File( path ); - text1.setText( name ); - if( file.isDirectory() ) - { - icon.setVisibility( View.VISIBLE ); - icon.setImageResource( R.drawable.ic_folder ); - } - else - { - icon.setVisibility( View.GONE ); - icon.setImageResource( 0 ); - } - } - text2.setVisibility( View.GONE ); - text2.setText( null ); - } - } - } ); - } -} \ No newline at end of file