Example usage for android.widget RelativeLayout findViewById

List of usage examples for android.widget RelativeLayout findViewById

Introduction

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

Prototype

@Nullable
public final <T extends View> T findViewById(@IdRes int id) 

Source Link

Document

Finds the first descendant view with the given ID, the view itself if the ID matches #getId() , or null if the ID is invalid (< 0) or there is no matching view in the hierarchy.

Usage

From source file:fm.feed.android.playersdk.view.PlayerView.java

private void initializeView() {
    RelativeLayout rootView = (RelativeLayout) inflate(getContext(), R.layout.view_player, this);
    mTitle = (TextView) rootView.findViewById(R.id.pu_title);
    mArtist = (TextView) rootView.findViewById(R.id.pu_artist);
    mAlbum = (TextView) rootView.findViewById(R.id.pu_album);
    mPrefix = (TextView) rootView.findViewById(R.id.pu_prefix);
    mSuffix = (TextView) rootView.findViewById(R.id.pu_suffix);
    mProgressBar = (ProgressBar) rootView.findViewById(R.id.pu_progress);

    LinearLayout topContainer = (LinearLayout) rootView.findViewById(R.id.pu_top_icons);
    LinearLayout bottomContainer = (LinearLayout) rootView.findViewById(R.id.pu_bottom_icons);

    // We need to create the SVGImageView instances and add them programmatically.
    mDislike = newSvgImage(1, ImageView.ScaleType.FIT_START);
    mLike = newSvgImage(2, ImageView.ScaleType.FIT_CENTER);
    mPlayPause = newSvgImage(2, ImageView.ScaleType.FIT_CENTER);
    mSkip = newSvgImage(1, ImageView.ScaleType.FIT_END);
    mVolume = newSvgImage(1, ImageView.ScaleType.FIT_START);
    mShare = newSvgImage(1, ImageView.ScaleType.FIT_END);

    // Set the SVG resource to the SVGImageView
    setSvgResource(mDislike, R.drawable.ic_thumbdown_faded, R.string.accessibility_dislike);
    setSvgResource(mLike, R.drawable.ic_thumbup_faded, R.string.accessibility_like);
    setSvgResource(mPlayPause, R.drawable.ic_play_faded, R.string.accessibility_play);
    setSvgResource(mSkip, R.drawable.ic_skip_disabled, R.string.accessibility_skip_disabled);
    setSvgResource(mVolume, R.drawable.ic_speakerhigh_faded, R.string.accessibility_volume_muted);
    setSvgResource(mShare, R.drawable.ic_share_faded, R.string.accessibility_share);

    // Add SVGImageViews to the layout.
    topContainer.addView(mDislike);//from w w  w. j ava  2  s.  com
    topContainer.addView(mLike);
    topContainer.addView(mPlayPause);
    topContainer.addView(mSkip);
    bottomContainer.addView(mVolume);
    bottomContainer.addView(mShare);

    mDislike.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mPlayer.hasPlay()) {
                return;
            }

            Play.LikeState likeState = mPlayer.getPlay().getLikeState();
            switch (likeState) {
            case NONE:
                setSvgResource(mDislike, R.drawable.ic_thumbdown_normal, R.string.accessibility_disliked);
                mPlayer.dislike();
                break;
            case LIKED:
                setSvgResource(mLike, R.drawable.ic_thumbup_faded, R.string.accessibility_like);
                mPlayer.unlike();
                break;
            case DISLIKED:
                // Do nothing
                break;
            }
        }
    });

    mLike.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!mPlayer.hasPlay()) {
                return;
            }

            Play.LikeState likeState = mPlayer.getPlay().getLikeState();
            switch (likeState) {
            case NONE:
                setSvgResource(mLike, R.drawable.ic_thumbup_normal, R.string.accessibility_liked);
                mPlayer.like();
                break;
            case LIKED:
                // Do nothing
                break;
            case DISLIKED:
                setSvgResource(mDislike, R.drawable.ic_thumbdown_faded, R.string.accessibility_unlike);
                setSvgResource(mLike, R.drawable.ic_thumbup_normal, R.string.accessibility_liked);
                mPlayer.like();
                break;
            }
        }
    });
    mPlayPause.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mPlayer.getState() == PlayInfo.State.PLAYING) {
                mPlayer.pause();
            } else {
                mPlayer.play();
            }
        }
    });
    mSkip.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mPlayer.isSkippable()) {
                setSvgResource(mSkip, R.drawable.ic_skip_normal, R.string.accessibility_skipping);
                mPlayer.skip();
            }
        }
    });
    mShare.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mPlayer == null || !mPlayer.hasPlay()) {
                Log.i(TAG, "Cannot share if not playing");
                return;
            }

            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);

            String subject = mShareSubject;
            String body = mShareBody;
            if (subject == null) {
                subject = getContext().getString(R.string.share_subject_template);
            }
            if (body == null) {
                Play play = mPlayer.getPlay();
                String title = play.getAudioFile().getTrack().getTitle();
                String artist = play.getAudioFile().getArtist().getName();
                String album = play.getAudioFile().getRelease().getTitle();

                body = getContext().getString(R.string.share_body_template, title, artist, album);
            }

            // Add data to the intent, the receiving app will decide what to do with it.
            intent.putExtra(Intent.EXTRA_SUBJECT, subject);
            intent.putExtra(Intent.EXTRA_TEXT, body);

            getContext()
                    .startActivity(Intent.createChooser(intent, getContext().getString(R.string.share_via)));
        }
    });

    mVolume.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
            int volume = mAudioSettingsContentObserver.getCurrentVolume();
            am.setStreamVolume(AudioManager.STREAM_MUSIC, volume, AudioManager.FLAG_SHOW_UI);
        }
    });

    updateSpeakerUI();
}

From source file:com.einzig.ipst2.activities.PSDetailsActivity.java

