Example usage for android.widget LinearLayout findViewById

List of usage examples for android.widget LinearLayout findViewById

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:com.cryart.sabbathschool.viewmodel.SSReadingViewModel.java

@Override
public void onSelectionStarted(float x, float y) {
    if (ssReadingActivityBinding != null) {
        LinearLayout view = ssReadingActivityBinding.ssReadingViewPager.findViewWithTag(
                "ssReadingView_" + ssReadingActivityBinding.ssReadingViewPager.getCurrentItem());
        NestedScrollView scrollView = view.findViewById(R.id.ss_reading_view_scroll);

        y = y - scrollView.getScrollY() + ssReadingActivityBinding.ssReadingViewPager.getTop();

        DisplayMetrics metrics = new DisplayMetrics();
        ((SSReadingActivity) context).getWindowManager().getDefaultDisplay().getMetrics(metrics);
        ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu
                .getLayoutParams();/*from w ww  .j a  v  a 2s  .c  om*/

        int contextMenuWidth = ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.getWidth();
        int contextMenuHeight = ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.getHeight();

        int screenWidth = metrics.widthPixels;
        int screenHeight = metrics.heightPixels;

        int margin = SSHelper.convertDpToPixels(context, 20);
        int jumpMargin = SSHelper.convertDpToPixels(context, 60);

        int contextMenuX = (int) x - (contextMenuWidth / 2);
        int contextMenuY = scrollView.getTop() + (int) y - contextMenuHeight - margin;

        if (contextMenuX - margin < 0) {
            contextMenuX = margin;
        }

        if (contextMenuX + contextMenuWidth + margin > screenWidth) {
            contextMenuX = screenWidth - margin - contextMenuWidth;
        }

        if (contextMenuY - margin < 0) {
            contextMenuY = contextMenuY + contextMenuHeight + jumpMargin;
        }

        params.setMargins(contextMenuX, contextMenuY, 0, 0);
        ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.setLayoutParams(params);
        ssReadingActivityBinding.ssContextMenu.ssReadingContextMenu.setVisibility(View.VISIBLE);
        highlightId = 0;
    }
}

From source file:com.ridhofkr.hanacaraka.LetterCardActivity.java

private void applyRotation(float start, float end, LinearLayout front, LinearLayout back, boolean flag) {
    final float centerX = front.getWidth() / 2.0f;
    final float centerY = front.getHeight() / 2.0f;

    final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, centerX, centerY, 310.0f, true);
    rotation.setDuration(300);/*from w  w  w  .ja  va  2  s .  c  o m*/
    rotation.setFillAfter(true);
    rotation.setInterpolator(new AccelerateInterpolator());
    rotation.setAnimationListener(new DisplayNextView(flag, front, back));

    LinearLayout inside = (LinearLayout) back.findViewById(R.id.backcardinside);
    if (flag) {
        String text = ((String) ((TextView) front.findViewById(R.id.cardinfotitle)).getText());
        front.startAnimation(rotation);
        removeSoundListener(front);
        inside.addView(ctrl.playAnimation(LetterCardActivity.this, text, category));
    } else {
        back.startAnimation(rotation);
        addSoundListener(front);
        inside.removeViewAt(2);
    }
}

From source file:org.matrix.console.activity.SettingsActivity.java

@Override
protected void onResume() {
    super.onResume();

    MyPresenceManager.advertiseAllOnline();

    for (MXSession session : Matrix.getMXSessions(this)) {
        final MyUser myUser = session.getMyUser();
        final MXSession fSession = session;

        final LinearLayout linearLayout = mLinearLayoutByMatrixId.get(fSession.getCredentials().userId);

        final View refreshingView = linearLayout.findViewById(R.id.profile_mask);
        refreshingView.setVisibility(View.VISIBLE);

        session.getProfileApiClient().displayname(myUser.userId, new SimpleApiCallback<String>(this) {
            @Override//from   w  ww.ja  v a  2 s. com
            public void onSuccess(String displayname) {

                if ((null != displayname) && !displayname.equals(myUser.displayname)) {
                    myUser.displayname = displayname;
                    EditText displayNameEditText = (EditText) linearLayout
                            .findViewById(R.id.editText_displayName);
                    displayNameEditText.setText(myUser.displayname);
                }

                if (fSession.isActive()) {
                    fSession.getProfileApiClient().avatarUrl(myUser.userId,
                            new SimpleApiCallback<String>(this) {
                                @Override
                                public void onSuccess(String avatarUrl) {
                                    if ((null != avatarUrl) && !avatarUrl.equals(myUser.getAvatarUrl())) {
                                        mTmpThumbnailUriByMatrixId.remove(fSession.getCredentials().userId);

                                        myUser.setAvatarUrl(avatarUrl);
                                        refreshProfileThumbnail(fSession, linearLayout);
                                    }

                                    refreshingView.setVisibility(View.GONE);
                                }
                            });
                }
            }
        });
    }

    // refresh the cache size
    Button clearCacheButton = (Button) findViewById(R.id.button_clear_cache);
    clearCacheButton.setText(getString(R.string.clear_cache) + " (" + computeApplicationCacheSize() + ")");

    refreshGCMEntries();
}

