Example usage for android.widget RelativeLayout setOnClickListener

List of usage examples for android.widget RelativeLayout setOnClickListener

Introduction

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

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:com.onyx.deskclock.deskclock.worldclock.CitySelectionActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setVolumeControlStream(AudioManager.STREAM_ALARM);

    setContentView(R.layout.cities_activity);

    RelativeLayout relativeLayout_back = (RelativeLayout) findViewById(R.id.back_function_layout);
    relativeLayout_back.setOnClickListener(new View.OnClickListener() {
        @Override//w w  w  .j a  va 2s .  co  m
        public void onClick(View v) {
            finish();
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.alarm_toolbar);
    setSupportActionBar(toolbar);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }

    mSearchMenuItemController = new SearchMenuItemController(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            return false;
        }

        @Override
        public boolean onQueryTextChange(String query) {
            mCitiesAdapter.filter(query);
            updateFastScrolling();
            return true;
        }
    }, savedInstanceState);
    mCitiesAdapter = new CityAdapter(this, mSearchMenuItemController);
    mActionBarMenuManager.addMenuItemController(new NavUpMenuItemController(this))
            .addMenuItemController(mSearchMenuItemController)
            .addMenuItemController(new SortOrderMenuItemController())
            .addMenuItemController(new SettingMenuItemController(this))
            .addMenuItemController(MenuItemControllerFactory.getInstance().buildMenuItemControllers(this));
    mCitiesList = (ListView) findViewById(R.id.cities_list);
    mCitiesList.setScrollBarStyle(View.SCROLLBARS_INSIDE_INSET);
    mCitiesList.setAdapter(mCitiesAdapter);

    updateFastScrolling();
}

From source file:org.mozilla.gecko.AboutHomeContent.java

public void init() {
    Context context = getContext();
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mInflater.inflate(R.layout.abouthome_content, this);

    mAccountManager = AccountManager.get(context);

    // The listener will run on the background thread (see 2nd argument)
    mAccountManager.addOnAccountsUpdatedListener(new OnAccountsUpdateListener() {
        public void onAccountsUpdated(Account[] accounts) {
            final GeckoApp.StartupMode startupMode = GeckoApp.mAppContext.getStartupMode();
            final boolean syncIsSetup = isSyncSetup();

            GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
                public void run() {
                    // The listener might run before the UI is initially updated.
                    // In this case, we should simply wait for the initial setup
                    // to happen.
                    if (mTopSitesAdapter != null)
                        updateLayout(startupMode, syncIsSetup);
                }/*from  w ww. j  av  a 2  s  .c o  m*/
            });
        }
    }, GeckoAppShell.getHandler(), false);

    mTopSitesGrid = (GridView) findViewById(R.id.top_sites_grid);
    mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Cursor c = (Cursor) parent.getItemAtPosition(position);

            String spec = c.getString(c.getColumnIndex(URLColumns.URL));
            Log.i(LOGTAG, "clicked: " + spec);

            if (mUriLoadCallback != null)
                mUriLoadCallback.callback(spec);
        }
    });

    mAddonsLayout = (LinearLayout) findViewById(R.id.recommended_addons);
    mLastTabsLayout = (LinearLayout) findViewById(R.id.last_tabs);

    TextView allTopSitesText = (TextView) findViewById(R.id.all_top_sites_text);
    allTopSitesText.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            GeckoApp.mAppContext.showAwesomebar(AwesomeBar.Type.EDIT);
        }
    });

    TextView allAddonsText = (TextView) findViewById(R.id.all_addons_text);
    allAddonsText.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (mUriLoadCallback != null)
                mUriLoadCallback.callback("https://addons.mozilla.org/android");
        }
    });

    TextView syncTextView = (TextView) findViewById(R.id.sync_text);
    String syncText = syncTextView.getText().toString() + " \u00BB";
    String boldName = getContext().getResources().getString(R.string.abouthome_sync_bold_name);
    int styleIndex = syncText.indexOf(boldName);

    // Highlight any occurrence of "Firefox Sync" in the string
    // with a bold style.
    if (styleIndex >= 0) {
        SpannableString spannableText = new SpannableString(syncText);
        spannableText.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), styleIndex, styleIndex + 12, 0);
        syncTextView.setText(spannableText, TextView.BufferType.SPANNABLE);
    }

    RelativeLayout syncBox = (RelativeLayout) findViewById(R.id.sync_box);
    syncBox.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Context context = v.getContext();
            Intent intent = new Intent(context, SetupSyncActivity.class);
            context.startActivity(intent);
        }
    });
}

