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.dm.wallpaper.board.activities.WallpaperBoardActivity.java

@Override
public void onWallpapersChecked(@Nullable Intent intent) {
    if (intent != null) {
        String packageName = intent.getStringExtra("packageName");
        LogUtil.d("Broadcast received from service with packageName: " + packageName);

        if (packageName == null)
            return;

        if (!packageName.equals(getPackageName())) {
            LogUtil.d("Received broadcast from different packageName, expected: " + getPackageName());
            return;
        }/*from  w ww.  j  a  va  2s . co m*/

        int size = intent.getIntExtra(Extras.EXTRA_SIZE, 0);
        int offlineSize = Database.get(this).getWallpapersCount();
        Preferences.get(this).setAvailableWallpapersCount(size);

        if (size > offlineSize) {
            int accent = ColorHelper.getAttributeColor(this, R.attr.colorAccent);
            LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(0).getActionView();
            if (container != null) {
                TextView counter = (TextView) container.findViewById(R.id.counter);
                if (counter == null)
                    return;

                ViewCompat.setBackground(counter,
                        DrawableHelper.getTintedDrawable(this, R.drawable.ic_toolbar_circle, accent));
                counter.setTextColor(ColorHelper.getTitleTextColor(accent));
                int newItem = (size - offlineSize);
                counter.setText(String.valueOf(newItem > 99 ? "99+" : newItem));
                container.setVisibility(View.VISIBLE);

                if (mFragmentTag.equals(Extras.TAG_WALLPAPERS)) {
                    WallpapersFragment fragment = (WallpapersFragment) mFragManager
                            .findFragmentByTag(Extras.TAG_WALLPAPERS);
                    if (fragment != null)
                        fragment.showPopupBubble();
                }
                return;
            }
        }
    }

    LinearLayout container = (LinearLayout) mNavigationView.getMenu().getItem(0).getActionView();
    if (container != null)
        container.setVisibility(View.GONE);
}

From source file:com.cloudTop.starshare.ui.wangyi.common.ui.viewpager.PagerSlidingTabStrip.java

public void updateTab(int index, ReminderItem item) {
    LinearLayout tabView = (LinearLayout) tabsContainer.getChildAt(index);
    ImageView indicatorView = (ImageView) tabView.findViewById(R.id.tab_new_indicator);
    final DropFake unreadTV = ((DropFake) tabView.findViewById(R.id.tab_new_msg_label));

    if (item == null || unreadTV == null || indicatorView == null) {
        unreadTV.setVisibility(View.GONE);
        indicatorView.setVisibility(View.GONE);
        return;/*from  w ww  . ja va2  s  .c  om*/
    }
    int unread = item.unread();
    boolean indicator = item.indicator();
    unreadTV.setVisibility(unread > 0 ? View.VISIBLE : View.GONE);
    indicatorView.setVisibility(indicator ? View.VISIBLE : View.GONE);
    if (unread > 0) {
        unreadTV.setText(String.valueOf(ReminderSettings.unreadMessageShowRule(unread)));
    }
}

From source file:eu.power_switch.gui.adapter.RoomRecyclerViewAdapter.java