public void setUpImageDetailsView() {
    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    portalImage.setOnClickListener(new View.OnClickListener() {
        @Override/*from   ww w .ja v a  2  s  .  c o  m*/
        public void onClick(View view) {
            try {
                AlertDialog.Builder builder = new AlertDialog.Builder(PSDetailsActivity.this);
                RelativeLayout itemLayout = (RelativeLayout) LayoutInflater.from(PSDetailsActivity.this)
                        .inflate(R.layout.image_details, null);
                builder.setView(itemLayout);
                final AlertDialog d = builder.show();
                Picasso.with(PSDetailsActivity.this).load(portal.getPictureURL())
                        .error(R.drawable.ic_warning_white)
                        .resize(displayMetrics.widthPixels, displayMetrics.heightPixels).centerInside()
                        .into((ImageView) itemLayout.findViewById(R.id.bigimage_imagedetails));
                itemLayout.findViewById(R.id.close_imagedetails).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        d.dismiss();
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

From source file:com.tencent.wstt.gt.activity.GTAUTFragment.java

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

    tv_Appstatus = (TextView) autLayout.findViewById(R.id.app_status);
    tv_select = (TextView) autLayout.findViewById(R.id.selected_app_bg);
    tv_select.setOnClickListener(select);
    tv_PkName = (TextView) autLayout.findViewById(R.id.select_tested_pkn);
    tv_selectedApp = (TextView) autLayout.findViewById(R.id.app_pic);
    tv_AppName = (TextView) autLayout.findViewById(R.id.selected_apn);
    tv_refresh = (TextView) autLayout.findViewById(R.id.app_refresh);

    tv_refresh.setOnTouchListener(new OnTouchListener() {

        @Override//  ww w.  jav  a  2 s  .  co  m
        public boolean onTouch(View v, MotionEvent event) {

            if (event.getAction() == MotionEvent.ACTION_DOWN) {

                proDialog = ProgressDialog.show(getActivity(), "Searching..", "searching..wait....", true,
                        false);

                tv_refresh.setTextColor(Color.GREEN);
                Thread loginThread = new Thread(new ProcessRefresher());
                loginThread.start();
                v.performClick();
            }

            return true;
        }
    });

    tv_refresh.setVisibility(View.GONE);
    cb_cpu = (CheckBox) autLayout.findViewById(R.id.cb_cpu);
    cb_jiffies = (CheckBox) autLayout.findViewById(R.id.cb_jiffies);
    cb_net = (CheckBox) autLayout.findViewById(R.id.cb_net);
    cb_pss = (CheckBox) autLayout.findViewById(R.id.cb_pss);
    cb_pd = (CheckBox) autLayout.findViewById(R.id.cb_pd);
    cb_boxs = new CheckBox[] { cb_cpu, cb_jiffies, cb_net, cb_pss, cb_pd };

    cb_cpu.setOnClickListener(cb_check);
    cb_jiffies.setOnClickListener(cb_check);
    cb_net.setOnClickListener(cb_check);
    cb_pss.setOnClickListener(cb_check);
    cb_pd.setOnClickListener(cb_check);

    memOn = (TextView) autLayout.findViewById(R.id.btn_memon);
    memOff = (TextView) autLayout.findViewById(R.id.btn_memoff);
    memSwitch = autLayout.findViewById(R.id.memswitch);
    selectDrawable = R.drawable.swbtn_selected;
    defaultDrawable = R.drawable.swbtn_default;

    if (isAutoGetMem) {
        memOn.setText("");
        memOn.setBackgroundResource(selectDrawable);
        memOff.setText("off");
        memOff.setBackgroundResource(defaultDrawable);
    } else {
        memOn.setText("on");
        memOn.setBackgroundResource(selectDrawable);
        memOff.setText("");
        memOff.setBackgroundResource(defaultDrawable);
    }

    RelativeLayout rl_save = (RelativeLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.gt_dailog_save, container, false);
    et_savePath = (EditText) rl_save.findViewById(R.id.save_editor);

    dlg_save = new Builder(getActivity()).setTitle(getString(R.string.save)).setView(rl_save)
            .setPositiveButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    GTMemHelperFloatview.memInfoList.clear();
                }
            }).setNegativeButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    // ??
                    String path = et_savePath.getText().toString();
                    LogUtils.writeTagMemData(tv_PkName.getText().toString(), path + ".csv");
                    GTMemHelperFloatview.memInfoList.clear();
                    dialog.dismiss();
                }
            }).create();

    memSwitch.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (!tv_PkName.getText().toString().equals("n/a")) {
                if (isAutoGetMem) {
                    isAutoGetMem = false;
                    memOn.setText("on");
                    memOn.setBackgroundResource(defaultDrawable);
                    memOff.setText("");
                    memOff.setBackgroundResource(selectDrawable);

                    // if(!tv_PkName.getText().toString().equals("n/a")){
                    Intent intent = new Intent(GTApp.getContext(), GTMemHelperFloatview.class);
                    intent.putExtra("pName", tv_PkName.getText().toString());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    PluginManager.getInstance().getPluginControler()
                            .startService(GTMemHelperFloatview.getInstance(), intent);
                    // }
                } else {
                    isAutoGetMem = true;
                    memOn.setText("");
                    memOn.setBackgroundResource(selectDrawable);
                    memOff.setText("off");
                    memOff.setBackgroundResource(defaultDrawable);

                    GTMemHelperFloatview.tagTimes = 0;

                    PluginManager.getInstance().getPluginControler()
                            .stopService(GTMemHelperFloatview.getInstance());
                    dlg_save.show();
                }
            }
            v.performClick();
            return false;
        }
    });

    return autLayout;
}

From source file:com.nookdevs.market.NookMarket.java