From source file:com.cypress.cysmart.GATTDBFragments.GattDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.gattdb_details, container, false);
    this.mContainer = container;
    mApplication = (CySmartApplication) getActivity().getApplication();
    mServiceName = (TextView) rootView.findViewById(R.id.txtservicename);
    mHexValue = (TextView) rootView.findViewById(R.id.txthex);
    mCharacteristiceName = (TextView) rootView.findViewById(R.id.txtcharatrname);
    mBtnnotify = (TextView) rootView.findViewById(R.id.txtnotify);
    mBtnIndicate = (TextView) rootView.findViewById(R.id.txtindicate);
    mBtnread = (TextView) rootView.findViewById(R.id.txtread);
    mBtnwrite = (TextView) rootView.findViewById(R.id.txtwrite);
    mAsciivalue = (TextView) rootView.findViewById(R.id.txtascii);
    mTimevalue = (TextView) rootView.findViewById(R.id.txttime);
    mDatevalue = (TextView) rootView.findViewById(R.id.txtdate);
    backbtn = (ImageView) rootView.findViewById(R.id.imgback);
    mProgressDialog = new ProgressDialog(getActivity());
    /**/*from  w w  w .j  a  v  a2s  .c  o m*/
     * Soft back button listner
     */
    backbtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().onBackPressed();

        }
    });
    btn_descriptor = (Button) rootView.findViewById(R.id.characteristic_descriptors);
    if (mApplication.getBluetoothgattcharacteristic().getDescriptors().size() == 0) {
        btn_descriptor.setVisibility(View.GONE);
    }
    /**
     * Descriptor button listner
     */
    btn_descriptor.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            /**
             * Passing the characteristic details to GattDetailsFragment and
             * adding that fragment to the view
             */
            Bundle bundle = new Bundle();
            bundle.putString(Constants.GATTDB_SELECTED_SERVICE, mServiceName.getText().toString());
            bundle.putString(Constants.GATTDB_SELECTED_CHARACTERISTICE,
                    mCharacteristiceName.getText().toString());
            FragmentManager fragmentManager = getFragmentManager();
            GattDescriptorFragment gattDescriptorFragment = new GattDescriptorFragment().create();
            gattDescriptorFragment.setArguments(bundle);
            fragmentManager.beginTransaction().add(R.id.container, gattDescriptorFragment).addToBackStack(null)
                    .commit();
        }
    });
    RelativeLayout parent = (RelativeLayout) rootView.findViewById(R.id.parent);
    parent.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

        }
    });
    /**
     * button listeners
     */
    mBtnread.setOnClickListener(this);
    mBtnnotify.setOnClickListener(this);
    mBtnIndicate.setOnClickListener(this);
    mBtnwrite.setOnClickListener(this);

    mServiceName.setSelected(true);
    mCharacteristiceName.setSelected(true);
    mAsciivalue.setSelected(true);
    mHexValue.setSelected(true);

    // Getting the characteristics from the application
    mReadCharacteristic = mApplication.getBluetoothgattcharacteristic();
    mNotifyCharacteristic = mApplication.getBluetoothgattcharacteristic();
    Bundle bundle = this.getArguments();
    if (bundle != null) {
        mServiceName.setText(bundle.getString(Constants.GATTDB_SELECTED_SERVICE));
        mCharacteristiceName.setText(bundle.getString(Constants.GATTDB_SELECTED_CHARACTERISTICE));
    }
    startNotifyText = getResources().getString(R.string.gatt_services_notify);
    stopNotifyText = getResources().getString(R.string.gatt_services_stop_notify);
    startIndicateText = getResources().getString(R.string.gatt_services_indicate);
    stopIndicateText = getResources().getString(R.string.gatt_services_stop_indicate);
    UIbuttonvisibility();
    setHasOptionsMenu(true);
    /**
     * Check for HID Service
     */
    BluetoothGattService mBluetoothGattService = mReadCharacteristic.getService();
    if (mBluetoothGattService.getUuid().toString()
            .equalsIgnoreCase(GattAttributes.HUMAN_INTERFACE_DEVICE_SERVICE)) {
        showHIDWarningMessage();
    }
    Logger.i("Notification status---->" + mIsNotifyEnabled);
    return rootView;
}