private void updateReceiverViews(final RoomRecyclerViewAdapter.ViewHolder holder, final Room room) {
    String inflaterString = Context.LAYOUT_INFLATER_SERVICE;
    LayoutInflater inflater = (LayoutInflater) fragmentActivity.getSystemService(inflaterString);

    // clear previous items
    holder.linearLayoutOfReceivers.removeAllViews();
    // add items//w  w w .j  a  v a  2 s.com
    for (final Receiver receiver : room.getReceivers()) {
        // create a new receiverRow for our current receiver and add it to
        // our table of all devices of our current room
        // the row will contain the device name and all buttons

        LinearLayout receiverLayout = (LinearLayout) inflater.inflate(R.layout.list_item_receiver,
                holder.linearLayoutOfReceivers, false);
        receiverLayout.setOrientation(LinearLayout.HORIZONTAL);
        holder.linearLayoutOfReceivers.addView(receiverLayout);

        // setup TextView to display device name
        TextView receiverName = (TextView) receiverLayout.findViewById(R.id.txt_name);
        receiverName.setText(receiver.getName());
        receiverName.setTextSize(18);

        TableLayout buttonLayout = (TableLayout) receiverLayout.findViewById(R.id.buttonLayout);
        int buttonsPerRow;
        if (receiver.getButtons().size() % 3 == 0) {
            buttonsPerRow = 3;
        } else {
            buttonsPerRow = 2;
        }

        int i = 0;
        final ArrayList<android.widget.Button> buttonViews = new ArrayList<>();
        long lastActivatedButtonId = receiver.getLastActivatedButtonId();
        TableRow buttonRow = null;
        for (final Button button : receiver.getButtons()) {
            final android.widget.Button buttonView = (android.widget.Button) inflater
                    .inflate(R.layout.simple_button, buttonRow, false);
            final ColorStateList defaultTextColor = buttonView.getTextColors(); //save original colors
            buttonViews.add(buttonView);
            buttonView.setText(button.getName());
            final int accentColor = ThemeHelper.getThemeAttrColor(fragmentActivity, R.attr.colorAccent);
            if (SmartphonePreferencesHandler.getHighlightLastActivatedButton() && lastActivatedButtonId != -1
                    && button.getId() == lastActivatedButtonId) {
                buttonView.setTextColor(accentColor);
            }
            buttonView.setOnClickListener(new android.widget.Button.OnClickListener() {

                @Override
                public void onClick(final View v) {
                    if (SmartphonePreferencesHandler.getVibrateOnButtonPress()) {
                        VibrationHandler.vibrate(fragmentActivity,
                                SmartphonePreferencesHandler.getVibrationDuration());
                    }

                    new AsyncTask<Void, Void, Void>() {
                        @Override
                        protected Void doInBackground(Void... params) {
                            // send signal
                            ActionHandler.execute(fragmentActivity, receiver, button);
                            return null;
                        }

                        @Override
                        protected void onPostExecute(Void aVoid) {
                            if (SmartphonePreferencesHandler.getHighlightLastActivatedButton()) {
                                for (android.widget.Button button : buttonViews) {
                                    if (button != v) {
                                        button.setTextColor(defaultTextColor);
                                    } else {
                                        button.setTextColor(accentColor);
                                    }
                                }
                            }
                        }
                    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                }
            });

            if (i == 0 || i % buttonsPerRow == 0) {
                buttonRow = new TableRow(fragmentActivity);
                buttonRow.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                        LinearLayout.LayoutParams.MATCH_PARENT));
                buttonRow.addView(buttonView);
                buttonLayout.addView(buttonRow);
            } else {
                buttonRow.addView(buttonView);
            }

            i++;
        }

        receiverLayout.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                ConfigureReceiverDialog configureReceiverDialog = ConfigureReceiverDialog
                        .newInstance(receiver.getId());
                configureReceiverDialog.setTargetFragment(recyclerViewFragment, 0);
                configureReceiverDialog.show(fragmentActivity.getSupportFragmentManager(), null);
                return true;
            }
        });
    }
}

From source file:org.ambient.control.config.EditConfigFragment.java

private void addFieldToView(LayoutInflater inflater, final Object config, LinearLayout content,
        final Field field)
        throws IllegalAccessException, ClassNotFoundException, java.lang.InstantiationException {

    LinearLayout fieldView = (LinearLayout) inflater.inflate(R.layout.layout_editconfig_entry, null);
    content.addView(fieldView);//  w ww.j  a v  a2  s . co m

    TextView title = (TextView) fieldView.findViewById(R.id.textViewTitleOfMap);
    title.setText(field.getName());

    if (field.getAnnotation(Presentation.class) != null
            && field.getAnnotation(Presentation.class).name().isEmpty() == false) {
        title.setText((field.getAnnotation(Presentation.class).name()));

        final String description = (field.getAnnotation(Presentation.class)).description();
        if (description.isEmpty() == false) {

            // add a help button with the description of this field to title
            fieldView.findViewById(R.id.imageViewEditEntryHelp).setVisibility(View.VISIBLE);
            LinearLayout header = (LinearLayout) fieldView.findViewById(R.id.linearLayoutConfigEntryHeader);
            header.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                    builder.setTitle("Hilfe").setMessage(description).setPositiveButton("OK", null).create()
                            .show();
                }
            });
        }
    }

    // draw concrete view elements for each supported field type
    LinearLayout contentArea = (LinearLayout) fieldView.findViewById(R.id.linearLayoutConfigEntryContent);
    TypeDef typedef = field.getAnnotation(TypeDef.class);

    if (typedef.fieldType().equals(FieldType.EXPRESSION)) {
        new ExpressionField(roomConfig, config, field, this, contentArea).createView();
    }

    if (typedef.fieldType().equals(FieldType.BEAN)) {
        new BeanField(roomConfig, config, field, this, contentArea).createView(selectedRoom);
    }

    if (typedef.fieldType().equals(FieldType.BEAN_SELECTION)) {
        new BeanSelectionField(roomConfig, config, field, this, contentArea).createView();
    }

    if (typedef.fieldType().equals(FieldType.STRING)) {
        new StringField(roomConfig, config, field, this, contentArea).createView();
    }

    if (typedef.fieldType().equals(FieldType.BOOLEAN)) {
        new BooleanField(roomConfig, config, field, this, contentArea).createView();
    }

    if (typedef.fieldType().equals(FieldType.COLOR)) {
        new ColorField(roomConfig, config, field, this, contentArea).createView();
    }

    if (typedef.fieldType().equals(FieldType.NUMERIC)) {
        new NumericField(roomConfig, config, field, this, contentArea).createView(typedef);
    }

    if (typedef.fieldType().equals(FieldType.MAP)) {
        new MapField(roomConfig, config, field, this, contentArea).createView(selectedRoom);
    }

    if (typedef.fieldType().equals(FieldType.SELECTION_LIST)) {
        new SelectionListField(roomConfig, config, field, this, contentArea).createView();
    }

    if (typedef.fieldType().equals(FieldType.SIMPLE_LIST)) {
        new SimpleListField(roomConfig, config, field, this, contentArea).createView(selectedRoom);
    }
}

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

