Example usage for android.widget LinearLayout HORIZONTAL

List of usage examples for android.widget LinearLayout HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

To view the source code for android.widget LinearLayout HORIZONTAL.

Click Source Link

Usage

From source file:cn.liucl.stationarytabstrip.PagerSlidingTabStrip.java

private void initContainerView(Context context) {

    //??/*  w  ww . ja v  a2s.  c om*/
    bodyContainer = new HorScrollView(context);
    bodyContainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    bodyContainer.setFillViewport(true);

    //???
    headsContainer = new LinearLayout(context);
    headsContainer.setOrientation(LinearLayout.HORIZONTAL);
    headsContainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    bodyContainer.addView(tabsContainer);

    //?
    setOrientation(LinearLayout.HORIZONTAL);
    addView(headsContainer);
    addView(bodyContainer);

    bodyContainer.setScrollViewListener(new ScrollListener());
}

From source file:com.cc.custom.uikit.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setFillViewport(true);//from   w  w w  .j  av a  2  s .  com
    setWillNotDraw(false);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    indicatorPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorPadding, dm);
    tabPadding = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get custom attrs

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    tabTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabTextColor, tabTextColor);
    tabSelectedTextColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTabSelectedTextColor,
            tabSelectedTextColor);
    tabTextSize = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabTextSize, (int) tabTextSize);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            (int) indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            (int) underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            (int) dividerPadding);
    indicatorPadding = a.getDimensionPixelOffset(R.styleable.PagerSlidingTabStrip_pstIndicatorPadding,
            (int) indicatorPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight,
            (int) tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    tabSelectedBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabSelectedBackgrground,
            tabSelectedBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset,
            (int) scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    a.recycle();

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.hichinaschool.flashcards.anki.multimediacard.activity.MultimediaCardEditorActivity.java

/**
 * Creates a TabBar in case action bar is not present as well as other UI Elements
 *///from  w  w w. j  a va2s  .co  m
private void initUI() {
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion <= android.os.Build.VERSION_CODES.GINGERBREAD_MR1) {
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.LinearLayoutForSpareMenu);
        createSpareMenu(linearLayout);
    }

    mEditorLayout = (LinearLayout) findViewById(R.id.LinearLayoutInScrollView);

    LinearLayout mToolsLayout = (LinearLayout) findViewById(R.id.LinearLayoutForButtons);

    LayoutParams pars = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);

    Button swapButton = new Button(this);
    swapButton.setText(gtxt(R.string.multimedia_editor_activity_swap_button));
    mToolsLayout.addView(swapButton, pars);
    swapButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            swap();
        }
    });

    LinearLayout mButtonsLayout = new LinearLayout(this);
    mButtonsLayout.setOrientation(LinearLayout.HORIZONTAL);
    mToolsLayout.addView(mButtonsLayout, pars);

    pars = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1);

    // DEPRECATED< BUT USED IN THE PROJECT.
    mModelButton = new Button(this);
    mModelButton.setOnClickListener(new OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_MODEL_SELECT);
        }
    });
    mButtonsLayout.addView(mModelButton, pars);

    mDeckButton = new Button(this);
    mDeckButton.setOnClickListener(new OnClickListener() {
        @SuppressWarnings("deprecation")
        @Override
        public void onClick(View v) {
            showDialog(DIALOG_DECK_SELECT);
        }
    });
    mButtonsLayout.addView(mDeckButton, pars);
}

From source file:br.org.funcate.dynamicforms.views.GPictureView.java

/**
 * @param fragmentDetail        the fragment detail  to use.
 * @param attrs                 attributes.
 * @param requestCode           the code for starting the activity with result.
 * @param parentView            parent/*  www  . j  av  a 2  s  .  co  m*/
 * @param label                 label
 * @param pictures              the value are the ids and binary data of the images.
 * @param constraintDescription constraints
 */
public GPictureView(final FragmentDetail fragmentDetail, AttributeSet attrs, final int requestCode,
        LinearLayout parentView, String label, Map<String, Map<String, String>> pictures,
        String constraintDescription) {
    super(fragmentDetail.getActivity(), attrs);

    thumbnailWidth = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_width);
    thumbnailHeight = fragmentDetail.getActivity().getResources().getInteger(R.integer.thumbnail_height);

    mFragmentDetail = fragmentDetail;

    _pictures = pictures;

    PICTURE_VIEW_RESULT = requestCode;

    final FragmentActivity activity = fragmentDetail.getActivity();
    LinearLayout textLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    layoutParams.setMargins(10, 10, 10, 10);
    textLayout.setPadding(10, 5, 10, 5);
    textLayout.setLayoutParams(layoutParams);
    textLayout.setOrientation(LinearLayout.VERTICAL);
    parentView.addView(textLayout);

    TextView textView = new TextView(activity);
    textView.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    textView.setPadding(2, 2, 2, 2);
    String t = label.replace(UNDERSCORE, " ").replace(COLON, " ") + " " + constraintDescription;
    textView.setText(t);
    textView.setTextColor(activity.getResources().getColor(R.color.formcolor));
    textLayout.addView(textView);

    final Button button = new Button(activity);
    button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(15, 5, 15, 5);
    button.setText(R.string.take_picture);
    textLayout.addView(button);

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            Intent cameraIntent = new Intent(activity, CameraActivity.class);

            cameraIntent.putExtra(FormUtilities.MAIN_APP_WORKING_DIRECTORY,
                    fragmentDetail.getWorkingDirectory());

            fragmentDetail.startActivityForResult(cameraIntent, requestCode);
        }
    });

    ScrollView scrollView = new ScrollView(activity);
    ScrollView.LayoutParams scrollLayoutParams = new ScrollView.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT);
    scrollView.setLayoutParams(scrollLayoutParams);
    scrollView.setHorizontalScrollBarEnabled(true);
    scrollView.setOverScrollMode(HorizontalScrollView.OVER_SCROLL_ALWAYS);
    parentView.addView(scrollView);

    imageLayout = new LinearLayout(activity);
    LinearLayout.LayoutParams imageLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    imageLayout.setLayoutParams(imageLayoutParams);
    imageLayout.setPadding(15, 5, 15, 5);
    imageLayout.setOrientation(LinearLayout.HORIZONTAL);
    imageLayout.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
    scrollView.addView(imageLayout);

    updateValueForm();
    try {
        refresh(activity);
    } catch (Exception e) {
        //GPLog.error(this, null, e);
        e.printStackTrace();
        Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }
}