From source file:at.alladin.rmbt.android.fragments.history.RMBTFilterFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    super.onCreateView(inflater, container, savedInstanceState);

    view = inflater.inflate(R.layout.history_filter, container, false);

    deviceListView = (LinearLayout) view.findViewById(R.id.deviceList);
    networkListView = (LinearLayout) view.findViewById(R.id.networkList);

    final RelativeLayout resultLimitView = (RelativeLayout) view.findViewById(R.id.Limit25Wrapper);
    limit25CheckBox = (CheckBox) view.findViewById(R.id.Limit25CheckBox);

    if (activity.getHistoryResultLimit() == 250)
        limit25CheckBox.setChecked(true);
    else/*from   w w  w .  j ava2s  .co  m*/
        limit25CheckBox.setChecked(false);

    resultLimitView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(final View v) {
            if (limit25CheckBox.isChecked()) {
                limit25CheckBox.setChecked(false);
                activity.setHistoryResultLimit(0);
            } else {
                limit25CheckBox.setChecked(true);
                activity.setHistoryResultLimit(250);
            }

        }

    });

    devicesToShow = activity.getHistoryFilterDevicesFilter();
    networksToShow = activity.getHistoryFilterNetworksFilter();

    if (devicesToShow == null && networksToShow == null) {
        devicesToShow = new ArrayList<String>();
        networksToShow = new ArrayList<String>();
    }

    final float scale = activity.getResources().getDisplayMetrics().density;

    final int leftRightItem = Helperfunctions.dpToPx(5, scale);
    // int topBottomItem = Helperfunctions.dpToPx(5, scale);

    // int leftRightDiv = Helperfunctions.dpToPx(0, scale);
    // int topBottomDiv = Helperfunctions.dpToPx(0, scale);
    final int heightDiv = Helperfunctions.dpToPx(1, scale);

    // int topBottomImg = Helperfunctions.dpToPx(1, scale);

    final String historyDevices[] = activity.getHistoryFilterDevices();

    if (historyDevices != null) {

        for (int i = 0; i < historyDevices.length; i++) {

            final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

            singleItemLayout.setId(i);
            singleItemLayout.setClickable(true);
            singleItemLayout.setBackgroundResource(R.drawable.list_selector);

            singleItemLayout.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight);

            RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemTitle.setLayoutParams(layout);
            itemTitle.setGravity(Gravity.LEFT);
            itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemTitle.setText(historyDevices[i]);

            singleItemLayout.addView(itemTitle, layout);

            final CheckBox itemCheck = new CheckBox(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemCheck.setLayoutParams(layout);

            itemCheck.setGravity(Gravity.RIGHT);
            itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemCheck.setOnClickListener(null);
            itemCheck.setClickable(false);
            itemCheck.setId(i + historyDevices.length);

            if (devicesToShow.isEmpty() || devicesToShow.contains(historyDevices[i]))
                itemCheck.setChecked(true);
            else
                itemCheck.setChecked(false);

            singleItemLayout.addView(itemCheck, layout);

            // layout = new
            // RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT,
            // RelativeLayout.LayoutParams.WRAP_CONTENT);

            // singleItemLayout.setLayoutParams(layout);

            singleItemLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyDevices.length);
                    if (check.isChecked()) {
                        check.setChecked(false);
                        devicesToShow.remove(historyDevices[v.getId()]);
                    } else {
                        check.setChecked(true);
                        devicesToShow.add(historyDevices[v.getId()]);
                    }

                }

            });

            deviceListView.addView(singleItemLayout);

            final View divider = new View(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv);

            divider.setBackgroundResource(R.drawable.bg_trans_light_10);

            deviceListView.addView(divider, layout);

        }
        deviceListView.invalidate();
    }

    final String historyNetworks[] = activity.getHistoryFilterNetworks();

    if (historyNetworks != null) {

        for (int i = 0; i < historyNetworks.length; i++) {

            final RelativeLayout singleItemLayout = new RelativeLayout(activity); // (LinearLayout)measurememtItemView.findViewById(R.id.measurement_item);

            singleItemLayout.setId(i);
            singleItemLayout.setClickable(true);
            singleItemLayout.setBackgroundResource(R.drawable.list_selector);

            singleItemLayout.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

            final TextView itemTitle = new TextView(activity, null, R.style.textMediumLight);
            RelativeLayout.LayoutParams layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemTitle.setLayoutParams(layout);
            itemTitle.setGravity(Gravity.LEFT);
            itemTitle.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemTitle.setText(historyNetworks[i]);

            singleItemLayout.addView(itemTitle, layout);

            final CheckBox itemCheck = new CheckBox(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            layout.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            layout.addRule(RelativeLayout.CENTER_VERTICAL);

            // itemCheck.setLayoutParams(layout);

            itemCheck.setGravity(Gravity.RIGHT);
            itemCheck.setPadding(leftRightItem, 0, leftRightItem, 0);
            itemCheck.setOnClickListener(null);
            itemCheck.setClickable(false);
            itemCheck.setId(i + historyNetworks.length);

            if (networksToShow.isEmpty() || networksToShow.contains(historyNetworks[i]))
                itemCheck.setChecked(true);
            else
                itemCheck.setChecked(false);

            singleItemLayout.addView(itemCheck, layout);

            singleItemLayout.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(final View v) {
                    final CheckBox check = (CheckBox) v.findViewById(v.getId() + historyNetworks.length);
                    if (check.isChecked()) {
                        check.setChecked(false);
                        networksToShow.remove(historyNetworks[v.getId()]);
                    } else {
                        check.setChecked(true);
                        networksToShow.add(historyNetworks[v.getId()]);
                    }
                    System.out.println(networksToShow.toString());
                }

            });

            networkListView.addView(singleItemLayout);

            final View divider = new View(activity);

            layout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, heightDiv);

            divider.setBackgroundResource(R.drawable.bg_trans_light_10);

            networkListView.addView(divider, layout);

        }
        networkListView.invalidate();
    }
    /*
     * // Set option as Multiple Choice. So that user can able to select
     * more the one option from list deviceListView.setAdapter(new
     * ArrayAdapter<String>(activity,
     * android.R.layout.simple_list_item_multiple_choice, historyDevices));
     * deviceListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
     * 
     * for (int i = 0; i < historyDevices.length; i++) {
     * //deviceListView.setItemChecked(i, true); }
     * 
     * deviceListView.setOnItemClickListener(new OnItemClickListener() {
     * 
     * @Override public void onItemClick(AdapterView<?> l, View v, int
     * position, long id) {
     * 
     * }
     * 
     * });
     * 
     * 
     * // Set option as Multiple Choice. So that user can able to select
     * more the one option from list networkListView.setAdapter(new
     * ArrayAdapter<String>(activity,
     * android.R.layout.simple_list_item_multiple_choice, networkDevices));
     * networkListView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
     * 
     * for (int i = 0; i < networkDevices.length; i++) {
     * networkListView.setItemChecked(i, true); }
     * 
     * SparseBooleanArray checked =
     * deviceListView.getCheckedItemPositions(); ArrayList<String>
     * devicesToShow = new ArrayList<String>(); for(int i = 0; i <
     * checked.size()+1; i++){ if(checked.get(i))
     * devicesToShow.add(historyDevices[i]); }
     */

    return view;
}