void refreshProfileThumbnail(MXSession session, LinearLayout baseLayout) {
    ImageView avatarView = (ImageView) baseLayout.findViewById(R.id.imageView_avatar);
    Uri newAvatarUri = mTmpThumbnailUriBySession.get(session);
    String avatarUrl = session.getMyUser().avatarUrl;

    if (null != newAvatarUri) {
        avatarView.setImageURI(newAvatarUri);
    } else if (avatarUrl == null) {
        avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light);
    } else {/*from   ww  w . j ava  2 s .c o m*/
        int size = getResources().getDimensionPixelSize(R.dimen.profile_avatar_size);
        mMediasCache.loadAvatarThumbnail(avatarView, avatarUrl, size);
    }
}

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

void refreshProfileThumbnail(MXSession session, LinearLayout baseLayout) {
    ImageView avatarView = (ImageView) baseLayout.findViewById(R.id.imageView_avatar);
    Uri newAvatarUri = mTmpThumbnailUriByMatrixId.get(session.getCredentials().userId);
    String avatarUrl = session.getMyUser().getAvatarUrl();

    if (null != newAvatarUri) {
        avatarView.setImageURI(newAvatarUri);
    } else if (avatarUrl == null) {
        avatarView.setImageResource(R.drawable.ic_contact_picture_holo_light);
    } else {//  w  w  w  . j a  v a2s  . c om
        int size = getResources().getDimensionPixelSize(R.dimen.profile_avatar_size);
        mMediasCache.loadAvatarThumbnail(session.getHomeserverConfig(), avatarView, avatarUrl, size);
    }
}

From source file:com.RSMSA.policeApp.Adapters.ViewPagerAccidentsDetailsAdapter.java

