Example usage for android.widget LinearLayout setVisibility

List of usage examples for android.widget LinearLayout setVisibility

Introduction

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

Prototype

@RemotableViewMethod
public void setVisibility(@Visibility int visibility) 

Source Link

Document

Set the visibility state of this view.

Usage

From source file:org.namelessrom.devicecontrol.modules.appmanager.AppDetailsActivity.java

private void setupPermissionsView() {
    final LinearLayout permissionsView = (LinearLayout) findViewById(R.id.permissions_section);
    final boolean supported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1;
    if (!supported) {
        permissionsView.setVisibility(View.GONE);
        return;/*from ww w .  ja  v  a 2s .  c  o  m*/
    }

    AppSecurityPermissions asp = new AppSecurityPermissions(this, mAppItem.getPackageName());
    // Make the security sections header visible
    LinearLayout securityList = (LinearLayout) findViewById(R.id.security_settings_list);
    securityList.removeAllViews();
    securityList.addView(asp.getPermissionsView());
    // If this app is running under a shared user ID with other apps,
    // update the description to explain this.
    String[] packages = mPm.getPackagesForUid(mAppItem.getApplicationInfo().uid);
    if (packages != null && packages.length > 1) {
        final ArrayList<CharSequence> pnames = new ArrayList<>();
        for (final String pkg : packages) {
            if (mAppItem.getPackageName().equals(pkg)) {
                continue;
            }
            try {
                ApplicationInfo ainfo = mPm.getApplicationInfo(pkg, 0);
                pnames.add(ainfo.loadLabel(mPm));
            } catch (PackageManager.NameNotFoundException ignored) {
            }
        }
        final int N = pnames.size();
        if (N > 0) {
            final Resources res = getResources();
            String appListStr;
            if (N == 1) {
                appListStr = pnames.get(0).toString();
            } else if (N == 2) {
                appListStr = res.getString(R.string.join_two_items, pnames.get(0), pnames.get(1));
            } else {
                appListStr = pnames.get(N - 2).toString();
                for (int i = N - 3; i >= 0; i--) {
                    appListStr = res.getString(
                            i == 0 ? R.string.join_many_items_first : R.string.join_many_items_middle,
                            pnames.get(i), appListStr);
                }
                appListStr = res.getString(R.string.join_many_items_last, appListStr, pnames.get(N - 1));
            }
            final TextView descr = (TextView) findViewById(R.id.security_settings_desc);
            descr.setText(res.getString(R.string.security_settings_desc_multi,
                    mAppItem.getApplicationInfo().loadLabel(mPm), appListStr));
        }
    }

}

From source file:org.openaccessbutton.openaccessbutton.advocacy.AdvocacyFragment.java

