Example usage for android.widget LinearLayout getParent

List of usage examples for android.widget LinearLayout getParent

Introduction

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

Prototype

public final ViewParent getParent() 

Source Link

Document

Gets the parent of this view.

Usage

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java

/**
 * Recording time ASYNCHRONOUSLY/*from   w ww.  j  a  v  a  2  s .  c om*/
 * 
 * @param v
 */
public void onClickRecord(View v) {

    LinearLayout llTimePicker = (LinearLayout) v.getParent();
    LinearLayout lllFrag = (LinearLayout) llTimePicker.getParent();
    LinearLayout llTime = (LinearLayout) llTimePicker.findViewById(R.id.llTimePicker);

    TimePicker tp = (TimePicker) llTime.findViewById(R.id.tpTask);
    Integer oiHour = tp.getCurrentHour();
    Integer oiMin = tp.getCurrentMinute();
    DateUtils du = new DateUtils();
    long lmills = du.toMills(oiHour, oiMin);

    ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem());
    String sSubjectId = as.getId_subject();
    double dLat = as.getLocation_latitude();
    double dLong = as.getLocation_longitude();
    long lCheckIn = new Date().getTime();
    long lCheckOut = lCheckIn + lmills;

    // Save data into both databases
    Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / "
            + du.duration(lCheckIn, lCheckOut));

    // TODO make some control here to make this transactional
    recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong,
            ActivityDO.ACTIVITY_RECORD_MODE_ASYNCHRONOUS);
    recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong);

    TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration);
    tvDuration.setText(
            du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId)));

    //
    // Update history layout
    //      
    LayoutInflater inflater = LayoutInflater.from(this);

    LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null);

    LinearLayout liContent = (LinearLayout) llParent.getChildAt(0);

    TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp);
    tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn));
    tvTimeStamp.setTag(Long.valueOf(lCheckIn));

    TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration);
    tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]");
    // Passing subject id as parameter        
    tvDurRecord.setTag(sSubjectId);

    LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory);
    // Set index number so that the record can be removed
    int iTag = (llHistory.getChildCount() - 1) / 2;
    llParent.setTag(iTag);
    llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1);
    llHistory.addView(llParent, 2);

    Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT)
            .show();

}

From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java

/**
 * Removes record both from sqlite and backend
 * //from   w  ww. j a  v a 2s .  c  om
 * @param v
 */
public void onClickDeleteActivity(View v) {

    LinearLayout llCheckItemRow = (LinearLayout) v.getParent();
    LinearLayout llCheckItemWrapper = (LinearLayout) llCheckItemRow.getParent();
    int iNumItemsHistory = 0;
    int iTag = 0;
    int iClicked = 0;

    try {

        llHistory = (LinearLayout) llCheckItemWrapper.getParent();

        llListFragment = (LinearLayout) llHistory.getParent();

        iNumItemsHistory = ((llHistory.getChildCount() - 1) / 2) - 1;
        iTag = new Integer(llCheckItemWrapper.getTag().toString());
        iClicked = (iTag - iNumItemsHistory) * (-1);
        iToRemove = (iClicked + 1) * 2;

    } catch (Exception e) {
        e.printStackTrace();
    }

    TextView myText = (TextView) llCheckItemRow.findViewById(R.id.textViewTimeStamp);
    lCheckInToDelete = (Long) myText.getTag();
    String sCheckIn = (String) myText.getText();
    TextView tvDur = (TextView) llCheckItemRow.findViewById(R.id.textViewDuration);
    sIdSbuject = (String) tvDur.getTag();

    new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Remove activity?")
            .setMessage("Are you sure to remove activity started at " + sCheckIn + " ?")
            .setPositiveButton("Yes", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    //Toast.makeText(getApplicationContext(), "About to delete activity "+sCheckIn+" ... ", Toast.LENGTH_SHORT).show();      
                    Log.d(CLASSNAME, "About to delte activity   mills[" + lCheckInToDelete + "]");

                    // Delete this transactional
                    // Issue 16
                    // https://code.google.com/p/lifelong-learning-hub/issues/detail?id=16      
                    deleteActivityBackend(lCheckInToDelete, Session.getSingleInstance().getUserName());
                    Session.getSingleInstance().getDatabaseHandler().deleteActivity(lCheckInToDelete);

                    DateUtils du = new DateUtils();

                    TextView tvDuration = (TextView) llListFragment.findViewById(R.id.tvDuration);
                    tvDuration.setText(du.duration(
                            Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sIdSbuject)));

                    llHistory.getChildAt(iToRemove).setVisibility(View.GONE);

                    //Stop the activity
                    //TimeLineActivity.this.finish();    
                }

            }).setNegativeButton("No", null).show();

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one audio radiobutton, deselect the rest of the radiobuttons
 * //from w  w w . j a v a 2  s. c o m
 * @param v
 */
