Example usage for android.widget BaseAdapter BaseAdapter

List of usage examples for android.widget BaseAdapter BaseAdapter

Introduction

In this page you can find the example usage for android.widget BaseAdapter BaseAdapter.

Prototype

BaseAdapter

Source Link

Usage

From source file:com.microsoft.identity.client.testapp.CacheFragment.java

private BaseAdapter createAdapter(final List<TokenListElement> tokenListElements) {
    return new BaseAdapter() {
        @Override/*  w  w w  .j a  v  a2 s.  c  om*/
        public int getCount() {
            return tokenListElements.size();
        }

        @Override
        public TokenListElement getItem(final int i) {
            return tokenListElements.get(i);
        }

        @Override
        public long getItemId(int i) {
            return 0;
        }

        @Override
        public View getView(final int position, View convertView, final ViewGroup viewGroup) {
            if (null == convertView) {
                convertView = LayoutInflater.from(getActivity()).inflate(R.layout.cache_list_item, viewGroup,
                        false);
            }

            final TokenListElement element = tokenListElements.get(position);
            final boolean isRt = tokenListElements.get(position)
                    .getElementType() == TokenListElement.ElementType.RT;

            // Client id
            final View clientIdLayout = convertView.findViewById(R.id.ll_row_clientid);
            final TextView valueClientId = (TextView) clientIdLayout.findViewById(R.id.value_clientid);
            valueClientId.setText(element.getClientId());

            // User identifier
            final View userIdentifierLayout = convertView.findViewById(R.id.ll_row_user_identifier);
            final TextView valueUserIdentifier = (TextView) userIdentifierLayout
                    .findViewById(R.id.value_user_identifier);
            valueUserIdentifier.setText(element.getUserIdentifier());

            // Displayable id
            final View displayableIdLayout = convertView.findViewById(R.id.ll_row_displayable_id);
            final TextView valueDisplayableId = (TextView) displayableIdLayout
                    .findViewById(R.id.value_displayable_id);
            valueDisplayableId.setText(element.getDisplayableId());

            // Scopes
            final View scopesLayout = convertView.findViewById(R.id.ll_row_scopes);
            scopesLayout.setVisibility(isRt ? View.GONE : View.VISIBLE);
            final TextView valueScopes = (TextView) convertView.findViewById(R.id.values_scopes);
            if (!isRt) {
                valueScopes.setText(element.getScopes());
            }

            // Expires on
            final View expiresOnLayout = convertView.findViewById(R.id.ll_row_expires_on);
            expiresOnLayout.setVisibility(isRt ? View.GONE : View.VISIBLE);
            final TextView valueExpiresOn = (TextView) convertView.findViewById(R.id.value_expires_on);
            if (!isRt) {
                valueExpiresOn.setText(element.getExpiresOn());
            }

            // Host
            final View hostLayout = convertView.findViewById(R.id.ll_row_host);
            hostLayout.setVisibility(isRt ? View.VISIBLE : View.GONE);
            final TextView valueHost = (TextView) convertView.findViewById(R.id.value_host);
            if (isRt) {
                // set it
                valueHost.setText(element.getHost());
            }

            // Designation
            final TextView tokenDesignation = (TextView) convertView.findViewById(R.id.tv_atrt);
            tokenDesignation.setText(element.getElementType().mDisplayValue);

            // Delete
            final Button deleteBtn = (Button) convertView.findViewById(R.id.btn_delete);
            deleteBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {
                    if (null != mListener) {
                        mListener.onDeleteToken(position, CacheFragment.this);
                    }
                }
            });

            return convertView;
        }
    };
}

From source file:cn.com.teamlink.workbench.ExplorerActivity.java