License:asdf

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_advocacy, container, false);

    mResourceName = getArguments().getString("filename");

    InputStream object;/*from ww w.  j a  v a 2s .c o  m*/
    // XML file containing content
    if (mResourceName.equals("diego.xml")) {
        object = this.getResources().openRawResource(R.raw.diego);
    } else if (mResourceName.equals("other_content.xml")) {
        object = this.getResources().openRawResource(R.raw.other_content);
    } else if (mResourceName.equals("take_action.xml")) {
        object = this.getResources().openRawResource(R.raw.take_action);
    } else {
        object = this.getResources().openRawResource(R.raw.advocacy);
    }
    // LinearLayout to append content to
    LinearLayout layout = (LinearLayout) view.findViewById(R.id.advocacy_content);

    try {
        XmlParser xmlParser = new XmlParser();
        xmlParser.parseToView(object, layout, getActivity());
    } catch (IOException e) {
        // TODO: Do something
        Log.e("openaccess", "exception", e);
    } catch (XmlPullParserException e) {
        // TODO: Do something
        Log.e("openaccess", "exception", e);
    }

    // Section for submitting an additional question
    final TextView askQuestion = (TextView) view.findViewById(R.id.askQuestion);
    final LinearLayout newQuestionWrapper = (LinearLayout) view.findViewById(R.id.newQuestionWrapper);
    final EditText newQuestion = (EditText) view.findViewById(R.id.newQuestion);
    final TextView questionSubmitted = (TextView) view.findViewById(R.id.questionSubmitted);
    final Button newQuestionSubmit = (Button) view.findViewById(R.id.newQuestionSubmit);

    askQuestion.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (newQuestionWrapper.getVisibility() == View.VISIBLE) {
                newQuestionWrapper.setVisibility(View.GONE);
                questionSubmitted.setVisibility(View.GONE);
                askQuestion.setText(getResources().getString(R.string.askQuestion));
            } else {
                newQuestionWrapper.setVisibility(View.VISIBLE);
                questionSubmitted.setVisibility(View.GONE);
                newQuestion.setText("");
                askQuestion.setText(getResources().getString(R.string.askQuestionClosed));
            }
        }
    });
    newQuestionSubmit.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (newQuestion.getText().length() > 0) {

                // Submit the question to the web service
                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        try {
                            String user_id;
                            ParseInstallation installation = ParseInstallation.getCurrentInstallation();
                            if (installation == null) {
                                user_id = "";
                            } else {
                                user_id = installation.getObjectId();
                            }

                            Log.w("asdf", user_id);

                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    newQuestionSubmit.setVisibility(View.INVISIBLE);
                                }
                            });

                            Webb webb = Webb.create();
                            JSONObject response = webb
                                    .post("http://oabuttonquestions.herokuapp.com/questions/new")
                                    .param("user_id", user_id).param("question", newQuestion.getText())
                                    .ensureSuccess().asJsonObject().getBody();

                            getActivity().runOnUiThread(new Runnable() {
                                @Override
                                public void run() {
                                    questionSubmitted.setVisibility(View.VISIBLE);
                                    newQuestion.setText("");
                                    newQuestionSubmit.setVisibility(View.VISIBLE);
                                }
                            });
                        } catch (Exception e) {
                            e.printStackTrace();

                            // TODO: Show error
                        }
                    }
                });
                thread.start();
            } else {
                Toast.makeText(getActivity(),
                        getActivity().getResources().getString(R.string.blank_question_error),
                        Toast.LENGTH_LONG).show();
            }
        }
    });

    return view;
}

From source file:com.android.mms.rcs.FavoriteDetailAdapter.java

@Override
public Object instantiateItem(ViewGroup view, int position) {
    mCursor.moveToPosition(position);/*from   www.j  a v  a 2 s.  c o m*/
    View content = mInflater.inflate(R.layout.message_detail_content, view, false);

    TextView bodyText = (TextView) content.findViewById(R.id.textViewBody);
    LinearLayout mLinearLayout = (LinearLayout) content.findViewById(R.id.other_type_layout);

    mMsgType = mCursor.getInt(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.MSG_TYPE));
    if (mMsgType == RcsUtils.RCS_MSG_TYPE_TEXT) {
        initTextMsgView(bodyText);
    } else {
        bodyText.setVisibility(View.GONE);
        mLinearLayout.setVisibility(View.VISIBLE);
        ImageView imageView = (ImageView) mLinearLayout.findViewById(R.id.image_view);
        TextView textView = (TextView) mLinearLayout.findViewById(R.id.type_text_view);
        if (mMsgType != RcsUtils.RCS_MSG_TYPE_CAIYUNFILE) {
            imageView.setOnClickListener(mOnClickListener);
        }
        if (mMsgType == RcsUtils.RCS_MSG_TYPE_IMAGE) {
            initImageMsgView(mLinearLayout);
            showContentFileSize(textView);
            mContentType = "image/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_AUDIO) {
            imageView.setImageResource(R.drawable.rcs_voice);
            showContentFileSize(textView);
            mContentType = "audio/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VIDEO) {
            String thumbPath = mCursor.getString(
                    mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL));
            Bitmap bitmap = BitmapFactory.decodeFile(thumbPath);
            imageView.setImageBitmap(bitmap);
            showContentFileSize(textView);
            mContentType = "video/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_MAP) {
            imageView.setImageResource(R.drawable.rcs_map);
            String body = mCursor
                    .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT));
            textView.setText(body);
            mContentType = "map/*";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VCARD) {
            textView.setVisibility(View.GONE);
            initVcardMagView(mLinearLayout);
            mContentType = "text/x-vCard";
        } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_PAID_EMO) {
            String messageBody = mCursor
                    .getString(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.FILE_NAME));
            String[] body = messageBody.split(",");
            RcsEmojiStoreUtil.getInstance().loadImageAsynById(imageView, body[0],
                    RcsEmojiStoreUtil.EMO_STATIC_FILE);
        } else {
            bodyText.setVisibility(View.VISIBLE);
            mLinearLayout.setVisibility(View.GONE);
            initTextMsgView(bodyText);
        }
    }

    TextView detailsText = (TextView) content.findViewById(R.id.textViewDetails);
    detailsText.setText(getTextMessageDetails(mContext, mCursor, true));
    view.addView(content);

    return content;
}