@Override
public Object instantiateItem(ViewGroup container, int position) {
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    android.widget.ScrollView itemView = (ScrollView) inflater.inflate(R.layout.accident_details, container,
            false);//ww w. j a  v  a  2  s  .  c  om

    final AccidentVehicle accidentVehicle = new AccidentVehicle();
    Button addPasenger = (Button) itemView.findViewById(R.id.add_witness);
    Button next = (Button) itemView.findViewById(R.id.next);
    final LinearLayout linearLayout = (LinearLayout) itemView.findViewById(R.id.passengers_layout);

    if (position == tabnames.size() - 1) {
        next.setVisibility(View.VISIBLE);
    } else {
        next.setVisibility(View.GONE);
    }
    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            AccidentReportFormActivity.showWitneses();
        }
    });

    final EditText fatalEdit = (EditText) itemView.findViewById(R.id.fatal_edit);
    fatalEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setFatal"));

    final EditText simpleEdit = (EditText) itemView.findViewById(R.id.simple_edit);
    simpleEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setSimple"));

    EditText injuryEdit = (EditText) itemView.findViewById(R.id.injury_edit);
    injuryEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setSevere_injured"));

    EditText notInjuredEdit = (EditText) itemView.findViewById(R.id.not_injured_edit);
    notInjuredEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setOnly_damage"));

    EditText driverLicenceEdit = (EditText) itemView.findViewById(R.id.license_one);
    driverLicenceEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setLicence_no") {
        public void afterFocus(final String text, final EditText editText) {
            new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected Boolean doInBackground(Void... params) {
                    DHIS2Modal dhis2Modal = new DHIS2Modal("Driver", null, MainOffence.username,
                            MainOffence.password);
                    JSONObject where = new JSONObject();
                    try {
                        where.put("value", text);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    JSONObject driverObject = null;
                    try {
                        JSONArray driver = dhis2Modal.getEvent(where);
                        Log.d(TAG, "returned driver json = " + driver.toString());
                        driverObject = driver.getJSONObject(0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    try {
                        if (driverObject.getString("Driver License Number").equals(text)) {
                            accidentVehicle.setProgram_driver(driverObject.getString("id"));
                            return true;
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (NullPointerException e) {
                        Log.e(TAG, "returned json object is null");
                    }
                    return false;
                }

                @Override
                protected void onPostExecute(Boolean aVoid) {
                    super.onPostExecute(aVoid);
                    if (!aVoid) {
                        editText.setTextColor(context.getResources().getColor(R.color.red));
                    } else {
                        editText.setTextColor(context.getResources().getColor(R.color.green_500));
                    }
                }
            }.execute();

        }
    });

    final EditText alcoholEdit = (EditText) itemView.findViewById(R.id.alcohol_edit);
    alcoholEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setAlcohol_percentage"));

    CheckBox drug = (CheckBox) itemView.findViewById(R.id.drug_edit);
    drug.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            accidentVehicle.setDrug(isChecked);
        }
    });

    CheckBox phone = (CheckBox) itemView.findViewById(R.id.phone_edit);
    phone.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            accidentVehicle.setPhone_use(isChecked);
        }
    });

    EditText plateNumber = (EditText) itemView.findViewById(R.id.registration_number_one);
    plateNumber.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setPlate_number") {
        public void afterFocus(final String text, final EditText editText) {
            new AsyncTask<Void, Void, Boolean>() {
                @Override
                protected Boolean doInBackground(Void... params) {
                    DHIS2Modal dhis2Modal = new DHIS2Modal("Vehicle", null, MainOffence.username,
                            MainOffence.password);
                    JSONObject where = new JSONObject();
                    try {
                        where.put("value", text);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }

                    JSONObject vehicleObject = null;
                    try {
                        JSONArray vehiclesArray = dhis2Modal.getEvent(where);
                        Log.d(TAG, "returned vehicle json = " + vehiclesArray.toString());
                        vehicleObject = vehiclesArray.getJSONObject(0);
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (NullPointerException e) {
                        e.printStackTrace();
                    }

                    try {
                        if (vehicleObject.getString("Vehicle Plate Number").equals(text)) {
                            accidentVehicle.setProgram_vehicle(vehicleObject.getString("id"));
                            return true;
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    } catch (NullPointerException e) {
                        Log.e(TAG, "returned json object is null");
                    }
                    return false;
                }

                @Override
                protected void onPostExecute(Boolean aVoid) {
                    super.onPostExecute(aVoid);
                    if (!aVoid) {
                        editText.setTextColor(context.getResources().getColor(R.color.red));
                    } else {
                        editText.setTextColor(context.getResources().getColor(R.color.light_gray));
                    }
                }
            }.execute();

        }
    });

    EditText repairCost = (EditText) itemView.findViewById(R.id.repair_amount_one);
    repairCost.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setEstimated_repair"));

    EditText vehicleEdit = (EditText) itemView.findViewById(R.id.vehicle_title_edit);
    vehicleEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setVehicle"));

    EditText vehicleTotalEdit = (EditText) itemView.findViewById(R.id.vehicle_total_edit);
    vehicleTotalEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setVehicle_total"));

    EditText infastructureEdit = (EditText) itemView.findViewById(R.id.infrastructure_edit);
    infastructureEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setInfastructure"));

    EditText costEdit = (EditText) itemView.findViewById(R.id.rescue_cost_edit);
    costEdit.setOnFocusChangeListener(new CustomeTimeWatcher(accidentVehicle, "setCost"));

    final List<PassengerVehicle> passengers = new ArrayList<PassengerVehicle>();

    addPasenger.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final PassengerVehicle passengerVehicle = new PassengerVehicle();
            LinearLayout passenger = (LinearLayout) inflater.inflate(R.layout.passenger, null);

            linearLayout.addView(passenger);

            EditText nameEdit = (EditText) passenger.findViewById(R.id.name_edit);
            nameEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setName"));

            final EditText dateOfBirth = (EditText) passenger.findViewById(R.id.dob_one);
            dateOfBirth.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setDate_of_birth"));

            EditText physicalAddressEdit = (EditText) passenger.findViewById(R.id.physical_address_one);
            physicalAddressEdit
                    .setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setPhysical_address"));

            EditText addressBoxEdit = (EditText) passenger.findViewById(R.id.address_box_one);
            addressBoxEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setAddress"));

            EditText nationalIDEdit = (EditText) passenger.findViewById(R.id.national_id_one);
            nationalIDEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setNational_id"));

            EditText phoneNoEdit = (EditText) passenger.findViewById(R.id.phone_no_one);
            phoneNoEdit.setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setPhone_no"));

            EditText alcoholPercentageEdit = (EditText) passenger.findViewById(R.id.alcohol_percentage);
            alcoholPercentageEdit
                    .setOnFocusChangeListener(new CustomeTimeWatcher(passengerVehicle, "setAlcohol_percent"));

            CheckBox seatbeltCheckbox = (CheckBox) passenger.findViewById(R.id.seat_belt_check);
            seatbeltCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    passengerVehicle.setHelmet(isChecked);
                }
            });

            Button date_picker = (Button) passenger.findViewById(R.id.date_picker);
            date_picker.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    DatePickerDialog newDatePickerDialogueFragment;
                    newDatePickerDialogueFragment = new DatePickerDialog();
                    newDatePickerDialogueFragment.show(AccidentReportFormActivity.fragmentManager,
                            "DatePickerDialogue");
                    newDatePickerDialogueFragment
                            .setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
                                @Override
                                public void onDateSet(DatePickerDialog dialog, int year, int monthOfYear,
                                        int dayOfMonth) {
                                    dateOfBirth.setText(dayOfMonth + " / " + (monthOfYear + 1) + " / " + year);
                                }
                            });
                }
            });

            final RadioButton male = (RadioButton) passenger.findViewById(R.id.male);
            male.setTypeface(MainOffence.Roboto_Regular);

            final RadioButton female = (RadioButton) passenger.findViewById(R.id.female);
            female.setTypeface(MainOffence.Roboto_Regular);

            passengerVehicle.setGender("Male");
            male.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked)
                        passengerVehicle.setGender("Male");
                }
            });

            female.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    if (isChecked)
                        passengerVehicle.setGender("Female");
                }
            });

            passengers.add(linearLayout.getChildCount() - 1, passengerVehicle);

        }
    });

    accident[position] = accidentVehicle;
    passanger.add(position, passengers);

    ((ViewPager) container).addView(itemView);
    return itemView;
}