From source file:com.wallerlab.compcellscope.Image_Gallery.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image__gallery);
    counter = 0;/*from   ww w .j  a  va 2  s  .  c o  m*/
    final ImageView currPic = new ImageView(this);

    DisplayMetrics metrics = this.getResources().getDisplayMetrics();
    final int screen_width = metrics.widthPixels;

    SharedPreferences settings = getSharedPreferences(Folder_Chooser.PREFS_NAME, 0);
    //SharedPreferences.Editor edit = settings.edit();
    String path = settings.getString(Folder_Chooser.location_name,
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString());

    //Log.d(LOG, "  |  " + path + " |  ");
    TextView text1 = (TextView) findViewById(R.id.text1);
    final TextView text2 = (TextView) findViewById(R.id.text2);

    text1.setText(path);

    File directory = new File(path);

    // get all the files from a directory
    File[] dump_files = directory.listFiles();
    Log.d(LOG, dump_files.length + " ");

    final File[] fList = removeElements(dump_files, "info.json");

    Log.d(LOG, "Filtered Length: " + fList.length);

    Arrays.sort(fList, new Comparator<File>() {
        @Override
        public int compare(File file, File file2) {
            String one = file.toString();
            String two = file2.toString();
            //Log.d(LOG, "one: " + one);
            //Log.d(LOG, "two: " + two);
            int num_one = Integer.parseInt(one.substring(one.lastIndexOf("(") + 1, one.lastIndexOf(")")));
            int num_two = Integer.parseInt(two.substring(two.lastIndexOf("(") + 1, two.lastIndexOf(")")));
            return num_one - num_two;
        }
    });

    try {
        writeJsonFile(fList);
    } catch (JSONException e) {
        Log.d(LOG, "JSON WRITE FAILED");
    }
    //List names programattically
    LinearLayout myLinearLayout = (LinearLayout) findViewById(R.id.linear_table);
    final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, screen_width + 4);

    myLinearLayout.setOrientation(LinearLayout.VERTICAL);

    if (fList != null) {
        File cur_pic = fList[0];

        BitmapFactory.Options opts = new BitmapFactory.Options();
        Log.d(LOG, "\n File Location: " + cur_pic.getAbsolutePath() + " \n" + " Parent: "
                + cur_pic.getParent().toString() + "\n");

        Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);

        currPic.setLayoutParams(params);
        currPic.setImageBitmap(myImage);
        currPic.setId(View.generateViewId());
        text2.setText(cur_pic.getName());
    }

    myLinearLayout.addView(currPic);

    //Seekbar
    seekBar = (SeekBar) findViewById(R.id.seekBar);
    seekBar.setEnabled(true);
    seekBar.setMax(fList.length - 1);
    seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        int progress = 0;
        int length = fList.length;

        @Override
        public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
            setCounter(i);
            if (getCounter() <= fList.length) {
                File cur_pic = fList[getCounter()];
                BitmapFactory.Options opts = new BitmapFactory.Options();
                opts.inJustDecodeBounds = true;
                Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                int image_width = opts.outWidth;
                int image_height = opts.outHeight;
                int sampleSize = image_width / screen_width;
                opts.inSampleSize = sampleSize;

                text2.setText(cur_pic.getName());

                opts.inJustDecodeBounds = false;
                myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);

                currPic.setImageBitmap(myImage);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    //Make Button Layout
    LinearLayout buttonLayout = new LinearLayout(this);
    buttonLayout.setOrientation(LinearLayout.HORIZONTAL);

    LinearLayout.LayoutParams LLParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f);
    buttonLayout.setLayoutParams(LLParams);
    buttonLayout.setId(View.generateViewId());

    //Button Layout Params
    LinearLayout.LayoutParams param_button = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0f);

    //Prev Pic
    Button prevPic = new Button(this);
    prevPic.setText("Previous");
    prevPic.setId(View.generateViewId());
    prevPic.setLayoutParams(param_button);

    prevPic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (fList != null) {
                decrementCounter();
                if (getCounter() >= 0) {
                    File cur_pic = fList[getCounter()];
                    BitmapFactory.Options opts = new BitmapFactory.Options();
                    opts.inJustDecodeBounds = true;
                    Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    int image_width = opts.outWidth;
                    int image_height = opts.outHeight;
                    int sampleSize = image_width / screen_width;
                    opts.inSampleSize = sampleSize;

                    text2.setText(cur_pic.getName());

                    opts.inJustDecodeBounds = false;
                    myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    //Log.d(LOG, getCounter() + "");
                    seekBar.setProgress(getCounter());
                    currPic.setImageBitmap(myImage);

                } else {
                    setCounter(0);
                }

            } else {
                Toast.makeText(Image_Gallery.this, "There are no pictures in this folder", Toast.LENGTH_SHORT);
                setCounter(getCounter() - 1);
            }
        }
    });

    buttonLayout.addView(prevPic);

    // Next Picture  Button
    Button nextPic = new Button(this);
    nextPic.setText("Next");
    nextPic.setId(View.generateViewId());
    nextPic.setLayoutParams(param_button);

    buttonLayout.addView(nextPic);
    nextPic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (fList != null) {
                incrementCounter();
                if (getCounter() < fList.length) {
                    File cur_pic = fList[getCounter()];
                    BitmapFactory.Options opts = new BitmapFactory.Options();
                    opts.inJustDecodeBounds = true;
                    Bitmap myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    int image_width = opts.outWidth;
                    int image_height = opts.outHeight;
                    int sampleSize = image_width / screen_width;
                    opts.inSampleSize = sampleSize;

                    text2.setText(cur_pic.getName());

                    opts.inJustDecodeBounds = false;
                    myImage = BitmapFactory.decodeFile(cur_pic.getAbsolutePath(), opts);
                    //Log.d(LOG, getCounter() + "");
                    seekBar.setProgress(getCounter());

                    currPic.setImageBitmap(myImage);
                } else {
                    setCounter(getCounter() - 1);
                }

            } else {
                Toast.makeText(Image_Gallery.this, "There are no pictures in this folder", Toast.LENGTH_SHORT);
                setCounter(getCounter() - 1);
            }
        }
    });

    myLinearLayout.addView(buttonLayout);
}