From source file:com.prey.activities.CheckPasswordActivity.java

@Override
protected void onResume() {
    super.onResume();
    bindPasswordControls();//  w w  w.  j ava2  s.  c o  m
    TextView device_ready_h2_text = (TextView) findViewById(R.id.device_ready_h2_text);
    final TextView textForgotPassword = (TextView) findViewById(R.id.link_forgot_password);

    Button password_btn_login = (Button) findViewById(R.id.password_btn_login);
    EditText password_pass_txt = (EditText) findViewById(R.id.password_pass_txt);

    TextView textView1 = (TextView) findViewById(R.id.textView1);
    TextView textView2 = (TextView) findViewById(R.id.textView2);

    Typeface titilliumWebRegular = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Regular.ttf");
    Typeface titilliumWebBold = Typeface.createFromAsset(getAssets(),
            "fonts/Titillium_Web/TitilliumWeb-Bold.ttf");
    Typeface magdacleanmonoRegular = Typeface.createFromAsset(getAssets(),
            "fonts/MagdaClean/magdacleanmono-regular.ttf");

    textView1.setTypeface(magdacleanmonoRegular);
    textView2.setTypeface(magdacleanmonoRegular);

    device_ready_h2_text.setTypeface(titilliumWebRegular);
    textForgotPassword.setTypeface(titilliumWebBold);
    password_btn_login.setTypeface(titilliumWebBold);
    password_pass_txt.setTypeface(magdacleanmonoRegular);

    try {

        textForgotPassword.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {
                try {
                    String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelUrl();
                    Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
                    startActivity(browserIntent);
                } catch (Exception e) {
                }
            }
        });
    } catch (Exception e) {
    }

    TextView textView5_1 = (TextView) findViewById(R.id.textView5_1);
    TextView textView5_2 = (TextView) findViewById(R.id.textView5_2);

    textView5_1.setTypeface(magdacleanmonoRegular);
    textView5_2.setTypeface(titilliumWebBold);

    TextView textViewUninstall = (TextView) findViewById(R.id.textViewUninstall);
    LinearLayout linearLayoutTour = (LinearLayout) findViewById(R.id.linearLayoutTour);
    textViewUninstall.setTypeface(titilliumWebBold);

    if (PreyConfig.getPreyConfig(getApplication()).getProtectTour()) {
        linearLayoutTour.setVisibility(View.GONE);
        textViewUninstall.setVisibility(View.VISIBLE);

        textViewUninstall.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = PreyConfig.getPreyConfig(getApplication()).getPreyUninstallUrl();

                Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse(url));
                startActivity(browserIntent);

                finish();
            }
        });
    } else {

        linearLayoutTour.setVisibility(View.VISIBLE);
        textViewUninstall.setVisibility(View.GONE);
        try {

            linearLayoutTour.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getApplication(), TourActivity1.class);
                    Bundle b = new Bundle();
                    b.putInt("id", 1);
                    intent.putExtras(b);
                    startActivity(intent);
                    finish();
                }
            });
        } catch (Exception e) {

        }
    }

    boolean showLocation = false;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        boolean canAccessFineLocation = PreyPermission.canAccessFineLocation(this);
        boolean canAccessCoarseLocation = PreyPermission.canAccessCoarseLocation(this);
        boolean canAccessCamera = PreyPermission.canAccessCamera(this);
        boolean canAccessReadPhoneState = PreyPermission.canAccessReadPhoneState(this);
        boolean canAccessReadExternalStorage = PreyPermission.canAccessReadExternalStorage(this);

        if (!canAccessFineLocation || !canAccessCoarseLocation || !canAccessCamera || !canAccessReadPhoneState
                || !canAccessReadExternalStorage) {

            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            final FrameLayout frameView = new FrameLayout(this);
            builder.setView(frameView);

            final AlertDialog alertDialog = builder.create();
            LayoutInflater inflater = alertDialog.getLayoutInflater();
            View dialoglayout = inflater.inflate(R.layout.warning, frameView);

            TextView warning_title = (TextView) dialoglayout.findViewById(R.id.warning_title);
            TextView warning_body = (TextView) dialoglayout.findViewById(R.id.warning_body);

            warning_title.setTypeface(magdacleanmonoRegular);
            warning_body.setTypeface(titilliumWebBold);

            Button button_ok = (Button) dialoglayout.findViewById(R.id.button_ok);
            Button button_close = (Button) dialoglayout.findViewById(R.id.button_close);
            button_ok.setTypeface(titilliumWebBold);
            button_close.setTypeface(titilliumWebBold);

            final Activity thisActivity = this;
            button_ok.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PreyLogger.d("askForPermission");
                    askForPermission();
                    alertDialog.dismiss();

                }
            });

            button_close.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    PreyLogger.d("close ask");

                    alertDialog.dismiss();
                }
            });

            alertDialog.show();
            showLocation = false;

        } else {
            showLocation = true;
        }

    } else {
        showLocation = true;
    }
    if (showLocation) {
        LocationManager mlocManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
        boolean isGpsEnabled = mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        boolean isNetworkEnabled = mlocManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        if (isGpsEnabled || isNetworkEnabled) {
            PreyLogger.d("isGpsEnabled || isNetworkEnabled");

        } else {
            PreyLogger.d("no gps ni red");
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            final AlertDialog alertDialog = builder.create();
            TextView textview = new TextView(this);
            textview.setText(getString(R.string.location_settings));
            textview.setMaxLines(10);
            textview.setTextSize(18F);
            textview.setPadding(20, 0, 20, 20);
            textview.setTextColor(Color.BLACK);
            builder.setView(textview);
            builder.setPositiveButton(getString(R.string.go_to_settings),
                    new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialoginterface, int i) {
                            dialoginterface.dismiss();
                            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                            startActivityForResult(intent, 0);
                            return;

                        }

                    });
            builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialoginterface, int i) {
                    dialoginterface.dismiss();
                }

            });
            builder.create().show();
        }
    }

}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