From source file:app.sunstreak.yourpisd.LoginActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login_new);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    if (toolbar != null) {
        setSupportActionBar(toolbar);/*w  ww. j  a  v  a2 s . co  m*/
    }
    final SharedPreferences sharedPrefs = getPreferences(Context.MODE_PRIVATE);
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    height = size.y;
    mLoginFormView = findViewById(R.id.login_form);
    mLoginStatusView = (LinearLayout) findViewById(R.id.login_status);
    mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);

    if (DateHelper.isAprilFools()) {
        LinearLayout container = (LinearLayout) mLoginFormView.findViewById(R.id.container);
        ImageView logo = (ImageView) container.findViewById(R.id.logo);
        InputStream is;
        try {
            is = getAssets().open("doge.png");
            logo.setImageBitmap(BitmapFactory.decodeStream(is));
            is.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    mAutoLogin = sharedPrefs.getBoolean("auto_login", false);
    System.out.println(mAutoLogin);

    session = ((YPApplication) getApplication()).session;

    try {
        boolean refresh = getIntent().getExtras().getBoolean("Refresh");

        if (refresh) {
            mEmail = session.getUsername();
            mPassword = session.getPassword();
            showProgress(true);
            mAuthTask = new UserLoginTask();
            mAuthTask.execute((Void) null);

            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0);
        } else
            mLoginFormView.setVisibility(View.VISIBLE);
    } catch (NullPointerException e) {
        // Keep going.
    }

    if (sharedPrefs.getBoolean("patched", false)) {
        SharedPreferences.Editor editor = sharedPrefs.edit();
        editor.remove("password");
        editor.putBoolean("patched", true);
        editor.commit();
    }

    if (!sharedPrefs.getBoolean("AcceptedUserAgreement", false)) {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(getResources().getString(R.string.user_agreement_title));
        builder.setMessage(getResources().getString(R.string.user_agreement));
        // Setting Positive "Yes" Button
        builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                sharedPrefs.edit().putBoolean("AcceptedUserAgreement", true).commit();
                dialog.cancel();
            }
        });

        // Setting Negative "NO" Button
        builder.setNegativeButton("Disagree", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // Write your code here to invoke NO event
                sharedPrefs.edit().putBoolean("AcceptedUserAgreement", false).commit();
                Toast.makeText(LoginActivity.this, "Quitting app", Toast.LENGTH_SHORT).show();
                finish();
            }
        });

        AlertDialog alertDialog = builder.create();
        alertDialog.show();
    }

    // Set up the remember_password CheckBox
    mRememberPasswordCheckBox = (CheckBox) findViewById(R.id.remember_password);
    mRememberPasswordCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mRememberPassword = isChecked;
        }
    });

    mRememberPassword = sharedPrefs.getBoolean("remember_password", false);
    mRememberPasswordCheckBox.setChecked(mRememberPassword);

    // Set up the auto_login CheckBox
    mAutoLoginCheckBox = (CheckBox) findViewById(R.id.auto_login);
    mAutoLoginCheckBox.setChecked(mAutoLogin);
    mAutoLoginCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton button, boolean isChecked) {
            mAutoLogin = isChecked;
            if (isChecked) {
                mRememberPasswordCheckBox.setChecked(true);
            }
        }

    });

    // Set up the login form.
    mEmailView = (EditText) findViewById(R.id.email);

    mPasswordView = (EditText) findViewById(R.id.password);
    mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });

    //Load stored username/password
    mEmailView.setText(sharedPrefs.getString("email", mEmail));
    mPasswordView.setText(new String(Base64.decode(sharedPrefs.getString("e_password", ""), Base64.DEFAULT)));
    // If the password was not saved, give focus to the password.
    if (mPasswordView.getText().equals(""))
        mPasswordView.requestFocus();

    mLoginFormView = findViewById(R.id.login_form);
    mLoginStatusView = (LinearLayout) findViewById(R.id.login_status);
    mLoginStatusMessageView = (TextView) findViewById(R.id.login_status_message);

    findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            attemptLogin();
        }
    });
    findViewById(R.id.sign_in_button).setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mPasswordView.getWindowToken(), 0);
            return false;
        }
    });
    mLoginFormView.setVisibility(View.VISIBLE);
    // Login if auto-login is checked.
    if (mAutoLogin)
        attemptLogin();
}