public void onCreate(Bundle savedInstanceState) {
    // //www.j a  v a  2  s.  com
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    // ?
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_explorer);

    try {
        gridview = (GridView) findViewById(R.id.explorer_grid_view);

        gridViewListItems = new ArrayList<HashMap<String, String>>();
        /*
        gridViewListItemAdapter = new SimpleAdapter(
            this,
            // ???
            gridViewListItems,
            R.layout.explorer_item,
            new String[]{"item_text"},
            new int[]{R.id.item_text_view}
        );
        */

        gridViewListItemAdapter = new BaseAdapter() {

            @Override
            public int getCount() {
                return gridViewListItems.size();
            }

            @Override
            public Object getItem(int position) {
                return null;
            }

            @Override
            public long getItemId(int position) {
                return 0;
            }

            @Override
            public int getItemViewType(int position) {
                // TODO Auto-generated method stub
                Map<String, String> item = gridViewListItems.get(position);
                if (item.get("type").equals("GRID_HEADER")) {
                    return 1;
                }
                return 0;
            }

            @Override
            public int getViewTypeCount() {
                return 2;
            }

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {

                if (getItemViewType(position) == 0) {
                    GridViewHeaderHolder gridViewHeaderHolder = null;

                    if (convertView != null) {
                        gridViewHeaderHolder = (GridViewHeaderHolder) convertView.getTag();
                    } else {
                        gridViewHeaderHolder = new GridViewHeaderHolder();

                        LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
                        convertView = inflater.inflate(R.layout.explorer_item, parent, false);

                        gridViewHeaderHolder.itemTextView = (TextView) convertView
                                .findViewById(R.id.item_text_view);
                        convertView.setTag(gridViewHeaderHolder);
                    }

                    gridViewHeaderHolder.itemTextView
                            .setText(gridViewListItems.get(position).get("item_text").toString());

                } else {

                    GridViewItemHolder gridViewItemHolder = null;

                    if (convertView != null) {
                        gridViewItemHolder = (GridViewItemHolder) convertView.getTag();
                    } else {
                        gridViewItemHolder = new GridViewItemHolder();

                        LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
                        convertView = inflater.inflate(R.layout.explorer_item, parent, false);
                        convertView.setBackgroundResource(R.color.deepGray);

                        gridViewItemHolder.itemTextView = (TextView) convertView
                                .findViewById(R.id.item_text_view);
                        convertView.setTag(gridViewItemHolder);
                    }

                    gridViewItemHolder.itemTextView
                            .setText(gridViewListItems.get(position).get("item_text").toString());

                }

                return convertView;
            }
        };

        // 
        gridview.setAdapter(gridViewListItemAdapter);
        // ??
        gridview.setOnItemClickListener(new ItemClickListener());

        // 
        addHeader();

        // ?
        addData();
    } catch (Exception e) {
        Dialog alertDialog = new AlertDialog.Builder(this).setTitle("??").setMessage(e.getMessage())
                .setIcon(R.mipmap.ic_launcher).create();
        alertDialog.show();
    }

    try {
        // ??
        String fileName = "fileDemo.txt";
        // ??
        FileOutputStream fos = openFileOutput(fileName, Context.MODE_PRIVATE);
        String text = "Some data";
        // ?
        fos.write(text.getBytes());
        // ?
        fos.flush();
        // FileOutputStream
        fos.close();

        // String fileName = "fileDemo.txt";
        FileInputStream fis = openFileInput(fileName);
        byte[] readBytes = new byte[fis.available()];
        while (fis.read(readBytes) != -1) {

        }

        Dialog alertDialog = new AlertDialog.Builder(this).setTitle("??").setMessage(new String(readBytes))
                .setIcon(R.mipmap.ic_launcher).create();
        alertDialog.show();
    } catch (Exception e) {

        Dialog alertDialog = new AlertDialog.Builder(this).setTitle("??")
                .setMessage(e.getLocalizedMessage()).setIcon(R.mipmap.ic_launcher).create();
        alertDialog.show();

        /*
        Dialog alertDialog = new AlertDialog.Builder(this).
            setTitle("").
            setMessage("???").
            setIcon(R.mipmap.ic_launcher).
            setPositiveButton(
                    "",
                    new DialogInterface.OnClickListener() {
                
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                        }
                    }
            ).
            setNegativeButton("?", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            }).
            setNeutralButton("", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            }).
            create();
        alertDialog.show();
        */

        /*
        final String[] arrayFruit = new String[]{"", "?", "?", ""};
        Dialog alertDialog = new AlertDialog
            .Builder(this).
            setTitle("??").
            setIcon(R.mipmap.ic_launcher)
            .setItems(
                    arrayFruit,
                    new DialogInterface.OnClickListener() {
                
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(ExplorerActivity.this, arrayFruit[which], Toast.LENGTH_SHORT).show();
                        }
                    }
            )
            .setNegativeButton(
                    "?",
                    new DialogInterface.OnClickListener() {
                
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO Auto-generated method stub
                        }
                    }
            ).create();
        alertDialog.show();
        */

        /*
        // int selectedFruitIndex = 0;
        final String[] arrayFruit = new String[]{"", "?", "?", ""};
                
        Dialog alertDialog = new AlertDialog.Builder(this)
            .setTitle("??")
            .setIcon(R.mipmap.ic_launcher)
            .setSingleChoiceItems(arrayFruit, 0, new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    selectedFruitIndex = which;
                }
            })
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    Toast.makeText(Dialog_AlertDialogDemoActivity.this, arrayFruit[selectedFruitIndex], Toast.LENGTH_SHORT).show();
                }
            }).setNegativeButton("?", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            }).create();
        alertDialog.show();
        */

        /*
        final String[] arrayFruit = new String[]{"", "?", "?", ""};
        final boolean[] arrayFruitSelected = new boolean[]{true, true, false, false};
                
        Dialog alertDialog = new AlertDialog.Builder(this)
            .setTitle("??")
            .setIcon(R.mipmap.ic_launcher)
            .setMultiChoiceItems(arrayFruit, arrayFruitSelected, new DialogInterface.OnMultiChoiceClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which, boolean isChecked) {
                    arrayFruitSelected[which] = isChecked;
                }
            })
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    StringBuilder stringBuilder = new StringBuilder();
                    for (int i = 0; i < arrayFruitSelected.length; i++) {
                        if (arrayFruitSelected[i] == true) {
                            stringBuilder.append(arrayFruit[i] + "?");
                        }
                    }
                    Toast.makeText(ExplorerActivity.this, stringBuilder.toString(), Toast.LENGTH_SHORT).show();
                }
            })
            .setNegativeButton("?", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            }).create();
        alertDialog.show();
        */

        /*
        // ?View
        LayoutInflater layoutInflater = LayoutInflater.from(this);
        View myLoginView = layoutInflater.inflate(R.layout.login, null);
                
        Dialog alertDialog = new AlertDialog.Builder(this)
            .setTitle("")
            .setIcon(R.mipmap.ic_launcher)
            .setView(myLoginView)
            .setPositiveButton("", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            })
            .setNegativeButton("?", new DialogInterface.OnClickListener() {
                
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // TODO Auto-generated method stub
                }
            }).create();
        alertDialog.show();
        */
    }
}

From source file:com.google.android.apps.muzei.settings.SettingsActivity.java