void startBuyFlow() {
    if (IAPService == null) {
        // TODO: res
        Toast.makeText(this, "Impossible de faire des achats sur un appareil non support par Google.",
                Toast.LENGTH_LONG).show();
        return;//from   ww  w  . j  a v  a  2 s .c  o m
    }

    try {
        Bundle buyIntentBundle = IAPService.getBuyIntent(3, getPackageName(), utils.SKU_DONATE, "inapp", null);
        int responseCode = (int) buyIntentBundle.get("RESPONSE_CODE");
        switch (responseCode) {
        case 0: // BILLING_RESPONSE_RESULT_OK
            PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
            try {
                if (pendingIntent != null) {
                    IntentSender sender = pendingIntent.getIntentSender();
                    startIntentSenderForResult(sender, PURCHASE_REQUEST_CODE, new Intent(), 0, 0, 0);
                }
            } catch (IntentSender.SendIntentException e) {
                Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT).show();
            }
            break;
        case 1: // BILLING_RESPONSE_RESULT_USER_CANCELED
            break;
        case 3: // BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 4: // BILLING_RESPONSE_RESULT_ITEM_UNAVAILABLE
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 5: // BILLING_RESPONSE_RESULT_DEVELOPER_ERROR
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 6: // BILLING_RESPONSE_RESULT_ERROR
            Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT);
            break;
        case 7: // BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED
            PrefUtils.setUserDonated(this, true);
            Toast.makeText(mContext, R.string.toast_purchase_thanks, Toast.LENGTH_LONG).show();
            mAdView.destroy();
            LinearLayout adLayout = (LinearLayout) findViewById(R.id.adLayout);
            adLayout.setVisibility(View.GONE);
            break;
        case 8: // BILLING_RESPONSE_RESULT_ITEM_NOT_OWNED
            break;
        }
    } catch (RemoteException e) {
        Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT).show();
    }
}

