Example usage for android.view View.OnLongClickListener View.OnLongClickListener

List of usage examples for android.view View.OnLongClickListener View.OnLongClickListener

Introduction

In this page you can find the example usage for android.view View.OnLongClickListener View.OnLongClickListener.

Prototype

View.OnLongClickListener

Source Link

Usage

From source file:uk.ac.hutton.ics.buntata.fragment.LogImageFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    /* Get the medium object */
    final LogEntryImage image = imageManager.getById(imageId);

    copyright.setVisibility(View.GONE);

    /* Load the image */
    Picasso.get().load(new File(image.getPath())).fit().centerCrop().into(imageView, new Callback() {
        @Override/*w ww .ja  v a  2  s  .  c  om*/
        public void onSuccess() {
            if (imageView != null) {
                photoViewAttacher = new PhotoViewAttacher(imageView);
                photoViewAttacher.setOnLongClickListener(new View.OnLongClickListener() {
                    @Override
                    public boolean onLongClick(View view) {
                        if (getActivity() instanceof LogDetailsActivity) {
                            DialogUtils.showDialog(getActivity(), R.string.dialog_delete_image_title,
                                    R.string.dialog_delete_image_message, R.string.generic_yes,
                                    R.string.generic_no, new DialogInterface.OnClickListener() {
                                        @Override
                                        public void onClick(DialogInterface dialogInterface, int i) {
                                            imageManager.delete(image);
                                            ((LogDetailsActivity) getActivity()).updateImageSection();
                                        }
                                    }, null);
                        }

                        return true;
                    }
                });
            }
        }

        @Override
        public void onError(Exception e) {
            System.out.println("");
        }
    });
}

From source file:SwipeListViewTouchListener.java

/**
 * Sets current item's front view/*from   ww w  .j  a va  2s  .  c om*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition);
        }
    });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                openAnimate(downPosition);
                return false;
            }
        });
    }
}

From source file:com.zhanggb.contacts.app.view.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view/* ww  w  . j  a v  a2 s  .  com*/
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView) {
    this.frontView = frontView;
    //        frontView.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                swipeListView.onClickFrontView(downPosition);
    //            }
    //        });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                openAnimate(downPosition);
                return false;
            }
        });
    }
}

From source file:com.daniel.view.swipelistview.SwipeListViewTouchListener.java

/**
 * Sets current item's front view//from  w  w w .j  a  v a  2 s.  c om
 *
 * @param frontView Front view
 */
private void setFrontView(View frontView) {
    this.frontView = frontView;
    frontView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            swipeListView.onClickFrontView(downPosition);
        }
    });
    if (swipeOpenOnLongPress) {
        frontView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                closeOpenedItems();
                openAnimate(downPosition);
                return false;
            }
        });
    }
}