private void loadApps(String url) {
    try {//from   w w w.j  a v a 2  s.  c  om
        final LayoutInflater inflater = getLayoutInflater();
        HttpGet request = new HttpGet(url);
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpResponse response = httpClient.execute(request);
        XmlPullParserFactory fact = XmlPullParserFactory.newInstance();
        fact.setNamespaceAware(false);
        XmlPullParser parser = fact.newPullParser();
        parser.setInput(response.getEntity().getContent(), null);
        int type;
        AppInfo app = null;
        String name = "";
        String title = null;
        boolean entry = false;
        boolean apk = false;
        boolean nooklet = false;
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
            if (type == XmlPullParser.START_TAG) {
                name = parser.getName();
                if (name.equals("entry")) {
                    entry = true;
                    app = new AppInfo();
                } else if (entry && name.equals("link")) {
                    String val = parser.getAttributeValue(null, "type");
                    if (val != null && val.equals("application/vnd.android.package-archive")) {
                        apk = true;
                    } else if (val != null && val.equals("application/atom+xml")) {
                        String url_new = parser.getAttributeValue(null, "href");
                        loadApps(url_new);
                        entry = false;
                        title = null;
                        continue;
                    } else if ("application/zip".equals(val)) {
                        if (m_NookletInstalled) {
                            nooklet = true;
                        } else {
                            entry = false;
                            title = null;
                            continue;
                        }
                    } else {
                        entry = false;
                        title = null;
                        continue;
                    }
                    if (app.version == null)
                        app.version = parser.getAttributeValue(null, "version");
                    app.url = parser.getAttributeValue(null, "href");
                    if (app.pkg == null)
                        app.pkg = parser.getAttributeValue(null, "pkg");
                }
            } else if (entry && type == XmlPullParser.TEXT) {
                String text = parser.getText().trim();
                if (text.equals(""))
                    continue;
                if (name.equals("title")) {
                    app.title = text;
                } else if (name.equals("content")) {
                    app.text = text;
                } else if (name.equals("version")) {
                    app.version = text;
                } else if (name.equals("pkg")) {
                    app.pkg = text;
                }
            } else if (entry && type == XmlPullParser.END_TAG && parser.getName().equals("entry")) {
                entry = false;
                final String orgPkg = app.pkg;
                if (apk || nooklet) {
                    if (nooklet) {
                        String currVersion = null;
                        File f = new File(m_NookletFolder + "/" + app.pkg + "/" + "version.txt");
                        if (f.exists()) {
                            BufferedReader fin = new BufferedReader(new FileReader(f));
                            currVersion = fin.readLine();
                            fin.close();
                            app.installed = true;
                        }
                        if (app.version != null) {
                            if (!app.title.contains(app.version))
                                app.title = app.title + " " + app.version;
                            if (currVersion != null && !app.version.trim().equals(currVersion)) {
                                app.updateAvailable = true;
                                app.text = "***Update Available***\n" + app.text;
                            }
                        }
                        app.pkg = "Nooklet/" + app.pkg;
                    } else {
                        apk = false;
                        if ("MyNook.Ru Launcher".equals(app.title) && "1.5.6".equals(app.version)) {
                            app = null;
                            continue;
                        }
                        if (installedApps.containsKey(app.pkg)) {
                            PackageInfo info = installedApps.get(app.pkg);
                            app.installed = true;
                            if (app.version != null) {
                                if (!app.title.contains(app.version))
                                    app.title = app.title + " " + app.version;
                                if (!app.version.trim().equals(info.versionName)) {
                                    app.updateAvailable = true;
                                    app.text = "***Update Available***\n" + app.text;
                                }
                            }
                        } else if (app.version != null && !app.title.contains(app.version)) {
                            app.title = app.title + " " + app.version;
                        }
                    }
                    final int idx = -Collections.binarySearch(availableApps, app, myComp) - 1;
                    availableApps.add(idx, app);
                    final AppInfo app1 = app;
                    final boolean nooklet1 = nooklet;
                    Runnable run = new Runnable() {
                        public void run() {
                            RelativeLayout appdetails = (RelativeLayout) inflater.inflate(R.layout.addapp,
                                    m_Content, false);
                            ImageButton icon = (ImageButton) appdetails.findViewById(R.id.appicon);
                            icon.setOnClickListener(appListener);
                            if (!app1.installed) {
                                icon.setImageResource(R.drawable.icon);
                            } else {
                                icon.setOnLongClickListener(appdelListener);
                                try {
                                    if (nooklet1) {
                                        File f = new File(m_NookletFolder + "/" + orgPkg + "/icon.png");
                                        if (f.exists())
                                            icon.setImageURI(
                                                    Uri.parse(m_NookletFolder + "/" + orgPkg + "/icon.png"));
                                        else
                                            icon.setImageResource(R.drawable.icon);
                                    } else if (installedApps.get(app1.pkg).activities != null
                                            && installedApps.get(app1.pkg).activities[0] != null)
                                        icon.setImageDrawable(installedApps.get(app1.pkg).activities[0]
                                                .loadIcon(getPackageManager()));
                                    else
                                        icon.setImageDrawable(installedApps.get(app1.pkg).applicationInfo
                                                .loadIcon(getPackageManager()));
                                } catch (Exception ex) {
                                    icon.setImageResource(R.drawable.icon);
                                }
                            }
                            icon.setTag(app1);
                            TextView text = (TextView) appdetails.findViewById(R.id.desc);
                            TextView title1 = (TextView) appdetails.findViewById(R.id.title);
                            text.setText(app1.text);
                            title1.setText(app1.title);

                            m_Content.addView(appdetails, idx);
                            if (idx == 0)
                                closeAlert();
                        }
                    };
                    m_Handler.post(run);
                    nooklet = false;
                } else {
                    app.installed = false;
                    app.updateAvailable = false;
                    app.version = null;
                    app.pkg = null;
                    documents.add(app);

                }
                app = null;
            }
        }
    } catch (Exception ex) {
        Log.e(LOGTAG, ex.getMessage(), ex);
        //alert and exit.
        if (availableApps.size() == 0)
            m_Handler.post(new Runnable() {
                public void run() {
                    closeAlert();
                    displayAlert(getString(R.string.network), getString(R.string.feed_error), 2,
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                    finish();
                                }
                            }, -1);
                }
            });
    }
}