From source file:com.cw.litenote.tabs.TabsHost.java

@Override
public void onTabSelected(TabLayout.Tab tab) {
    System.out.println("TabsHost / _onTabSelected: " + tab.getPosition());

    setFocus_tabPos(tab.getPosition());/*from   www. j a va  2  s  .  c o m*/

    // keep focus view page table Id
    int pageTableId = mTabsPagerAdapter.dbFolder.getPageTableId(getFocus_tabPos(), true);
    Pref.setPref_focusView_page_tableId(MainAct.mAct, pageTableId);

    // current page table Id
    mFocusPageTableId = pageTableId;

    // refresh list view of selected page
    Page_recycler page = mTabsPagerAdapter.fragmentList.get(getFocus_tabPos());
    if ((tab.getPosition() == audioPlayTabPos) && (page != null) && (page.itemAdapter != null)) {
        RecyclerView listView = page.recyclerView;
        if ((audioPlayer_page != null) && !isDoingMarking && (listView != null)
                && (Audio_manager.getPlayerState() != Audio_manager.PLAYER_AT_STOP)) {
            audioPlayer_page.scrollHighlightAudioItemToVisible(listView);
        }
    }

    // add for update page item view
    if ((page != null) && (page.itemAdapter != null)) {
        page.itemAdapter.notifyDataSetChanged();
        System.out.println("TabsHost / _onTabSelected / notifyDataSetChanged ");
    } else
        System.out.println("TabsHost / _onTabSelected / not notifyDataSetChanged ");

    // set tab audio icon when audio playing
    if ((MainAct.mPlaying_folderPos == FolderUi.getFocus_folderPos())
            && (Audio_manager.getPlayerState() != Audio_manager.PLAYER_AT_STOP)
            && (tab.getPosition() == audioPlayTabPos)) {
        if (tab.getCustomView() == null) {
            LinearLayout tabLinearLayout = (LinearLayout) MainAct.mAct.getLayoutInflater()
                    .inflate(R.layout.tab_custom, null);
            TextView title = (TextView) tabLinearLayout.findViewById(R.id.tabTitle);
            title.setText(mTabsPagerAdapter.dbFolder.getPageTitle(tab.getPosition(), true));
            title.setTextColor(MainAct.mAct.getResources().getColor(R.color.colorWhite));
            title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_audio, 0, 0, 0);
            tab.setCustomView(title);
        }
    } else
        tab.setCustomView(null);

    // call onCreateOptionsMenu
    MainAct.mAct.invalidateOptionsMenu();

    // set text color
    mTabLayout.setTabTextColors(ContextCompat.getColor(MainAct.mAct, R.color.colorGray), //normal
            ContextCompat.getColor(MainAct.mAct, R.color.colorWhite) //selected
    );

    // set long click listener
    setLongClickListener();

    TabsHost.showFooter(MainAct.mAct);

    isDoingMarking = false;
}