From source file:org.wso2.iot.agent.activities.AlreadyRegisteredActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_already_registered);

    textViewLastSync = (TextView) findViewById(R.id.textViewLastSync);
    imageViewRefresh = (ImageView) findViewById(R.id.imageViewRefresh);
    devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
    cdmDeviceAdmin = new ComponentName(this, AgentDeviceAdminReceiver.class);
    context = this;
    DeviceInfo info = new DeviceInfo(context);
    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        if (extras.containsKey(getResources().getString(R.string.intent_extra_fresh_reg_flag))) {
            isFreshRegistration = extras
                    .getBoolean(getResources().getString(R.string.intent_extra_fresh_reg_flag));
        }//from  w ww  . ja  v  a2s .  c  o m
    }
    String registrationId = Preference.getString(context, Constants.PreferenceFlag.REG_ID);

    if (registrationId != null && !registrationId.isEmpty()) {
        regId = registrationId;
    } else {
        regId = info.getDeviceId();
    }

    if (isFreshRegistration) {
        Preference.putBoolean(context, Constants.PreferenceFlag.REGISTERED, true);
        if (!isDeviceAdminActive()) {
            startEvents();
        }
        // In FCM, for fresh registrations, the initial FCM notification has been ignored
        // purposely to avoid calling the server during enrollment flow and causing threading
        // issues. Therefore after initial enrollment, pending operations is called manually.
        if (Constants.NOTIFIER_FCM
                .equals(Preference.getString(context, Constants.PreferenceFlag.NOTIFIER_TYPE))) {
            MessageProcessor messageProcessor = new MessageProcessor(context);
            try {
                if (Preference.getBoolean(context, Constants.PreferenceFlag.REGISTERED)) {
                    messageProcessor.getMessages();
                }
            } catch (AndroidAgentException e) {
                Log.e(TAG, "Failed to perform operation", e);
            }
        }
        isFreshRegistration = false;
    }

    RelativeLayout relativeLayoutSync = (RelativeLayout) findViewById(R.id.layoutSync);
    relativeLayoutSync.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Preference.getBoolean(context, Constants.PreferenceFlag.REGISTERED) && isDeviceAdminActive()) {
                syncWithServer();
            }
        }
    });

    RelativeLayout relativeLayoutDeviceInfo = (RelativeLayout) findViewById(R.id.layoutDeviceInfo);
    relativeLayoutDeviceInfo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadDeviceInfoActivity();
        }
    });

    RelativeLayout relativeLayoutChangePIN = (RelativeLayout) findViewById(R.id.layoutChangePIN);
    relativeLayoutChangePIN.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            loadPinCodeActivity();
        }
    });

    RelativeLayout relativeLayoutRegistration = (RelativeLayout) findViewById(R.id.layoutRegistration);
    if (Constants.HIDE_UNREGISTER_BUTTON) {
        relativeLayoutRegistration.setVisibility(View.GONE);
    } else {
        relativeLayoutRegistration.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showUnregisterDialog();
            }
        });
    }

    TextView textViewAgentVersion = (TextView) findViewById(R.id.textViewVersion);
    String versionText = BuildConfig.BUILD_TYPE + " v" + BuildConfig.VERSION_NAME + " ("
            + BuildConfig.VERSION_CODE + ") ";
    textViewAgentVersion.setText(versionText);

    if (Build.VERSION.SDK_INT >= 23) {
        List<String> missingPermissions = new ArrayList<>();

        if (ActivityCompat.checkSelfPermission(this,
                android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
            missingPermissions.add(android.Manifest.permission.READ_PHONE_STATE);
        }
        if (ActivityCompat.checkSelfPermission(this,
                android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            missingPermissions.add(android.Manifest.permission.ACCESS_COARSE_LOCATION);
        }
        if (ActivityCompat.checkSelfPermission(this,
                android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            missingPermissions.add(android.Manifest.permission.ACCESS_FINE_LOCATION);
        }
        if (ActivityCompat.checkSelfPermission(this,
                android.Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
            missingPermissions.add(android.Manifest.permission.WRITE_EXTERNAL_STORAGE);
        }

        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        // This is to handle permission obtaining for Android N devices where operations such
        // as mute that can cause a device to go into "do not disturb" will need additional
        // permission. Added here as well to support already enrolled devices to optain the
        // permission without reenrolling.
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M
                && !devicePolicyManager.isProfileOwnerApp(Constants.AGENT_PACKAGE)
                && notificationManager != null && !notificationManager.isNotificationPolicyAccessGranted()) {
            CommonDialogUtils.getAlertDialogWithOneButtonAndTitle(context,
                    getResources().getString(R.string.dialog_do_not_distrub_title),
                    getResources().getString(R.string.dialog_do_not_distrub_message),
                    getResources().getString(R.string.ok), doNotDisturbClickListener);
        }

        if (missingPermissions.isEmpty()) {
            NotificationManager mNotificationManager = (NotificationManager) context
                    .getSystemService(Context.NOTIFICATION_SERVICE);
            mNotificationManager.cancel(Constants.PERMISSION_MISSING,
                    Constants.PERMISSION_MISSING_NOTIFICATION_ID);
        } else {
            ActivityCompat.requestPermissions(AlreadyRegisteredActivity.this,
                    missingPermissions.toArray(new String[missingPermissions.size()]), 110);
        }
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        try {
            int locationSetting = Settings.Secure.getInt(context.getContentResolver(),
                    Settings.Secure.LOCATION_MODE);
            if (locationSetting == 0) {
                Intent enableLocationIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(enableLocationIntent);
                Toast.makeText(context, R.string.msg_need_location, Toast.LENGTH_LONG).show();
            }
        } catch (Settings.SettingNotFoundException e) {
            Log.w(TAG, "Location setting is not available on this device");
        }
    }

    boolean isRegistered = Preference.getBoolean(context, Constants.PreferenceFlag.REGISTERED);
    if (isRegistered) {
        if (CommonUtils.isNetworkAvailable(context)) {
            String serverIP = Constants.DEFAULT_HOST;
            String prefIP = Preference.getString(context, Constants.PreferenceFlag.IP);
            if (prefIP != null) {
                serverIP = prefIP;
            }
            regId = Preference.getString(context, Constants.PreferenceFlag.REG_ID);

            if (regId != null) {
                if (serverIP != null && !serverIP.isEmpty()) {
                    ServerConfig utils = new ServerConfig();
                    utils.setServerIP(serverIP);
                    if (utils.getHostFromPreferences(context) != null
                            && !utils.getHostFromPreferences(context).isEmpty()) {
                        CommonUtils.callSecuredAPI(AlreadyRegisteredActivity.this,
                                utils.getAPIServerURL(context) + Constants.DEVICES_ENDPOINT + regId
                                        + Constants.IS_REGISTERED_ENDPOINT,
                                HTTP_METHODS.GET, null, AlreadyRegisteredActivity.this,
                                Constants.IS_REGISTERED_REQUEST_CODE);
                    } else {
                        try {
                            CommonUtils.clearAppData(context);
                        } catch (AndroidAgentException e) {
                            String msg = "Device already dis-enrolled.";
                            Log.e(TAG, msg, e);
                        }
                        loadInitialActivity();
                    }
                } else {
                    Log.e(TAG, "There is no valid IP to contact server");
                }
            }
        } else {
            if (!Constants.HIDE_ERROR_DIALOG) {
                CommonDialogUtils.showNetworkUnavailableMessage(AlreadyRegisteredActivity.this);
            }
        }
    } else {
        loadInitialActivity();
    }
}

From source file:Steps.StepsFragment.java

private void showStickerMoreInfo(final Sticker clickedSticker) {
    // custom dialog
    clickedSticker.getName();// www. j  ava2 s. c o  m
    Log.d("NAMe", clickedSticker.getName());

    final Dialog dialog = new Dialog(getActivity());

    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            dialog.dismiss();
        }
    });

    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));
    dialog.setContentView(R.layout.sticker_dialog);
    ImageView image = (ImageView) (dialog).findViewById(R.id.image);

    //get the correct image
    String file = clickedSticker.getImagesrc();
    file = file.substring(0, file.lastIndexOf(".")); //trim the extension
    Resources resources = getActivity().getResources();
    int resourceId = resources.getIdentifier(file, "drawable", getActivity().getPackageName());
    image.setImageBitmap(SampleImage.decodeSampledBitmapFromResource(getResources(), resourceId, 250, 250));

    //load the additional details and information
    TextView id = (TextView) (dialog).findViewById(R.id.sticker_id);
    id.setText("#" + Integer.toString(clickedSticker.getId()));

    TextView status = (TextView) (dialog).findViewById(R.id.sticker_status);
    //at this poinrt only glued and notSticker available glued=1 notGlued=0
    String statuss = clickedSticker.getStatus().equals(2) ? "1" : "0";
    Integer count = clickedSticker.getCount();
    status.setText("(" + statuss + " glued, " + count + " left)");

    TextView title = (TextView) (dialog).findViewById(R.id.sticker_title);
    title.setText(clickedSticker.getName());

    TextView rarity = (TextView) (dialog).findViewById(R.id.rarity);
    rarity.setText(clickedSticker.getPopularity());

    TextView movie = (TextView) (dialog).findViewById(R.id.sticker_movie);
    movie.setText(clickedSticker.getMovie());
    //set the layout to have the same widh and height as the  windows screen

    Display display = getActivity().getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = width;
    lp.height = height;
    dialog.getWindow().setAttributes(lp);
    RelativeLayout mainLayout = (RelativeLayout) dialog.findViewById(R.id.showStickerLayout);
    dialog.show();
    // if button is clicked, close the custom dialog
    mainLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }

    });
    //listen for the inf tab
    ImageView info = (ImageView) (dialog).findViewById(R.id.info_image);
    info.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showInfoDialog(clickedSticker);
        }

    });

}