From source file:com.swetha.easypark.GetParkingLots.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (!isGooglePlayServicesAvailable()) {
        finish();/*from   w ww  .j  a  va  2s  .c om*/
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.getparkinglots);

    SupportMapFragment supportMapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    googleMap = supportMapFragment.getMap();

    googleMap.setMyLocationEnabled(true);
    LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
    gps_enabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if (gps_enabled) {
        Criteria criteria = new Criteria();

        provider = locationManager.getBestProvider(criteria, true);

        if (provider != null && !provider.equals("")) {

            locationManager.requestLocationUpdates(provider, 500, 1, GetParkingLots.this);
            // Get the location from the given provider 
            location = locationManager.getLastKnownLocation(provider);

        }
    }
    Log.i("GetParkingLots", "Value of network_enabled and location" + network_enabled + location);
    if (location == null && network_enabled) {

        location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 500, 1, GetParkingLots.this);

    }

    if (location == null && !network_enabled && !gps_enabled) {
        Toast.makeText(getBaseContext(), "Enable your location services", Toast.LENGTH_LONG).show();
    }
    if (location != null)
        onLocationChanged(location);
    else {

        Toast.makeText(getBaseContext(), "Location can't be retrieved", Toast.LENGTH_SHORT).show();
    }

    tv_fromTime = (TextView) findViewById(R.id.tv_fromTime);
    fromTimeString = Constants.dtf.format(new Date()).toString();
    tv_fromTime.setText(fromTimeString);
    long lval = DateTimeHelpers.convertToLongFromTime(Constants.dtf.format(new Date()).toString());
    Log.i("GetParkingLots",
            "The value of current time:" + Constants.dtf.format(new Date()).toString() + "in long is" + lval);
    Log.i("GetParkingLots",
            "The value of current time:" + lval + "in long is" + DateTimeHelpers.convertToTimeFromLong(lval));
    tv_toTime = (TextView) findViewById(R.id.tv_ToTime);
    // Parsing the date
    toTimeString = Constants.dtf.format(new Date()).toString();
    tv_toTime.setText(toTimeString);

    btnFromTime = (Button) findViewById(R.id.fromButton);
    btnFromTime.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            // Create the dialog
            final Dialog mDateTimeDialog = new Dialog(GetParkingLots.this);
            // Inflate the root layout
            final RelativeLayout mDateTimeDialogView = (RelativeLayout) getLayoutInflater()
                    .inflate(R.layout.date_time_dialog, null);
            // Grab widget instance
            mDateTimePicker = (DateTimePicker) mDateTimeDialogView.findViewById(R.id.DateTimePicker);
            mDateTimePicker.setDateChangedListener(GetParkingLots.this);

            // Update demo TextViews when the "OK" button is clicked 
            ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime))
                    .setOnClickListener(new OnClickListener() {
                        Calendar cal;

                        @SuppressWarnings("deprecation")
                        public void onClick(View v) {
                            mDateTimePicker.clearFocus();
                            try {
                                cal = new GregorianCalendar(mDateTimePicker.getYear(),
                                        Integer.parseInt(mDateTimePicker.getMonth()), mDateTimePicker.getDay(),
                                        mDateTimePicker.getHour(), mDateTimePicker.getMinute());
                                fromTimeString = DateTimeHelpers.dtf.format(cal.getTime());
                                tv_fromTime.setText(fromTimeString);
                            } catch (Exception e) {
                                final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this)
                                        .create();

                                alertDialog.setMessage("Enter a valid date");

                                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {

                                        alertDialog.dismiss();
                                    }
                                });

                                alertDialog.show();
                            }

                            mDateTimeDialog.dismiss();
                        }
                    });

            // Cancel the dialog when the "Cancel" button is clicked
            ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog))
                    .setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimeDialog.cancel();
                        }
                    });

            // Reset Date and Time pickers when the "Reset" button is clicked

            ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime))
                    .setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimePicker.reset();
                        }
                    });

            // Setup TimePicker
            // No title on the dialog window
            mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            // Set the dialog content view
            mDateTimeDialog.setContentView(mDateTimeDialogView);
            // Display the dialog
            mDateTimeDialog.show();

        }
    });

    btnToTime = (Button) findViewById(R.id.toButton);
    btnToTime.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            // Create the dialog
            final Dialog mDateTimeDialog = new Dialog(GetParkingLots.this);
            // Inflate the root layout
            final RelativeLayout mDateTimeDialogView = (RelativeLayout) getLayoutInflater()
                    .inflate(R.layout.date_time_dialog, null);
            // Grab widget instance
            final DateTimePicker mDateTimePicker = (DateTimePicker) mDateTimeDialogView
                    .findViewById(R.id.DateTimePicker);
            mDateTimePicker.setDateChangedListener(GetParkingLots.this);

            // Update demo TextViews when the "OK" button is clicked 
            ((Button) mDateTimeDialogView.findViewById(R.id.SetDateTime))
                    .setOnClickListener(new OnClickListener() {
                        Calendar cal;

                        @SuppressWarnings("deprecation")
                        public void onClick(View v) {
                            mDateTimePicker.clearFocus();

                            Log.i("toButton", "Value of ToString before cal" + toTimeString);
                            try {
                                cal = new GregorianCalendar(mDateTimePicker.getYear(),
                                        Integer.parseInt(mDateTimePicker.getMonth()), mDateTimePicker.getDay(),
                                        mDateTimePicker.getHour(), mDateTimePicker.getMinute());
                                toTimeString = DateTimeHelpers.dtf.format(cal.getTime());
                                Log.i("toButton", "Value of ToString before cal" + toTimeString);

                                tv_toTime.setText(toTimeString);

                            } catch (Exception e) // fixing the bug where the user doesnt enter anything in the textbox
                            {
                                final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this)
                                        .create();

                                alertDialog.setMessage("Enter a valid date");
                                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        alertDialog.dismiss();
                                    }
                                });

                                alertDialog.show();
                            }
                            //dateTimeTo = new DateTime(mDateTimePicker.getYear(), Integer.parseInt(mDateTimePicker.getMonth()) ,  mDateTimePicker.getDay(),  mDateTimePicker.getHour(),  mDateTimePicker.getMinute()); ;

                            mDateTimeDialog.dismiss();
                        }
                    });

            ((Button) mDateTimeDialogView.findViewById(R.id.CancelDialog))
                    .setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimeDialog.cancel();
                        }
                    });

            // Reset Date and Time pickers when the "Reset" button is clicked

            ((Button) mDateTimeDialogView.findViewById(R.id.ResetDateTime))
                    .setOnClickListener(new OnClickListener() {

                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            mDateTimePicker.reset();
                        }
                    });

            // Setup TimePicker
            // No title on the dialog window
            mDateTimeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            // Set the dialog content view
            mDateTimeDialog.setContentView(mDateTimeDialogView);
            // Display the dialog
            mDateTimeDialog.show();

        }
    });

    btnGetParkingLots = (Button) findViewById(R.id.getNearByParkingLotsButton);
    btnGetParkingLots.setOnClickListener(new View.OnClickListener() {

        @SuppressWarnings("deprecation")
        public void onClick(View v) {
            et_search = (EditText) findViewById(R.id.edittextsearch);
            rg = (RadioGroup) findViewById(R.id.rg);
            checkedRbId = rg.getCheckedRadioButtonId();
            Log.i("LOG_TAG: GetParkingLots", "checked radiobutton id is" + checkedRbId);

            if (checkedRbId == R.id.rbradius) {
                isRadiusIndicator = true;
                radius = et_search.getText().toString();
            } else {
                isRadiusIndicator = false;
                zipcode = et_search.getText().toString();
            }

            final Intent intent = new Intent(GetParkingLots.this, DisplayVacantParkingLots.class);
            Log.i(TAG, "Inside getNearByParkingLots");
            Log.i(TAG, "Value of fromString" + fromTimeString);
            long lFromVal = DateTimeHelpers.convertToLongFromTime(fromTimeString);
            Log.i(TAG, "Value of ToString" + toTimeString);
            long lToVal = DateTimeHelpers.convertToLongFromTime(toTimeString);
            if ((lToVal - lFromVal) < Constants.thrityMinInMilliSeconds) {
                final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this).create();

                alertDialog.setMessage("You have to park the car for at least 30 min");

                alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {

                        alertDialog.dismiss();
                    }
                });

                alertDialog.show();

            } else {
                intent.putExtra(LATITUDE, latitude);
                intent.putExtra(LONGITUDE, longitude);
                intent.putExtra(FROMTIME, lFromVal);
                intent.putExtra(TOTIME, lToVal);
                intent.putExtra(RadiusOrZIPCODE, isRadiusIndicator);
                if (isRadiusIndicator)
                    try {

                        intent.putExtra(RADIUS, Double.parseDouble(radius));
                        startActivity(intent);
                    } catch (Exception e) {
                        final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this).create();

                        alertDialog.setMessage("Enter valid radius");

                        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {

                                alertDialog.dismiss();

                            }
                        });

                        alertDialog.show();
                    }
                else {
                    try {

                        intent.putExtra(ZIPCODE, Long.parseLong(zipcode));
                        startActivity(intent);
                    } catch (Exception e) {
                        final AlertDialog alertDialog = new AlertDialog.Builder(GetParkingLots.this).create();

                        alertDialog.setMessage("Enter a valid Zip code");

                        alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                                alertDialog.dismiss();

                            }
                        });

                        alertDialog.show();
                    }
                }

            }

        }
    });

}