private void setupAppBar() {
    mAppBar = (Toolbar) findViewById(R.id.app_bar);
    mAppBar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override/*  ww w .  ja  v  a 2 s .  c  om*/
        public void onClick(View view) {
            onNavigateUp();
        }
    });

    final LayoutInflater inflater = LayoutInflater.from(this);
    Spinner sectionSpinner = (Spinner) findViewById(R.id.section_spinner);
    sectionSpinner.setAdapter(new BaseAdapter() {
        @Override
        public int getCount() {
            return SECTION_LABELS.length;
        }

        @Override
        public Object getItem(int position) {
            return SECTION_LABELS[position];
        }

        @Override
        public long getItemId(int position) {
            return position + 1;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item, parent, false);
            }
            ((TextView) convertView.findViewById(android.R.id.text1))
                    .setText(getString(SECTION_LABELS[position]));
            return convertView;
        }

        @Override
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = inflater.inflate(R.layout.settings_ab_spinner_list_item_dropdown, parent, false);
            }
            ((TextView) convertView.findViewById(android.R.id.text1))
                    .setText(getString(SECTION_LABELS[position]));
            return convertView;
        }
    });

    sectionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> spinner, View view, int position, long id) {
            Class<? extends Fragment> fragmentClass = SECTION_FRAGMENTS[position];
            Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_container);
            if (currentFragment != null && fragmentClass.equals(currentFragment.getClass())) {
                return;
            }

            inflateMenuFromFragment(0);

            try {
                Fragment newFragment = fragmentClass.newInstance();
                getSupportFragmentManager().beginTransaction()
                        .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                        .setTransitionStyle(R.style.Muzei_SimpleFadeFragmentAnimation)
                        .replace(R.id.content_container, newFragment).commitAllowingStateLoss();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> spinner) {
        }
    });

    sectionSpinner.setSelection(mStartSection);

    inflateMenuFromFragment(0);
    mAppBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            switch (item.getItemId()) {
            case R.id.action_get_more_sources:
                try {
                    Intent playStoreIntent = new Intent(Intent.ACTION_VIEW,
                            Uri.parse("http://play.google.com/store/search?q=Muzei&c=apps"))
                                    .addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
                    preferPackageForIntent(SettingsActivity.this, playStoreIntent, PLAY_STORE_PACKAGE_NAME);
                    startActivity(playStoreIntent);
                } catch (ActivityNotFoundException activityNotFoundException1) {
                    Toast.makeText(SettingsActivity.this, R.string.play_store_not_found, Toast.LENGTH_LONG)
                            .show();
                }
                return true;

            case R.id.action_about:
                startActivity(new Intent(SettingsActivity.this, AboutActivity.class));
                return true;
            }

            Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_container);
            if (currentFragment != null && currentFragment instanceof SettingsActivityMenuListener) {
                ((SettingsActivityMenuListener) currentFragment).onSettingsActivityMenuItemClick(item);
            }

            return false;
        }
    });
}