From source file:com.limewoodmedia.nsdroid.activities.World.java

private void doSearch(final String string) {
    searchResults.removeAllViews();//from w  w  w .j  a va 2s  . co  m
    final LoadingView loadingView = (LoadingView) search.findViewById(R.id.loading);
    LoadingHelper.startLoading(loadingView, R.string.searching, this);
    // Don't update automatically if we're reading back in history
    errorMessage = getResources().getString(R.string.general_error);
    new ParallelTask<Void, Void, Boolean>() {
        protected Boolean doInBackground(Void... params) {
            try {
                try {
                    nData = API.getInstance(World.this).getNationInfo(string, NationData.Shards.NAME,
                            NationData.Shards.CATEGORY, NationData.Shards.REGION);
                } catch (UnknownNationException e) {
                    nData = null;
                }

                try {
                    rData = API.getInstance(World.this).getRegionInfo(string, NAME, NUM_NATIONS, DELEGATE);
                } catch (UnknownRegionException e) {
                    rData = null;
                }

                return true;
            } catch (RateLimitReachedException e) {
                e.printStackTrace();
                errorMessage = getResources().getString(R.string.rate_limit_reached);
            } catch (RuntimeException e) {
                e.printStackTrace();
                errorMessage = e.getMessage();
            } catch (XmlPullParserException e) {
                e.printStackTrace();
                errorMessage = getResources().getString(R.string.xml_parser_exception);
            } catch (IOException e) {
                e.printStackTrace();
                errorMessage = getResources().getString(R.string.api_io_exception);
            }

            return false;
        }

        protected void onPostExecute(Boolean result) {
            LoadingHelper.stopLoading(loadingView);
            if (result) {
                // Show search results
                RelativeLayout nation = (RelativeLayout) getLayoutInflater().inflate(R.layout.search_nation,
                        searchResults, false);
                if (nData != null) {
                    ((TextView) nation.findViewById(R.id.nation_name)).setText(nData.name);
                    ((TextView) nation.findViewById(R.id.nation_category)).setText(nData.category);
                    ((TextView) nation.findViewById(R.id.nation_region)).setText(nData.region);
                    nation.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(World.this, Nation.class);
                            intent.setData(Uri.parse(
                                    "com.limewoodMedia.nsdroid.nation://" + TagParser.nameToId(nData.name)));
                            startActivity(intent);
                        }
                    });
                } else {
                    ((TextView) nation.findViewById(R.id.nation_name)).setText(R.string.no_nation_found);
                    ((TextView) nation.findViewById(R.id.nation_category)).setVisibility(View.GONE);
                    ((TextView) nation.findViewById(R.id.nation_region)).setVisibility(View.GONE);
                }
                searchResults.addView(nation);
                RelativeLayout region = (RelativeLayout) getLayoutInflater().inflate(R.layout.search_region,
                        searchResults, false);
                if (rData != null) {
                    ((TextView) region.findViewById(R.id.region_name)).setText(rData.name);
                    ((TextView) region.findViewById(R.id.region_nations))
                            .setText(Integer.toString(rData.numNations));
                    ((TextView) region.findViewById(R.id.region_wad)).setText(rData.delegate);
                    region.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            Intent intent = new Intent(World.this, Region.class);
                            intent.setData(Uri.parse(
                                    "com.limewoodMedia.nsdroid.region://" + TagParser.nameToId(rData.name)));
                            startActivity(intent);
                        }
                    });
                } else {
                    ((TextView) region.findViewById(R.id.region_name)).setText(R.string.no_region_found);
                    ((TextView) region.findViewById(R.id.region_nations_label)).setVisibility(View.GONE);
                    ((TextView) region.findViewById(R.id.region_nations)).setVisibility(View.GONE);
                    ((TextView) region.findViewById(R.id.region_wad_label)).setVisibility(View.GONE);
                    ((TextView) region.findViewById(R.id.region_wad)).setVisibility(View.GONE);
                }
                searchResults.addView(region);
            } else {
                Toast.makeText(World.this, errorMessage, Toast.LENGTH_SHORT).show();
            }
            View view = World.this.getCurrentFocus();
            if (view != null) {
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }
        }
    }.execute();
}