From source file:mx.klozz.xperience.tweaker.fragments.CPUSettings.java

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

    mIsTegra3 = new File(TEGRA_MAX_FREQ_PATH).exists();
    mIsDynFreq = new File(DYN_MAX_FREQ_PATH).exists() && new File(DYN_MIN_FREQ_PATH).exists();

    lCurrentCPU = (LinearLayout) view.findViewById(R.id.lCurCPU);

    mCurFreq = (TextView) view.findViewById(R.id.current_speed);
    mCurFreq.setOnClickListener(new View.OnClickListener() {
        @Override//from w  w  w .j  a va2 s .  c om
        public void onClick(View view) {
            if (nCpus == 1)
                return;
            if (++MainActivity.CurrentCPU > (nCpus - 1))
                MainActivity.CurrentCPU = 0;
            setCPUval(MainActivity.CurrentCPU);
        }
    });

    mCurFreq.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (new File(CPU_ON_PATH.replace("cpu0", "cpu" + MainActivity.CurrentCPU)).exists()
                    && MainActivity.CurrentCPU > 0) {
                final StringBuilder sb = new StringBuilder();
                if (MainActivity.mCPUOn.get(MainActivity.CurrentCPU).equals("1")) {
                    sb.append("set_val \"").append(CPU_ON_PATH.replace("cpu0", "cpu" + MainActivity.CurrentCPU))
                            .append("\" \"0\";\n");
                    MainActivity.mCPUOn.set(MainActivity.CurrentCPU, "0");
                } else {
                    sb.append("set_val \"").append(CPU_ON_PATH.replace("cpu0", "cpu" + MainActivity.CurrentCPU))
                            .append("\" \"1\";\n");
                    MainActivity.mCPUOn.set(MainActivity.CurrentCPU, "1");
                }
                Helpers.shExec(sb, context, true);

                setCPUval(MainActivity.CurrentCPU);
            }

            return true;
        }
    });

    final int mFrequenciesNum = MainActivity.mAvailableFrequencies.length - 1;

    mMaxSlider = (SeekBar) view.findViewById(R.id.max_slider);
    mMaxSlider.setMax(mFrequenciesNum);
    mMaxSlider.setOnSeekBarChangeListener(this);
    mMaxSpeedText = (TextView) view.findViewById(R.id.max_speed_text);

    mMinSlider = (SeekBar) view.findViewById(R.id.min_slider);
    mMinSlider.setMax(mFrequenciesNum);
    mMinSlider.setOnSeekBarChangeListener(this);
    mMinSpeedText = (TextView) view.findViewById(R.id.min_speed_text);

    mGovernor = (Spinner) view.findViewById(R.id.pref_governor);
    String[] mAvailableGovernors = Helpers.LeerUnaLinea(GOVERNORS_LIST_PATH).split(" ");
    ArrayAdapter<CharSequence> governorAdapter = new ArrayAdapter<CharSequence>(context,
            android.R.layout.simple_spinner_item);
    governorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    for (String mAvailableGovernor : mAvailableGovernors) {
        governorAdapter.add(mAvailableGovernor.trim());
    }
    mGovernor.setAdapter(governorAdapter);
    mGovernor.setSelection(Arrays.asList(mAvailableGovernors)
            .indexOf(MainActivity.mCurrentGovernor.get(MainActivity.CurrentCPU)));
    mGovernor.post(new Runnable() {
        public void run() {
            mGovernor.setOnItemSelectedListener(new GovListener());
        }
    });

    mIo = (Spinner) view.findViewById(R.id.pref_io);
    String[] mAvailableIo = Helpers.getAvailableIOSchedulers(IO_SCHEDULER_PATH);

    ArrayAdapter<CharSequence> ioAdapter = new ArrayAdapter<CharSequence>(context,
            android.R.layout.simple_spinner_item);
    ioAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    for (String aMAvailableIo : mAvailableIo) {
        ioAdapter.add(aMAvailableIo);
    }
    mIo.setAdapter(ioAdapter);
    mIo.setSelection(
            Arrays.asList(mAvailableIo).indexOf(MainActivity.mCurrentIOSched.get(MainActivity.CurrentCPU)));
    mIo.post(new Runnable() {
        public void run() {
            mIo.setOnItemSelectedListener(new IOListener());
        }
    });

    Switch mSetOnBoot = (Switch) view.findViewById(R.id.cpu_sob);
    mSetOnBoot.setChecked(mPreferences.getBoolean(CPU_SOB, false));
    mSetOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton v, boolean checked) {
            final SharedPreferences.Editor editor = mPreferences.edit();
            editor.putBoolean(CPU_SOB, checked);
            if (checked) {
                for (int i = 0; i < nCpus; i++) {
                    editor.putString(PREF_MIN_CPU + i, MainActivity.mMinimunFreqSetting.get(i));
                    editor.putString(PREF_MAX_CPU + i, MainActivity.mMaximunFreqSetting.get(i));
                    editor.putString(PREF_GOV, MainActivity.mCurrentGovernor.get(i));
                    editor.putString(PREF_IO, MainActivity.mCurrentIOSched.get(i));
                    editor.putString("cpuon" + i, MainActivity.mCPUOn.get(i));
                }
            }
            editor.apply();
        }
    });

    //if(nCpus>1){
    LinearLayout vcpus[] = new LinearLayout[nCpus];
    for (int i = 0; i < nCpus; i++) {
        vcpus[i] = (LinearLayout) inflater.inflate(R.layout.cpu_view, root, false);
        vcpus[i].setId(i);
        TextView nc = (TextView) vcpus[i].findViewById(R.id.ncpu);
        nc.setText(Integer.toString(i + 1));
        if (i != MainActivity.CurrentCPU)
            nc.setText(" ");
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,
                LinearLayout.LayoutParams.WRAP_CONTENT, (float) 0.1);
        lCurrentCPU.addView(vcpus[i], params);
    }
    //}

    setCPUval(MainActivity.CurrentCPU);

    return view;
}