public void onSelectAudioRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llRadioButton.getParent();

    RadioButton rbB = (RadioButton) llRoot.findViewById(R.id.rbBeep);
    RadioButton rbM = (RadioButton) llRoot.findViewById(R.id.rbMelody1);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_beep).compareTo(sTag) == 0) {

        rbM.setChecked(false);

    } else if (getString(R.string.rb_melody).compareTo(sTag) == 0) {

        rbB.setChecked(false);

    }

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one color radiobutton, deselect the rest of the radiobuttons
 * //from ww w.java2s  .co  m
 * @param v
 */
public void onSelectColorRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llRadioButton.getParent();

    RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFullColor);
    RadioButton rbP = (RadioButton) llRoot.findViewById(R.id.rbPartColor);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_fully).compareTo(sTag) == 0) {

        rbP.setChecked(false);

    } else if (getString(R.string.rb_partly).compareTo(sTag) == 0) {

        rbF.setChecked(false);

    }

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * On click one radiobutton, deslect the rest of the radiobuttons
 * /*from   w w  w.j a  v  a 2s  .  c o  m*/
 * @param v
 */
public void onSelectRadioButton(View v) {

    LinearLayout llRadioButton = (LinearLayout) v.getParent();
    LinearLayout llBranch = (LinearLayout) llRadioButton.getParent();
    LinearLayout llRoot = (LinearLayout) llBranch.getParent();

    RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFade);
    RadioButton rbRainbow = (RadioButton) llRoot.findViewById(R.id.rbRainbow);
    RadioButton rbRainbowC = (RadioButton) llRoot.findViewById(R.id.rbRainbowCircle);

    String sTag = v.getTag().toString();
    if (getString(R.string.rb_fade).compareTo(sTag) == 0) {

        rbRainbow.setChecked(false);
        rbRainbowC.setChecked(false);

    } else if (getString(R.string.rb_rainbow).compareTo(sTag) == 0) {

        rbF.setChecked(false);
        rbRainbowC.setChecked(false);

    } else if (getString(R.string.rb_rainbow_circle).compareTo(sTag) == 0) {

        rbF.setChecked(false);
        rbRainbow.setChecked(false);

    }

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * Replaces sampler button in jukebox//from   w w w  .jav  a  2s  .  c  o  m
 * 
 * @param v
 */
public void onClickReplaceSamplerButton(View v) {

    // Rename button

    LinearLayout llButtons = (LinearLayout) v.getParent();
    LinearLayout llParent = (LinearLayout) llButtons.getParent();

    EditText etRen = (EditText) llParent.findViewById(R.id.editTextRename);
    String sNewName = etRen.getText().toString();
    Button but = (Button) v;
    but.setTextColor(Color.CYAN);
    but.setText(sNewName);

    //      Fragment f = mAppSectionsPagerAdapter.getItem(iActiveFragment);
    //
    //      
    //
    //      
    //      if(f.getClass().equals(VisualSectionFragment.class)){
    //         
    //         FCColor fcc = (FCColor)ifcc;
    //         Sampler samp = new Sampler(fcc, sNewName);
    //         FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);         
    //         
    //      }else if (f.getClass().equals(AudioSectionFragment.class)){
    //               
    //         FCBeep fcc = (FCBeep)ifcc;
    //         Sampler samp = new Sampler(fcc, sNewName);
    //         FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);         
    //         
    //      }else if (f.getClass().equals(EffectsSectionFragment.class)){
    //         
    //         
    //         if(ifcc.getClass().equals(FCRainbow.class)){
    //            FCRainbow fcc = (FCRainbow)ifcc;
    //            Sampler samp = new Sampler(fcc, sNewName);
    //            FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);
    //         }else if (ifcc.getClass().equals(FCRainbowCircle.class)){
    //            FCRainbowCircle fcc = (FCRainbowCircle)ifcc;
    //            Sampler samp = new Sampler(fcc, sNewName);
    //            FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);
    //         }else if (ifcc.getClass().equals(FCFade.class){   
    //
    //         
    //            FCFade fcc = (FCFade)ifcc;
    //            Sampler samp = new Sampler(fcc, sNewName);
    //            FeedbackCubeConfig.getSingleInstance().addSampler((String)v.getTag(), samp, this);
    //         }
    //         
    //         
    //      }
    //      
    Sampler samp = new Sampler(ifcc, sNewName);
    FeedbackCubeConfig.getSingleInstance().addSampler((String) v.getTag(), samp, this);

}