From source file:com.juick.android.UserCenterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    JuickAdvancedApplication.setupTheme(this);
    handler = new Handler();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.user_center);
    final ListView list = (ListView) findViewById(R.id.list);
    final View listWait = findViewById(R.id.list_wait);
    final TextView userRealName = (TextView) findViewById(R.id.user_realname);
    final ImageView userPic = (ImageView) findViewById(R.id.userpic);
    final TextView userName = (TextView) findViewById(R.id.username);
    search = findViewById(R.id.search);/*from w  ww. j  a v a2s.co m*/
    final View stats = findViewById(R.id.stats);
    userRealName.setText("...");
    Bundle extras = getIntent().getExtras();
    if (extras == null) {
        finish();
        return;
    }
    uname = extras.getString("uname");
    final int uid = extras.getInt("uid");

    final MessageID mid = (MessageID) extras.getSerializable("mid");
    final MessagesSource messagesSource = (MessagesSource) extras.getSerializable("messagesSource");
    if (uname == null || mid == null) {
        finish();
        return;
    }
    int height = getWindow().getWindowManager().getDefaultDisplay().getHeight();
    final int userpicSize = height <= 320 ? 32 : 96;
    float scaledDensity = getResources().getDisplayMetrics().scaledDensity;
    userPic.setMinimumHeight((int) (scaledDensity * userpicSize));
    userPic.setMinimumWidth((int) (scaledDensity * userpicSize));
    stats.setEnabled(false);
    userName.setText("@" + uname);
    final boolean russian = Locale.getDefault().getLanguage().equals("ru");
    new Thread() {
        @Override
        public void run() {
            final Utils.RESTResponse json = Utils.getJSON(UserCenterActivity.this,
                    "http://" + Utils.JA_ADDRESS + "/api/userinfo?uname=" + Uri.encode(uname), null);
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    stats.setEnabled(true);
                    if (json.getErrorText() != null) {
                        Toast.makeText(UserCenterActivity.this, "JA server: " + json.getErrorText(),
                                Toast.LENGTH_LONG).show();
                        listWait.setVisibility(View.GONE);
                    } else {
                        final UserInfo userInfo = new Gson().fromJson(json.getResult(), UserInfo.class);
                        if (userInfo == null) {
                            Toast.makeText(UserCenterActivity.this, "Unable to parse JSON", Toast.LENGTH_LONG)
                                    .show();
                            listWait.setVisibility(View.GONE);
                        } else {
                            userRealName.setText(userInfo.fullName);
                            listWait.setVisibility(View.GONE);
                            list.setVisibility(View.VISIBLE);
                            list.setAdapter(new BaseAdapter() {
                                @Override
                                public int getCount() {
                                    return userInfo.getExtraInfo().size();
                                }

                                @Override
                                public Object getItem(int position) {
                                    return userInfo.getExtraInfo().get(position);
                                }

                                @Override
                                public long getItemId(int position) {
                                    return position;
                                }

                                @Override
                                public View getView(int position, View convertView, ViewGroup parent) {
                                    if (convertView == null) {
                                        convertView = getLayoutInflater().inflate(R.layout.listitem_userinfo,
                                                null);
                                    }
                                    TextView text = (TextView) convertView.findViewById(R.id.text);
                                    TextView text2 = (TextView) convertView.findViewById(R.id.text2);
                                    String info = userInfo.getExtraInfo().get(position);
                                    int ix = info.indexOf("|");
                                    if (ix == -1) {
                                        text.setText(info);
                                        if (russian && UserInfo.translations.containsKey(info)) {
                                            info = UserInfo.translations.get(info);
                                        }
                                        text2.setText("");
                                    } else {
                                        String theInfo = info.substring(0, ix);
                                        if (russian && UserInfo.translations.containsKey(theInfo)) {
                                            theInfo = UserInfo.translations.get(theInfo);
                                        }
                                        text.setText(theInfo);
                                        String value = info.substring(ix + 1);
                                        if (value.startsWith("Date:")) {
                                            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                                            value = value.substring(5);
                                            value = sdf.format(new Date(Long.parseLong(value)));
                                        }
                                        text2.setText(value);
                                    }
                                    return convertView;
                                }
                            });
                        }
                    }
                }
            });
        }

    }.start();

    View subscribe_user = findViewById(R.id.subscribe_user);
    View unsubscribe_user = findViewById(R.id.unsubscribe_user);
    View subscribe_comments = findViewById(R.id.subscribe_comments);
    View unsubscribe_comments = findViewById(R.id.unsubscribe_comments);
    View filter_user = findViewById(R.id.filter_user);
    View blacklist_user = findViewById(R.id.blacklist_user);
    View show_blog = findViewById(R.id.show_blog);
    MicroBlog microBlog = MainActivity.getMicroBlog(mid.getMicroBlogCode());
    final MessageMenu mm = microBlog.getMessageMenu(this, messagesSource, null, null);
    JuickMessage message = microBlog.createMessage();
    mm.listSelectedItem = message;
    message.User = new JuickUser();
    message.User.UName = uname;
    message.User.UID = uid;
    message.setMID(mid);
    final UserpicStorage.AvatarID avatarID = microBlog.getAvatarID(message);

    final UserpicStorage.Listener userpicListener = new UserpicStorage.Listener() {
        @Override
        public void onUserpicReady(UserpicStorage.AvatarID id, int size) {
            final UserpicStorage.Listener thiz = this;
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    UserpicStorage.instance.removeListener(avatarID, userpicSize, thiz);
                    final Bitmap userpic = UserpicStorage.instance.getUserpic(UserCenterActivity.this, avatarID,
                            userpicSize, thiz);
                    userPic.setImageBitmap(userpic); // can be null
                }
            });
        }
    };
    Bitmap userpic = UserpicStorage.instance.getUserpic(this, avatarID, userpicSize, userpicListener);
    userPic.setImageBitmap(userpic); // can be null

    subscribe_user.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mm.actionSubscribeUser();
        }
    });
    show_blog.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mm.listSelectedItem.User.UID == 0) {
                JuickMicroBlog.obtainProperUserIdByName(UserCenterActivity.this, mm.listSelectedItem.User.UName,
                        "Getting Juick User Id", new Utils.Function<Void, Pair<String, String>>() {
                            @Override
                            public Void apply(Pair<String, String> cred) {
                                mm.listSelectedItem.User.UID = Integer.parseInt(cred.first);
                                mm.actionUserBlog();
                                return null;
                            }
                        });
            } else {
                mm.actionUserBlog();
            }
        }
    });
    search.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            search.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
                @Override
                public void onCreateContextMenu(ContextMenu menu, View v,
                        ContextMenu.ContextMenuInfo menuInfo) {
                    menu.add(0, SEARCH_PAST_CONVERSATIONS, 0, "My dialogs with user");
                    menu.add(0, SEARCH_MORE, 1, "More");
                }
            });
            search.showContextMenu();
        }
    });
    stats.setOnClickListener(new View.OnClickListener() {

        NewJuickPreferenceActivity.MenuItem[] items = new NewJuickPreferenceActivity.MenuItem[] {
                new NewJuickPreferenceActivity.MenuItem(R.string.UserAllTimeActivityReport,
                        R.string.UserAllTimeActivityReport2, new Runnable() {
                            @Override
                            public void run() {
                                NewJuickPreferenceActivity.showChart(UserCenterActivity.this,
                                        "USER_ACTIVITY_VOLUME", "uid=" + uid);
                            }
                        }),
                new NewJuickPreferenceActivity.MenuItem(R.string.UserHoursReport, R.string.UserHoursReport2,
                        new Runnable() {
                            @Override
                            public void run() {
                                NewJuickPreferenceActivity.showChart(UserCenterActivity.this,
                                        "USER_HOURS_ACTIVITY", "uid=" + uid + "&tzoffset="
                                                + TimeZone.getDefault().getRawOffset() / 1000 / 60 / 60);
                            }
                        }) };

        @Override
        public void onClick(View v) {
            list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    items[position].action.run();
                }
            });
            list.setAdapter(new BaseAdapter() {
                @Override
                public int getCount() {
                    return items.length;
                }

                @Override
                public Object getItem(int position) {
                    return items[position];
                }

                @Override
                public long getItemId(int position) {
                    return position;
                }

                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    LayoutInflater layoutInflater = getLayoutInflater();
                    View listItem = layoutInflater.inflate(android.R.layout.simple_list_item_2, null);
                    TextView text = (TextView) listItem.findViewById(android.R.id.text1);
                    text.setText(items[position].labelId);
                    TextView text2 = (TextView) listItem.findViewById(android.R.id.text2);
                    text2.setText(items[position].label2Id);
                    return listItem;
                }
            });
        }
    });
    blacklist_user.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mm.actionBlacklistUser();
        }
    });
    filter_user.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mm.actionFilterUser(uname);
        }
    });
    unsubscribe_user.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mm.actionUnsubscribeUser();
        }
    });
    subscribe_comments.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            enableJAM(new Runnable() {
                @Override
                public void run() {
                    JAMService.instance.client.subscribeToComments(uname);
                }
            });
        }
    });
    unsubscribe_comments.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            enableJAM(new Runnable() {
                @Override
                public void run() {
                    JAMService.instance.client.unsubscribeFromComments(uname);
                }
            });
        }
    });
}

From source file:com.layer.atlas.AtlasMessagesList.java