From source file:net.ustyugov.jtalk.activity.vcard.VCardActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    service = JTalkService.getInstance();
    account = getIntent().getStringExtra("account");
    jid = getIntent().getStringExtra("jid");
    setTheme(Colors.isLight ? R.style.AppThemeLight : R.style.AppThemeDark);
    setContentView(R.layout.paged_activity);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    setTitle("vCard");
    getActionBar().setSubtitle(jid);//from   ww w . j  a v  a  2s  .c om

    if (service.getConferencesHash(account).containsKey(StringUtils.parseBareAddress(jid))) {
        Presence p = service.getConferencesHash(account).get(StringUtils.parseBareAddress(jid))
                .getOccupantPresence(jid);
        if (p != null) {
            MUCUser mucUser = (MUCUser) p.getExtension("x", "http://jabber.org/protocol/muc#user");
            if (mucUser != null) {
                String j = mucUser.getItem().getJid();
                if (j != null && j.length() > 3)
                    getActionBar().setSubtitle(j);
            }
        }
    }

    LinearLayout linear = (LinearLayout) findViewById(R.id.linear);
    linear.setBackgroundColor(Colors.BACKGROUND);

    LayoutInflater inflater = LayoutInflater.from(this);
    View aboutPage = inflater.inflate(R.layout.vcard_about, null);
    View homePage = inflater.inflate(R.layout.vcard_home, null);
    View workPage = inflater.inflate(R.layout.vcard_work, null);
    View avatarPage = inflater.inflate(R.layout.vcard_avatar, null);
    View statusPage = inflater.inflate(R.layout.list_activity, null);

    first = (MyTextView) aboutPage.findViewById(R.id.firstname);
    middle = (MyTextView) aboutPage.findViewById(R.id.middlename);
    last = (MyTextView) aboutPage.findViewById(R.id.lastname);
    nick = (MyTextView) aboutPage.findViewById(R.id.nickname);
    bday = (MyTextView) aboutPage.findViewById(R.id.bday);
    url = (MyTextView) aboutPage.findViewById(R.id.url);
    about = (MyTextView) aboutPage.findViewById(R.id.desc);

    ctry = (MyTextView) homePage.findViewById(R.id.ctry);
    locality = (MyTextView) homePage.findViewById(R.id.locality);
    street = (MyTextView) homePage.findViewById(R.id.street);
    emailHome = (MyTextView) homePage.findViewById(R.id.homemail);
    phoneHome = (MyTextView) homePage.findViewById(R.id.homephone);

    org = (MyTextView) workPage.findViewById(R.id.org);
    unit = (MyTextView) workPage.findViewById(R.id.unit);
    role = (MyTextView) workPage.findViewById(R.id.role);
    emailWork = (MyTextView) workPage.findViewById(R.id.workmail);
    phoneWork = (MyTextView) workPage.findViewById(R.id.workphone);

    av = (ImageView) avatarPage.findViewById(R.id.av);
    av.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            File file = new File(Constants.PATH + jid.replaceAll("/", "%"));
            Uri uri = Uri.fromFile(file);
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(uri, "image/*");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException ignored) {
            }
        }
    });

    av.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            String fname = Constants.PATH + jid.replaceAll("/", "%");
            String saveto = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/Avatars/";

            File folder = new File(saveto);
            folder.mkdirs();

            try {
                FileInputStream fis = new FileInputStream(fname);
                byte[] buffer = new byte[fis.available()];
                fis.read(buffer);
                fis.close();

                FileOutputStream fos = new FileOutputStream(saveto + "/" + jid.replaceAll("/", "%") + ".png");
                fos.write(buffer);
                fos.close();
                Toast.makeText(VCardActivity.this, "Copied to " + saveto, Toast.LENGTH_LONG).show();
            } catch (Exception e) {
                Toast.makeText(VCardActivity.this, "Failed to copy", Toast.LENGTH_LONG).show();
            }
            return true;
        }
    });

    statusProgress = (ProgressBar) statusPage.findViewById(R.id.progress);
    aboutProgress = (ProgressBar) aboutPage.findViewById(R.id.progress);
    homeProgress = (ProgressBar) homePage.findViewById(R.id.progress);
    workProgress = (ProgressBar) workPage.findViewById(R.id.progress);
    avatarProgress = (ProgressBar) avatarPage.findViewById(R.id.progress);

    aboutScroll = (ScrollView) aboutPage.findViewById(R.id.scroll);
    homeScroll = (ScrollView) homePage.findViewById(R.id.scroll);
    workScroll = (ScrollView) workPage.findViewById(R.id.scroll);
    avatarScroll = (ScrollView) avatarPage.findViewById(R.id.scroll);

    list = (ListView) statusPage.findViewById(R.id.list);
    list.setDividerHeight(0);
    list.setCacheColorHint(0x00000000);

    aboutPage.setTag(getString(R.string.About));
    homePage.setTag(getString(R.string.Home));
    workPage.setTag(getString(R.string.Work));
    avatarPage.setTag(getString(R.string.Photo));
    statusPage.setTag(getString(R.string.Status));

    ArrayList<View> mPages = new ArrayList<View>();
    mPages.add(aboutPage);
    mPages.add(homePage);
    mPages.add(workPage);
    mPages.add(avatarPage);
    mPages.add(statusPage);

    MainPageAdapter adapter = new MainPageAdapter(mPages);
    ViewPager mPager = (ViewPager) findViewById(R.id.pager);
    mPager.setAdapter(adapter);
    mPager.setCurrentItem(0);

    TitlePageIndicator mTitleIndicator = (TitlePageIndicator) findViewById(R.id.indicator);
    mTitleIndicator.setTextColor(0xFF555555);
    mTitleIndicator.setViewPager(mPager);
    mTitleIndicator.setCurrentItem(0);

    new LoadTask().execute();
}