From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java

private void updateSearchView(final String query) {
    View view = getView();/*from ww  w .  jav a2  s  .c o  m*/
    if (view == null) {
        logger.error("No view created yet!!! query: " + query);
        return;
    }

    RelativeLayout callSearchLayout = (RelativeLayout) view.findViewById(R.id.callSearchLayout);

    if (StringUtils.isNullOrEmpty(query)) {
        if (callSearchLayout != null) {
            callSearchLayout.setVisibility(View.INVISIBLE);
            callSearchLayout.getLayoutParams().height = 0;
        }
    } else {
        if (callSearchLayout != null) {
            TextView searchContactView = (TextView) callSearchLayout.findViewById(R.id.callSearchContact);

            searchContactView.setText(query);
            callSearchLayout.getLayoutParams().height = searchContactView.getResources()
                    .getDimensionPixelSize(R.dimen.account_list_row_height);

            callSearchLayout.setVisibility(View.VISIBLE);

            final ImageButton callButton = (ImageButton) callSearchLayout.findViewById(R.id.contactCallButton);
            callButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    AndroidCallUtil.createAndroidCall(getActivity(), callButton, query);
                }
            });
        }
    }
}

From source file:com.sonymobile.android.media.testmediaplayer.MainActivity.java

public void reset() {
    mSeekBarUpdater.deactivate();/*w w w.  j a v  a2s .c o  m*/
    mTimeTracker.stopUpdating();
    mMediaPlayer.reset();
    mHolder.setFormat(PixelFormat.TRANSPARENT);
    mHolder.setFormat(PixelFormat.OPAQUE);
    mMediaPlayer.setScreenOnWhilePlaying(true);
    mMediaPlayer.setDisplay(mHolder);
    mBottomControls.setVisibility(View.INVISIBLE);
    mSeekbar.setVisibility(View.GONE);
    mTimeLayout.setVisibility(View.GONE);
    mDecorView.setOnSystemUiVisibilityChangeListener(this);
    mMediaPlayer.setOnCompletionListener(this);
    mMediaPlayer.setOnPreparedListener(this);
    mMediaPlayer.setOnInfoListener(this);
    mMediaPlayer.setOnSeekCompleteListener(this);
    mMediaPlayer.setOnSubtitleDataListener(this);
    mSeekbar.setOnSeekBarChangeListener(new OwnOnSeekBarChangeListener(mMediaPlayer));
    mSeekBarUpdater = new SeekbarUpdater(mSeekbar, mMediaPlayer);
    mTimeTracker.setMediaPlayer(mMediaPlayer);
    mSubtitleRenderer.stopRendering();
    RelativeLayout browsingL = (RelativeLayout) findViewById(R.id.activity_main_browsing_layout);
    RelativeLayout debugLayout = (RelativeLayout) findViewById(R.id.activity_main_debug_view);
    LinearLayout debugLinearLayout = (LinearLayout) debugLayout.findViewById(R.id.activity_main_debug_linear);
    mFileBrowser = new MediaBrowser(this,
            (ExpandableListView) browsingL.findViewById(R.id.file_browsing_exp_list_view),
            (ListView) browsingL.findViewById(R.id.file_browsing_listview), mMediaPlayer, (MainActivity) this,
            mDrawerLayout, debugLinearLayout);
    mAudioPos = 0;
    mSubPos = 0;
    mMediaPlayer.setOnOutputControlListener(this);
}