From source file:com.example.fan.horizontalscrollview.PagerSlidingTabStrip.java

private void addCmTab(final int position, String title, int resId) {
    RelativeLayout tab = (RelativeLayout) inflate(getContext(), R.layout.cm_pst__tab, null);
    ImageView iv = (ImageView) tab.findViewById(R.id.pst_iv_tab);
    iv.setImageResource(resId);//w ww  .  jav  a2 s .  c om
    iv.setVisibility(View.VISIBLE);
    TextView tv = (TextView) tab.findViewById(R.id.pst_tv_tab);
    tv.setText(title);
    tv.setGravity(Gravity.CENTER);
    tv.setSingleLine();
    tab.setFocusable(true);
    tab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (null != mOnPageClickedLisener) {
                mOnPageClickedLisener.onPageClicked(position);
            }
            pager.setCurrentItem(position);
        }
    });

    tabsContainer.addView(tab);
}

From source file:com.hackensack.umc.activity.ProfileSelfieActivity.java

private void showHelpView(LayoutInflater layoutInflater) {
    if (Util.gethelpboolean(this, Constant.HELP_PREF_PROFILE)) {
        Util.storehelpboolean(this, Constant.HELP_PREF_PROFILE, false);
        helpView = layoutInflater.inflate(R.layout.profile_help, null, false);
        helpLl = (RelativeLayout) helpView.findViewById(R.id.profile_help_ll);
        helpLl.setY(bottom);/*from   w  ww .  j a  va2s  .c o  m*/
        TextView arrowTv = (TextView) helpView.findViewById(R.id.profile_help_arrow);
        arrowTv.setTypeface(Util.getArrowFont(this));
        int x = getWindowManager().getDefaultDisplay().getWidth() / 3 - right + 30;
        LinearLayout linearLayout = (LinearLayout) helpView.findViewById(R.id.layoutStepInstruction);
        linearLayout.setX(x);

        TextView arrowSteps = (TextView) helpView.findViewById(R.id.txtStepsArrow);
        arrowSteps.setTypeface(Util.getArrowFont(this));

        TextView txtCoatch = ((TextView) helpView.findViewById(R.id.txtCoachMarks));
        txtCoatch.setTypeface(Util.getFontSegoe(this));

        /* if ((getResources().getConfiguration().screenLayout &
            Configuration.SCREENLAYOUT_SIZE_MASK) ==
            Configuration.SCREENLAYOUT_SIZE_LARGE|| Configuration.SCREENLAYOUT_LAYOUTDIR_MASK==Configuration.SCREENLAYOUT_SIZE_NORMAL||Configuration.SCREENLAYOUT_LAYOUTDIR_MASK==Configuration.SCREENLAYOUT_SIZE_XLARGE||Configuration.SCREENLAYOUT_LAYOUTDIR_MASK==Configuration.SCREENLAYOUT_SIZE_UNDEFINED) {
        txtCoatch.setTypeface(Util.getFontSegoe(this));
        txtCoatch.setVisibility(View.VISIBLE);
                
         }else {
        txtCoatch.setVisibility(View.GONE);
         }*/
        int h = getWindowManager().getDefaultDisplay().getHeight();
        if (getWindowManager().getDefaultDisplay().getHeight() <= 800) {
            txtCoatch.setVisibility(View.GONE);
        }

        ((TextView) helpView.findViewById(R.id.profile_tap_tv)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.profile_tap_tv_1)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.profile_tap_tv_2)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.profile_tap_tv_3)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.tap_tv_dismiss)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.txtCoachMarks)).setTypeface(Util.getFontSegoe(this));
        ((TextView) helpView.findViewById(R.id.txtSteps)).setTypeface(Util.getFontSegoe(this));

        // arrowTv.setX((left+right) / 2);

        TextView txtHelp = ((TextView) helpView.findViewById(R.id.profile_help_tv));
        txtHelp.setTypeface(Util.getFontSegoe(this));
        //txtHelp.setY(bottom);;

        //((TextView) helpView.findViewById(R.id.help_tv)).setX((left+right) / 4);
        RelativeLayout helpLayout = ((RelativeLayout) helpView.findViewById(R.id.profile_help_rl));
        helpLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                frameLayout.removeView(helpView);
            }
        });
        frameLayout.addView(helpView);
    }
}

From source file:com.ymt.demo1.plates.exportConsult.ExportConsultMainActivity.java

/**
 * ?/*from ww w .  j av a2s .  co m*/
 */
protected void initTodTomExport() {
    //info 
    RelativeLayout todayExportView = (RelativeLayout) findViewById(R.id.today_export_layout);
    RelativeLayout tomorrowExportView = (RelativeLayout) findViewById(R.id.tomorrow_export_layout);
    todayExportIcon = (ImageView) findViewById(R.id.today_export_icon);
    todayExportName = (TextView) findViewById(R.id.today_export_name);
    todayExportCount = (TextView) findViewById(R.id.today_export_major);
    tomorrowExportIcon = (ImageView) findViewById(R.id.tomorrow_export_icon);
    tomorrowExportName = (TextView) findViewById(R.id.tomorrow_export_name);
    tomorrowExportCount = (TextView) findViewById(R.id.tomorrow_export_major);

    //
    todayExportView.setOnClickListener(this);
    tomorrowExportView.setOnClickListener(this);
}