public void init(final LayerClient layerClient, final Atlas.ParticipantProvider participantProvider) {
    if (layerClient == null)
        throw new IllegalArgumentException("LayerClient cannot be null");
    if (participantProvider == null)
        throw new IllegalArgumentException("ParticipantProvider cannot be null");

    this.client = layerClient;
    LayoutInflater.from(getContext()).inflate(R.layout.atlas_messages_list, this);

    // --- message view
    messagesList = (ListView) findViewById(R.id.atlas_messages_list);
    messagesList.setAdapter(messagesAdapter = new BaseAdapter() {

        public View getView(int position, View convertView, ViewGroup parent) {
            final Cell cell = cells.get(position);
            MessagePart part = cell.messagePart;
            String userId = part.getMessage().getSender().getUserId();

            boolean myMessage = client.getAuthenticatedUserId().equals(userId);

            if (convertView == null) {
                convertView = LayoutInflater.from(parent.getContext())
                        .inflate(R.layout.atlas_view_messages_convert, parent, false);
            }/*from  w w  w  .j a  va2 s.  c om*/

            View spacerTop = convertView.findViewById(R.id.atlas_view_messages_convert_spacer_top);
            spacerTop.setVisibility(
                    cell.clusterItemId == cell.clusterHeadItemId && !cell.timeHeader ? View.VISIBLE
                            : View.GONE);

            View spacerBottom = convertView.findViewById(R.id.atlas_view_messages_convert_spacer_bottom);
            spacerBottom.setVisibility(cell.clusterTail ? View.VISIBLE : View.GONE);

            // format date
            View timeBar = convertView.findViewById(R.id.atlas_view_messages_convert_timebar);
            TextView timeBarDay = (TextView) convertView
                    .findViewById(R.id.atlas_view_messages_convert_timebar_day);
            TextView timeBarTime = (TextView) convertView
                    .findViewById(R.id.atlas_view_messages_convert_timebar_time);
            if (cell.timeHeader) {

                Calendar cal = Calendar.getInstance();
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                long todayMidnight = cal.getTimeInMillis();
                long yesterMidnight = todayMidnight - (24 * 60 * 60 * 1000); // 24h less
                Date sentAt = cell.messagePart.getMessage().getSentAt();
                if (sentAt == null)
                    sentAt = new Date();

                String timeBarTimeText = timeFormat.format(sentAt.getTime());
                String timeBarDayText = null;
                if (sentAt.getTime() > todayMidnight) {
                    timeBarDayText = "Today";
                } else if (sentAt.getTime() > yesterMidnight) {
                    timeBarDayText = "Yesterday";
                } else {
                    timeBarDayText = Tools.sdfDayOfWeek.format(sentAt);
                }
                timeBarDay.setText(timeBarDayText);
                timeBarTime.setText(timeBarTimeText);
                timeBar.setVisibility(View.VISIBLE);
            } else {
                timeBar.setVisibility(View.GONE);
            }

            TextView textAvatar = (TextView) convertView
                    .findViewById(R.id.atlas_view_messages_convert_initials);
            View spacerRight = convertView.findViewById(R.id.atlas_view_messages_convert_spacer_right);
            if (myMessage) {
                spacerRight.setVisibility(View.GONE);
                textAvatar.setVisibility(View.INVISIBLE);
            } else {
                spacerRight.setVisibility(View.VISIBLE);
                Atlas.Participant participant = participantProvider.getParticipant(userId);
                String displayText = participant != null ? Atlas.getInitials(participant) : "";
                textAvatar.setText(displayText);
                textAvatar.setVisibility(View.VISIBLE);
            }

            // mark unsent messages
            View cellContainer = convertView.findViewById(R.id.atlas_view_messages_cell_container);
            cellContainer.setAlpha(
                    (myMessage && !cell.messagePart.getMessage().isSent()) ? CELL_CONTAINER_ALPHA_UNSENT
                            : CELL_CONTAINER_ALPHA_SENT);

            // delivery receipt check
            TextView receiptView = (TextView) convertView
                    .findViewById(R.id.atlas_view_messages_convert_delivery_receipt);
            receiptView.setVisibility(View.GONE);
            if (latestDeliveredMessage != null
                    && latestDeliveredMessage.getId().equals(cell.messagePart.getMessage().getId())) {
                receiptView.setVisibility(View.VISIBLE);
                receiptView.setText("Delivered");
            }
            if (latestReadMessage != null
                    && latestReadMessage.getId().equals(cell.messagePart.getMessage().getId())) {
                receiptView.setVisibility(View.VISIBLE);
                receiptView.setText("Read");
            }

            // processing cell
            bindCell(convertView, cell);

            // mark displayed message as read
            Message msg = part.getMessage();
            if (!msg.getSender().getUserId().equals(client.getAuthenticatedUserId())) {
                msg.markAsRead();
            }

            timeBarDay.setTextColor(dateTextColor);
            timeBarTime.setTextColor(dateTextColor);
            textAvatar.setTextColor(avatarTextColor);
            ((GradientDrawable) textAvatar.getBackground()).setColor(avatarBackgroundColor);

            return convertView;
        }

        private void bindCell(View convertView, final Cell cell) {

            ViewGroup cellContainer = (ViewGroup) convertView
                    .findViewById(R.id.atlas_view_messages_cell_container);

            View cellRootView = cell.onBind(cellContainer);
            boolean alreadyInContainer = false;
            // cleanUp container
            cellRootView.setVisibility(View.VISIBLE);
            for (int iChild = 0; iChild < cellContainer.getChildCount(); iChild++) {
                View child = cellContainer.getChildAt(iChild);
                if (child != cellRootView) {
                    child.setVisibility(View.GONE);
                } else {
                    alreadyInContainer = true;
                }
            }
            if (!alreadyInContainer) {
                cellContainer.addView(cellRootView);
            }
        }

        public long getItemId(int position) {
            return position;
        }

        public Object getItem(int position) {
            return cells.get(position);
        }

        public int getCount() {
            return cells.size();
        }

    });

    messagesList.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cell item = cells.get(position);
            if (clickListener != null) {
                clickListener.onItemClick(item);
            }
        }
    });
    // --- end of messageView

    updateValues();
}

From source file:com.hzx.luoyechat.activity.SettingsFragment.java

private void initSwitchColor() {
    dialog = new android.support.v7.app.AlertDialog.Builder(getActivity()).setAdapter(new BaseAdapter() {
        @Override//  w w w.ja  v  a 2  s  .  c om
        public int getCount() {
            return colors.length;
        }

        @Override
        public Object getItem(int position) {
            return colors[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = new View(getActivity());
                convertView.setLayoutParams(new AbsListView.LayoutParams(-1, 70));
            }

            convertView.setBackgroundColor(getResources().getColor((Integer) getItem(position)));
            return convertView;
        }
    }, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {
            //                  Snackbar.make(theme_color, i + ": ", 0).show();
            HXPreferenceUtils.getInstance().setThemeColor(i);
            HXPreferenceUtils.getInstance().setTabIndex(2);
            theme_color.setBackgroundResource(colors[i]);
            getActivity().finish();
            startActivity(new Intent(getActivity(), MainActivity.class));
        }
    });/**/
    rl_switch_theme_color.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            dialog.show();
        }
    });
    int colorindex = HXPreferenceUtils.getInstance().getThemeColor();
    theme_color.setBackgroundResource(colors[colorindex]);
}