From source file:com.bringcommunications.etherpay.SendActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overlay_frame_layout = new FrameLayout(getApplicationContext());
    setContentView(overlay_frame_layout);
    ////from  www  . j a  va2  s . c  o m
    context = this;
    hex = new Hex();
    preferences = getSharedPreferences("etherpay.bringcommunications.com", MODE_PRIVATE);
    private_key = preferences.getString("key", private_key);
    acct_addr = preferences.getString("acct_addr", acct_addr);
    long wei_balance = preferences.getLong("balance", 0);
    eth_balance = (float) wei_balance / Util.WEI_PER_ETH;
    price = preferences.getFloat("price", price);
    show_gas = preferences.getBoolean("show_gas", show_gas);
    show_data = preferences.getBoolean("show_data", show_data);
    boolean denomination_eth = preferences.getBoolean("denomination_eth", true);
    System.out.println("denomination_eth is " + denomination_eth);
    denomination = denomination_eth ? Denomination.ETH : Denomination.FINNEY;
    auto_pay = getIntent().getStringExtra("AUTO_PAY");
    to_addr = getIntent().getStringExtra("TO_ADDR");
    String size_str = getIntent().getStringExtra("SIZE");
    eth_size = Float.valueOf(size_str);
    data = getIntent().getStringExtra("DATA");
    send_is_done = false;
    //
    View activity_send_view = getLayoutInflater().inflate(R.layout.activity_send, overlay_frame_layout, false);
    setContentView(activity_send_view);
    //
    Spinner dropdown = (Spinner) findViewById(R.id.denomination);
    String[] items = new String[] { "ETH", "Finney" };
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,
            items);
    dropdown.setSelection((denomination == Denomination.ETH) ? 0 : 1);
    dropdown.setOnItemSelectedListener(this);
    dropdown.setAdapter(adapter);
    //
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    String app_name = getResources().getString(R.string.app_name);
    toolbar.setTitle(app_name);
    toolbar.setSubtitle("Send Payment");
    toolbar.setBackgroundResource(R.color.color_toolbar);
    setSupportActionBar(toolbar);
    //
    TextView to_addr_view = (TextView) findViewById(R.id.to_addr);
    to_addr_view.setText(to_addr);
    //
    TextView size_view = (TextView) findViewById(R.id.size);
    size_str = (denomination == Denomination.ETH) ? String.format("%1.03f", eth_size)
            : String.format("%03d", (int) (eth_size * 1000 + 0.5));
    size_view.setText(size_str);
    //
    LinearLayout gas_layout = (LinearLayout) findViewById(R.id.gas_layout);
    TextView gas_prompt_view = (TextView) findViewById(R.id.gas_prompt);
    TextView gas_view = (TextView) findViewById(R.id.gas);
    ImageButton gas_help_view = (ImageButton) findViewById(R.id.gas_help);
    if (show_gas) {
        String gas_str = String.format("%7d", gas_limit);
        gas_view.setText(gas_str);
        gas_layout.setVisibility(View.VISIBLE);
        gas_prompt_view.setVisibility(View.VISIBLE);
        gas_help_view.setVisibility(View.VISIBLE);
        gas_view.setVisibility(View.VISIBLE);
    } else {
        gas_layout.setVisibility(View.GONE);
        gas_prompt_view.setVisibility(View.GONE);
        gas_help_view.setVisibility(View.GONE);
        gas_view.setVisibility(View.GONE);
    }

    LinearLayout data_layout = (LinearLayout) findViewById(R.id.data_layout);
    TextView data_prompt_view = (TextView) findViewById(R.id.data_prompt);
    TextView data_view = (TextView) findViewById(R.id.data);
    ImageButton data_help_view = (ImageButton) findViewById(R.id.data_help);
    if (show_data) {
        data_view.setText(data);
        data_layout.setVisibility(View.VISIBLE);
        data_prompt_view.setVisibility(View.VISIBLE);
        data_help_view.setVisibility(View.VISIBLE);
        data_view.setVisibility(View.VISIBLE);
    } else {
        data = "";
        data_layout.setVisibility(View.GONE);
        data_prompt_view.setVisibility(View.GONE);
        data_help_view.setVisibility(View.GONE);
        data_view.setVisibility(View.GONE);
    }

    //
    //sanity check
    if (to_addr.length() != 42) {
        this.finish();
    }
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case SETTINGS_REQUEST_CODE:
        AppWidgetManager man = AppWidgetManager.getInstance(this);
        if (man != null) {
            int[] ids = man.getAppWidgetIds(new ComponentName(mAppContext, HomeScreenWidgetProvider.class));
            Intent updateIntent = new Intent();
            updateIntent.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
            updateIntent.putExtra(HomeScreenWidgetProvider.WIDGET_IDS_KEY, ids);
            this.sendBroadcast(updateIntent);
        }/*from   ww  w .  j a va  2 s  .  c o m*/

        if (resultCode == RESULT_CONNECT_GOOGLE_CODE) {
            mTaskFragment.connectPlayServices(findViewById(VIEW_ID_POPUPS));
        }
        break;

    case PURCHASE_REQUEST_CODE:
        if (resultCode == RESULT_OK) {
            String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
            try {
                JSONObject jo = new JSONObject(purchaseData);
                String sku = jo.getString("productId");
                if (sku.equals(utils.SKU_DONATE)) {
                    PrefUtils.setUserDonated(this, true);
                    Toast.makeText(this, R.string.toast_purchase_thanks, Toast.LENGTH_LONG).show();
                    mAdView.destroy();
                    LinearLayout adLayout = (LinearLayout) findViewById(R.id.adLayout);
                    adLayout.setVisibility(View.GONE);
                }
            } catch (JSONException e) {
                Toast.makeText(mContext, R.string.error, Toast.LENGTH_SHORT).show();
            }
        }
        break;

    case BlindGameActivity.REQUEST_CODE:
        /*if (resultCode == RESULT_OK){
           selectItem(DrawerPosition.GAMES, data.getExtras());
        } else selectItem(DrawerPosition.GAMES, null);*/
        break;

    case 1001:
        if (resultCode == RESULT_OK) {
            mTaskFragment.connectPlayServices(findViewById(VIEW_ID_POPUPS));
        } else {
            PrefUtils.setRefusedGoogle(this, true);
        }
        break;
    }
}