From source file:com.brewcrewfoo.performance.fragments.BatteryInfo.java

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

    mbattery_percent = (TextView) view.findViewById(R.id.batt_percent);
    mbattery_volt = (TextView) view.findViewById(R.id.batt_volt);
    mbattery_status = (TextView) view.findViewById(R.id.batt_status);
    mBattIcon = (ImageView) view.findViewById(R.id.batt_icon);

    if (new File(BAT_VOLT_PATH).exists()) {
        int volt = Integer.parseInt(Helpers.readOneLine(BAT_VOLT_PATH));
        if (volt > 5000)
            volt = (int) Math.round(volt / 1000.0);// in microvolts
        mbattery_volt.setText(volt + " mV");
        mBattIcon.setVisibility(ImageView.GONE);
        mbattery_volt.setVisibility(TextView.VISIBLE);
        mbattery_volt.setOnClickListener(new View.OnClickListener() {
            @Override// w w  w  .  j  a  v  a 2  s.  c  o  m
            public void onClick(View view) {
                Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
                if (powerUsageIntent.resolveActivity(context.getPackageManager()) != null)
                    startActivity(powerUsageIntent);
            }
        });
        mbattery_volt.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                mBattIcon.setVisibility(ImageView.VISIBLE);
                mbattery_volt.setVisibility(TextView.GONE);
                return true;
            }
        });
    } else {
        mBattIcon.setVisibility(ImageView.VISIBLE);
        mbattery_volt.setVisibility(TextView.GONE);
        mBattIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
                    startActivity(powerUsageIntent);
                } catch (Exception e) {
                }
            }
        });
    }

    SeekBar mBlxSlider = (SeekBar) view.findViewById(R.id.blx_slider);
    if (new File(BLX_PATH).exists()) {
        no_settings = false;
        mBlxSlider.setMax(100);

        mBlxVal = (TextView) view.findViewById(R.id.blx_val);
        mBlxVal.setText(getString(R.string.blx_title) + " " + Helpers.readOneLine(BLX_PATH) + "%");

        mBlxSlider.setProgress(Integer.parseInt(Helpers.readOneLine(BLX_PATH)));
        mBlxSlider.setOnSeekBarChangeListener(this);
        Switch mSetOnBoot = (Switch) view.findViewById(R.id.blx_sob);
        mSetOnBoot.setChecked(mPreferences.getBoolean(BLX_SOB, false));
        mSetOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton v, boolean checked) {
                final SharedPreferences.Editor editor = mPreferences.edit();
                editor.putBoolean(BLX_SOB, checked);
                if (checked) {
                    editor.putInt(PREF_BLX, Integer.parseInt(Helpers.readOneLine(BLX_PATH)));
                }
                editor.commit();
            }
        });
    } else {
        LinearLayout mpart = (LinearLayout) view.findViewById(R.id.blx_layout);
        mpart.setVisibility(LinearLayout.GONE);
    }
    mFastChargePath = Helpers.fastcharge_path();
    if (mFastChargePath != null) {
        no_settings = false;
        mFastchargeOnBoot = (Switch) view.findViewById(R.id.fastcharge_sob);
        mFastchargeOnBoot.setChecked(
                mPreferences.getBoolean(PREF_FASTCHARGE, Helpers.readOneLine(mFastChargePath).equals("1")));
        mFastchargeOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton v, boolean checked) {
                mPreferences.edit().putBoolean(PREF_FASTCHARGE, checked).apply();
                final NotificationManager nm = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                if (checked) {
                    new CMDProcessor().su.runWaitFor("busybox echo 1 > " + mFastChargePath);
                    Notification n = new Notification.Builder(context)
                            .setContentTitle(context.getText(R.string.app_name))
                            .setContentText(context.getText(R.string.fast_charge_notification_title))
                            .setTicker(context.getText(R.string.fast_charge_notification_title))
                            .setSmallIcon(R.drawable.ic_fastcharge).setWhen(System.currentTimeMillis())
                            .getNotification();
                    //n.flags = Notification.FLAG_NO_CLEAR;
                    nm.notify(1337, n);
                } else {
                    new CMDProcessor().su.runWaitFor("busybox echo 0 > " + mFastChargePath);
                    nm.cancel(1337);
                }
            }
        });
    } else {
        LinearLayout mpart = (LinearLayout) view.findViewById(R.id.fastcharge_layout);
        mpart.setVisibility(LinearLayout.GONE);
    }
    if (no_settings) {
        LinearLayout ns = (LinearLayout) view.findViewById(R.id.no_settings);
        ns.setVisibility(LinearLayout.VISIBLE);
    }

    return view;
}