From source file:net.quduo.pixel.interfaces.android.fragment.ChatFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    this.inflater = inflater;
    View v = inflater.inflate(R.layout.fragment_chat, container, false);

    mChatListView = (ListView) v.findViewById(R.id.chat_list_view);

    // TODO: ?/*w w  w .j  a v a2  s  . c  om*/
    mSourceDataList = new ArrayList<ChatListDataModel>();
    ChatListDataModel sourceData = new ChatListDataModel();
    sourceData.setChatAvatar(R.drawable.default_contact_action_01);
    sourceData.setChatTitle("?");
    sourceData.setChatSummary(":?, ...");
    mSourceDataList.add(sourceData);

    ChatListDataModel sourceData1 = new ChatListDataModel();
    sourceData1.setChatAvatar(R.drawable.default_contact_action_04);
    sourceData1.setChatTitle("");
    sourceData1.setChatSummary("?");
    mSourceDataList.add(sourceData1);

    ChatListDataModel sourceData2 = new ChatListDataModel();
    sourceData2.setChatAvatar(R.drawable.default_contact_action_03);
    sourceData2.setChatTitle("");
    sourceData2.setChatSummary("?...");
    mSourceDataList.add(sourceData2);

    ChatListDataModel sourceData3 = new ChatListDataModel();
    sourceData3.setChatAvatar(R.drawable.default_contact_action_02);
    sourceData3.setChatTitle("");
    sourceData3.setChatSummary("?");
    mSourceDataList.add(sourceData3);

    // TODO ContextMenu
    final ArrayList<HashMap<String, Object>> mPopupWindowListItem = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> map1 = new HashMap<String, Object>();
    // map1.put("item_image", R.drawable.icon_message);
    map1.put("item_icon", R.string.icon_chat_add_group);
    // map1.put("item_text", "" + i + "");
    map1.put("item_title", "??");
    mPopupWindowListItem.add(map1);
    HashMap<String, Object> map2 = new HashMap<String, Object>();
    // map2.put("item_image", R.drawable.icon_message);
    map2.put("item_icon", R.string.icon_chat_add_group);
    // map2.put("item_text", "" + i + "");
    map2.put("item_title", "");
    mPopupWindowListItem.add(map2);

    mChatListAdapter = new ChatListAdapter(this.getActivity(), mSourceDataList);
    mChatListView.setAdapter(mChatListAdapter);
    mChatListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            if (DEBUG)
                Log.d(TAG, mSourceDataList.get(i).getChatTitle());

            Intent intent = new Intent(getActivity(), ChatFormActivity.class);
            getActivity().startActivity(intent);
            getActivity().finish();
            // ?
            getActivity().overridePendingTransition(R.anim.activity_open_enter, R.anim.activity_close_exit);

        }
    });
    mChatListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) {
            if (DEBUG)
                Log.d(TAG, mSourceDataList.get(i).getChatTitle());

            // ??
            View contextMenuView = inflater.inflate(R.layout.layout_common_context_menu, null);
            // PopupWindow
            final PopupWindow popupWindow = new PopupWindow(contextMenuView,
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, false);
            // ???
            // new ColorDrawable(0) getResources().getDrawable(R.drawable.popup_window_background)
            popupWindow.setBackgroundDrawable(new ColorDrawable(0x90000000));
            // ??
            // popupWindow.setOutsideTouchable(true);
            // ??
            popupWindow.setFocusable(true);
            // ?
            // popupWindow.setAnimationStyle(R.style.PopupAnimation);
            // ?
            // popupWindow.setOnDismissListenerd(new PopupWindow.OnDismissListener(){});
            /*
            // PopupWindow,PopupWindow
            popupWindow.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    popupWindow.dismiss();
                    return true;
                }
                return false;
            }
            });
            */
            popupWindow.getContentView().setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    popupWindow.dismiss();
                }
            });
            if (popupWindow.isShowing()) {
                // ???????????
                popupWindow.dismiss();
            } else {
                // SimpleAdapter mSimpleAdapter = new SimpleAdapter(getApplicationContext(), mPopupWindowListItem, R.layout.main_popup_menu_item, new String[]{"item_icon", "item_title"}, new int[]{R.id.popup_menu_item_icon, R.id.popup_menu_item_title});

                BaseAdapter mSimpleAdapter = new BaseAdapter() {

                    @Override
                    public int getCount() {
                        return mPopupWindowListItem.size();
                    }

                    @Override
                    public Object getItem(int i) {
                        return null;
                    }

                    @Override
                    public long getItemId(int i) {
                        return 0;
                    }

                    @Override
                    public View getView(int position, View convertView, ViewGroup parent) {

                        if (convertView == null) {
                            LayoutInflater inflater = LayoutInflater.from(getActivity());
                            convertView = inflater.inflate(R.layout.list_item_common_context_menu, parent,
                                    false);
                        }
                        // TextView popupMenuItemIcon = (TextView) convertView.findViewById(R.id.popup_menu_item_icon);
                        // if (DEBUG) Log.d(TAG, "item_icon:" + mPopupWindowListItem.get(position).get("item_icon"));
                        // popupMenuItemIcon.setTypeface(typeface);
                        // if (popupMenuItemIcon.getTypeface() != typeface) {
                        //    popupMenuItemIcon.setTypeface(typeface);
                        // }
                        // popupMenuItemIcon.setText(Integer.valueOf(mPopupWindowListItem.get(position).get("item_icon").toString()));

                        TextView popupMenuItemTitle = (TextView) convertView
                                .findViewById(R.id.context_menu_action_text_view);
                        popupMenuItemTitle
                                .setText(mPopupWindowListItem.get(position).get("item_title").toString());

                        return convertView;
                    }
                };

                TextView contextMenuTitle = (TextView) contextMenuView.findViewById(R.id.context_menu_title);
                contextMenuTitle.setText(mSourceDataList.get(i).getChatTitle());

                ListView mPopupMenuListView = (ListView) contextMenuView
                        .findViewById(R.id.context_menu_list_view);
                mPopupMenuListView.setAdapter(mSimpleAdapter);

                // ?
                // PopupWindow??View?x,y?????
                // popupWindow.showAsDropDown(v, -460, 0);
                // ?View?,?parent????-90
                // Gravity.TOP|Gravity.LEFT, 0, 150
                popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
                popupWindow.update();
            }
            return true;
        }
    });
    // mChatListView.setOnItemSelectedListener();

    // #ContextMenu
    // this.unregisterForContextMenu(mChatListView);
    // mChatListView.setOnCreateContextMenuListener(null);
    // this.registerForContextMenu(mChatListView);
    return v;
}

