Java Code Examples for android.widget.ImageView#setOnFocusChangeListener()

The following examples show how to use android.widget.ImageView#setOnFocusChangeListener() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: hyperion-android-grabber   File: MainActivity.java    License: MIT License 6 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mMediaProjectionManager = (MediaProjectionManager)
                                    getSystemService(Context.MEDIA_PROJECTION_SERVICE);

    ImageView iv = findViewById(R.id.power_toggle);
    iv.setOnClickListener(this);
    iv.setOnFocusChangeListener(this);
    iv.setFocusable(true);
    iv.requestFocus();

    setImageViews(mRecorderRunning, false);

    LocalBroadcastManager.getInstance(this).registerReceiver(
            mMessageReceiver, new IntentFilter(HyperionScreenService.BROADCAST_FILTER));
    checkForInstance();
}
 
Example 2
Source Project: hyperion-android-grabber   File: MainActivity.java    License: MIT License 5 votes vote down vote up
private void initActivity() {
    // assume the recorder is not running until we are notified otherwise
    mRecorderRunning = false;

    setContentView(R.layout.activity_main);
    AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
    mMediaProjectionManager = (MediaProjectionManager)
                                    getSystemService(Context.MEDIA_PROJECTION_SERVICE);

    ImageView iv = findViewById(R.id.power_toggle);
    iv.setOnClickListener(this);
    iv.setOnFocusChangeListener(this);
    iv.setFocusable(true);
    iv.requestFocus();

    ImageButton ib = findViewById(R.id.settingsButton);
    ib.setOnClickListener(this);
    ib.setOnFocusChangeListener(this);
    ib.setFocusable(true);

    setImageViews(mRecorderRunning, false);

    LocalBroadcastManager.getInstance(this).registerReceiver(
            mMessageReceiver, new IntentFilter(BROADCAST_FILTER));

    // request an update on the running status
    checkForInstance();
}
 
Example 3
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    mAllAppsHandle = (ImageView) findViewById(R.id.all_apps_handle);
    mAllAppsHandle.setImageDrawable(getCaretDrawable());
    mAllAppsHandle.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
    mAllAppsHandle.setOnClickListener(mLauncher);
    mAllAppsHandle.setOnLongClickListener(mLauncher);
    mAllAppsHandle.setOnFocusChangeListener(mLauncher.mFocusHandler);
    mLauncher.setAllAppsButton(mAllAppsHandle);
}
 
Example 4
/**
 * Set up the dashboard of buttons to launch the various services of the
 * app. This covers things like touch/focus listeners, authentication,
 * intent to launch, etc.
 */
private void setupDashBoardButtons() {
    scheduleCheck = (ImageView) findViewById(R.id.scheduleCheck);
    balanceCheck = (ImageView) findViewById(R.id.balanceCheck);
    dataCheck = (ImageView) findViewById(R.id.dataCheck);

    ProgressBar scheduleProgress = (ProgressBar) findViewById(R.id.scheduleProgress);
    ProgressBar balanceProgress = (ProgressBar) findViewById(R.id.balanceProgress);
    ProgressBar dataProgress = (ProgressBar) findViewById(R.id.dataProgress);

    final Intent schedule = new Intent(this, ScheduleActivity.class);
    final Intent balance = new Intent(this, BalanceActivity.class);
    final Intent map = new Intent(this, CampusMapActivity.class);
    final Intent data = new Intent(this, DataUsageActivity.class);
    final Intent menu = new Intent(this, MenuActivity.class);



    DashboardButtonData buttonData[] = new DashboardButtonData[6];
    buttonData[0] = new DashboardButtonData(schedule, R.id.schedule_button, authCookie,
            scheduleCheck, scheduleProgress, !loginFailed);
    buttonData[1] = new DashboardButtonData(balance, R.id.balance_button, authCookie,
            balanceCheck, balanceProgress, !loginFailed);
    buttonData[2] = new DashboardButtonData(data, R.id.data_button, authCookie,
            dataCheck, dataProgress, !loginFailed);
    buttonData[3] = new DashboardButtonData(map, R.id.map_button);
    buttonData[4] = new DashboardButtonData(menu, R.id.menu_button);

    featureButtons = new ImageView[5];
    for (int i = 0; i < 5; i++) {
        ImageView ib = (ImageView) findViewById(buttonData[i].imageButtonId);
        ib.setOnTouchListener(new ImageButtonTouchListener(
                (TransitionDrawable) ib.getDrawable()));
        ib.setOnFocusChangeListener(new ImageButtonFocusListener());
        ib.setTag(buttonData[i]);
        if (buttonData[i].enabled) {
            enableFeature(ib);
        } else {
            disableFeature(ib);
        }
        featureButtons[i] = ib;
    }
}