From source file:de.da_sense.moses.client.AvailableFragment.java

/**
 * Controls what to do and what to show in case we get an empty APK list.
 *///  w w w. j  a v  a  2  s .co m
private void initControlsEmptyArrivedList() {
    if (isVisible()) {
        if (lastSetLayout != LayoutState.EMPTYLIST_HINT) {
            // show an empty list, because the list we got was empty
            LinearLayout emptylistCtrls = (LinearLayout) mActivity.findViewById(R.id.apklist_emptylistLayout);
            emptylistCtrls.setVisibility(View.VISIBLE);
            LinearLayout apkListCtrls = (LinearLayout) mActivity.findViewById(R.id.apklist_mainListLayout);
            apkListCtrls.setVisibility(View.GONE);

            // we don't need any buttons here
            Button actionBtn1 = (Button) mActivity.findViewById(R.id.apklist_emptylistActionBtn1);
            actionBtn1.setVisibility(View.GONE);

            // set last layout
            setLastSetLayout(LayoutState.EMPTYLIST_HINT);
        }
    }
}

From source file:com.metinkale.prayerapp.vakit.fragments.NotificationPrefs.java

private void initCuma(int switchId, int textId, int expandId, final Vakit vakit) {
    final SwitchCompat sw = (SwitchCompat) mView.findViewById(switchId);
    final LinearLayout expand = (LinearLayout) mView.findViewById(expandId);

    sw.setChecked(mTimes.isCumaActive());
    sw.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override//from w  w w . j  a v a  2 s . c o m
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            mTimes.setCumaActive(b);
            if (!b && expand.getVisibility() == View.VISIBLE) {
                expand.setVisibility(View.GONE);
            }

        }
    });

    View title = (View) mView.findViewById(textId).getParent();

    title.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            if (!BuildConfig.DEBUG) {
                return false;
            }
            mTestAlarm = true;
            Times.Alarm a = new Times.Alarm();
            a.time = System.currentTimeMillis() + (5 * 1000);
            a.city = mTimes.getID();
            a.cuma = true;
            a.vakit = vakit;
            AlarmReceiver.setAlarm(getActivity(), a);
            Toast.makeText(App.getContext(), "Will play within 5 seconds", Toast.LENGTH_LONG).show();
            return true;
        }
    });

    title.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (sw.isChecked()) {
                expand.setVisibility((expand.getVisibility() == View.VISIBLE) ? View.GONE : View.VISIBLE);
            } else {
                Toast.makeText(getActivity(), R.string.activateForMorePrefs, Toast.LENGTH_LONG).show();
            }
        }
    });

    PrefsView sound = (PrefsView) expand.findViewById(R.id.sound);
    sound.setPrefType(PrefsView.Pref.Sela);
    sound.setVakit(vakit);
    sound.setPrefFunctions(new PrefsView.PrefsFunctions() {
        @Override
        public Object getValue() {
            return mTimes.getCumaSound();
        }

        @Override
        public void setValue(Object obj) {
            mTimes.setCumaSound((String) obj);
        }
    });

    PrefsView vibr = (PrefsView) expand.findViewById(R.id.vibration);
    vibr.setPrefFunctions(new PrefsView.PrefsFunctions() {
        @Override
        public Object getValue() {
            return mTimes.hasCumaVibration();
        }

        @Override
        public void setValue(Object obj) {
            mTimes.setCumaVibration((boolean) obj);
        }
    });

    PrefsView silenter = (PrefsView) expand.findViewById(R.id.silenter);
    silenter.setPrefFunctions(new PrefsView.PrefsFunctions() {
        @Override
        public Object getValue() {
            return mTimes.getCumaSilenterDuration();
        }

        @Override
        public void setValue(Object obj) {
            mTimes.setCumaSilenterDuration((int) obj);
        }
    });

    PrefsView dua = (PrefsView) expand.findViewById(R.id.dua);
    dua.setVisibility(View.GONE);

    PrefsView time = (PrefsView) expand.findViewById(R.id.time);
    time.setPrefFunctions(new PrefsView.PrefsFunctions() {
        @Override
        public Object getValue() {
            return mTimes.getCumaTime();
        }

        @Override
        public void setValue(Object obj) {
            mTimes.setCumaTime((int) obj);
        }
    });
}