From source file:fr.cph.chicago.activity.StationActivity.java

@SuppressWarnings("unchecked")
@Override/*from w  w w  .j a  va2  s  . c o  m*/
protected final void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ChicagoTracker.checkTrainData(this);
    if (!this.isFinishing()) {
        // Load data
        DataHolder dataHolder = DataHolder.getInstance();
        this.mTrainData = dataHolder.getTrainData();

        mIds = new HashMap<String, Integer>();

        // Load right xml
        setContentView(R.layout.activity_station);

        // Get station id from bundle extra
        if (mStationId == null) {
            mStationId = getIntent().getExtras().getInt("stationId");
        }

        // Get station from station id
        mStation = mTrainData.getStation(mStationId);

        MultiMap<String, String> reqParams = new MultiValueMap<String, String>();
        reqParams.put("mapid", String.valueOf(mStation.getId()));
        new LoadData().execute(reqParams);

        // Call google street api to load image
        new DisplayGoogleStreetPicture().execute(mStation.getStops().get(0).getPosition());

        this.mIsFavorite = isFavorite();

        TextView textView = (TextView) findViewById(R.id.activity_bike_station_station_name);
        textView.setText(mStation.getName().toString());

        mStreetViewImage = (ImageView) findViewById(R.id.activity_bike_station_streetview_image);

        mStreetViewText = (TextView) findViewById(R.id.activity_bike_station_steetview_text);

        mMapImage = (ImageView) findViewById(R.id.activity_bike_station_map_image);

        mDirectionImage = (ImageView) findViewById(R.id.activity_bike_station_map_direction);

        mFavoritesImage = (ImageView) findViewById(R.id.activity_bike_station_favorite_star);
        if (mIsFavorite) {
            mFavoritesImage.setImageDrawable(getResources().getDrawable(R.drawable.ic_save_active));
        }
        mFavoritesImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                StationActivity.this.switchFavorite();
            }
        });

        LinearLayout stopsView = (LinearLayout) findViewById(R.id.activity_bike_station_details);

        this.mParamsStop = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

        Map<TrainLine, List<Stop>> stops = mStation.getStopByLines();
        CheckBox checkBox = null;
        for (Entry<TrainLine, List<Stop>> e : stops.entrySet()) {
            final TrainLine line = e.getKey();
            List<Stop> stopss = e.getValue();
            Collections.sort(stopss);
            LayoutInflater layoutInflater = (LayoutInflater) ChicagoTracker.getAppContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.activity_station_line_title, null);

            TextView lineTextView = (TextView) view.findViewById(R.id.activity_bus_station_value);
            lineTextView.setText(line.toStringWithLine());

            TextView lineColorTextView = (TextView) view.findViewById(R.id.activity_bus_color);
            lineColorTextView.setBackgroundColor(line.getColor());
            stopsView.addView(view);

            for (final Stop stop : stopss) {
                LinearLayout line2 = new LinearLayout(this);
                line2.setOrientation(LinearLayout.HORIZONTAL);
                line2.setLayoutParams(mParamsStop);

                checkBox = new CheckBox(this);
                checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        Preferences.saveTrainFilter(mStationId, line, stop.getDirection(), isChecked);
                    }
                });
                checkBox.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        // Update timing
                        MultiMap<String, String> reqParams = new MultiValueMap<String, String>();
                        reqParams.put("mapid", String.valueOf(mStation.getId()));
                        new LoadData().execute(reqParams);
                    }
                });
                checkBox.setChecked(Preferences.getTrainFilter(mStationId, line, stop.getDirection()));
                checkBox.setText(stop.getDirection().toString());
                checkBox.setTextColor(getResources().getColor(R.color.grey));

                line2.addView(checkBox);
                stopsView.addView(line2);

                LinearLayout line3 = new LinearLayout(this);
                line3.setOrientation(LinearLayout.VERTICAL);
                line3.setLayoutParams(mParamsStop);
                int id3 = Util.generateViewId();
                line3.setId(id3);
                mIds.put(line.toString() + "_" + stop.getDirection().toString(), id3);

                stopsView.addView(line3);
            }

        }
        getActionBar().setDisplayHomeAsUpEnabled(true);

        Util.trackScreen(this, R.string.analytics_train_details);
    }
}