From source file:project.pamela.slambench.fragments.TemperaturePlot.java

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

    // Replace LinearLayout by the type of the root element of the layout you're trying to load
    LinearLayout llLayout = (LinearLayout) inflater.inflate(R.layout.fragment_plot, container, false);

    // Retrieve bench number
    Intent mIntent = super.getActivity().getIntent();
    final int intValue = mIntent.getIntExtra(ResultActivity.SELECTED_TEST_TAG, 0);
    SLAMResult value = SLAMBenchApplication.getResults().get(intValue);

    if (!value.isFinished()) {
        Log.e(SLAMBenchApplication.LOG_TAG,
                this.getResources().getString(R.string.debug_proposed_value_not_valid));
        return llLayout;
    }// w w w.  j a  v a  2  s . com

    // initialize our XYPlot reference:
    XYPlot plot = (XYPlot) llLayout.findViewById(R.id.mySimpleXYPlot);

    plot.setBackgroundColor(Color.WHITE);
    plot.setTitle(value.test.name);
    plot.setDomainLabel(this.getResources().getString(R.string.legend_frame_number));
    plot.setRangeLabel(this.getResources().getString(R.string.legend_degrees));
    plot.setBackgroundColor(Color.WHITE);
    plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);
    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.WHITE);

    plot.getGraphWidget().getDomainLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeLabelPaint().setColor(Color.BLACK);

    plot.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.BLACK);
    plot.getGraphWidget().getDomainOriginLinePaint().setColor(Color.BLACK);
    plot.getGraphWidget().getRangeOriginLinePaint().setColor(Color.BLACK);

    plot.getGraphWidget().setRangeValueFormat(new DecimalFormat("#####.##"));

    int border = 60;
    int legendsize = 110;

    plot.getGraphWidget().position(border, XLayoutStyle.ABSOLUTE_FROM_LEFT, border,
            YLayoutStyle.ABSOLUTE_FROM_BOTTOM, AnchorPosition.LEFT_BOTTOM);
    plot.getGraphWidget()
            .setSize(new SizeMetrics(border + legendsize, SizeLayoutType.FILL, border, SizeLayoutType.FILL));

    // reduce the number of range labels
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 10);
    plot.setDomainValueFormat(new DecimalFormat("#"));
    plot.setRangeStep(XYStepMode.SUBDIVIDE, 10);

    //Remove legend
    //plot.getLayoutManager().remove(plot.getLegendWidget());
    //plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    //plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());

    // Set legend
    plot.getLegendWidget().setTableModel(new DynamicTableModel(4, 2));

    Paint bgPaint = new Paint();
    bgPaint.setColor(Color.BLACK);
    bgPaint.setStyle(Paint.Style.FILL);
    bgPaint.setAlpha(140);

    plot.getLegendWidget().setBackgroundPaint(bgPaint);

    plot.getLegendWidget()
            .setSize(new SizeMetrics(legendsize, SizeLayoutType.ABSOLUTE, 0, SizeLayoutType.FILL));

    plot.getLegendWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_RIGHT, 0, YLayoutStyle.ABSOLUTE_FROM_TOP,
            AnchorPosition.RIGHT_TOP);

    plot.getDomainLabelWidget().position(0, XLayoutStyle.ABSOLUTE_FROM_CENTER, 0,
            YLayoutStyle.RELATIVE_TO_BOTTOM, AnchorPosition.BOTTOM_MIDDLE);

    int strokecolor = Color.rgb(67, 137, 192);
    int fillcolor = Color.rgb(213, 229, 255);

    Double temperatureNumbers[] = value.gettemperatureList();
    XYSeries series = new SimpleXYSeries(Arrays.asList(temperatureNumbers),
            SimpleXYSeries.ArrayFormat.Y_VALS_ONLY, this.getResources().getString(R.string.legend_degrees));
    LineAndPointFormatter seriesFormat = new LineAndPointFormatter(strokecolor, strokecolor, null, null);

    Paint lineFill = new Paint();
    lineFill.setAlpha(200);
    DisplayMetrics metrics = new DisplayMetrics();
    super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    lineFill.setShader(
            new LinearGradient(0, 0, 0, metrics.heightPixels, Color.WHITE, fillcolor, Shader.TileMode.MIRROR));
    seriesFormat.setPointLabeler(new PointLabeler() {
        @Override
        public String getLabel(XYSeries series, int index) {
            return "o";
        }
    });
    seriesFormat.setFillPaint(lineFill);
    plot.addSeries(series, seriesFormat);

    plot.redraw();

    plot.calculateMinMaxVals();
    PointF minXY = new PointF(plot.getCalculatedMinX().floatValue(), plot.getCalculatedMinY().floatValue());
    PointF maxXY = new PointF(plot.getCalculatedMaxX().floatValue(), plot.getCalculatedMaxY().floatValue());

    plot.setDomainBoundaries(0, value.test.dataset.getFrameCount() - 1, BoundaryMode.FIXED);
    plot.setRangeBoundaries(Math.min(0, minXY.y), maxXY.y * 1.2f, BoundaryMode.FIXED);

    plot.redraw();

    return llLayout;
}