From source file:mx.klozz.xperience.tweaker.fragments.BatteryInfo.java

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

    mBattery_Percent = (TextView) view.findViewById(R.id.battery_percent);
    mBattery_volt = (TextView) view.findViewById(R.id.battery_volt);
    mBattery_Status = (TextView) view.findViewById(R.id.battery_status);
    mBatteryIcon = (ImageView) view.findViewById(R.id.battery_icon);

    //Checamos si existe algo relacionado con la direccion de voltajes
    if (new File(BAT_VOLT_PATH).exists()) {
        int volt = Integer.parseInt(Helpers.LeerUnaLinea(BAT_VOLT_PATH));//vemos si existe el directorio
        if (volt > 5000)
            volt = (int) Math.round(volt / 1000.0);//Convertimos a microvolts

        mBattery_volt.setText(volt + " mV");//Hacemos visible los datos
        mBatteryIcon.setVisibility(ImageView.GONE);
        mBattery_volt.setVisibility(TextView.VISIBLE);
        mBattery_volt.setOnClickListener(new View.OnClickListener() {
            @Override//  www  .  j  a v  a2 s .  co  m
            public void onClick(View view) {
                Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
                if (powerUsageIntent.resolveActivity(context.getPackageManager()) != null)
                    startActivity(powerUsageIntent);
            }
        });
        mBattery_volt.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                mBatteryIcon.setVisibility(ImageView.VISIBLE);
                mBattery_volt.setVisibility(TextView.GONE);
                return true;
            }
        });
    } else {
        mBatteryIcon.setVisibility(ImageView.VISIBLE);
        mBattery_volt.setVisibility(TextView.GONE);
        mBatteryIcon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    Intent powerUsageIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY);
                    startActivity(powerUsageIntent);
                } catch (Exception e) {
                }
            }
        });
    }

    mFastChargePath = Helpers.fastcharge_path();
    if (mFastChargePath != null) {
        no_settings = false;
        mFastChargeOnBoot = (Switch) view.findViewById(R.id.fastcharge_sob);
        mFastChargeOnBoot.setChecked(
                mPreferences.getBoolean(PREF_FASTCHARGE, Helpers.LeerUnaLinea(mFastChargePath).equals("1")));
        mFastChargeOnBoot.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton v, boolean checked) {
                mPreferences.edit().putBoolean(PREF_FASTCHARGE, checked).apply();
                final NotificationManager NM = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                if (checked) {
                    new CMDProcessor().su.runWaitFor("busybox exho 1 > " + mFastChargePath);
                    Notification N = new Notification.Builder(context)
                            .setContentTitle(context.getText(R.string.app_name))
                            .setContentText(context.getText(R.string.fast_charge_notification_title))
                            .setTicker(context.getText(R.string.fast_charge_notification_title))
                            .setSmallIcon(R.drawable.ic_fastcharge).setWhen(System.currentTimeMillis())
                            .getNotification();
                    NM.notify(1337, N);
                } else {
                    new CMDProcessor().su.runWaitFor("busybox echo 0 > " + mFastChargePath);
                    NM.cancel(1337);

                }
            }

        });
    } else {
        LinearLayout mPart = (LinearLayout) view.findViewById(R.id.fastcharge_layout);
        mPart.setVisibility(LinearLayout.GONE);
    }
    if (no_settings) {
        LinearLayout NS = (LinearLayout) view.findViewById(R.id.no_settings);
        NS.setVisibility(LinearLayout.VISIBLE);
    }
    return view;
}