From source file:ch.fixme.status.Main.java

private void populateDataHs() {
    try {//from  w w w . jav  a 2 s.c  om
        HashMap<String, Object> data = new ParseGeneric(mResultHs).getData();

        // Initialize views
        LayoutInflater inflater = getLayoutInflater();
        LinearLayout vg = (LinearLayout) inflater.inflate(R.layout.base, null);
        ScrollView scroll = (ScrollView) findViewById(R.id.scroll);
        scroll.removeAllViews();
        scroll.addView(vg);

        // Mandatory fields
        ((TextView) findViewById(R.id.space_name)).setText((String) data.get(ParseGeneric.API_NAME));
        ((TextView) findViewById(R.id.space_url)).setText((String) data.get(ParseGeneric.API_URL));
        getImageTask = new GetImage(R.id.space_image);
        getImageTask.execute((String) data.get(ParseGeneric.API_LOGO));

        // Status text
        String status_txt = "";
        if ((Boolean) data.get(ParseGeneric.API_STATUS)) {
            status_txt = OPEN;
            ((TextView) findViewById(R.id.status_txt))
                    .setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.presence_online, 0, 0, 0);
        } else {
            status_txt = CLOSED;
            ((TextView) findViewById(R.id.status_txt))
                    .setCompoundDrawablesWithIntrinsicBounds(android.R.drawable.presence_busy, 0, 0, 0);
        }
        if (data.containsKey(ParseGeneric.API_STATUS_TXT)) {
            status_txt += ": " + (String) data.get(ParseGeneric.API_STATUS_TXT);
        }
        ((TextView) findViewById(R.id.status_txt)).setText(status_txt);

        // Status last change
        if (data.containsKey(ParseGeneric.API_LASTCHANGE)) {
            TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
            tv.setAutoLinkMask(0);
            tv.setText(
                    getString(R.string.api_lastchange) + " " + (String) data.get(ParseGeneric.API_LASTCHANGE));
            vg.addView(tv);
        }

        // Status duration
        if (data.containsKey(ParseGeneric.API_EXT_DURATION) && (Boolean) data.get(ParseGeneric.API_STATUS)) {
            TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
            tv.setText(getString(R.string.api_duration) + " " + (String) data.get(ParseGeneric.API_EXT_DURATION)
                    + getString(R.string.api_duration_hours));
            vg.addView(tv);
        }

        // Location
        Pattern ptn = Pattern.compile("^.*$", Pattern.DOTALL);
        if (data.containsKey(ParseGeneric.API_ADDRESS) || data.containsKey(ParseGeneric.API_LON)) {
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(getString(R.string.api_location));
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);
            // Address
            if (data.containsKey(ParseGeneric.API_ADDRESS)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setAutoLinkMask(0);
                tv.setText((String) data.get(ParseGeneric.API_ADDRESS));
                Linkify.addLinks(tv, ptn, MAP_SEARCH);
                vg.addView(tv);
            }
            // Lon/Lat
            if (data.containsKey(ParseGeneric.API_LON) && data.containsKey(ParseGeneric.API_LAT)) {
                String addr = (data.containsKey(ParseGeneric.API_ADDRESS))
                        ? (String) data.get(ParseGeneric.API_ADDRESS)
                        : getString(R.string.empty);
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setAutoLinkMask(0);
                tv.setText((String) data.get(ParseGeneric.API_LON) + ", "
                        + (String) data.get(ParseGeneric.API_LAT));
                Linkify.addLinks(tv, ptn, String.format(MAP_COORD, (String) data.get(ParseGeneric.API_LAT),
                        (String) data.get(ParseGeneric.API_LON), addr));
                vg.addView(tv);
            }
        }

        // Contact
        if (data.containsKey(ParseGeneric.API_PHONE) || data.containsKey(ParseGeneric.API_TWITTER)
                || data.containsKey(ParseGeneric.API_IRC) || data.containsKey(ParseGeneric.API_EMAIL)
                || data.containsKey(ParseGeneric.API_ML)) {
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(R.string.api_contact);
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);

            // Phone
            if (data.containsKey(ParseGeneric.API_PHONE)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_PHONE));
                vg.addView(tv);
            }
            // SIP
            if (data.containsKey(ParseGeneric.API_SIP)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_SIP));
                vg.addView(tv);
            }
            // Twitter
            if (data.containsKey(ParseGeneric.API_TWITTER)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText(TWITTER + (String) data.get(ParseGeneric.API_TWITTER));
                vg.addView(tv);
            }
            // Identica
            if (data.containsKey(ParseGeneric.API_IDENTICA)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_IDENTICA));
                vg.addView(tv);
            }
            // Foursquare
            if (data.containsKey(ParseGeneric.API_FOURSQUARE)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText(FOURSQUARE + (String) data.get(ParseGeneric.API_FOURSQUARE));
                vg.addView(tv);
            }
            // IRC
            if (data.containsKey(ParseGeneric.API_IRC)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setAutoLinkMask(0);
                tv.setText((String) data.get(ParseGeneric.API_IRC));
                vg.addView(tv);
            }
            // Email
            if (data.containsKey(ParseGeneric.API_EMAIL)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_EMAIL));
                vg.addView(tv);
            }
            // Jabber
            if (data.containsKey(ParseGeneric.API_JABBER)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_JABBER));
                vg.addView(tv);
            }
            // Mailing-List
            if (data.containsKey(ParseGeneric.API_ML)) {
                TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                tv.setText((String) data.get(ParseGeneric.API_ML));
                vg.addView(tv);
            }
        }

        // Sensors
        if (data.containsKey(ParseGeneric.API_SENSORS)) {
            // Title
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(getString(R.string.api_sensors));
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);

            HashMap<String, ArrayList<HashMap<String, String>>> sensors = (HashMap<String, ArrayList<HashMap<String, String>>>) data
                    .get(ParseGeneric.API_SENSORS);
            Set<String> names = sensors.keySet();
            Iterator<String> it = names.iterator();
            while (it.hasNext()) {
                String name = it.next();
                // Subtitle
                String name_title = name.toLowerCase().replace("_", " ");
                name_title = name_title.substring(0, 1).toUpperCase()
                        + name_title.substring(1, name_title.length());
                TextView subtitle = (TextView) inflater.inflate(R.layout.subtitle, null);
                subtitle.setText(name_title);
                vg.addView(subtitle);
                // Sensors data
                ArrayList<HashMap<String, String>> sensorsData = sensors.get(name);
                for (HashMap<String, String> elem : sensorsData) {
                    RelativeLayout rl = (RelativeLayout) inflater.inflate(R.layout.entry_sensor, null);
                    if (elem.containsKey(ParseGeneric.API_VALUE)) {
                        ((TextView) rl.findViewById(R.id.entry_value))
                                .setText(elem.get(ParseGeneric.API_VALUE));
                    } else {
                        rl.findViewById(R.id.entry_value).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_UNIT)) {
                        ((TextView) rl.findViewById(R.id.entry_unit)).setText(elem.get(ParseGeneric.API_UNIT));
                    } else {
                        rl.findViewById(R.id.entry_unit).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_NAME2)) {
                        ((TextView) rl.findViewById(R.id.entry_name)).setText(elem.get(ParseGeneric.API_NAME2));
                    } else {
                        rl.findViewById(R.id.entry_name).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_LOCATION2)) {
                        ((TextView) rl.findViewById(R.id.entry_location))
                                .setText(elem.get(ParseGeneric.API_LOCATION2));
                    } else {
                        rl.findViewById(R.id.entry_location).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_DESCRIPTION)) {
                        ((TextView) rl.findViewById(R.id.entry_description))
                                .setText(elem.get(ParseGeneric.API_DESCRIPTION));
                    } else {
                        rl.findViewById(R.id.entry_description).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_PROPERTIES)) {
                        ((TextView) rl.findViewById(R.id.entry_properties))
                                .setText(elem.get(ParseGeneric.API_PROPERTIES));
                    } else {
                        rl.findViewById(R.id.entry_properties).setVisibility(View.GONE);
                    }
                    if (elem.containsKey(ParseGeneric.API_MACHINES)) {
                        ((TextView) rl.findViewById(R.id.entry_other))
                                .setText(elem.get(ParseGeneric.API_MACHINES));
                    } else if (elem.containsKey(ParseGeneric.API_NAMES)) {
                        ((TextView) rl.findViewById(R.id.entry_other))
                                .setText(elem.get(ParseGeneric.API_NAMES));
                    } else {
                        rl.findViewById(R.id.entry_other).setVisibility(View.GONE);
                    }
                    vg.addView(rl);
                }
            }
        }

        // Stream and cam
        if (data.containsKey(ParseGeneric.API_STREAM) || data.containsKey(ParseGeneric.API_CAM)) {
            TextView title = (TextView) inflater.inflate(R.layout.title, null);
            title.setText(getString(R.string.api_stream));
            vg.addView(title);
            inflater.inflate(R.layout.separator, vg);
            // Stream
            if (data.containsKey(ParseGeneric.API_STREAM)) {
                HashMap<String, String> stream = (HashMap<String, String>) data.get(ParseGeneric.API_STREAM);
                for (Entry<String, String> entry : stream.entrySet()) {
                    final String type = entry.getKey();
                    final String url = entry.getValue();
                    TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                    tv.setText(url);
                    tv.setOnClickListener(new View.OnClickListener() {
                        public void onClick(View v) {
                            Intent i = new Intent(Intent.ACTION_VIEW);
                            i.setDataAndType(Uri.parse(url), type);
                            startActivity(i);
                        }
                    });
                    vg.addView(tv);
                }
            }
            // Cam
            if (data.containsKey(ParseGeneric.API_CAM)) {
                HashMap<String, String> cam = (HashMap<String, String>) data.get(ParseGeneric.API_CAM);
                for (String value : cam.values()) {
                    TextView tv = (TextView) inflater.inflate(R.layout.entry, null);
                    tv.setText(value);
                    vg.addView(tv);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        showError(e.getClass().getCanonicalName(), e.getLocalizedMessage() + getString(R.string.error_generic));
    }
}

From source file:com.agustinprats.myhrv.fragment.MonitorFragment.java

/** Shows the connect dialog displaying a list of available devices to connect */
private void showConnectDialog() {

    LayoutInflater inflater = getMainActivity().getLayoutInflater();

    // Init view// ww  w .j av a 2 s  .com
    RelativeLayout devicesDialogView = (RelativeLayout) inflater.inflate(R.layout.devices_dialog, null);

    AlertDialog.Builder devicesDialogBuilder = new AlertDialog.Builder(getMainActivity());
    devicesDialogBuilder.setTitle(R.string.devices_available);
    devicesDialogBuilder.setView(devicesDialogView);
    final AlertDialog devicesDialog = devicesDialogBuilder.create();

    _searchingDevicesText = (TextView) devicesDialogView.findViewById(R.id.searchingText);

    ListView listView = (ListView) devicesDialogView.findViewById(R.id.listView);
    listView.setEmptyView(_searchingDevicesText);
    final HeartRateDeviceListAdapter mHeartRateDeviceListAdapter = new HeartRateDeviceListAdapter(inflater);
    _heartRateDeviceListAdapter = mHeartRateDeviceListAdapter;

    final HeartRateService service = getMainActivity().getHeartRateService();
    service.startScanningDevices();
    listView.setAdapter(mHeartRateDeviceListAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            final HeartRateDevice device = mHeartRateDeviceListAdapter.getDevice(position);
            if (device != null) {

                if (service.isScanning())
                    service.stopScanningDevices();

                Log.d(TAG, "connecting from devices dialog");
                service.connect(device.getAddress());
            }
            devicesDialog.dismiss();
        }
    });

    devicesDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {

            service.stopScanningDevices();
            _heartRateDeviceListAdapter = null;
        }
    });

    devicesDialog.show();
}