From source file:com.haedrian.curo.HomeScreen.Contacts.ContactDetailFragment.java

/**
 * Builds an address LinearLayout based on address information from the Contacts Provider.
 * Each address for the contact gets its own LinearLayout object; for example, if the contact
 * has three postal addresses, then 3 LinearLayouts are generated.
 *
 * @param addressType From/*from  w w w  .  j  a  v  a 2s . c o  m*/
 * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#TYPE}
 * @param addressTypeLabel From
 * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#LABEL}
 * @param address From
 * {@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#FORMATTED_ADDRESS}
 * @return A LinearLayout to add to the contact details layout,
 *         populated with the provided address details.
 */
private LinearLayout buildAddressLayout(int addressType, String addressTypeLabel, final String address) {

    // Inflates the address layout
    final LinearLayout addressLayout = (LinearLayout) LayoutInflater.from(getActivity())
            .inflate(R.layout.item_contact_detail, mDetailsLayout, false);

    // Gets handles to the view objects in the layout
    final TextView headerTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_header);
    final TextView addressTextView = (TextView) addressLayout.findViewById(R.id.contact_detail_item);

    // If there's no addresses for the contact, shows the empty view and message, and hides the
    // header and button.
    if (addressTypeLabel == null && addressType == 0) {
        headerTextView.setVisibility(View.GONE);
        addressTextView.setText(R.string.no_address);
    } else {
        // Gets postal address label type
        CharSequence label = StructuredPostal.getTypeLabel(getResources(), addressType, addressTypeLabel);

        // Sets TextView objects in the layout
        headerTextView.setText(label);
        addressTextView.setText(address);

    }
    return addressLayout;
}

From source file:im.vector.activity.SettingsActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUEST_IMAGE) {
        if (resultCode == RESULT_OK) {

            this.runOnUiThread(new Runnable() {
                @Override/*  www  . j av  a2  s .c o m*/
                public void run() {
                    final LinearLayout linearLayout = mLinearLayoutBySession.get(mUpdatingSession);
                    ImageView avatarView = (ImageView) linearLayout.findViewById(R.id.imageView_avatar);

                    Uri imageUri = data.getData();
                    Bitmap thumbnailBitmap = null;
                    Uri scaledImageUri = data.getData();

                    try {
                        ResourceUtils.Resource resource = ResourceUtils.openResource(SettingsActivity.this,
                                imageUri);

                        // with jpg files
                        // check exif parameter and reduce image size
                        if ("image/jpg".equals(resource.mimeType) || "image/jpeg".equals(resource.mimeType)) {
                            InputStream stream = resource.contentStream;
                            int rotationAngle = ImageUtils.getRotationAngleForBitmap(SettingsActivity.this,
                                    imageUri);

                            String mediaUrl = ImageUtils.scaleAndRotateImage(SettingsActivity.this, stream,
                                    resource.mimeType, 1024, rotationAngle, SettingsActivity.this.mMediasCache);
                            scaledImageUri = Uri.parse(mediaUrl);
                        } else {
                            ContentResolver resolver = getContentResolver();

                            List uriPath = imageUri.getPathSegments();
                            long imageId = -1;
                            String lastSegment = (String) uriPath.get(uriPath.size() - 1);

                            // > Kitkat
                            if (lastSegment.startsWith("image:")) {
                                lastSegment = lastSegment.substring("image:".length());
                            }

                            imageId = Long.parseLong(lastSegment);
                            thumbnailBitmap = MediaStore.Images.Thumbnails.getThumbnail(resolver, imageId,
                                    MediaStore.Images.Thumbnails.MINI_KIND, null);
                        }

                        resource.contentStream.close();

                    } catch (Exception e) {
                        Log.e(LOG_TAG, "MediaStore.Images.Thumbnails.getThumbnail " + e.getMessage());
                    }

                    if (null != thumbnailBitmap) {
                        avatarView.setImageBitmap(thumbnailBitmap);
                    } else {
                        avatarView.setImageURI(scaledImageUri);
                    }

                    mTmpThumbnailUriBySession.put(mUpdatingSession, scaledImageUri);

                    final Button saveButton = (Button) linearLayout.findViewById(R.id.button_save);
                    saveButton.setEnabled(true); // Enable the save button if it wasn't already
                }
            });
        }

        mUpdatingSession = null;
    }
}

From source file:com.cw.litenote.tabs.TabsHost.java