From source file:com.vonglasow.michael.satstat.ui.RadioSectionFragment.java

private final void addWifiResult(ScanResult result) {
    // needed to pass a persistent reference to the OnClickListener
    final ScanResult r = result;
    android.view.View.OnClickListener clis = new android.view.View.OnClickListener() {

        @Override/*www. j a  v  a  2 s . c  o  m*/
        public void onClick(View v) {
            onWifiEntryClick(r.BSSID);
        }
    };

    LinearLayout wifiLayout = new LinearLayout(wifiAps.getContext());
    wifiLayout.setLayoutParams(
            new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    wifiLayout.setOrientation(LinearLayout.HORIZONTAL);
    wifiLayout.setWeightSum(22);
    wifiLayout.setMeasureWithLargestChildEnabled(false);

    ImageView wifiType = new ImageView(wifiAps.getContext());
    wifiType.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.MATCH_PARENT, 3));
    if (WifiCapabilities.isAdhoc(result)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_adhoc);
    } else if ((WifiCapabilities.isEnterprise(result))
            || (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.EAP)) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_eap);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.PSK) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_psk);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.WEP) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_wep);
    } else if (WifiCapabilities.getScanResultSecurity(result) == WifiCapabilities.OPEN) {
        wifiType.setImageResource(R.drawable.ic_content_wifi_open);
    } else {
        wifiType.setImageResource(R.drawable.ic_content_wifi_unknown);
    }

    wifiType.setScaleType(ScaleType.CENTER);
    wifiLayout.addView(wifiType);

    TableLayout wifiDetails = new TableLayout(wifiAps.getContext());
    wifiDetails.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    TableRow innerRow1 = new TableRow(wifiAps.getContext());
    TextView newMac = new TextView(wifiAps.getContext());
    newMac.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 14));
    newMac.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newMac.setText(result.BSSID);
    innerRow1.addView(newMac);
    TextView newCh = new TextView(wifiAps.getContext());
    newCh.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
    newCh.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newCh.setText(getChannelFromFrequency(result.frequency));
    innerRow1.addView(newCh);
    TextView newLevel = new TextView(wifiAps.getContext());
    newLevel.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3));
    newLevel.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Medium);
    newLevel.setText(String.valueOf(result.level));
    innerRow1.addView(newLevel);
    innerRow1.setOnClickListener(clis);
    wifiDetails.addView(innerRow1,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    TableRow innerRow2 = new TableRow(wifiAps.getContext());
    TextView newSSID = new TextView(wifiAps.getContext());
    newSSID.setLayoutParams(new TableRow.LayoutParams(0, LayoutParams.WRAP_CONTENT, 19));
    newSSID.setTextAppearance(wifiAps.getContext(), android.R.style.TextAppearance_Small);
    newSSID.setText(result.SSID);
    innerRow2.addView(newSSID);
    innerRow2.setOnClickListener(clis);
    wifiDetails.addView(innerRow2,
            new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    wifiLayout.addView(wifiDetails);
    wifiLayout.setOnClickListener(clis);
    wifiAps.addView(wifiLayout);
}

From source file:com.mishiranu.dashchan.ui.navigator.page.PostsPage.java

@Override
protected void onCreate() {
    Activity activity = getActivity();/*from   w  ww .  ja  v a  2 s  .  co m*/
    PullableListView listView = getListView();
    PageHolder pageHolder = getPageHolder();
    UiManager uiManager = getUiManager();
    hidePerformer = new HidePerformer();
    PostsExtra extra = getExtra();
    listView.setDivider(ResourceUtils.getDrawable(activity, R.attr.postsDivider, 0));
    ChanConfiguration.Board board = getChanConfiguration().safe().obtainBoard(pageHolder.boardName);
    if (board.allowPosting) {
        replyable = data -> getUiManager().navigator().navigatePosting(pageHolder.chanName,
                pageHolder.boardName, pageHolder.threadNumber, data);
    }
    PostsAdapter adapter = new PostsAdapter(activity, pageHolder.chanName, pageHolder.boardName, uiManager,
            replyable, hidePerformer, extra.userPostNumbers, listView);
    initAdapter(adapter, adapter);
    ImageLoader.getInstance().observable().register(this);
    listView.getWrapper().setPullSides(PullableWrapper.Side.BOTH);
    uiManager.observable().register(this);
    hidePerformer.setPostsProvider(adapter);

    Context darkStyledContext = new ContextThemeWrapper(activity, R.style.Theme_General_Main_Dark);
    searchController = new LinearLayout(darkStyledContext);
    searchController.setOrientation(LinearLayout.HORIZONTAL);
    searchController.setGravity(Gravity.CENTER_VERTICAL);
    float density = ResourceUtils.obtainDensity(getResources());
    int padding = (int) (10f * density);
    searchTextResult = new Button(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    searchTextResult.setTextSize(11f);
    if (!C.API_LOLLIPOP) {
        searchTextResult.setTypeface(null, Typeface.BOLD);
    }
    searchTextResult.setPadding((int) (14f * density), 0, (int) (14f * density), 0);
    searchTextResult.setMinimumWidth(0);
    searchTextResult.setMinWidth(0);
    searchTextResult.setOnClickListener(v -> showSearchDialog());
    searchController.addView(searchTextResult, LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    ImageView backButtonView = new ImageView(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    backButtonView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    backButtonView.setImageResource(obtainIcon(R.attr.actionBack));
    backButtonView.setPadding(padding, padding, padding, padding);
    backButtonView.setOnClickListener(v -> findBack());
    searchController.addView(backButtonView, (int) (48f * density), (int) (48f * density));
    ImageView forwardButtonView = new ImageView(darkStyledContext, null, android.R.attr.borderlessButtonStyle);
    forwardButtonView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    forwardButtonView.setImageResource(obtainIcon(R.attr.actionForward));
    forwardButtonView.setPadding(padding, padding, padding, padding);
    forwardButtonView.setOnClickListener(v -> findForward());
    searchController.addView(forwardButtonView, (int) (48f * density), (int) (48f * density));
    if (C.API_LOLLIPOP) {
        for (int i = 0, last = searchController.getChildCount() - 1; i <= last; i++) {
            View view = searchController.getChildAt(i);
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) view.getLayoutParams();
            if (i == 0) {
                layoutParams.leftMargin = (int) (-6f * density);
            }
            if (i == last) {
                layoutParams.rightMargin = (int) (6f * density);
            } else {
                layoutParams.rightMargin = (int) (-6f * density);
            }
        }
    }

    scrollToPostNumber = pageHolder.initialPostNumber;
    FavoritesStorage.getInstance().getObservable().register(this);
    LocalBroadcastManager.getInstance(activity).registerReceiver(galleryPagerReceiver,
            new IntentFilter(C.ACTION_GALLERY_NAVIGATE_POST));
    boolean hasNewPostDatas = handleNewPostDatas();
    extra.forceRefresh = hasNewPostDatas || !pageHolder.initialFromCache;
    if (extra.cachedPosts != null && extra.cachedPostItems.size() > 0) {
        onDeserializePostsCompleteInternal(true, extra.cachedPosts, new ArrayList<>(extra.cachedPostItems),
                true);
    } else {
        deserializeTask = new DeserializePostsTask(this, pageHolder.chanName, pageHolder.boardName,
                pageHolder.threadNumber, extra.cachedPosts);
        deserializeTask.executeOnExecutor(DeserializePostsTask.THREAD_POOL_EXECUTOR);
        getListView().getWrapper().startBusyState(PullableWrapper.Side.BOTH);
        switchView(ViewType.PROGRESS, null);
    }
    pageHolder.setInitialPostsData(false, null);
}

From source file:com.google.android.apps.santatracker.doodles.tilt.SwimmingFragment.java

@Override
protected void firstPassLoadOnUiThread() {
    final FrameLayout.LayoutParams wrapperLP = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);/*  ww w  . jav  a 2s . c  om*/

    final SwimmingFragment that = this;
    scoreView = getScoreView();
    pauseView = getPauseView();

    int diveViewBottomMargin = (int) context.getResources().getDimension(R.dimen.dive_margin_bottom);
    int diveViewStartMargin = (int) context.getResources().getDimension(R.dimen.dive_margin_left);
    int diveViewSize = (int) context.getResources().getDimension(R.dimen.dive_image_size);

    FrameLayout.LayoutParams diveViewLP = new LayoutParams(diveViewSize, diveViewSize);
    diveViewLP.setMargins(diveViewStartMargin, 0, 0, diveViewBottomMargin);
    diveViewLP.gravity = Gravity.BOTTOM | Gravity.LEFT;

    if (VERSION.SDK_INT >= 17) {
        diveViewLP.setMarginStart(diveViewStartMargin);
    }
    diveView = new DiveView(context);

    countdownView = new TextView(context);
    countdownView.setGravity(Gravity.CENTER);
    countdownView.setTextColor(context.getResources().getColor(R.color.ui_text_yellow));
    countdownView.setTypeface(Typeface.DEFAULT_BOLD);
    countdownView.setText("0");
    countdownView.setVisibility(View.INVISIBLE);
    Locale locale = context.getResources().getConfiguration().locale;
    countdownView.setText(NumberFormat.getInstance(locale).format(3));
    Point screenDimens = AndroidUtils.getScreenSize();
    UIUtil.fitToBounds(countdownView, screenDimens.x / 10, screenDimens.y / 10);

    LinearLayout gameView = new LinearLayout(context);
    gameView.setOrientation(LinearLayout.VERTICAL);

    // Add game view.
    swimmingView = new SwimmingView(context);
    LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT, 7);
    gameView.addView(swimmingView, lp);

    if (editorMode) {
        LinearLayout buttonWrapper = new LinearLayout(context);
        buttonWrapper.setOrientation(LinearLayout.HORIZONTAL);
        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.WRAP_CONTENT, 1);
        gameView.addView(buttonWrapper, lp);

        resetButton = getButton(R.string.reset_level, new OnClickListener() {
            @Override
            public void onClick(View v) {
                SwimmingModel level = levelManager.loadDefaultLevel();
                initializeLevel(level, false);

                getActivity().getSharedPreferences(context.getString(R.string.swimming), Context.MODE_PRIVATE)
                        .edit().putString(CURRENT_LEVEL_KEY, null).commit();
            }
        });
        deleteButton = getButton(R.string.delete_levels, new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment dialogFragment = new DeleteLevelDialogFragment();
                dialogFragment.show(getActivity().getFragmentManager(), "delete");
            }
        });
        loadButton = getButton(R.string.load_level, new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment dialogFragment = new LoadLevelDialogFragment(that);
                dialogFragment.show(getActivity().getFragmentManager(), "load");
            }
        });
        saveButton = getButton(R.string.save_level, new OnClickListener() {
            @Override
            public void onClick(View v) {
                DialogFragment dialogFragment = new SaveLevelDialogFragment(that);
                dialogFragment.show(getActivity().getFragmentManager(), "save");
            }
        });
        collisionModeButton = new ToggleButton(context);
        collisionModeButton.setText(R.string.scenery_mode);
        collisionModeButton.setTextOff(context.getString(R.string.scenery_mode));
        collisionModeButton.setTextOn(context.getString(R.string.collision_mode));
        collisionModeButton.setOnCheckedChangeListener(new OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                model.collisionMode = isChecked;
            }
        });

        lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                LinearLayout.LayoutParams.MATCH_PARENT, 1);
        buttonWrapper.addView(deleteButton, lp);
        buttonWrapper.addView(resetButton, lp);
        buttonWrapper.addView(loadButton, lp);
        buttonWrapper.addView(saveButton, lp);
        buttonWrapper.addView(collisionModeButton, lp);
    }

    sensorManager = (SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE);
    accelerometerSensor = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    if (accelerometerSensor == null) {
        // TODO: The game won't be playable without this, so what should we do?
        Log.d(TAG, "Accelerometer sensor is null");
    }
    displayRotation = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay()
            .getRotation();

    wrapper.addView(gameView, 0, wrapperLP);
    wrapper.addView(countdownView, 1);
    wrapper.addView(diveView, 2, diveViewLP);
    wrapper.addView(scoreView, 3);
    wrapper.addView(pauseView, 4);
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.OrgProfile.java