From source file:com.eeshana.icstories.activities.UploadVideoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // this will copy the license file and the demo video file.
    // to the videokit work folder location.
    // without the license file the library will not work.
    //copyLicenseAndDemoFilesFromAssetsToSDIfNeeded();
    setContentView(R.layout.upload_video_activity);

    height = SignInActivity.getScreenHeight(UploadVideoActivity.this);
    width = SignInActivity.getScreenWidth(UploadVideoActivity.this);
    mProgressDialog = new ProgressDialog(UploadVideoActivity.this);
    pDialog = new ProgressDialog(UploadVideoActivity.this);
    showCustomToast = new ShowCustomToast();
    connectionDetector = new ConnectionDetector(UploadVideoActivity.this);
    //      mProgressDialog=new ProgressDialog(UploadVideoActivity.this,AlertDialog.THEME_HOLO_LIGHT);
    //      mProgressDialog.setFeatureDrawableResource(height,R.drawable.rounded_toast);
    prefs = getSharedPreferences("PREF", MODE_PRIVATE);
    regId = prefs.getString("regid", "NA");
    SharedPreferences pref = getSharedPreferences("DB", 0);
    userid = pref.getString("userid", "1");
    SharedPreferences assign_prefs = getSharedPreferences("ASSIGN", 0);
    assignment_id = assign_prefs.getString("ASSIGN_ID", "");
    videoPath = getIntent().getStringExtra("VIDEOPATH");

    //      iCTextView=(TextView) findViewById(R.id.tvIC);
    //      iCTextView.setTypeface(CaptureVideoActivity.ic_typeface,Typeface.BOLD);
    //      storiesTextView=(TextView) findViewById(R.id.tvStories);
    //      storiesTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.BOLD);
    //      watsStoryTextView=(TextView) findViewById(R.id.tvWhatsStory);
    //      watsStoryTextView.setTypeface(CaptureVideoActivity.stories_typeface,Typeface.ITALIC);

    //      logoImageView=(ImageView) findViewById(R.id.ivLogo);
    //      RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams((int) (width/1.9), (int) (height/9.5));
    //      lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
    //      lp.setMargins(0, 0, 0, 0);
    //      logoImageView.setLayoutParams(lp);

    uploadtTextView = (TextView) findViewById(R.id.tvUpload);
    uploadtTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    //      extension=getIntent().getStringExtra("EXTENSION");
    //      folderPath = Environment.getExternalStorageDirectory().getPath()+"/ICStoriesFolder";
    //      if (!FileUtils.checkIfFolderExists(folderPath)) {
    //         boolean isFolderCreated = FileUtils.createFolder(folderPath);
    //         Log.i(Prefs.TAG, folderPath + " created? " + isFolderCreated);
    //         if (isFolderCreated) {
    ///*from  ww w. j  a v  a2 s  . co m*/
    //         }
    //      }
    //command for rotating video 90 degree
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=1 -s 160x120 -r 30 -aspect 4:3 -ab 48000 -ac 2 -ar 22050 -b 2097k "+folderPath+"/out."+extension;

    //Change Video Resolution:
    //String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -vf transpose=3 -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/res."+extension;

    //command for compressing video 
    //      String commandStr="ffmpeg -y -i "+videoPath+" -strict experimental -s 320x240 -r 15 -aspect 3:4 -ab 12288 -vcodec mpeg4 -b 2097152 -sample_fmt s16 "+folderPath+"/test."+extension;
    //      setCommand(commandStr);
    //      runTranscoing();

    thumb = ThumbnailUtils.createVideoThumbnail(videoPath, MediaStore.Images.Thumbnails.MINI_KIND);
    System.out.println("THUMB IMG  in uplaod== " + thumb);

    titleEditText = (EditText) findViewById(R.id.etTitle);
    titleEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    descriptionEditText = (EditText) findViewById(R.id.etDescripton);
    descriptionEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    locationEditText = (EditText) findViewById(R.id.etLocation);
    locationEditText.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton = (Button) findViewById(R.id.buttonCheck);
    isAssignmentButton.setTypeface(CaptureVideoActivity.stories_typeface);
    isAssignmentButton.setOnClickListener(this);
    dailyAssignTextView = (TextView) findViewById(R.id.tvDailyAssignment);
    dailyAssignTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    uploadButton = (Button) findViewById(R.id.buttonUpload);
    uploadButton.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout uploadRelativeLayout = (RelativeLayout) findViewById(R.id.rlUpload);
    RelativeLayout.LayoutParams lp9 = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, height / 17);
    lp9.addRule(RelativeLayout.BELOW, R.id.rlDailyAssignment);
    lp9.setMargins(width / 7, 30, width / 7, 0);
    uploadRelativeLayout.setLayoutParams(lp9);
    uploadButton.setOnClickListener(this);

    //bottom bar

    homeRelativeLayout = (RelativeLayout) findViewById(R.id.rlHome);
    homeRelativeLayout.setBackgroundResource(R.drawable.press_border);
    homeRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    homeTextView = (TextView) homeRelativeLayout.findViewById(R.id.tvHome);
    homeTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    homeTextView.setTextColor(Color.parseColor("#fffffe"));
    RelativeLayout.LayoutParams lp4 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp4.addRule(RelativeLayout.ALIGN_LEFT);
    homeRelativeLayout.setLayoutParams(lp4);
    homeRelativeLayout.setOnClickListener(this);

    wallRelativeLayout = (RelativeLayout) findViewById(R.id.rlWall);
    wallRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    wallTextView = (TextView) wallRelativeLayout.findViewById(R.id.tvWall);
    wallTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp5 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp5.addRule(RelativeLayout.RIGHT_OF, R.id.rlHome);
    wallRelativeLayout.setLayoutParams(lp5);
    wallRelativeLayout.setOnClickListener(this);

    settingsRelativeLayout = (RelativeLayout) findViewById(R.id.rlSettings);
    settingsRelativeLayout.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    settingsTextView = (TextView) settingsRelativeLayout.findViewById(R.id.tvSettings);
    settingsTextView.setTypeface(CaptureVideoActivity.stories_typeface, Typeface.BOLD);
    RelativeLayout.LayoutParams lp6 = new RelativeLayout.LayoutParams(width / 3, width / 5);
    lp6.addRule(RelativeLayout.RIGHT_OF, R.id.rlWall);
    settingsRelativeLayout.setLayoutParams(lp6);
    settingsRelativeLayout.setOnClickListener(this);

    // current location
    locationDialog = new Dialog(UploadVideoActivity.this);
    locationDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    locationDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    locationDialog.setContentView(R.layout.location_dialog);
    locationDialog.setCancelable(true);
    LinearLayout dialogLayout = (LinearLayout) locationDialog.findViewById(R.id.ll1);
    okButton = (Button) dialogLayout.findViewById(R.id.OkBtn);
    okButton.setOnClickListener(this);
    cancelButton = (Button) dialogLayout.findViewById(R.id.cancelBtn);
    cancelButton.setOnClickListener(this);

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    boolean network_enabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
    if (network_enabled) {
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
    } else {
        showCustomToast.showToast(UploadVideoActivity.this,
                "Could not find current location. Please enable location services of your device.");
    }
    //      else if(gps_enabled == false){
    //         locationDialog.show();
    //      }
}