From source file:de.da_sense.moses.client.AvailableFragment.java

/**
 * Controls what to show and what to do when there is no connection.
 *///from  ww  w.ja  v  a 2s.  co  m
private void initControlsNoConnectivity() {
    /*
     * Following statements need to be executed regardless if we the last
     * layout state NO_CONNECTIVITY or not
     */
    LinearLayout apkListCtrls = (LinearLayout) mActivity.findViewById(R.id.apklist_mainListLayout);
    apkListCtrls.setVisibility(View.GONE);
    // display button to refresh and set action to perform
    final Button actionBtn1 = (Button) mActivity.findViewById(R.id.apklist_emptylistActionBtn1);
    final String tryToReconnectMessage = getString(R.string.retry);

    actionBtn1.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            refreshResfreshBtnTimeout(actionBtn1, tryToReconnectMessage, LayoutState.NO_CONNECTIVITY);
            requestExternalApplications();
        }
    });
    if (lastSetLayout != LayoutState.NO_CONNECTIVITY) {
        // no connection so show an empty list
        LinearLayout emptylistCtrls = (LinearLayout) mActivity.findViewById(R.id.apklist_emptylistLayout);
        emptylistCtrls.setVisibility(View.VISIBLE);

        // set hint that there is no connection
        TextView instructionView = (TextView) mActivity.findViewById(R.id.availableApkHeaderInstructions);
        instructionView.setText(R.string.apklist_hint_noconnectivity);

        // set the last layout
        setLastSetLayout(LayoutState.NO_CONNECTIVITY);

        refreshResfreshBtnTimeout(actionBtn1, tryToReconnectMessage, LayoutState.NO_CONNECTIVITY);
    }
}