@Override
protected void onCreate(Bundle arg0) {
    super.onCreate(arg0);
    Intent i = this.getIntent();
    Bundle b = i.getExtras();/*from w w w .j a  v  a2 s.co m*/

    __keys = new CipherSuit[3];
    __keys[KEY_IDX_ECDSA_BIG] = newCipherSuit(Cipher.ECDSA, Cipher.SHA384, ECDSA.P_521);
    __keys[KEY_IDX_ECDSA] = newCipherSuit(Cipher.ECDSA, Cipher.SHA1, ECDSA.P_256);
    __keys[KEY_IDX_RSA] = newCipherSuit(Cipher.RSA, Cipher.SHA512, 1024);

    // top panel setting
    organization_position = b.getInt(Orgs.O_ID);
    organization_LID = b.getString(Orgs.O_LID);
    organization_GIDH = b.getString(Orgs.O_GIDH);

    oLID = Util.lval(organization_LID, -1);
    if (oLID <= 0)
        return;
    this.org = D_Organization.getOrgByLID(oLID, true, false);
    if (org == null)
        return;

    try {
        Identity crt_identity = Identity.getCurrentConstituentIdentity();
        if (crt_identity == null) {
            Log.d(TAG, "No identity");
        } else
            constituent_LID = net.ddp2p.common.config.Identity.getDefaultConstituentIDForOrg(oLID);
    } catch (P2PDDSQLException e1) {
        e1.printStackTrace();
    }

    if (constituent_LID > 0) {
        constituent = D_Constituent.getConstByLID(constituent_LID, true, false);
        Log.d(TAG, "Got const: " + constituent);
    }

    setContentView(R.layout.org_profile);

    forename = (EditText) findViewById(R.id.profile_furname);
    surname = (EditText) findViewById(R.id.profile_surname);
    neiborhood = (Button) findViewById(R.id.profile_neiborhood);
    submit = (Button) findViewById(R.id.submit_profile);
    submit_new = (Button) findViewById(R.id.submit_profile_new);
    if (constituent == null)
        submit.setVisibility(Button.GONE);
    else
        submit.setVisibility(Button.VISIBLE);
    keys = (Spinner) findViewById(R.id.profile_keys);
    hasRightToVote = (CheckedTextView) findViewById(R.id.profile_hasRightToVote);
    email = (EditText) findViewById(R.id.profile_email);
    slogan = (EditText) findViewById(R.id.profile_slogan);
    slogan.setActivated(false);
    profilePic = (TextView) findViewById(R.id.profile_picture);
    profilePicImg = (ImageView) findViewById(R.id.profile_picture_img);
    // eligibility = (Spinner) findViewById(R.id.profile_eligibility);

    if (constituent != null) {
        forename.setText(constituent.getForename());
        surname.setText(constituent.getSurname());
        hasRightToVote.setChecked(Util.ival(constituent.getWeight(), 0) > 0);
        email.setText(constituent.getEmail());
        slogan.setText(constituent.getSlogan());
    }

    custom_fields = (LinearLayout) findViewById(R.id.profile_view);
    custom_index = 8;
    // custom_fields = (LinearLayout) findViewById(R.id.profile_custom);
    // custom_index = 0;

    custom_params = org.params.orgParam;

    if (custom_params == null || custom_params.length == 0) {
        custom_params = new D_OrgParam[0];// 3
        /*
         * custom_params[0] = new D_OrgParam(); custom_params[0].label =
         * "School"; custom_params[0].entry_size = 5; custom_params[1] = new
         * D_OrgParam(); custom_params[1].label = "Street"; custom_params[2]
         * = new D_OrgParam(); custom_params[2].label = "Year";
         * custom_params[2].list_of_values = new
         * String[]{"2010","2011","2012"};
         */
    }
    D_FieldValue[] field_values = null;
    if (constituent != null && constituent.address != null)
        field_values = constituent.address;
    for (int crt_field = 0; crt_field < custom_params.length; crt_field++) {
        D_OrgParam field = custom_params[crt_field];
        LinearLayout custom_entry = new LinearLayout(this);
        custom_entry.setOrientation(LinearLayout.HORIZONTAL);
        custom_entry.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        TextView custom_label = new TextView(this);
        custom_label.setText(field.label);
        custom_entry.addView(custom_label);

        if (field.list_of_values != null && field.list_of_values.length > 0) {
            Log.d(TAG, "spinner:" + field);
            Spinner custom_spin = new Spinner(this);
            ArrayAdapter<String> custom_spin_Adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_spinner_item, field.list_of_values);
            custom_spin_Adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            custom_spin.setAdapter(custom_spin_Adapter);
            custom_entry.addView(custom_spin);
            D_FieldValue fv = locateFV(field_values, field);
            if (fv != null) {
                int position = 0;
                for (int k = 0; k <= field.list_of_values.length; k++) {
                    if (Util.equalStrings_null_or_not(field.list_of_values[k], fv.value)) {
                        position = k;
                        break;
                    }
                }
                custom_spin.setSelection(position);
            }
        } else {
            Log.d(TAG, "edit: " + field);
            EditText edit_text = new EditText(this);
            edit_text.setText(field.default_value);
            edit_text.setInputType(InputType.TYPE_CLASS_TEXT);
            if (field.entry_size > 0)
                edit_text.setMinimumWidth(field.entry_size * 60);
            Log.d(TAG, "edit: size=" + field.entry_size);
            custom_entry.addView(edit_text);
            // Button child = new Button(this);
            // child.setText("Test");
            D_FieldValue fv = locateFV(field_values, field);
            if (fv != null)
                edit_text.setText(fv.value);
        }
        custom_fields.addView(custom_entry, custom_index++);
    }

    ArrayAdapter<String> keysAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, m);
    keysAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    keys.setAdapter(keysAdapter);
    keys.setOnItemSelectedListener(new KeysListener());

    if (constituent != null) {
        SK sk = constituent.getSK();
        if (sk != null) {
            Cipher cipher = Cipher.getCipher(sk, null);
            if (cipher instanceof net.ddp2p.ciphersuits.RSA) {
                keys.setSelection(KEY_IDX_RSA, true);
            }
            if (cipher instanceof net.ddp2p.ciphersuits.ECDSA) {
                ECDSA ecdsa = (ECDSA) cipher;
                CipherSuit e = ECDSA.getCipherSuite(ecdsa.getPK());
                if (e.hash_alg == Cipher.SHA1) {
                    keys.setSelection(KEY_IDX_ECDSA, true);
                } else {
                    keys.setSelection(KEY_IDX_ECDSA_BIG, true);
                }
            }
        }
    }

    ArrayAdapter<String> eligibilityAdapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, m);
    eligibilityAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // eligibility.setAdapter(eligibilityAdapter);
    // eligibility.setOnItemSelectedListener(new EligibilityListener());

    hasRightToVote.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            hasRightToVote.setChecked(!hasRightToVote.isChecked());
        }
    });

    setProfilePhoto = (ImageView) findViewById(R.id.org_profile_set_profile_photo);
    /*TODO this part only make the whole stuff slow       
    if (constituent_LID > 0) {
     constituent = D_Constituent.getConstByLID(constituent_LID, true,
       true);
     Log.d(TAG, "Got const: " + constituent);
    }
    */
    /*      boolean gotIcon = false;
          if (constituent != null) {
             if (constituent.getPicture() != null) {
    byte[] icon = constituent.getPicture();
    Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0,
          icon.length - 1);
    setProfilePhoto.setImageBitmap(bmp);
    gotIcon = true;
             }
            
             if (!gotIcon) {
    int imgPath = R.drawable.constitutent_person_icon;
    Bitmap bmp = BitmapFactory.decodeResource(getResources(),
          imgPath);
    setProfilePhoto.setImageBitmap(bmp);
             }
          } else {
             int imgPath = R.drawable.constitutent_person_icon;
             Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath);
             setProfilePhoto.setImageBitmap(bmp);
          }
            
          setProfilePhoto.setOnClickListener(new OnClickListener() {
            
             @Override
             public void onClick(View v) {
    if (Build.VERSION.SDK_INT < 19) {
       Intent intent = new Intent();
       intent.setType("image/*");
       intent.setAction(Intent.ACTION_GET_CONTENT);
       startActivityForResult(intent, SELECT_PROFILE_PHOTO);
    } else {
       Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
       intent.setType("image/*");
       startActivityForResult(intent, SELECT_PPROFILE_PHOTO_KITKAT);
    }
             }
          });*/

    submit.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String _forename = forename.getText().toString();
            String _surname = surname.getText().toString();
            int _keys = OrgProfile._selectedKey;
            boolean rightToVote = hasRightToVote.isChecked();
            String _weight = rightToVote ? "1" : "0";
            String _email = email.getText().toString();
            String _slogan = slogan.getText().toString();
            boolean external = false;

            if (constituent == null) {
                D_Constituent new_const = D_Constituent.createConstituent(_forename, _surname, _email, oLID,
                        external, _weight, _slogan, OrgProfile.__keys[_keys].cipher,
                        OrgProfile.__keys[_keys].hash_alg, OrgProfile.__keys[_keys].ciphersize, null, null);

                Log.d(TAG, "saved constituent=" + new_const.getNameFull());
                try {
                    // Identity.DEBUG = true;
                    Identity.setCurrentConstituentForOrg(new_const.getLID(), oLID);
                } catch (P2PDDSQLException e) {
                    e.printStackTrace();
                }
                Log.d(TAG, "saved new constituent=" + new_const);
                constituent = new_const;
            } else {
                constituent = D_Constituent.getConstByConst_Keep(constituent);
                constituent.setEmail(_email);
                constituent.setForename(_forename);
                constituent.setSurname(_surname);
                constituent.setWeight(rightToVote);
                constituent.setSlogan(_slogan);
                constituent.setExternal(false);
                constituent.setCreationDate();
                constituent.sign();
                if (constituent.dirty_any())
                    constituent.storeRequest();
                constituent.releaseReference();
                Log.d(TAG, "saved constituent=" + constituent);
                try {
                    // Identity.DEBUG = true;
                    Identity.setCurrentConstituentForOrg(constituent.getLID(), oLID);
                } catch (P2PDDSQLException e) {
                    e.printStackTrace();
                }
                Log.d(TAG, "saved constituent=" + constituent.getLID() + " oLID=" + oLID);
            }
            if (constituent != null) {
                constituent = D_Constituent.getConstByConst_Keep(constituent);
                if (constituent != null) {
                    if (constituent.getSK() != null) {
                        constituent.setPicture(byteIcon);
                        constituent.setCreationDate();
                        constituent.sign();
                        constituent.storeRequest();
                        constituent.releaseReference();
                        Log.d(TAG, "saved constituent pic: " + constituent.getPicture());
                    }
                }
            }

            if (!org.getBroadcasted()) {
                D_Organization _org = D_Organization.getOrgByOrg_Keep(org);
                if (_org != null) {
                    _org.setBroadcasting(true);
                    if (_org.dirty_any())
                        _org.storeRequest();
                    _org.releaseReference();
                    org = _org;
                }
            }
            Log.d(TAG, "saved constituent pic: " + constituent.getPicture());
            Log.d(TAG, "saved constituent Done");
            finish();
        }
    });
    submit_new.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            String _forename = forename.getText().toString();
            String _surname = surname.getText().toString();
            int _keys = OrgProfile._selectedKey;
            boolean rightToVote = hasRightToVote.isChecked();
            String _weight = rightToVote ? "1" : "0";
            String _email = email.getText().toString();
            String _slogan = slogan.getText().toString();
            boolean external = false;

            D_Constituent new_const = D_Constituent.createConstituent(_forename, _surname, _email, oLID,
                    external, _weight, _slogan, OrgProfile.__keys[_keys].cipher,
                    OrgProfile.__keys[_keys].hash_alg, OrgProfile.__keys[_keys].ciphersize, null, null);

            Log.d(TAG, "saved constituent=" + new_const.getNameFull());
            try {
                // Identity.DEBUG = true;
                Identity.setCurrentConstituentForOrg(new_const.getLID(), oLID);
                Log.d("CONST", "No Set: oLID=" + oLID + " c=" + new_const.getLID());
            } catch (P2PDDSQLException e) {
                e.printStackTrace();
            }
            constituent = new_const;
            constituent_LID = new_const.getLID();
            if (constituent_LID > 0) {
                constituent = D_Constituent.getConstByLID(constituent_LID, true, true);
                Log.d(TAG, "Got const: " + constituent);
            }

            if (constituent != null) {
                if (constituent.getSK() != null) {
                    constituent.setPicture(byteIcon);
                    constituent.setCreationDate();
                    constituent.sign();
                    constituent.storeRequest();
                    constituent.releaseReference();
                    Log.d(TAG, "saved constituent pic: " + constituent.getPicture());
                }
            }

            if (!org.getBroadcasted()) {
                D_Organization _org = D_Organization.getOrgByOrg_Keep(org);
                if (_org != null) {
                    _org.setBroadcasting(true);
                    if (_org.dirty_any())
                        _org.storeRequest();
                    _org.releaseReference();
                    org = _org;
                }
            }
            Log.d(TAG, "saved constituent=" + new_const);
            finish();
        }
    });
}