From source file:com.ehret.mixit.fragment.PeopleDetailFragment.java

private void addPeopleSession(Member membre) {
    //On recupere aussi la liste des sessions de l'utilisateur
    List<Talk> conferences = ConferenceFacade.getInstance().getSessionMembre(membre, getActivity());

    //On vide les lments
    sessionLayout.removeAllViews();/*w  w w  .j  a  v a2 s . c  o  m*/

    //On affiche les liens que si on a recuperer des choses
    if (conferences != null && !conferences.isEmpty()) {
        //On ajoute un table layout
        TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(
                TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT);
        TableLayout tableLayout = new TableLayout(getActivity().getBaseContext());
        tableLayout.setLayoutParams(tableParams);

        if (mInflater != null) {

            for (final Talk conf : conferences) {
                LinearLayout row = (LinearLayout) mInflater.inflate(R.layout.item_talk, tableLayout, false);
                row.setBackgroundResource(R.drawable.row_transparent_background);
                //Dans lequel nous allons ajouter le contenu que nous faisons mapp dans
                TextView horaire = (TextView) row.findViewById(R.id.talk_horaire);
                TextView talkImageText = (TextView) row.findViewById(R.id.talkImageText);
                TextView talkSalle = (TextView) row.findViewById(R.id.talk_salle);
                ImageView imageFavorite = (ImageView) row.findViewById(R.id.talk_image_favorite);
                ImageView langImage = (ImageView) row.findViewById(R.id.talk_image_language);

                ((TextView) row.findViewById(R.id.talk_name)).setText(conf.getTitle());
                ((TextView) row.findViewById(R.id.talk_shortdesciptif)).setText(conf.getSummary().trim());

                SimpleDateFormat sdf = new SimpleDateFormat("EEE");
                if (conf.getStart() != null && conf.getEnd() != null) {
                    horaire.setText(String.format(getResources().getString(R.string.periode),
                            sdf.format(conf.getStart()),
                            DateFormat.getTimeInstance(DateFormat.SHORT).format(conf.getStart()),
                            DateFormat.getTimeInstance(DateFormat.SHORT).format(conf.getEnd())));
                } else {
                    horaire.setText(getResources().getString(R.string.pasdate));

                }
                if (conf.getLang() != null && "ENGLISH".equals(conf.getLang())) {
                    langImage.setImageDrawable(getResources().getDrawable(R.drawable.en));
                } else {
                    langImage.setImageDrawable(getResources().getDrawable(R.drawable.fr));
                }
                Salle salle = Salle.INCONNU;
                if (conf instanceof Talk && Salle.INCONNU != Salle.getSalle(conf.getRoom())) {
                    salle = Salle.getSalle(conf.getRoom());
                }
                talkSalle.setText(String.format(getResources().getString(R.string.Salle), salle.getNom()));
                talkSalle.setBackgroundColor(getResources().getColor(salle.getColor()));

                if (conf instanceof Talk) {
                    if ("Workshop".equals(((Talk) conf).getFormat())) {
                        talkImageText.setText("Atelier");
                    } else {
                        talkImageText.setText("Talk");
                    }
                } else {
                    talkImageText.setText("L.Talk");
                }

                row.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        TypeFile typeFile;
                        int page = 6;
                        if (conf instanceof Talk) {
                            if ("Workshop".equals(((Talk) conf).getFormat())) {
                                typeFile = TypeFile.workshops;
                                page = 4;
                            } else {
                                typeFile = TypeFile.talks;
                                page = 3;
                            }
                        } else {
                            typeFile = TypeFile.lightningtalks;
                        }
                        ((HomeActivity) getActivity()).changeCurrentFragment(SessionDetailFragment.newInstance(
                                typeFile.toString(), conf.getIdSession(), page), typeFile.toString());
                    }
                });

                //On regarde si la conf fait partie des favoris
                SharedPreferences settings = getActivity().getSharedPreferences(UIUtils.PREFS_FAVORITES_NAME,
                        0);
                boolean trouve = false;
                for (String key : settings.getAll().keySet()) {
                    if (key.equals(String.valueOf(conf.getIdSession()))) {
                        trouve = true;
                        imageFavorite.setImageDrawable(
                                getActivity().getResources().getDrawable(R.drawable.ic_action_important));
                        break;
                    }
                }
                if (!trouve) {
                    imageFavorite.setImageDrawable(
                            getActivity().getResources().getDrawable(R.drawable.ic_action_not_important));
                }
                tableLayout.addView(row);
            }
        }
        sessionLayout.addView(tableLayout);
    } else {
        titleSessions.getLayoutParams().height = 0;
    }
}