From source file:com.pixplicity.castdemo.MainActivity.java

private void updateMessages() {
    if (mMessageListMessages.size() > 0) {
        mVgLogo.setVisibility(View.INVISIBLE);
    }//from   w  ww  . jav a 2s  .  c o  m
    if (mMessageAdapter == null) {
        mMessageAdapter = new BaseAdapter() {

            @SuppressLint("InflateParams")
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View row;
                if (convertView == null) {
                    LayoutInflater inflater = (LayoutInflater) getApplicationContext()
                            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                    row = inflater.inflate(R.layout.list_messages, null);
                } else {
                    row = convertView;
                }
                /* TODO
                Message msg = getItem(position);
                row.getText1().setText(msg.username);
                row.getText2().setText(msg.message);
                */
                ((TextView) row.findViewById(R.id.tv_username)).setText(mMessageListUsernames.get(position));
                ((TextView) row.findViewById(R.id.tv_message)).setText(mMessageListMessages.get(position));
                return row;
            }

            @Override
            public int getCount() {
                return mMessageListMessages.size();
            }

            @Override
            public Message getItem(int position) {
                // TODO return mMessageList.get(position);
                return null;
            }

            @Override
            public long getItemId(int position) {
                return 0;
            }
        };
        mLvMessages.setAdapter(mMessageAdapter);
    }
}

From source file:org.droid2droid.test.TestDroid2DroidListFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Log.v(TAG, "Fragment.onCreate");
    super.onCreate(savedInstanceState);
    mDiscoveredAndroid = Droid2DroidManager.newDiscoveredAndroid(getActivity(), this);
    Intent market = Droid2DroidManager.getIntentForMarket(getActivity());
    if (market == null) {
        //           mRetain=(Retain)getActivity().getLastNonConfigurationInstance(); // FIXME: single fragment in activity
        Droid2DroidManager.bindManager(getActivity(), new ManagerListener() {

            @Override/* w w w . j  ava2s  .co  m*/
            public void bind(Droid2DroidManager manager) {
                mManager = manager;
            }

            @Override
            public void unbind(Droid2DroidManager manager) {
                mDiscoveredAndroid = null;
                setDiscover(false);
                setBurst(mBurst);
                mManager = null;
            }

        });
        if (savedInstanceState != null) {
            mBurst = savedInstanceState.getBoolean(EXTRA_BURST);
        }

        mItemAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, mItems);
        mAdapter = new BaseAdapter() {

            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
                View view;
                Caches caches;
                if (convertView == null) {
                    Activity activity = getActivity();
                    if (activity == null) {
                        Log.d(TAG, "null activity");
                        return null;
                    }
                    view = getActivity().getLayoutInflater().inflate(R.layout.test_item, null);
                    caches = new Caches();
                    caches.mUri = (Spinner) view.findViewById(R.id.uri);
                    caches.mUri.setOnItemSelectedListener(TestDroid2DroidListFragment.this);
                    caches.mActive = (ToggleButton) view.findViewById(R.id.active);
                    caches.mActive.setOnClickListener(TestDroid2DroidListFragment.this);
                    caches.mInstall = (Button) view.findViewById(R.id.install);
                    caches.mInstall.setOnClickListener(TestDroid2DroidListFragment.this);
                    caches.mBind = (ToggleButton) view.findViewById(R.id.bind);
                    caches.mBind.setOnClickListener(TestDroid2DroidListFragment.this);
                    caches.mInvoke = (Button) view.findViewById(R.id.invoke);
                    caches.mInvoke.setOnClickListener(TestDroid2DroidListFragment.this);
                    caches.mStatus = (TextView) view.findViewById(R.id.status);
                    view.setTag(caches);

                    mItemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
                    caches.mUri.setAdapter(mItemAdapter);

                } else {
                    view = convertView;
                    caches = (Caches) view.getTag();
                }
                caches.mUri.setTag(position);
                caches.mActive.setTag(position);
                caches.mInstall.setTag(position);
                caches.mBind.setTag(position);
                caches.mInvoke.setTag(position);
                Droid2DroidContext racontext = mRemoteAndroids.get(position);
                if (racontext.mUri != null) {

                    for (int i = 0; i < mItems.size(); ++i) {
                        if (racontext.mUri.equals(mItems.get(i))) {
                            caches.mUri.setSelection(i);
                            break;
                        }
                    }
                }
                caches.mActive.setEnabled((racontext.mState != Droid2DroidContext.State.BindingRemoteAndroid));
                caches.mActive.setChecked(racontext.mRemoteAndroid != null);
                boolean enabled = (racontext.mRemoteAndroid != null);
                caches.mInstall.setEnabled(enabled);
                caches.mBind.setEnabled(enabled);
                caches.mBind.setChecked(racontext.binded);
                caches.mInvoke.setEnabled(racontext.mRemoteObject != null);
                caches.mStatus.setText(racontext.mStatus);
                return view;
            }

            @Override
            public long getItemId(int position) {
                return position;
            }

            @Override
            public Object getItem(int position) {
                // TODO Auto-generated method stub
                return null;
            }

            @Override
            public int getCount() {
                return mRemoteAndroids.size();
            }
        };
        setListAdapter(mAdapter);
        setHasOptionsMenu(true);
    }
}