@Override
public void onResume() {
    super.onResume();
    // default// w  w  w  .ja v  a 2s .  c om
    setFocus_tabPos(0);

    if (Drawer.getFolderCount() == 0)
        return;//todo Check again

    // restore focus view page
    int pageCount = mTabsPagerAdapter.dbFolder.getPagesCount(true);
    for (int i = 0; i < pageCount; i++) {
        int pageTableId = mTabsPagerAdapter.dbFolder.getPageTableId(i, true);

        if (pageTableId == Pref.getPref_focusView_page_tableId(MainAct.mAct)) {
            setFocus_tabPos(i);
            mFocusPageTableId = pageTableId;
        }
    }

    System.out.println("TabsHost / _onResume / _getFocus_tabPos = " + getFocus_tabPos());

    // auto scroll to show focus tab
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            if (mTabLayout.getTabAt(getFocus_tabPos()) != null)
                mTabLayout.getTabAt(getFocus_tabPos()).select();
        }
    }, 100);

    // set audio icon after Key Protect
    TabLayout.Tab tab = mTabLayout.getTabAt(audioPlayTabPos);
    if (tab != null) {
        if ((MainAct.mPlaying_folderPos == FolderUi.getFocus_folderPos())
                && (Audio_manager.getPlayerState() != Audio_manager.PLAYER_AT_STOP)
                && (tab.getPosition() == audioPlayTabPos)) {
            if (tab.getCustomView() == null) {
                LinearLayout tabLinearLayout = (LinearLayout) MainAct.mAct.getLayoutInflater()
                        .inflate(R.layout.tab_custom, null);
                TextView title = (TextView) tabLinearLayout.findViewById(R.id.tabTitle);
                title.setText(mTabsPagerAdapter.dbFolder.getPageTitle(tab.getPosition(), true));
                title.setTextColor(MainAct.mAct.getResources().getColor(R.color.colorWhite));
                title.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_audio, 0, 0, 0);
                tab.setCustomView(title);
            }
        } else
            tab.setCustomView(null);
    }

    // for incoming phone call case or after Key Protect
    if ((audioUi_page != null) && (Audio_manager.getPlayerState() != Audio_manager.PLAYER_AT_STOP)
            && (Audio_manager.getAudioPlayMode() == Audio_manager.PAGE_PLAY_MODE)) {
        audioUi_page.initAudioBlock(MainAct.mAct);

        audioPlayer_page.page_runnable.run();//todo Why exception when adding new text?

        //todo Why dose this panel disappear?
        UtilAudio.updateAudioPanel(audioUi_page.audioPanel_play_button,
                audioUi_page.audio_panel_title_textView);
    }

    // set long click listener
    setLongClickListener();
}

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

/**
 * Adds a form with all its questions to the ScrollView so that it is visible to the user.
 * //from   w  ww . j a va  2  s.c  om
 * @param form the form to be displayed
 * @param ll the contained of the scrollview
 */
private void addFormToLayout(Form form, LinearLayout scrollViewContainer) {

    LinearLayout linearLayoutInsideAScrollView = (LinearLayout) scrollViewContainer.findViewById(R.id.ll_quest);

    List<Question> questions = form.getQuestions();
    Collections.sort(questions);

    // Check if there is at least a question to display
    if (questions.size() > 0) {

        for (int i = 0; i < questions.size(); i++) {
            Question question = questions.get(i);
            switch (questions.get(i).getType()) {
            case (Question.TYPE_SINGLE_CHOICE): {
                makeSingleChoice(questions.get(i), linearLayoutInsideAScrollView, i + 1);
                break;
            }
            case (Question.TYPE_MULTIPLE_CHOICE): {
                makeMultipleChoice(questions.get(i), linearLayoutInsideAScrollView, i + 1);
                break;
            }
            case (Question.TYPE_TEXT_QUESTION): {
                makeTextQuestion(questions.get(i), linearLayoutInsideAScrollView, i + 1);
                break;
            }
            case (Question.TYPE_LIKERT_SCALE): {
                makeSingleChoice(question, linearLayoutInsideAScrollView, i + 1);
                break;
            }
            case (Question.TYPE_YES_NO_QUESTION): {
                makeSingleChoice(question, linearLayoutInsideAScrollView, i + 1);
                break;
            }
            default:
                break;
            }
        }
    } else {
        Log.w(LOG_TAG, "No Questions found in form[" + mFormID + "]");
    }

}