From source file:com.rstar.mobile.thermocouple.ui.FormulaFragment.java

private void displayPolynomial(LayoutInflater inflater) {
    if (inflater == null) {
        inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }/*  w  w w.  j a  v  a 2 s.  c  o  m*/

    // Remove any existing table
    LinearLayout parent = mPolynomialView;
    if (tablePolynomial_Id != 0) {
        View view = parent.findViewById(tablePolynomial_Id);
        if (view != null)
            parent.removeView(view);
    }

    int order = -1;

    if (inputType == inputType_T) {
        if (fnResult == null)
            return;
        order = fnResult.polynomial.getOrder();
    } else if (inputType == inputType_E) {
        if (fnInvResult == null)
            return;
        order = fnInvResult.polynomial.getOrder();
    }
    Savelog.d(TAG, debug, "order=" + order);

    if (order == -1) {
        return;
    }

    int tableSize = 0;
    tablePolynomial_Id = 0;
    TableLayout tableLayout = null;

    if (order >= 0) {
        View view = inflater.inflate(R.layout.table_polynomial, parent, true);
        tableLayout = (TableLayout) view.findViewById(R.id.tablePolynomial_id);
        tableSize = PolynomialTable.MaxOrder;
        tablePolynomial_Id = R.id.tablePolynomial_id;
    }

    // Each row is a term in the polynomial

    for (int row = 0; row <= order; row++) {
        int cell_id;
        int column;
        int term = row;
        TextView cell;

        double coefficient = 0.0;
        if (inputType == inputType_T) {
            coefficient = fnResult.polynomial.getCoefficent(term);
        } else if (inputType == inputType_E) {
            coefficient = fnInvResult.polynomial.getCoefficent(term);
        }

        if (row == order) {
            column = 0;
            cell_id = PolynomialTable.cell_ids[row][column];
            cell = (TextView) tableLayout.findViewById(cell_id);
            cell.setText("+");
        }

        column = 1;
        cell_id = PolynomialTable.cell_ids[row][column];
        cell = (TextView) tableLayout.findViewById(cell_id);
        cell.setText("" + coefficient);

        column = 2;
        cell_id = PolynomialTable.cell_ids[row][column];
        cell = (TextView) tableLayout.findViewById(cell_id);
        cell.setText(Html.fromHtml("(" + mInput + ")<sup>" + term + "</sup>"));

    }
    for (int row = order + 1; row <= tableSize; row++) {
        int row_id = PolynomialTable.row_ids[row];
        TableRow tableRow = (TableRow) tableLayout.findViewById(row_id);
        tableLayout.removeView(tableRow);
    }

    // The result row shows the value computed by the polynomial

    {
        CharSequence sumPolyLabel = "";
        String sumPoly = "";
        if (inputType == inputType_T) {
            sumPoly = String.format("%.3f", fnResult.Epoly);
            sumPolyLabel = EequalLabel;
            // If there is an exponential term, use a different label
            if (fnResult.exponential != null)
                sumPolyLabel = getText(R.string.label_EPequals);

        } else if (inputType == inputType_E) {
            sumPoly = String.format("%.3f", fnInvResult.T);
            sumPolyLabel = TequalLabel;
        }

        int result_id;

        TextView resultCell;
        result_id = PolynomialTable.result_ids[1]; // column 1
        resultCell = (TextView) tableLayout.findViewById(result_id);
        resultCell.setText(sumPolyLabel);

        result_id = PolynomialTable.result_ids[2]; // column 2
        resultCell = (TextView) tableLayout.findViewById(result_id);
        resultCell.setText(sumPoly);
    }
}