From source file:net.quduo.pixel.interfaces.android.fragment.ContactFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_contact, container, false);

    // TODO ContextMenu
    final ArrayList<HashMap<String, Object>> mPopupWindowListItem = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> map1 = new HashMap<String, Object>();
    // map1.put("item_image", R.drawable.icon_message);
    map1.put("item_icon", R.string.icon_chat_add_group);
    // map1.put("item_text", "" + i + "");
    map1.put("item_title", "??");
    mPopupWindowListItem.add(map1);//from ww w  . j  a  v  a 2  s .c om
    HashMap<String, Object> map2 = new HashMap<String, Object>();
    // map2.put("item_image", R.drawable.icon_message);
    map2.put("item_icon", R.string.icon_chat_add_group);
    // map2.put("item_text", "" + i + "");
    map2.put("item_title", "");
    mPopupWindowListItem.add(map2);

    // Set the adapter
    mContactListAdapter = new ContactListAdapter(this.getActivity(), mSourceDataList);
    mListView = (ListView) view.findViewById(R.id.contact_list_view);
    mListView.setAdapter(mContactListAdapter);

    // Set OnItemClickListener so we can be notified on item clicks
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (null != mListener) {
                // Notify the active callbacks interface (the activity, if the
                // fragment is attached to one) that an item has been selected.
                // mListener.onFragmentInteraction(DummyContent.ITEMS.get(position).id);
            }
        }
    });
    mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapterView, View v, int i, long l) {
            // Log.e(TAG, DummyContent.ITEMS.get(i).content);
            Log.e(TAG, mSourceDataList.get(i).getContactName());

            // ??
            View contextMenuView = inflater.inflate(R.layout.layout_common_context_menu, null);
            // PopupWindow
            final PopupWindow popupWindow = new PopupWindow(contextMenuView,
                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, false);
            // ???
            // new ColorDrawable(0) getResources().getDrawable(R.drawable.popup_window_background)
            popupWindow.setBackgroundDrawable(new ColorDrawable(0x90000000));
            // ??
            // popupWindow.setOutsideTouchable(true);
            // ??
            popupWindow.setFocusable(true);
            // ?
            // popupWindow.setAnimationStyle(R.style.PopupAnimation);
            // ?
            // popupWindow.setOnDismissListenerd(new PopupWindow.OnDismissListener(){});
            /*
            // PopupWindow,PopupWindow
            popupWindow.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
                    popupWindow.dismiss();
                    return true;
                }
                return false;
            }
            });
            */
            popupWindow.getContentView().setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    popupWindow.dismiss();
                }
            });
            if (popupWindow.isShowing()) {
                // ???????????
                popupWindow.dismiss();
            } else {
                // SimpleAdapter mSimpleAdapter = new SimpleAdapter(getApplicationContext(), mPopupWindowListItem, R.layout.main_popup_menu_item, new String[]{"item_icon", "item_title"}, new int[]{R.id.popup_menu_item_icon, R.id.popup_menu_item_title});

                BaseAdapter mSimpleAdapter = new BaseAdapter() {

                    @Override
                    public int getCount() {
                        return mPopupWindowListItem.size();
                    }

                    @Override
                    public Object getItem(int i) {
                        return null;
                    }

                    @Override
                    public long getItemId(int i) {
                        return 0;
                    }

                    @Override
                    public View getView(int position, View convertView, ViewGroup parent) {

                        if (convertView == null) {
                            LayoutInflater inflater = LayoutInflater.from(getActivity());
                            convertView = inflater.inflate(R.layout.list_item_common_context_menu, parent,
                                    false);
                        }
                        // TextView popupMenuItemIcon = (TextView) convertView.findViewById(R.id.popup_menu_item_icon);
                        // if (DEBUG) Log.d(TAG, "item_icon:" + mPopupWindowListItem.get(position).get("item_icon"));
                        // popupMenuItemIcon.setTypeface(typeface);
                        // if (popupMenuItemIcon.getTypeface() != typeface) {
                        //    popupMenuItemIcon.setTypeface(typeface);
                        // }
                        // popupMenuItemIcon.setText(Integer.valueOf(mPopupWindowListItem.get(position).get("item_icon").toString()));

                        TextView popupMenuItemTitle = (TextView) convertView
                                .findViewById(R.id.context_menu_action_text_view);
                        popupMenuItemTitle
                                .setText(mPopupWindowListItem.get(position).get("item_title").toString());

                        return convertView;
                    }
                };

                TextView contextMenuTitle = (TextView) contextMenuView.findViewById(R.id.context_menu_title);
                contextMenuTitle.setText(mSourceDataList.get(i).getContactName());

                ListView mPopupMenuListView = (ListView) contextMenuView
                        .findViewById(R.id.context_menu_list_view);
                mPopupMenuListView.setAdapter(mSimpleAdapter);

                // ?
                // PopupWindow??View?x,y?????
                // popupWindow.showAsDropDown(v, -460, 0);
                // ?View?,?parent????-90
                // Gravity.TOP|Gravity.LEFT, 0, 150
                popupWindow.showAtLocation(v, Gravity.CENTER, 0, 0);
                popupWindow.update();
            }

            return true;
        }
    });

    mLetterQueryView = (LetterQueryView) view.findViewById(R.id.letter_query_view);
    mLetterTextDialog = (TextView) view.findViewById(R.id.letter_text_dialog);
    mLetterQueryView.setTextView(mLetterTextDialog);

    // ??
    mLetterQueryView.setOnTouchingLetterChangedListener(new LetterQueryView.OnTouchingLetterChangedListener() {

        @Override
        public void onTouchingLetterChanged(String s) {
            // ??
            int position = mContactListAdapter.getPositionForSection(s.charAt(0));
            if (position != -1) {
                mListView.setSelection(position);
            }

        }
    });

    return view;
}