From source file:com.nice295.scratchgames.fragment.ShowRoomFragment.java

@Nullable
@Override/*from   w  ww. j  av  a2s.co  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RelativeLayout ll = (RelativeLayout) inflater.inflate(R.layout.fragment_showroom, container, false);

    //mMyItemArray = new ArrayList<ShowRoomItem>();
    mMyItemArray = Paper.book().read("showroom", new ArrayList<ShowRoomItem>());
    mMyItemExtHash = Paper.book().read("showroom-ext", new HashMap<String, ShowRoomExtItem>());
    mListLikes = Paper.book().read("likes", new LinkedList<String>());

    mLvMyItems = (ListView) ll.findViewById(R.id.lvShowroom);
    mAdapter = new ListViewAdapter(getActivity(), R.layout.layout_item_list_item, mMyItemArray);
    mLvMyItems.setAdapter(mAdapter);

    /* 170620
    final View header = getActivity().getLayoutInflater().inflate(R.layout.layout_showroom_header, null, false);
    mLvMyItems.addHeaderView(header);
    */

    final View header = getActivity().getLayoutInflater().inflate(R.layout.layout_item_list_item_ad, null,
            false);
    mLvMyItems.addHeaderView(header, null, false);
    NativeExpressAdView adView = (NativeExpressAdView) header.findViewById(R.id.adView);
    AdRequest request = new AdRequest.Builder().build();
    adView.loadAd(request);

    // Obtain the FirebaseAnalytics instance.
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(getActivity());
    mDatabase = FirebaseDatabase.getInstance().getReference();

    Query showroomExtQuery = mDatabase.child("showroom-ext");
    showroomExtQuery.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            mMyItemExtHash.clear();

            if (dataSnapshot.getChildrenCount() != 0) {
                for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                    ShowRoomExtItem item = postSnapshot.getValue(ShowRoomExtItem.class);
                    Log.d(TAG, "postSnapshot.getKey(): " + postSnapshot.getKey());
                    Log.d(TAG, "viewCount: " + item.getViewCount());

                    mMyItemExtHash.put(postSnapshot.getKey(), item);
                }

                mAdapter.notifyDataSetChanged();
                EventBus.getDefault().post(new EventShowroom(mAdapter.getCount()));

                Paper.book().write("showroom-ext", mMyItemExtHash);
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.w(TAG, "showroom-ext:onCancelled", databaseError.toException());
        }
    });

    Query myTopPostsQuery = mDatabase.child("showroom").orderByChild("name");
    myTopPostsQuery.addValueEventListener(
            //mDatabase.child("my-items").addValueEventListener(
            new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    mMyItemArray.clear();

                    if (dataSnapshot.getChildrenCount() != 0) {
                        for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
                            ShowRoomItem item = postSnapshot.getValue(ShowRoomItem.class);
                            mMyItemArray.add(item);
                        }

                        mAdapter.notifyDataSetChanged();
                        EventBus.getDefault().post(new EventShowroom(mAdapter.getCount()));

                        Paper.book().write("showroom", mMyItemArray);
                    }
                }

                @Override
                public void onCancelled(DatabaseError databaseError) {
                    Log.w(TAG, "my-items:onCancelled", databaseError.toException());
                }
            });

    mLvMyItems.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            Intent intent = new Intent(getActivity(), ShowWebView.class);

            /* 170620
            if (i == 0) {
            intent.putExtra("id", "147132284");
            intent.putExtra("user", getString(R.string.developer));
            intent.putExtra("name", getString(R.string.how_to_add_new_game));
                    
            } else {
            i -= mLvMyItems.getHeaderViewsCount();
            ShowRoomItem item = mAdapter.getItem().get(i);
                    
            intent.putExtra("id", item.getId());
            intent.putExtra("user", item.getUser());
            intent.putExtra("name", item.getName());
                    
            // Add view count
            ShowRoomExtItem showRoomExtItem = mMyItemExtHash.get(item.getId());
            if (showRoomExtItem != null) {
                increaseViewCount(item.getId(), showRoomExtItem.getViewCount());
            }
                    
            }*/

            i -= mLvMyItems.getHeaderViewsCount(); // because of header
            ShowRoomItem item = mAdapter.getItem().get(i);

            intent.putExtra("id", item.getId());
            intent.putExtra("user", item.getUser());
            intent.putExtra("name", item.getName());

            // Add view count
            ShowRoomExtItem showRoomExtItem = mMyItemExtHash.get(item.getId());
            if (showRoomExtItem != null) {
                increaseViewCount(item.getId(), showRoomExtItem.getViewCount());
            }

            startActivity(intent);
        }
    });

    mAndroidId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
    Log.d(TAG, "ANDROID_ID: " + mAndroidId);

    mLvMyItems.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int position, long id) {

            ShowRoomItem item = mAdapter.getItem().get(position);
            ShowRoomExtItem showRoomExtItem = mMyItemExtHash.get(item.getId());

            if (mAndroidId != null && (mAndroidId.equals("3aebba2c123546da")
                    || mAndroidId.equals(showRoomExtItem.getReserved1()))) {
                /* 170620
                if (position != 0) {
                        
                position -= mLvMyItems.getHeaderViewsCount();
                ShowRoomItem item = mAdapter.getItem().get(position);
                showDeleteDialog(item.getId());
                return true;
                }
                */
                showDeleteDialog(item.getId());

                return true;
            }

            return false;
        }
    });

    AddFloatingActionButton fab = (AddFloatingActionButton) ll.findViewById(R.id.fab_add);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            showAddDialog();
        }
    });

    /*
    Boolean tooltipDelete = Paper.book().read("tooltipDelete", false);
            
    if (tooltipDelete) {
    ViewTooltip
            .on(mVTooltip)
            .autoHide(false, 1000)
            .color(Color.BLACK)
            .clickToHide(true)
            .position(ViewTooltip.Position.BOTTOM)
            .text(getString(R.string.tooltipdelete))
            .onHide(new ViewTooltip.ListenerHide() {
                @Override
                public void onHide(View view) {
                    Paper.book().write("tooltipDelete", true);
                }
            })
            .show();
    }
    */

    return ll;
}