From source file:org.ounl.lifelonglearninghub.fcube.navigate.SwipeFragmentActivity.java

/**
 * Returns active command for controls selected in view .
 * Returns null for wrong command//w w  w.  j a  va 2  s  . c  o  m
 * 
 * @param v
 * @return
 */
private IFeedbackCubeCommnads getCommnand(View v) {

    LinearLayout llButtons = (LinearLayout) v.getParent();
    LinearLayout llRoot = (LinearLayout) llButtons.getParent();

    String sTag = v.getTag().toString();
    if (sTag.compareTo(getString(R.string.tab_vi)) == 0) {

        TextView tvRed = (TextView) llRoot.findViewById(R.id.textViewRedValue);
        TextView tvGreen = (TextView) llRoot.findViewById(R.id.textViewGreenValue);
        TextView tvBlue = (TextView) llRoot.findViewById(R.id.textViewBlueValue);

        RadioButton rbF = (RadioButton) llRoot.findViewById(R.id.rbFullColor);
        RadioButton rbP = (RadioButton) llRoot.findViewById(R.id.rbPartColor);

        if (rbP.isChecked()) {

            NumberPicker npStart = (NumberPicker) llRoot.findViewById(R.id.npLedStart);
            NumberPicker npStop = (NumberPicker) llRoot.findViewById(R.id.npLedStop);

            FCPieChart c = new FCPieChart(FeedbackCubeConfig.getSingleInstance().getIp(),
                    npStart.getValue() + "", npStop.getValue() + "", tvRed.getText().toString(),
                    tvGreen.getText().toString(), tvBlue.getText().toString());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else {
            FCColor c = new FCColor(FeedbackCubeConfig.getSingleInstance().getIp(), tvRed.getText().toString(),
                    tvGreen.getText().toString(), tvBlue.getText().toString());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        }

    } else if (sTag.compareTo(getString(R.string.tab_au)) == 0) {

        //         CheckBox cb = (CheckBox) llRoot.findViewById(R.id.cbBeep);
        //         if (cb.isChecked()) {
        //            FCBeep c = new FCBeep(FeedbackCubeConfig.getSingleInstance()
        //                  .getIp());
        ////            Toast.makeText(this, "Launch cube " + c.toString(),
        ////                  Toast.LENGTH_SHORT).show();
        //
        //            return c;
        //         } else {
        //            Toast.makeText(this,
        //                  "Check off the Beep! to launch the action.",
        //                  Toast.LENGTH_SHORT).show();
        //         }

        RadioButton rbBeep = (RadioButton) llRoot.findViewById(R.id.rbBeep);
        RadioButton rbMelody = (RadioButton) llRoot.findViewById(R.id.rbMelody1);

        if (rbBeep.isChecked()) {

            FCBeep c = new FCBeep(FeedbackCubeConfig.getSingleInstance().getIp());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbMelody.isChecked()) {

            FCMelody1 c = new FCMelody1(FeedbackCubeConfig.getSingleInstance().getIp());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        }

    } else if (sTag.compareTo(getString(R.string.tab_ef)) == 0) {

        RadioButton rbRainbow = (RadioButton) llRoot.findViewById(R.id.rbRainbow);
        RadioButton rbRainbowC = (RadioButton) llRoot.findViewById(R.id.rbRainbowCircle);
        RadioButton rbFade = (RadioButton) llRoot.findViewById(R.id.rbFade);

        if (rbRainbow.isChecked()) {

            FCRainbow c = new FCRainbow(FeedbackCubeConfig.getSingleInstance().getIp());
            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbRainbowC.isChecked()) {

            FCRainbowCircle c = new FCRainbowCircle(FeedbackCubeConfig.getSingleInstance().getIp());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;

        } else if (rbFade.isChecked()) {

            NumberPicker npD = (NumberPicker) llRoot.findViewById(R.id.npDelay);
            NumberPicker npN = (NumberPicker) llRoot.findViewById(R.id.npNumber);

            FCFade c = new FCFade(FeedbackCubeConfig.getSingleInstance().getIp(), "" + npN.getValue(),
                    "" + npD.getValue());

            //            Toast.makeText(this, "Launch cube " + c.toString(),
            //                  Toast.LENGTH_SHORT).show();

            return c;
        }

    }
    return null;

}

From source file:com.android.calendar.event.EditEventView.java

@Override
public void onClick(View view) {
    if (view == mRruleButton) {
        Bundle b = new Bundle();
        b.putLong(RecurrencePickerDialog.BUNDLE_START_TIME_MILLIS, mStartTime.toMillis(false));
        b.putString(RecurrencePickerDialog.BUNDLE_TIME_ZONE, mStartTime.timezone);

        // TODO may be more efficient to serialize and pass in
        // EventRecurrence
        b.putString(RecurrencePickerDialog.BUNDLE_RRULE, mRrule);

        FragmentManager fm = mActivity.getSupportFragmentManager();
        RecurrencePickerDialog rpd = (RecurrencePickerDialog) fm.findFragmentByTag(FRAG_TAG_RECUR_PICKER);
        if (rpd != null) {
            rpd.dismiss();// w  w w  . ja va2  s  .c  om
        }
        rpd = new RecurrencePickerDialog();
        rpd.setArguments(b);
        rpd.setOnRecurrenceSetListener(EditEventView.this);
        rpd.show(fm, FRAG_TAG_RECUR_PICKER);
        return;
    }

    // This must be a click on one of the "remove reminder" buttons
    LinearLayout reminderItem = (LinearLayout) view.getParent();
    LinearLayout parent = (LinearLayout) reminderItem.getParent();
    parent.removeView(reminderItem);
    mReminderItems.remove(reminderItem);
    updateRemindersVisibility(mReminderItems.size());
    EventViewUtils.updateAddReminderButton(mView, mReminderItems, mModel.mCalendarMaxReminders);
}

From source file:com.android.calendar.EventInfoFragment.java

@Override
public void onClick(View view) {

    // This must be a click on one of the "remove reminder" buttons
    LinearLayout reminderItem = (LinearLayout) view.getParent();
    LinearLayout parent = (LinearLayout) reminderItem.getParent();
    parent.removeView(reminderItem);//from ww  w  .  j a va2 s  .  c o m
    mReminderViews.remove(reminderItem);
    mUserModifiedReminders = true;
    EventViewUtils.updateAddReminderButton(mView, mReminderViews, mMaxReminders);
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

private void onCreateSetupActionBarAndSearchView() {
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);

    final LinearLayout customSearchView = new LinearLayout(getSupportActionBar().getThemedContext());

    final LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    customSearchView.setLayoutParams(layoutParams);

    listView.setOnItemClickListener(new OnItemClickListener() {
        @Override/*from  w  ww .  j a va 2s .co m*/
        public void onItemClick(AdapterView<?> parent, View view, int row, long id) {
            onListItemClick(getListView(), view, row, id);
        }
    });

    languageButton = new ImageButton(customSearchView.getContext());
    languageButton.setScaleType(ScaleType.FIT_CENTER);
    languageButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            onLanguageButtonClick();
        }
    });
    languageButton.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            onLanguageButtonLongClick(v.getContext());
            return true;
        }
    });
    languageButton.setAdjustViewBounds(true);
    LinearLayout.LayoutParams lpb = new LinearLayout.LayoutParams(application.languageButtonPixels,
            LinearLayout.LayoutParams.MATCH_PARENT);
    customSearchView.addView(languageButton, lpb);

    searchView = new SearchView(getSupportActionBar().getThemedContext());

    // Get rid of search icon, it takes up too much space.
    // There is still text saying "search" in the search field.
    searchView.setIconifiedByDefault(true);
    searchView.setIconified(false);

    searchView.setQueryHint(getString(R.string.searchText));
    searchView.setSubmitButtonEnabled(false);
    searchView.setInputType(InputType.TYPE_CLASS_TEXT);
    searchView.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI |
    // EditorInfo.IME_FLAG_NO_FULLSCREEN | // Requires API
    // 11
            EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    onQueryTextListener = new OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            Log.d(LOG, "OnQueryTextListener: onQueryTextSubmit: " + searchView.getQuery());
            hideKeyboard();
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            Log.d(LOG, "OnQueryTextListener: onQueryTextChange: " + searchView.getQuery());
            onSearchTextChange(searchView.getQuery().toString());
            return true;
        }
    };
    searchView.setOnQueryTextListener(onQueryTextListener);
    searchView.setFocusable(true);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, FrameLayout.LayoutParams.WRAP_CONTENT, 1);
    customSearchView.addView(searchView, lp);

    actionBar.setCustomView(customSearchView);
    actionBar.setDisplayShowCustomEnabled(true);

    // Avoid wasting space on large left inset
    Toolbar tb = (Toolbar) customSearchView.getParent();
    tb.setContentInsetsRelative(0, 0);
}