From source file:org.quantumbadger.redreader.fragments.CommentListingFragment.java

public CommentListingFragment(final AppCompatActivity parent, final Bundle savedInstanceState,
        final ArrayList<RedditURLParser.RedditURL> urls, final UUID session, final String searchString,
        final boolean forceDownload) {

    super(parent, savedInstanceState);

    if (savedInstanceState != null) {
        mPreviousFirstVisibleItemPosition = savedInstanceState.getInt(SAVEDSTATE_FIRST_VISIBLE_POS);
    }/*from   w w  w  . j  ava 2  s. c  o m*/

    mCommentListingManager = new FilteredCommentListingManager(parent, searchString);
    mAllUrls = urls;

    mUrlsToDownload = new LinkedList<>(mAllUrls);

    this.mSession = session;

    if (forceDownload) {
        mDownloadStrategy = DownloadStrategyAlways.INSTANCE;

    } else {
        mDownloadStrategy = DownloadStrategyIfNotCached.INSTANCE;
    }

    mUser = RedditAccountManager.getInstance(getActivity()).getDefaultAccount();

    parent.invalidateOptionsMenu();

    final Context context = getActivity();

    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    mCommentFontScale = PrefsUtility.appearance_fontscale_comments(context, prefs);
    mShowLinkButtons = PrefsUtility.pref_appearance_linkbuttons(context, prefs);

    mOuterFrame = new FrameLayout(context);

    final ScrollbarRecyclerViewManager recyclerViewManager = new ScrollbarRecyclerViewManager(context, null,
            false);

    if (parent instanceof OptionsMenuUtility.OptionsMenuCommentsListener
            && PrefsUtility.pref_behaviour_enable_swipe_refresh(context, prefs)) {

        recyclerViewManager.enablePullToRefresh(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                ((OptionsMenuUtility.OptionsMenuCommentsListener) parent).onRefreshComments();
            }
        });
    }

    mRecyclerView = recyclerViewManager.getRecyclerView();
    mCommentListingManager.setLayoutManager((LinearLayoutManager) mRecyclerView.getLayoutManager());

    mRecyclerView.setAdapter(mCommentListingManager.getAdapter());
    mOuterFrame.addView(recyclerViewManager.getOuterView());

    mRecyclerView.setItemAnimator(null);

    /* TODO
    {
       final RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
       itemAnimator.setRemoveDuration(80);
       itemAnimator.setChangeDuration(80);
       itemAnimator.setAddDuration(80);
       itemAnimator.setMoveDuration(80);
    }
    */

    if (!PrefsUtility.pref_appearance_comments_show_floating_toolbar(context, prefs)) {
        mFloatingToolbar = null;

    } else {
        mFloatingToolbar = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.floating_toolbar,
                mOuterFrame, false);

        // We need a container so that setVisible() doesn't mess with the Z-order
        final FrameLayout floatingToolbarContainer = new FrameLayout(context);

        floatingToolbarContainer.addView(mFloatingToolbar);
        mOuterFrame.addView(floatingToolbarContainer);

        if (PrefsUtility.isNightMode(context)) {
            mFloatingToolbar.setBackgroundColor(Color.argb(0xCC, 0x33, 0x33, 0x33));
        }

        final int buttonVPadding = General.dpToPixels(context, 12);
        final int buttonHPadding = General.dpToPixels(context, 16);

        {
            final ImageButton previousButton = (ImageButton) LayoutInflater.from(context)
                    .inflate(R.layout.flat_image_button, mFloatingToolbar, false);

            previousButton.setPadding(buttonHPadding, buttonVPadding, buttonHPadding, buttonVPadding);
            previousButton.setImageResource(R.drawable.ic_ff_up_dark);
            previousButton.setContentDescription(getString(R.string.button_prev_comment_parent));
            mFloatingToolbar.addView(previousButton);

            previousButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {

                    final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView
                            .getLayoutManager();

                    for (int pos = layoutManager.findFirstVisibleItemPosition() - 1; pos > 0; pos--) {

                        final GroupedRecyclerViewAdapter.Item item = mCommentListingManager
                                .getItemAtPosition(pos);

                        if (item instanceof RedditCommentListItem && ((RedditCommentListItem) item).isComment()
                                && ((RedditCommentListItem) item).getIndent() == 0) {

                            layoutManager.scrollToPositionWithOffset(pos, 0);
                            return;
                        }
                    }

                    layoutManager.scrollToPositionWithOffset(0, 0);
                }
            });

            previousButton.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(final View view) {
                    General.quickToast(context, R.string.button_prev_comment_parent);
                    return true;
                }
            });
        }

        {
            final ImageButton nextButton = (ImageButton) LayoutInflater.from(context)
                    .inflate(R.layout.flat_image_button, mFloatingToolbar, false);

            nextButton.setPadding(buttonHPadding, buttonVPadding, buttonHPadding, buttonVPadding);
            nextButton.setImageResource(R.drawable.ic_ff_down_dark);
            nextButton.setContentDescription(getString(R.string.button_next_comment_parent));
            mFloatingToolbar.addView(nextButton);

            nextButton.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View view) {

                    final LinearLayoutManager layoutManager = (LinearLayoutManager) mRecyclerView
                            .getLayoutManager();

                    for (int pos = layoutManager.findFirstVisibleItemPosition() + 1; pos < layoutManager
                            .getItemCount(); pos++) {

                        final GroupedRecyclerViewAdapter.Item item = mCommentListingManager
                                .getItemAtPosition(pos);

                        if (item instanceof RedditCommentListItem && ((RedditCommentListItem) item).isComment()
                                && ((RedditCommentListItem) item).getIndent() == 0) {

                            layoutManager.scrollToPositionWithOffset(pos, 0);
                            break;
                        }
                    }
                }
            });

            nextButton.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(final View view) {
                    General.quickToast(context, R.string.button_next_comment_parent);
                    return true;
                }
            });
        }
    }

    final SideToolbarOverlay toolbarOverlay = new SideToolbarOverlay(context);

    final BezelSwipeOverlay bezelOverlay = new BezelSwipeOverlay(context,
            new BezelSwipeOverlay.BezelSwipeListener() {
                @Override
                public boolean onSwipe(@BezelSwipeOverlay.SwipeEdge int edge) {

                    if (mPost == null)
                        return false;

                    toolbarOverlay.setContents(mPost.generateToolbar(getActivity(), true, toolbarOverlay));
                    toolbarOverlay
                            .show(edge == BezelSwipeOverlay.LEFT ? SideToolbarOverlay.SideToolbarPosition.LEFT
                                    : SideToolbarOverlay.SideToolbarPosition.RIGHT);
                    return true;
                }

                public boolean onTap() {

                    if (toolbarOverlay.isShown()) {
                        toolbarOverlay.hide();
                        return true;
                    }

                    return false;
                }
            });

    mOuterFrame.addView(bezelOverlay);
    mOuterFrame.addView(toolbarOverlay);

    bezelOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
    bezelOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

    toolbarOverlay.getLayoutParams().width = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;
    toolbarOverlay.getLayoutParams().height = android.widget.FrameLayout.LayoutParams.MATCH_PARENT;

    makeNextRequest(context);
}

From source file:org.jitsi.android.gui.call.VideoCallActivity.java

/**
 * Initializes the microphone button view.
 *//*from  ww  w  .j a v  a  2s.c o  m*/
private void initMicrophoneView() {
    final ImageView microphoneButton = (ImageView) findViewById(R.id.callMicrophoneButton);

    microphoneButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            CallManager.setMute(call, !isMuted());
        }
    });
    microphoneButton.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View view) {
            DialogFragment newFragment = VolumeControlDialog.createInputVolCtrlDialog();
            newFragment.show(getSupportFragmentManager(), "vol_ctrl_dialog");
            return true;
        }
    });
}