Example #1
0
  private void initMenuButtons() {
    final int dividerHeight = (int) (2.0f * density);

    menuLayout.setOrientation(LinearLayout.VERTICAL);
    menuLayout.setBackgroundColor(Color.DKGRAY);
    menuLayout.setPadding(dividerHeight, 0, dividerHeight, 0);

    final PaintDrawable divider = new PaintDrawable(Color.WHITE);
    divider.setIntrinsicHeight(dividerHeight);
    menuLayout.setDividerDrawable(divider);
    menuLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);

    saveButton.setText("Save");
    saveButton.setTextSize(20);
    saveButton.setTextColor(this.getResources().getColorStateList(R.color.text_button_color));
    saveButton.setGravity(Gravity.LEFT);
    saveButton.setPadding(
        (int) (10.0f * density),
        (int) (2.0f * density),
        (int) (2.0f * density),
        (int) (10.0f * density));
    saveButton.setBackgroundColor(this.getResources().getColor(R.color.clear));
    menuLayout.addView(saveButton);

    shareButton.setText("Share");
    shareButton.setTextSize(20);
    shareButton.setTextColor(this.getResources().getColorStateList(R.color.text_button_color));
    shareButton.setGravity(Gravity.LEFT);
    shareButton.setPadding(
        (int) (10.0f * density),
        (int) (2.0f * density),
        (int) (2.0f * density),
        (int) (10.0f * density));
    shareButton.setBackgroundColor(this.getResources().getColor(R.color.clear));
    menuLayout.addView(shareButton);

    renameButton.setText("Rename");
    renameButton.setTextSize(20);
    renameButton.setTextColor(this.getResources().getColorStateList(R.color.text_button_color));
    renameButton.setGravity(Gravity.LEFT);
    renameButton.setPadding(
        (int) (10.0f * density),
        (int) (2.0f * density),
        (int) (2.0f * density),
        (int) (10.0f * density));
    renameButton.setBackgroundColor(this.getResources().getColor(R.color.clear));
    menuLayout.addView(renameButton);
  }
Example #2
0
  private void addButtons(LinearLayout mainContainer, int id) {
    int identifier[] = {BUTTON_CLEAR, BUTTON_OK, BUTTON_CANCEL};
    LinearLayout.LayoutParams row_Params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams box_Params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ConvertToPx(mContext, 45), 1f);

    box_Params.setMargins(
        ConvertToPx(mContext, 4),
        ConvertToPx(mContext, 9),
        ConvertToPx(mContext, 4),
        ConvertToPx(mContext, 9));
    LinearLayout row = new LinearLayout(mContext);
    row.setOrientation(LinearLayout.HORIZONTAL);
    row.setLayoutParams(row_Params);
    mainContainer.addView(row);
    for (int i = 0; i < 3; i++) {
      Button tv = new Button(mContext);
      tv.setText(getText(identifier[i]));
      String tvTag;
      if (identifier[i] == BUTTON_OK) tvTag = id + DELIMITER + getText(identifier[i]);
      else tvTag = identifier[i] + DELIMITER + getText(identifier[i]);
      tv.setTag(tvTag);
      tv.setTextColor(Color.BLACK);
      tv.setBackgroundResource(R.drawable.btn_white_transparency_20);
      tv.setGravity(Gravity.CENTER);
      tv.setPadding(0, ConvertToPx(mContext, 2), 0, 0);
      tv.setLayoutParams(box_Params);
      tv.setOnClickListener(Process_Input);
      row.addView(tv);
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    drawer = (MaterialNavigationDrawer) getActivity();

    Button button = new Button(this.getActivity());
    button.setText("start child fragment");
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    button.setLayoutParams(params);
    button.setGravity(Gravity.CENTER);

    button.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            drawer.changeFragment(new ChildFragment(), "Child Title");
            // normally currentSection gets unselect on setCustomFragment call
            // in the next relase, i will add a new method without unselect
            drawer.getCurrentSectionFragment().select();

            // call on current git head. drawer.getCurrentSectionFragment().select(); is not needed
            // drawer.setCustomFragment(drawer.getCurrentSectionFragment().getTargetFragment(),
            // drawer.getCurrentSectionFragment().getFragmentTitle(), true, false);
          }
        });

    return button;
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DBHelper dbHelper = DBHelper.getInstance(getApplicationContext());

    setContentView(R.layout.activity_buoc);

    LinearLayout gardenLayout = (LinearLayout) findViewById(R.id.gardenLayoutLinear);

    // create buttons to put inside linear layout
    int counter = 1;
    for (int rows = 0; rows < 10; rows++) {
      LinearLayout currentLinear = new LinearLayout(this);
      currentLinear.setOrientation(LinearLayout.HORIZONTAL);

      for (int cols = 0; cols < 3; cols++) {
        final Button currButton = new Button(this);
        LinearLayout.LayoutParams param;
        param =
            new LinearLayout.LayoutParams(
                Toolbar.LayoutParams.WRAP_CONTENT, Toolbar.LayoutParams.WRAP_CONTENT, 1.0f);
        currButton.setLayoutParams(param);
        currButton.setWidth(50);
        currButton.setHeight(125);
        currButton.setGravity(Gravity.CENTER);
        currButton.setId(counter);
        currButton.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                redirectToBedOptions(currButton);
              }
            });
        currButton.setText("" + currButton.getId());
        currentLinear.addView(currButton);
        counter++;
      }
      gardenLayout.addView(currentLinear);
    }

    // Grab the first five garden notes and display them in the notes section
    // for now we will mock up data to show.
    final ListView gardenNotePreviewList = (ListView) findViewById(R.id.gardenNotePreviewList);
    Note mock_up_data[] = null;
    try {
      mock_up_data = new Note[5];
      mock_up_data[0] = new Note("Warning signs around garden", "");
      mock_up_data[1] = new Note("Cleaned around garden.", "");
      mock_up_data[2] = new Note("Created new Garden Worksheet.", "");
      mock_up_data[3] = new Note("subject 4", "");
      mock_up_data[4] = new Note("subject 5", "");

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

    GardenLayoutNotePreviewListAdapter adapter =
        new GardenLayoutNotePreviewListAdapter(this, R.layout.custom_garden_note, mock_up_data);
    gardenNotePreviewList.setAdapter(adapter);
  }
Example #5
0
 public void generateScreen() {
   List<String> names = presenter.getAccountNames(username, password);
   LinearLayout layout = (LinearLayout) findViewById(R.id.accountArray);
   TextView account = new TextView(this);
   Point size = new Point();
   Display display =
       ((android.view.WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
   display.getSize(size);
   Button temp;
   if (!(names.size() > 0)) {
     return;
   }
   account.setBackgroundColor(Color.BLACK);
   account.setHeight(2);
   account.setWidth(size.x);
   layout.addView(account);
   for (String name : names) {
     temp = new Button(this);
     temp.setText(name);
     temp.setGravity(Gravity.CENTER);
     temp.setOnClickListener(AccountClickListener);
     layout.addView(temp);
     account = new TextView(this);
     account.setWidth(size.x);
     account.setBackgroundColor(Color.BLACK);
     account.setHeight(2);
     layout.addView(account);
   }
 }
 /** Создаёт новую кнопку элемента меню */
 View newView(MenuEntry ent) {
   Button btn = new Button(st.c());
   int pad = (int) st.floatDp(10, st.c());
   if (st.kv().isDefaultDesign()) {
     btn.setBackgroundDrawable(st.kv().m_drwKeyBack.mutate());
   } else {
     try {
       RectShape clon = st.kv().m_curDesign.m_keyBackground.clone();
       btn.setBackgroundDrawable(((GradBack) clon).getStateDrawable());
     } catch (Throwable e) {
       // TODO: handle exception
     }
   }
   //        setButtonKeyboardBackground(btn);
   btn.setHeight(st.kv().m_KeyHeight);
   btn.setTextColor(st.paint().mainColor);
   if (st.has(m_state, STAT_TEMPLATES) || st.has(m_state, STAT_CLIPBOARD)) {
     btn.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
     btn.setLongClickable(true);
     btn.setOnLongClickListener(m_longListener);
   }
   btn.setMaxLines(1);
   btn.setEllipsize(TruncateAt.MARQUEE);
   btn.setPadding(pad, pad, pad, pad);
   btn.setTag(ent);
   btn.setText(ent.text);
   btn.setOnClickListener(m_listener);
   return btn;
 }
 @Override
 public View onCreateView(
     LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
   Button button = new Button(this.getActivity());
   button.setText("哎呀!出了一些问题,刷新一下试试。。");
   button.setGravity(Gravity.CENTER);
   return button;
 }
Example #8
0
 public Button createListPageButton(
     Activity paramActivity, Map<String, Object> paramMap, String paramString, int paramInt) {
   Button localButton = new Button(paramActivity);
   localButton.setId(paramInt);
   localButton.setTag(Integer.valueOf(5));
   localButton.setText(paramString);
   localButton.setGravity(17);
   localButton.setPadding(3, 0, 3, 0);
   return localButton;
 }
Example #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout layoutMain = new LinearLayout(this);
    layoutMain.setOrientation(LinearLayout.VERTICAL);
    layoutMain.setBackgroundColor(Color.CYAN);

    LinearLayout layoutTitle = new LinearLayout(this);
    layoutTitle.setOrientation(LinearLayout.VERTICAL);
    layoutTitle.setGravity(Gravity.TOP);
    layoutMain.addView(layoutTitle);

    TextView heading = new TextView(this);
    heading.setText("DETECTING INPUT EVENTS \n (Click Or Long Press)");
    heading.setHeight(100);
    heading.setGravity(Gravity.TOP | Gravity.CENTER);
    heading.setBackgroundColor(Color.YELLOW);
    heading.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    heading.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    layoutTitle.addView(heading);

    LinearLayout layoutBody = new LinearLayout(this);
    layoutBody.setOrientation(LinearLayout.VERTICAL);
    layoutBody.setGravity(Gravity.CENTER_HORIZONTAL);
    layoutMain.addView(layoutBody);

    Button btn1 = new Button(this);
    btn1.setWidth(10);
    btn1.setGravity(Gravity.CENTER);
    btn1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    btn1.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    btn1.setText("Click Me With Any Style");
    layoutBody.addView(btn1);

    btn1.setOnClickListener(this);
    btn1.setOnLongClickListener(
        new View.OnLongClickListener() {
          public boolean onLongClick(View v) {
            result.setText("You long pressed the button !!");
            return true;
          }
        });

    result = new TextView(this);
    result.setHeight(200);
    result.setGravity(Gravity.CENTER);
    result.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    result.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    layoutBody.addView(result);

    setContentView(layoutMain);
  }
Example #10
0
  /** @param sortBy */
  void fillData(JobsCursor.SortBy sortBy) {
    // Create a new list to track the addition of TextViews
    lstTable = new ArrayList<View>(); // a list of the TableRow's added
    // Get all of the rows from the database and create the table
    // Keep track of the TextViews added in list lstTable
    cursor = db.getJobs(sortBy);
    // Create a table row that contains two lists
    // (one for job titles, one for employers)
    // Now load the lists with job title and employer name
    // for (Jobs row : rows) {
    for (int rowNum = 0; rowNum < cursor.getCount(); rowNum++) {
      cursor.moveToPosition(rowNum);
      TableRow tr = new TableRow(this);
      tr.setLayoutParams(
          new LayoutParams(
              android.view.ViewGroup.LayoutParams.FILL_PARENT,
              android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
      // Create a Button for the job title.
      mjButton btn1 = new mjButton(this);
      // Button btn1 = new Button(this);
      btn1.jrow = rowNum;
      btn1.setText(cursor.getColTitle());
      btn1.setPadding(1, 0, 3, 0);
      btn1.setHeight(40);
      btn1.setGravity(android.view.Gravity.CENTER);
      btn1.setBackgroundColor(colorByStatus((int) cursor.getColStatus()));
      btn1.setOnClickListener(onTitleClick);
      // Add job title to job list.
      tr.addView(btn1);

      Button btn2 = new Button(this);
      btn2.setPadding(1, 0, 3, 0);
      btn2.setText(cursor.getColEmployerName());
      btn2.setHeight(40);
      btn2.setGravity(android.view.Gravity.CENTER);
      btn2.setBackgroundColor(Color.WHITE);
      /* Add employer name to that list. */
      tr.addView(btn2);

      tblJobs.addView(tr);
      // lstJobs.add(btn1.getId()); // keep job id to get more info later if needed
      lstTable.add(tr); // keep track of the rows we've added (to remove later)
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    LinearLayout ll = new LinearLayout(getActivity());
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);

    Button label = new Button(getActivity());
    label.setText("Toggle Skybox");
    label.setTextSize(20);
    label.setGravity(Gravity.CENTER_HORIZONTAL);
    label.setHeight(100);
    ll.addView(label);
    label.setOnClickListener((SkyboxRenderer) mRenderer);
    mLayout.addView(ll);

    return mLayout;
  }
Example #12
0
  private void addAlphabets(LinearLayout mainContainer) {
    String alphabets[] = {
      "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
      "T", "U", "V", "W", "X", "Y", "Z", "_", ".", " ", "<-"
    };
    int length = alphabets.length;

    LinearLayout.LayoutParams row_Params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams box_Params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ConvertToPx(mContext, 40), 1f);
    RelativeLayout.LayoutParams verticalDivider_params =
        new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
    RelativeLayout.LayoutParams horizontalDivider_params =
        new RelativeLayout.LayoutParams(1, ViewGroup.LayoutParams.MATCH_PARENT);
    int i = 0;
    while (i < length) {
      LinearLayout row = new LinearLayout(mContext);
      row.setOrientation(LinearLayout.HORIZONTAL);
      row.setLayoutParams(row_Params);
      mainContainer.addView(row);
      mainContainer.addView(getDivider(verticalDivider_params));
      for (int col = 0; col < 5 && i < length; col++, i++) {
        Button tv = new Button(mContext);
        tv.setText(alphabets[i]);
        String tvTag = ALPHABET + DELIMITER + alphabets[i];
        tv.setTag(tvTag);
        tv.setTextColor(Color.BLACK);
        tv.setBackgroundColor(Color.argb(180, 255, 255, 255));
        tv.setGravity(Gravity.CENTER);
        tv.setPadding(0, ConvertToPx(mContext, 3), 0, 0);
        tv.setLayoutParams(box_Params);
        tv.setOnClickListener(Process_Input);
        row.addView(tv);
        row.addView(getDivider(horizontalDivider_params));
      }
    }
  }
Example #13
0
  public GateView(Context context) {

    LayoutInflater inflater = LayoutInflater.from(context);
    view = inflater.inflate(R.layout.gatelayout, null);
    view.setVisibility(View.INVISIBLE);
    // メインのスクロールビュー
    maintable = (TableLayout) view.findViewById(R.id.gate_maintable);
    tagLabel = (TextView) view.findViewById(R.id.gate_taglabel);
    titleLabel = (TextView) view.findViewById(R.id.gate_titlelabel);
    commuLabel = (TextView) view.findViewById(R.id.gate_commulabel);
    descLabel = (TextView) view.findViewById(R.id.gate_desclabel);
    close = (FrameLayout) view.findViewById(R.id.gate_close_frame);

    progressParent = inflater.inflate(R.layout.progressbar, null);
    progressArea = (ViewGroup) view.findViewById(R.id.progresslinear);
    ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.ProgressBarHorizontal);
    progressArea.removeView(progressBar);

    commuThumbNail = (ImageView) view.findViewById(R.id.community_thumbnail);
    commuThumbNail.setScaleType(ImageView.ScaleType.CENTER_CROP);
    start = (TextView) view.findViewById(R.id.open_livetime);
    seet_num = (TextView) view.findViewById(R.id.seet_num);
    //		open = (TextView) view.findViewById(R.id.open_roomtime);
    passedtime = (TextView) view.findViewById(R.id.passed_time);
    commuName = (TextView) view.findViewById(R.id.gate_community_name);
    ownerName = (TextView) view.findViewById(R.id.gate_owner_name);
    // タグテキストの親
    tagP = (LinearLayout) view.findViewById(R.id.gate_tags_parent);
    // タイトルテキストの親
    titleP = (LinearLayout) view.findViewById(R.id.gate_title_parent);
    // 詳細の親
    descP = (LinearLayout) view.findViewById(R.id.gate_desc_parent);
    // コミュニティインフォの親
    commuP = (LinearLayout) view.findViewById(R.id.gate_commuinfo_parent);
    // 来場、コメ数
    viewCount = (TextView) view.findViewById(R.id.gate_viewcount);
    resNum = (TextView) view.findViewById(R.id.gate_resnum);

    reserveBt = (Button) view.findViewById(R.id.gate_reserve_bt);

    NLiveRoid app = (NLiveRoid) context.getApplicationContext();
    this.width = (int) (app.getViewWidth() * app.getMetrics());
    this.height = (int) (app.getViewHeight() * app.getMetrics());
    // 何故メトリックスをかけなきゃいけないのかがわからない
    int bWidth = (int) (width / 6);
    // 下のボタン
    Log.d("NLiveRoid", "GateBt " + width);
    copyBt = new Button(context);
    copyBt.setText("コピー");
    copyBt.setTextSize(width / 65);
    communityBt = new Button(context);
    communityBt.setText("コミュ機能");
    communityBt.setTextSize(width / 80);
    browserBt = new Button(context);
    browserBt.setText("ブラウザ");
    browserBt.setTextSize(width / 65);
    tagLinkBt = new Button(context);
    tagLinkBt.setText("タグ");
    tagLinkBt.setTextSize(width / 60);
    snsBt = new Button(context);
    snsBt.setText("SNS");
    snsBt.setTextSize(width / 60);
    goPlayerB = new Button(context);
    goPlayerB.setText("視聴する");
    goPlayerB.setGravity(Gravity.TOP);
    lParent = (TableRow) view.findViewById(R.id.gate_linkbutton_parent);
    lParent.addView(copyBt, bWidth, 80);
    lParent.addView(communityBt, bWidth, 80);
    lParent.addView(browserBt, bWidth, 80);
    lParent.addView(tagLinkBt, bWidth, 80);
    lParent.addView(snsBt, bWidth, 80);
    lParent.addView(goPlayerB, bWidth * 2, 80);
  }
Example #14
0
  /**
   * Ajoute une nouvelle TableRow au TableLayout contenant la liste des ports favoris.
   *
   * @param selectedPort le port à ajouter
   */
  public void addTableRow(int selectedPort) {
    TableRow tr = new TableRow(this);
    tr.setId(1000 + selectedPort);
    tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    TextView labelPort = new TextView(this);
    labelPort.setId(2000 + selectedPort);
    labelPort.setText(mPortName[selectedPort]);
    // labelPort.setTextColor(Color.RED);
    labelPort.setLayoutParams(
        new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    tr.addView(labelPort);

    // Quand on clique sur le nom du port, on va lancer l'activité qui
    // affiche les marées pour le port en question
    labelPort.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            // On récupère l'ID du port
            int port = v.getId() - 2000;

            // Le Bundle sert à stocker des valeurs que l'on souhaite
            // transmettre à la nouvelle activité. Ici le numéro du port
            // pour pouvoir construire l'URL du widget, et le nom du port
            // pour l'afficher dans la barre de titre (purement cosmétique).
            Bundle bundle = new Bundle();
            bundle.putInt("info.yakablog.hmarees.port", mPortNumber[port]);
            bundle.putString("info.yakablog.hmarees.portName", mPortName[port]);

            // On lance l'activité qui va afficher les horaires de marées.
            Intent myIntent = new Intent(v.getContext(), ViewTides.class);
            myIntent.putExtras(bundle);
            startActivity(myIntent);
          }
        });

    // On crée le bouton "supprimer" et on l'ajoute à la TableRow
    Button supprPort = new Button(this);
    supprPort.setId(3000 + selectedPort);
    supprPort.setText("[-]");
    supprPort.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    supprPort.setGravity(Gravity.RIGHT);
    tr.addView(supprPort);

    // On exécute l'action suivante lorsqu'on clique sur le bouton Supprimer
    supprPort.setOnClickListener(
        new OnClickListener() {

          public void onClick(View v) {
            int port = v.getId() - 3000;
            int viewToRemoveIndex = tablePorts.indexOfChild((View) v.getParent());

            // Supprime la TableRow sélectionnée (donc le nom du port et
            // le bouton "supprimer" associé)
            tablePorts.removeViewAt(viewToRemoveIndex);
            // Supprime le séparateur suivant la TableRow qu'on vient de
            // supprimer (ce séparateur a maintenant le même index que la
            // TableRow)
            tablePorts.removeViewAt(viewToRemoveIndex);

            // Maintenant on reconstruit la liste des ports sans celui qui
            // vient d'être supprimé et on écrit cette liste dans les
            // préférences.
            SharedPreferences.Editor editor = prefs.edit();
            String listePorts = prefs.getString("listeports", "");
            String[] arrayListPortsSrc = listePorts.split("#");
            ArrayList<String> arrayListPortsDest = new ArrayList<String>();
            for (String thisPort : arrayListPortsSrc) {
              if (!thisPort.equals("" + port)) {
                arrayListPortsDest.add(thisPort);
              }
            }
            String newPortsList = "";
            for (String newPort : arrayListPortsDest) {
              if (!newPortsList.equals("")) {
                newPortsList += "#";
              }
              newPortsList += newPort;
            }
            editor.putString("listeports", newPortsList);
            editor.commit();
          }
        });

    // On ajoute la TableRow enfin créée à la table des ports favoris
    tablePorts.addView(
        tr, new TableLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

    // On ajoute également à la suite de la nouvelle TableRow un séparateur
    View separation = new View(this);
    separation.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 2));
    separation.setBackgroundColor(Color.parseColor("#FF909090"));
    tablePorts.addView(separation);
  }
Example #15
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.reply);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);

    ExitApplication.getInstance().addActivity(this);

    sharedPreferences = getSharedPreferences("userApp", Context.MODE_PRIVATE);
    replyNum = sharedPreferences.getInt("replyNum", 10);
    replyListView = (ListView) findViewById(R.id.replyListview);
    replyProgressbar = (ProgressBar) findViewById(R.id.reply_progressbar);
    replyProgressbar.setIndeterminate(false);

    model = sharedPreferences.getInt("imgState", 0);
    headImgState = sharedPreferences.getInt("headImgState", 0);

    bundle = this.getIntent().getExtras();

    replyLinearLayout = (LinearLayout) findViewById(R.id.reply_ll);
    replyLinearLayout.setVisibility(View.INVISIBLE);

    backImgbtn = (ImageButton) findViewById(R.id.reply_back_imgbtn);
    refreshImgbtn = (ImageButton) findViewById(R.id.reply_refresh_imgbtn);
    backImgbtn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            finish();
          }
        });
    refreshImgbtn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            refreshTask();
          }
        });
    more_layout = new LinearLayout(this);

    title_text = new TextView(this);
    title_text.setPadding(10, 0, 0, 0);
    title_text.setText(bundle.getString("name"));
    title_text.setTextColor(0xff000000);
    title_text.setTextSize(16);
    title_text.setBackgroundResource(R.drawable.reply_subject_bg);
    title_text.setGravity(Gravity.CENTER_VERTICAL);
    replyListView.addHeaderView(title_text);

    nextPage = new Button(this);
    nextPage.setText(R.string.next);
    nextPage.setBackgroundResource(R.drawable.mforum_bg);
    nextPage.setGravity(Gravity.CENTER);
    more_layout.addView(nextPage, FWLayoutParams);

    nextPage.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            ++page;
            replyTask();
          }
        });
    refreshImgbtn.setVisibility(View.INVISIBLE);
    backImgbtn.setVisibility(View.INVISIBLE);
    replyListView.setOnTouchListener(ListViewOnTouchListener);
  }
Example #16
0
    @Override
    public View getChildView(
        int groupPosition,
        int childPosition,
        boolean isLastChild,
        View convertView,
        ViewGroup parent) {
      final Entity ent = (Entity) getChild(groupPosition, childPosition);
      // Set an id depending on the table ent belongs to
      int entId;
      if (ent.getTable() == "homework") {
        entId = 1;
      } else if (ent.getTable() == "assignment") {
        entId = 2;
      } else if (ent.getTable() == "exam") {
        entId = 3;
      } else {
        entId = 4;
      }

      // Depending on the id, do something different. For the first three, the only bit that changes
      // is the string in the alertDialog and the activity
      // that's opened when you press the element on the list. I'll comment due homework list, the
      // other are the same.
      switch (entId) {
          // Due homework list
        case 1:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_dueitem, null);
          try {
            Button title = (Button) convertView.findViewById(R.id.title);
            ImageView remove = (ImageView) convertView.findViewById(R.id.dueremove);
            TextView dueclass = (TextView) convertView.findViewById(R.id.dueclass);
            LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.linearLayout1);

            // When editing this element, get the date it was set, not the date you're viewing.
            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(ent.getLong("setDate"));

            // Set text
            title.setText("- " + ent.getString("title"));
            // If the homework is done, strike it through.
            if (ent.getInt("done") == 1) {
              title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              layout.setBackgroundColor(getResources().getColor(R.color.grey));
            }
            title.setOnClickListener(
                new OnClickListener() {

                  // When the element's pressed, open AddHwDialog with all the necessary data to
                  // edit it.
                  public void onClick(View addexam) {
                    Intent i = new Intent(AgendaDay.this, AddHwDialog.class);
                    i.putExtra("homework_id", ent.getId());
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_EDIT);
                  }
                });

            remove.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View removerecord) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                    builder
                        .setMessage(R.string.sureHomework)
                        .setTitle(R.string.sureHomeworkTitle)
                        .setCancelable(true)
                        .setNegativeButton(
                            R.string.cancel,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                dialog.cancel();
                              }
                            })
                        .setPositiveButton(
                            R.string.accept,
                            new DialogInterface.OnClickListener() {
                              // Remove the element.
                              public void onClick(DialogInterface dialog, int arg1) {
                                ent.delete();
                                fillList();
                              }
                            });
                    AlertDialog AD = builder.create();
                    AD.show();
                  }
                });

            // Get the subject this element is associated with...
            Entity classEnt = new Entity("class", ent.getLong("class_id"));
            Entity subject = new Entity("subject", classEnt.getLong("subject_id"));

            // ...to put it as the name that appears.
            dueclass.setText(subject.getString("title"));
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
          // Due assignment list
        case 2:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_dueitem, null);
          try {
            Button title = (Button) convertView.findViewById(R.id.title);
            ImageView remove = (ImageView) convertView.findViewById(R.id.dueremove);
            TextView dueclass = (TextView) convertView.findViewById(R.id.dueclass);
            LinearLayout layout = (LinearLayout) convertView.findViewById(R.id.linearLayout1);

            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(ent.getLong("setDate"));

            title.setText("- " + ent.getString("title"));
            if (ent.getInt("done") == 1) {
              title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              layout.setBackgroundColor(getResources().getColor(R.color.grey));
            }
            title.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View addexam) {
                    Intent i = new Intent(AgendaDay.this, AddAssignDialog.class);
                    i.putExtra("assign_id", ent.getId());
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_EDIT);
                  }
                });

            remove.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View removerecord) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                    builder
                        .setMessage(R.string.sureAssignment)
                        .setTitle(R.string.sureAssignmentTitle)
                        .setCancelable(true)
                        .setNegativeButton(
                            R.string.cancel,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                dialog.cancel();
                              }
                            })
                        .setPositiveButton(
                            R.string.accept,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                ent.delete();
                                fillList();
                              }
                            });
                    AlertDialog AD = builder.create();
                    AD.show();
                  }
                });

            Entity classEnt = new Entity("class", ent.getLong("class_id"));
            Entity subject = new Entity("subject", classEnt.getLong("subject_id"));

            dueclass.setText(subject.getString("title"));
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
          // Due exam list
        case 3:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_dueitem, null);
          try {
            Button title = (Button) convertView.findViewById(R.id.title);
            ImageView remove = (ImageView) convertView.findViewById(R.id.dueremove);
            TextView dueclass = (TextView) convertView.findViewById(R.id.dueclass);

            final Calendar c = Calendar.getInstance();
            c.setTimeInMillis(ent.getLong("setDate"));

            title.setText("- " + ent.getString("title"));
            title.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View addexam) {
                    Intent i = new Intent(AgendaDay.this, AddExamDialog.class);
                    i.putExtra("exam_id", ent.getId());
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_EDIT);
                  }
                });

            remove.setOnClickListener(
                new OnClickListener() {

                  public void onClick(View removerecord) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                    builder
                        .setMessage(R.string.sureExam)
                        .setTitle(R.string.sureExamTitle)
                        .setCancelable(true)
                        .setNegativeButton(
                            R.string.cancel,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                dialog.cancel();
                              }
                            })
                        .setPositiveButton(
                            R.string.accept,
                            new DialogInterface.OnClickListener() {
                              public void onClick(DialogInterface dialog, int arg1) {
                                ent.delete();
                                fillList();
                              }
                            });
                    AlertDialog AD = builder.create();
                    AD.show();
                  }
                });

            Entity classEnt = new Entity("class", ent.getLong("class_id"));
            Entity subject = new Entity("subject", classEnt.getLong("subject_id"));

            dueclass.setText(subject.getString("title"));
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
          // Today's classes list
        case 4:
          convertView = View.inflate(AgendaDay.this, R.layout.agendaday_item, null);
          try {
            Long subjectid = (Long) ent.getValue("subject_id");
            Entity subjectent = new Entity("subject", subjectid);

            // Get when the class starts and when it ends to...
            String starttimehour = ent.getString("starttimehour");
            // Add a 0 if it's lower than 10, Java doesn't do it automatically.
            if (Integer.parseInt(starttimehour) < 10) {
              starttimehour = "0" + starttimehour;
            }
            String starttimeminute = ent.getString("starttimeminute");
            if (Integer.parseInt(starttimeminute) < 10) {
              starttimeminute = "0" + starttimeminute;
            }
            String endtimehour = ent.getString("endtimehour");
            if (Integer.parseInt(endtimehour) < 10) {
              endtimehour = "0" + endtimehour;
            }
            String endtimeminute = ent.getString("endtimeminute");
            if (Integer.parseInt(endtimeminute) < 10) {
              endtimeminute = "0" + endtimeminute;
            }

            // ...display it nicely in a TextView
            String classLength =
                " ("
                    + starttimehour
                    + ":"
                    + starttimeminute
                    + "-"
                    + endtimehour
                    + ":"
                    + endtimeminute
                    + ")";

            TextView subject = (TextView) convertView.findViewById(R.id.subjectname);
            TextView classLengthText = (TextView) convertView.findViewById(R.id.classlength);
            subject.setText(subjectent.getString("title"));
            classLengthText.setText(classLength);

            LinearLayout hwlist =
                (LinearLayout) convertView.findViewById(R.id.homeworkLinearLayout);
            LinearLayout assignlist =
                (LinearLayout) convertView.findViewById(R.id.assignmentLinearLayout);
            LinearLayout examlist = (LinearLayout) convertView.findViewById(R.id.examLinearLayout);

            try {
              // Start my three arraylists.
              entHw = new ArrayList<Entity>();
              entExams = new ArrayList<Entity>();
              entAssignments = new ArrayList<Entity>();
              // Get today's date.
              Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
              c.set(mYear, mMonth, mDay, 0, 0, 0);
              c.set(Calendar.MILLISECOND, 0);

              // Get all homework associated to the class you're viewing.
              List<Entity> entclassHw =
                  db.getEntityList("homework", "class_id = '" + ent.getId() + "'");
              Iterator<Entity> iter = entclassHw.iterator();
              // Put in entHw only those that are set on the day you're viewing
              while (iter.hasNext()) {
                Entity HwEnt = (Entity) iter.next();
                Calendar d = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                d.setTimeInMillis(HwEnt.getLong("setDate"));
                if (d.getTimeInMillis() == c.getTimeInMillis()) {
                  entHw.add(HwEnt);
                }
              }
              List<Entity> entclassAssignments =
                  db.getEntityList("assignment", "class_id = '" + ent.getId() + "'");
              Iterator<Entity> iter2 = entclassAssignments.iterator();
              while (iter2.hasNext()) {
                Entity AssignEnt = (Entity) iter2.next();
                Calendar d = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                d.setTimeInMillis(AssignEnt.getLong("setDate"));
                if (d.get(Calendar.YEAR) == c.get(Calendar.YEAR)
                    && d.get(Calendar.DAY_OF_YEAR) == c.get(Calendar.DAY_OF_YEAR)) {
                  entAssignments.add(AssignEnt);
                }
              }
              List<Entity> entclassExams =
                  db.getEntityList("exam", "class_id = '" + ent.getId() + "'");
              Iterator<Entity> iter3 = entclassExams.iterator();
              while (iter3.hasNext()) {
                Entity ExamEnt = (Entity) iter3.next();
                Calendar d = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
                d.setTimeInMillis(ExamEnt.getLong("setDate"));
                if (d.get(Calendar.YEAR) == c.get(Calendar.YEAR)
                    && d.get(Calendar.DAY_OF_YEAR) == c.get(Calendar.DAY_OF_YEAR)) {
                  entExams.add(ExamEnt);
                }
              }
            } catch (Exception e) {
              e.printStackTrace();
            }

            // Get a date for the day you're viewing
            final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
            c.set(mYear, mMonth, mDay, 0, 0, 0);
            c.set(Calendar.MILLISECOND, 0);

            // For every homework you have on the day your viewing and the class element the list is
            // at.
            for (final Entity ent2 : entHw) {
              LinearLayout linear = new LinearLayout(getApplicationContext());
              linear.setOrientation(LinearLayout.HORIZONTAL);
              LayoutParams linearLayoutParams =
                  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
              linear.setLayoutParams(linearLayoutParams);
              linear.setBackgroundResource(R.color.purple);

              Button hwTitle = new Button(getApplicationContext());
              hwTitle.setText("- " + ent2.getString("title"));
              if (ent2.getInt("done") == 1) {
                hwTitle.setPaintFlags(hwTitle.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              }
              hwTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 19);
              hwTitle.setGravity(Gravity.LEFT);
              hwTitle.setPadding(5, 5, 0, 5);
              LayoutParams titleButtonLayoutParams =
                  new LinearLayout.LayoutParams(
                      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
              hwTitle.setLayoutParams(titleButtonLayoutParams);
              hwTitle.setBackgroundColor(android.R.color.transparent);

              hwTitle.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View addexam) {
                      Intent i = new Intent(AgendaDay.this, AddHwDialog.class);
                      i.putExtra("homework_id", ent2.getId());
                      i.putExtra("todayCalendar", c.getTimeInMillis());
                      startActivityForResult(i, ACTIVITY_EDIT);
                    }
                  });

              ImageView remove = new ImageView(getApplicationContext());
              LayoutParams removeButtonLayoutParams =
                  new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              removeButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL;
              remove.setBackgroundDrawable(getResources().getDrawable(R.drawable.remove));
              remove.setLayoutParams(removeButtonLayoutParams);

              remove.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View removerecord) {
                      AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                      builder
                          .setMessage(R.string.sureHomework)
                          .setTitle(R.string.sureHomeworkTitle)
                          .setCancelable(true)
                          .setNegativeButton(
                              R.string.cancel,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  dialog.cancel();
                                }
                              })
                          .setPositiveButton(
                              R.string.accept,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  ent2.delete();
                                  fillList();
                                }
                              });
                      AlertDialog AD = builder.create();
                      AD.show();
                    }
                  });

              linear.addView(hwTitle);
              linear.addView(remove);
              hwlist.addView(linear);
            }

            for (final Entity ent2 : entAssignments) {
              LinearLayout linear = new LinearLayout(getApplicationContext());
              linear.setOrientation(LinearLayout.HORIZONTAL);
              LayoutParams linearLayoutParams =
                  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
              linear.setLayoutParams(linearLayoutParams);
              linear.setBackgroundResource(R.color.light_green);

              Button assignTitle = new Button(getApplicationContext());
              assignTitle.setText("- " + ent2.getString("title"));
              if (ent2.getInt("done") == 1) {
                assignTitle.setPaintFlags(
                    assignTitle.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
              }
              assignTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
              assignTitle.setGravity(Gravity.LEFT);
              assignTitle.setPadding(5, 5, 0, 5);
              LayoutParams titleButtonLayoutParams =
                  new LinearLayout.LayoutParams(
                      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
              assignTitle.setLayoutParams(titleButtonLayoutParams);
              assignTitle.setBackgroundColor(android.R.color.transparent);

              assignTitle.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View addexam) {
                      Intent i = new Intent(AgendaDay.this, AddAssignDialog.class);
                      i.putExtra("assign_id", ent2.getId());
                      i.putExtra("todayCalendar", c.getTimeInMillis());
                      startActivityForResult(i, ACTIVITY_EDIT);
                    }
                  });

              ImageView remove = new ImageView(getApplicationContext());
              LayoutParams removeButtonLayoutParams =
                  new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              removeButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL;
              remove.setBackgroundDrawable(getResources().getDrawable(R.drawable.remove));
              remove.setLayoutParams(removeButtonLayoutParams);

              remove.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View removerecord) {
                      AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                      builder
                          .setMessage(R.string.sureAssignment)
                          .setTitle(R.string.sureAssignmentTitle)
                          .setCancelable(true)
                          .setNegativeButton(
                              R.string.cancel,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  dialog.cancel();
                                }
                              })
                          .setPositiveButton(
                              R.string.accept,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  ent2.delete();
                                  fillList();
                                }
                              });
                      AlertDialog AD = builder.create();
                      AD.show();
                    }
                  });

              linear.addView(assignTitle);
              linear.addView(remove);
              assignlist.addView(linear);
            }

            for (final Entity ent2 : entExams) {
              LinearLayout linear = new LinearLayout(getApplicationContext());
              linear.setOrientation(LinearLayout.HORIZONTAL);
              LayoutParams linearLayoutParams =
                  new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
              linear.setLayoutParams(linearLayoutParams);
              linear.setBackgroundResource(R.color.light_orange);

              Button examTitle = new Button(getApplicationContext());
              examTitle.setText("- " + ent2.getString("title"));
              examTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
              examTitle.setGravity(Gravity.LEFT);
              examTitle.setPadding(5, 5, 0, 5);
              LayoutParams titleButtonLayoutParams =
                  new LinearLayout.LayoutParams(
                      LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1);
              examTitle.setLayoutParams(titleButtonLayoutParams);
              examTitle.setBackgroundColor(android.R.color.transparent);

              examTitle.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View addexam) {
                      Intent i = new Intent(AgendaDay.this, AddExamDialog.class);
                      i.putExtra("exam_id", ent2.getId());
                      i.putExtra("todayCalendar", c.getTimeInMillis());
                      startActivityForResult(i, ACTIVITY_EDIT);
                    }
                  });

              ImageView remove = new ImageView(getApplicationContext());
              LayoutParams removeButtonLayoutParams =
                  new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
              removeButtonLayoutParams.gravity = Gravity.CENTER_VERTICAL;
              remove.setBackgroundDrawable(getResources().getDrawable(R.drawable.remove));
              remove.setLayoutParams(removeButtonLayoutParams);

              remove.setOnClickListener(
                  new OnClickListener() {

                    public void onClick(View removerecord) {
                      AlertDialog.Builder builder = new AlertDialog.Builder(AgendaDay.this);
                      builder
                          .setMessage(R.string.sureExam)
                          .setTitle(R.string.sureExamTitle)
                          .setCancelable(true)
                          .setNegativeButton(
                              R.string.cancel,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  dialog.cancel();
                                }
                              })
                          .setPositiveButton(
                              R.string.accept,
                              new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int arg1) {
                                  ent2.delete();
                                  fillList();
                                }
                              });
                      AlertDialog AD = builder.create();
                      AD.show();
                    }
                  });

              linear.addView(examTitle);
              linear.addView(remove);
              examlist.addView(linear);
            }

            ImageView add = (ImageView) convertView.findViewById(R.id.add);

            add.setOnClickListener(
                new OnClickListener() {
                  public void onClick(View addsubject) {
                    Intent i = new Intent(AgendaDay.this, AddAssignmentListDialog.class);
                    i.putExtra("class_id", ent.getId());
                    Calendar c = Calendar.getInstance();
                    c.set(mYear, mMonth, mDay, 0, 0, 0);
                    c.set(Calendar.MILLISECOND, 0);
                    c.setTimeZone(TimeZone.getTimeZone("GMT"));
                    i.putExtra("todayCalendar", c.getTimeInMillis());
                    startActivityForResult(i, ACTIVITY_CREATE);
                  }
                });
          } catch (Exception e) {
            e.printStackTrace();
          }
          break;
      }
      return convertView;
    }
  private void initComponents() {
    LinearLayout llRoot = (LinearLayout) this.findViewById(R.id.llRoot);
    LinearLayout llHeaderBase = (LinearLayout) this.findViewById(R.id.llHeaderBase);

    LinearLayout llHeaderUserSelector = (LinearLayout) this.findViewById(R.id.llHeaderUserSelector);
    EditText etFilterName = (EditText) this.findViewById(R.id.etFilterName);
    Button btnSearch = (Button) findViewById(R.id.btnSearch);
    btnFollowing = (Button) findViewById(R.id.btnFollowing);
    btnRecentContact = (Button) findViewById(R.id.btnRecentContact);
    lvUser = (ListView) this.findViewById(R.id.lvUser);

    LinearLayout llToolbar = (LinearLayout) this.findViewById(R.id.llToolbar);
    Button btnConfirm = (Button) this.findViewById(R.id.btnConfirm);
    Button btnCancel = (Button) this.findViewById(R.id.btnCancel);

    ThemeUtil.setRootBackground(llRoot);
    ThemeUtil.setSecondaryHeader(llHeaderBase);

    llHeaderUserSelector.setBackgroundDrawable(theme.getDrawable("bg_header_corner_search"));
    int padding6 = theme.dip2px(6);
    int padding8 = theme.dip2px(8);
    llHeaderUserSelector.setPadding(padding6, padding8, padding6, padding8);
    etFilterName.setBackgroundDrawable(theme.getDrawable("bg_input_frame_left_half"));
    btnSearch.setBackgroundDrawable(theme.getDrawable("selector_btn_search"));
    btnFollowing.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_left"));
    btnFollowing.setPadding(0, 0, 0, 0);
    ColorStateList selectorBtnTab = theme.getColorStateList("selector_btn_tab");
    btnFollowing.setTextColor(selectorBtnTab);
    btnFollowing.setGravity(Gravity.CENTER);
    btnRecentContact.setBackgroundDrawable(theme.getDrawable("selector_tab_toggle_right"));
    btnRecentContact.setPadding(0, 0, 0, 0);
    btnRecentContact.setTextColor(selectorBtnTab);
    btnRecentContact.setGravity(Gravity.CENTER);

    ThemeUtil.setListViewStyle(lvUser);
    llToolbar.setBackgroundDrawable(theme.getDrawable("bg_toolbar"));
    ThemeUtil.setBtnActionPositive(btnConfirm);
    ThemeUtil.setBtnActionNegative(btnCancel);

    TextView tvTitle = (TextView) this.findViewById(R.id.tvTitle);
    tvTitle.setText(title);

    selectorAdapter = new UserQuickSelectorListAdapter(this, account, selectMode);
    showLoadingFooter();
    lvUser.setAdapter(selectorAdapter);
    lvUser.setFastScrollEnabled(yibo.isSliderEnabled());
    setBack2Top(lvUser);

    recyclerListener = new UserSelectorRecyclerListener();
    lvUser.setRecyclerListener(recyclerListener);

    lvUser.setOnItemClickListener(
        new OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (position == parent.getCount() - 1) {
              view.performClick();
            } else {
              CheckBox checkBox = (CheckBox) view.findViewById(R.id.cbUser);
              checkBox.performClick();
              UserQuickSelectorActivity.this.updateButtonState();
            }
          }
        });
  }
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    if (simTopUpNameEdit == null) {
      simTopUpNameEdit = (EditText) findViewById(R.id.name_edit);
      if (BaseActivity.initValue) {
        simTopUpNameEdit.setText("seekting.x.zhang");
      }
      phoneNumberEdit = (EditText) findViewById(R.id.phone_edit);
      if (BaseActivity.initValue) {
        phoneNumberEdit.setText("13691168978");
      }
      operatorText = (TextView) findViewById(R.id.operator);
      bankTransferLayout = (LinearLayout) findViewById(R.id.bank_transfer_layout);
      transferEntryLayout = (LinearLayout) findViewById(R.id.transfer_entry_layout);
      simtopUpLayout = (LinearLayout) findViewById(R.id.sim_top_up_layout);
      prepaidCardLayout = (LinearLayout) findViewById(R.id.prepaid_card_reloadlayout);
      addToBeneficiariesCheckBox = (CheckBox) findViewById(R.id.ad_to_beneficiaries);
      // banktransfer
      bankTransferNameEditText = (EditText) findViewById(R.id.bank_name_edit);
      ibanEdtiText = (EditText) findViewById(R.id.iban_code);
      bicEditText = (EditText) findViewById(R.id.bic_code);

      // transferEntry

      tranGroup = (RadioGroup) findViewById(R.id.transfer_entry_rg);
      tranGroup.removeAllViews();

      // re

      beneficiaryNameEditText = (EditText) findViewById(R.id.beneficiary_name);

      cardNumberEditText = (EditText) findViewById(R.id.card_number);
      myCardBtn = (ImageButton) findViewById(R.id.my_card_btn);
      vertifyBtn = (ImageButton) findViewById(R.id.vertify_card_btn);
      myCardBtn.setOnClickListener(this);
      vertifyBtn.setOnClickListener(this);

      expandFocusResultChange(simTopUpNameEdit.getText().toString());
      // value = generateValue();
      TextWatcher textWatcher = newTextChangeListener();

      bankTransferNameEditText.addTextChangedListener(textWatcher);
      // ibanEdtiText.addTextChangedListener(textWatcher);
      // bicEditText.addTextChangedListener(textWatcher);

      // phoneNumberEdit.addTextChangedListener(textWatcher);
      simTopUpNameEdit.addTextChangedListener(textWatcher);
      phoneNumberEdit.addTextChangedListener(textWatcher);

      beneficiaryNameEditText.addTextChangedListener(textWatcher);
      cardNumberEditText.addTextChangedListener(textWatcher);

      bankTransferNameEditText.setOnFocusChangeListener(this);
      ibanEdtiText.setOnFocusChangeListener(this);
      bicEditText.setOnFocusChangeListener(this);

      simTopUpNameEdit.setOnFocusChangeListener(this);
      phoneNumberEdit.setOnFocusChangeListener(this);

      beneficiaryNameEditText.setOnFocusChangeListener(this);
      cardNumberEditText.setOnFocusChangeListener(this);
    }
    operatorText.setOnClickListener(this);
    payee = (Button) findViewById(R.id.payees);
    payee.setSingleLine(true);
    payee.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    payee.setOnClickListener(this);
    payees_layout = (LinearLayout) findViewById(R.id.payees_layout);
  }
Example #19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_album);

    // Get the application
    amr = (AMuRate) getApplicationContext();

    // Store the itself
    albumActivity = this;

    // Initialize the views
    albumTitle = (TextView) findViewById(R.id.album_title);
    albumArtist = (TextView) findViewById(R.id.album_artist);
    albumImage = (ImageView) findViewById(R.id.album_image);
    albumImageClose = (Button) findViewById(R.id.album_image_close);
    playcount = (TextView) findViewById(R.id.album_playcount);
    listeners = (TextView) findViewById(R.id.album_listeners);
    tracksLayout = (LinearLayout) findViewById(R.id.album_tracks);
    summary = (TextView) findViewById(R.id.album_summary);

    // Initialize members
    isDownloading = false;

    // Get the album to be displayed from the Extra's
    Intent intent = getIntent();
    if (intent.hasExtra("album")) {
      album = new Album(intent.getStringExtra("album"));
    } else if (intent.hasExtra("fromArtist")) {
      try {
        album = new Album(new JSONObject(intent.getStringExtra("fromArtist")).toString());
      } catch (JSONException e) {
        finish();
      }
    } else {
      // If we could not get it, we can't display this activity
      finish();
      Toast.makeText(amr, R.string.msg_couldnt_obtain, Toast.LENGTH_SHORT).show();
    }

    // Set the text of the album title and the artist of the album
    albumTitle.setText(album.getAlbumTitle());
    albumTitle.setTextSize(20);
    albumArtist.setText(album.getArtistName());
    albumArtist.setTextSize(17);

    // Set the text "X" on the close button
    albumImageClose.setText(R.string.album_x);
    // Define layout parameters (margins), and gravity to the right
    LinearLayout.LayoutParams closeLp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    closeLp.setMargins(120, 10, 0, 0); // 120left, top, right, bottom
    albumImageClose.setGravity(Gravity.RIGHT);
    albumImageClose.setLayoutParams(closeLp);
    // When clicked on the close button, we clear the previous activities
    // from the stack and navigate to the main screen
    albumImageClose.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            finish();
            Intent next = new Intent(amr, MainActivity.class);
            next.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(next);
          }
        });

    // Load the album image. If there is a link for the Large one, download it
    // Otherwise we display a standard picture.
    if (album.getImageL().length() > 0) {
      DownloadImageTask download = new DownloadImageTask(albumImage);
      download.execute(album.getImageL());
    } else albumImage.setImageResource(R.drawable.not_available);

    // Set the playcount and the listeners count
    playcount.setText(amr.getString(R.string.album_playcount) + album.getPlaycount());
    listeners.setText(amr.getString(R.string.album_listeners) + album.getListeners());

    // Set the summary of the album in the scrollview.
    // Use fromHtml to make the links work
    summary.setText(Html.fromHtml(album.getSummary()));
    // If there is no info, don't display it
    if (album.getSummary().equals("")) summary.setVisibility(View.INVISIBLE);

    // Set the tracks of the album in a scrollview
    try {
      JSONArray tracks = album.getTracks();

      // We keep track of the skipped tracks. We filter the tracks which
      // have no MBID and no duration associated with.
      // By keeping this counter, we kan correctly number the good tracks.
      int skipped = 0;

      for (int i = 0; i < tracks.length(); i++) {
        JSONObject oneTrack = tracks.getJSONObject(i);
        final String tit = oneTrack.getString("name");
        final String mbid = oneTrack.getString("mbid");

        // Parse the JSON to a Track object
        Track track = new Track();
        track.loadFromSearch(oneTrack);

        // If no duration and no mbid: filter away
        if (track.getDurationInt() <= 0 && mbid != null && mbid.equals("")) {
          skipped++;
          continue;
        }

        // Make a custom button for the track
        final Button bt = new Button(amr);
        bt.setBackgroundResource(R.layout.rounded_corners);

        // The layout parameters
        LinearLayout.LayoutParams lp =
            new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        lp.setMargins(8, 10, 8, 4); // left, top, right, bottom
        bt.setLayoutParams(lp);

        // Set the button text like this:     n: Song title
        bt.setText("" + (i + 1 - skipped) + ":" + tit);

        // When the user clicks on it, we do a small check if there is a MBID
        // Before we start downloading info for that mbid.
        bt.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                if (!isDownloading) {
                  if (mbid.length() == 0) {
                    Toast.makeText(amr, R.string.msg_no_mbid_track, Toast.LENGTH_SHORT).show();
                  } else {
                    isDownloading = true;
                    clickedButton = bt;
                    clickedText = bt.getText();
                    bt.setText(R.string.loading);
                    DownloadLastFM dl =
                        new DownloadLastFM(albumActivity, DownloadLastFM.dl_album_track_info);
                    dl.execute(tit, album.getArtistName());
                  }
                } else {
                  Toast.makeText(amr, R.string.msg_already_downloading, Toast.LENGTH_SHORT).show();
                }
              }
            });

        // When we are done, we add the button to the view
        tracksLayout.addView(bt);
      }

    } catch (JSONException je) {
      System.out.println("JSONException in AlbumActivity");
    }
  }
Example #20
0
  protected void onCreate(Bundle savedInstanceState) {
    final FotoBot fb = (FotoBot) getApplicationContext();
    super.onCreate(savedInstanceState);
    fb.LoadSettings();

    // fb.logger.fine("Tab_Foto_Activity");

    Log.d(LOG_TAG, "Tab3: onCreate");
    //      final FotoBot fb = (FotoBot) getApplicationContext();
    Display display = getWindowManager().getDefaultDisplay();
    screenWidth = display.getWidth();
    screenHeight = display.getHeight();

    // Main Container (Vertical LinearLayout)
    LinearLayout FullFrame = new LinearLayout(this);
    FullFrame.setOrientation(LinearLayout.VERTICAL);
    FullFrame.setPadding(5, 5, 5, 5);
    FullFrame.setBackgroundColor(Color.rgb(192, 192, 192));
    LinearLayout.LayoutParams lpFull_Frame =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    FullFrame.setLayoutParams(lpFull_Frame);
    FullFrame.setMinimumHeight(fb.Working_Area_Height - fb.menuheight);
    // FullFrame.setBackgroundColor(Color.WHITE);
    //  setContentView(FullFrame);

    // ------------------------------------------------------------------------------------------------

    // JPEG сжатие

    // Контейнер для JPG сжатие
    RelativeLayout linLayout_JPEG_Compression = new RelativeLayout(this);
    //   linLayout_JPEG_Compression.setOrientation(LinearLayout.HORIZONTAL);
    RelativeLayout.LayoutParams lpView =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lpView_et =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    linLayout_JPEG_Compression.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для пояснение
    LinearLayout linLayout_JPEG_Compression_notes = new LinearLayout(this);
    linLayout_JPEG_Compression_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_JPEG_Compression_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для разделителя
    LinearLayout linLayout_JPEG_Compression_divider = new LinearLayout(this);
    linLayout_JPEG_Compression_divider.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_JPEG_Compression_divider.setPadding(5, 9, 5, 9);

    // Название
    TextView tv_JPEG_Compression = new TextView(this);
    tv_JPEG_Compression.setTypeface(Typeface.DEFAULT_BOLD);
    tv_JPEG_Compression.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_JPEG_Compression.setTextColor(Color.BLACK);
    tv_JPEG_Compression.setText(getResources().getString(R.string.jpeg_compression));
    tv_JPEG_Compression.setWidth((screenWidth - padding) / 100 * 80);
    tv_JPEG_Compression.setLayoutParams(lpView);
    tv_JPEG_Compression.setTypeface(Typeface.DEFAULT_BOLD);

    lpView.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_JPEG_Compression.getId());
    tv_JPEG_Compression.setLayoutParams(lpView);
    linLayout_JPEG_Compression.addView(tv_JPEG_Compression);

    // Ввод данных

    editText_JPEG_Compression = new EditText(this);
    editText_JPEG_Compression.setLayoutParams(lpView_et);
    String jpg = Integer.toString(fb.JPEG_Compression);
    editText_JPEG_Compression.setText(jpg);
    editText_JPEG_Compression.setTextColor(Color.rgb(50, 100, 150));
    ViewGroup.LayoutParams lp = editText_JPEG_Compression.getLayoutParams();
    lp.width = (screenWidth - padding) / 100 * 20;
    editText_JPEG_Compression.setLayoutParams(lp);
    //   editText_JPEG_Compression.setGravity(Gravity.RIGHT);

    lpView_m.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, editText_JPEG_Compression.getId());
    editText_JPEG_Compression.setLayoutParams(lpView_m);
    linLayout_JPEG_Compression.addView(editText_JPEG_Compression);

    // Заметка для JPEG сжатия
    TextView tv_JPEG_Compression_note = new TextView(this);
    tv_JPEG_Compression_note.setTypeface(null, Typeface.NORMAL);
    tv_JPEG_Compression_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_JPEG_Compression_note.setTextColor(Color.BLACK);
    tv_JPEG_Compression_note.setText(
        getResources().getString(R.string.jpeg_compression_description));
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_JPEG_Compression_note.setLayoutParams(lpView);
    //  tv_JPEG_Compression_note.setTextColor(Color.GRAY);
    tv_JPEG_Compression_note.setPadding(5, 9, 5, 9);
    linLayout_JPEG_Compression_notes.addView(tv_JPEG_Compression_note);

    // Разделитель
    View line_JPEG_Compression = new View(this);
    line_JPEG_Compression.setLayoutParams(
        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1));
    line_JPEG_Compression.setBackgroundColor(Color.rgb(210, 210, 210));
    line_JPEG_Compression.getLayoutParams().height = 3;
    linLayout_JPEG_Compression_divider.addView(line_JPEG_Compression);

    // ------------------------------------------------------------------------------------------------

    // Метод обработки фото

    // Контейнер для метода
    RelativeLayout linLayout_Photo_Processing_Method = new RelativeLayout(this);
    //   linLayout_Photo_Processing_Method.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method.setBackgroundColor(Color.rgb(192, 192, 192));
    RelativeLayout.LayoutParams lpView_m1 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m2 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    //        LinearLayout.LayoutParams lpView = new
    // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
    // LinearLayout.LayoutParams.WRAP_CONTENT);
    //      LinearLayout.LayoutParams lpView_et = new
    // LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
    // LinearLayout.LayoutParams.WRAP_CONTENT);

    // Контейнер для пояснение
    LinearLayout linLayout_Photo_Processing_Method_notes = new LinearLayout(this);
    linLayout_Photo_Processing_Method_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для разделителя
    LinearLayout linLayout_Photo_Processing_Method_divider = new LinearLayout(this);
    linLayout_Photo_Processing_Method_divider.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method_divider.setPadding(5, 9, 5, 9);

    // Название
    TextView tv_Photo_Processing_Method = new TextView(this);
    tv_Photo_Processing_Method.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Photo_Processing_Method.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_Photo_Processing_Method.setTextColor(Color.BLACK);
    tv_Photo_Processing_Method.setText(getResources().getString(R.string.photo_processing_method));
    //   tv_Photo_Processing_Method.setWidth((screenWidth - padding) / 100 * 80);
    //   tv_Photo_Processing_Method.setLayoutParams(lpView);
    tv_Photo_Processing_Method.setTypeface(Typeface.DEFAULT_BOLD);

    lpView_m1.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Processing_Method.getId());
    lpView_m1.width = (screenWidth - padding) / 100 * 60;
    tv_Photo_Processing_Method.setLayoutParams(lpView_m1);
    linLayout_Photo_Processing_Method.addView(tv_Photo_Processing_Method);

    // Список
    spinnerArray_ppm = new ArrayList<String>();
    spinnerArray_ppm.add("Hardware");
    spinnerArray_ppm.add("Software");

    spinner_ppm = new Spinner(this);
    ArrayAdapter<String> spinnerArrayAdapter_ppm =
        new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray_ppm);
    spinner_ppm.setAdapter(spinnerArrayAdapter_ppm);
    spinner_ppm.setSelection(getIndex(spinner_ppm, fb.Photo_Post_Processing_Method));
    spinner_ppm.setMinimumWidth((screenWidth - padding) / 100 * 50);
    spinner_ppm.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {

          public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {

            if (spinnerArray_ppm.get(i) == "Hardware") {
              tv_Photo_Size_s.setVisibility(View.GONE);
              spinner_Software.setVisibility(View.GONE);
              tv_Photo_Size_h.setVisibility(View.VISIBLE);
              spinner_Hardware.setVisibility(View.VISIBLE);
              linLayout_Photo_Size_h_notes.setVisibility(View.VISIBLE);
              linLayout_Photo_Size_s_notes.setVisibility(View.GONE);
            } else {
              tv_Photo_Size_s.setVisibility(View.VISIBLE);
              spinner_Software.setVisibility(View.VISIBLE);
              tv_Photo_Size_h.setVisibility(View.GONE);
              spinner_Hardware.setVisibility(View.GONE);
              linLayout_Photo_Size_h_notes.setVisibility(View.GONE);
              linLayout_Photo_Size_s_notes.setVisibility(View.VISIBLE);
            }
          }

          // If no option selected
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    lpView_m2.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_ppm.getId());
    lpView_m2.width = (screenWidth - padding) / 100 * 40;
    spinner_ppm.setLayoutParams(lpView_m2);
    linLayout_Photo_Processing_Method.addView(spinner_ppm);

    // Заметка для метода
    TextView tv_Photo_Processing_Method_note = new TextView(this);
    tv_Photo_Processing_Method_note.setTypeface(null, Typeface.NORMAL);
    tv_Photo_Processing_Method_note.setTextSize(
        TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_Photo_Processing_Method_note.setTextColor(Color.BLACK);
    tv_Photo_Processing_Method_note.setText(
        getResources().getString(R.string.photo_processing_method_dscription));
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_Photo_Processing_Method_note.setLayoutParams(lpView);
    //   tv_Photo_Processing_Method_note.setTextColor(Color.GRAY);
    tv_Photo_Processing_Method_note.setPadding(5, 9, 5, 9);
    linLayout_Photo_Processing_Method_notes.addView(tv_Photo_Processing_Method_note);

    // ------------------------------------------------------------------------------------------------

    // Параметры изображения

    // Контейнер для метода
    RelativeLayout linLayout_Photo_Size = new RelativeLayout(this);
    // linLayout_Photo_Size.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lpView_photo_size =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lpView_photo_size_et =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    RelativeLayout.LayoutParams lpView_m3 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m4 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m5 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_m6 =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);

    linLayout_Photo_Size.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для пояснение
    linLayout_Photo_Size_h_notes = new LinearLayout(this);
    linLayout_Photo_Size_h_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Size_h_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для пояснение
    linLayout_Photo_Size_s_notes = new LinearLayout(this);
    linLayout_Photo_Size_s_notes.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Size_s_notes.setBackgroundColor(Color.rgb(192, 192, 192));

    // Контейнер для разделителя
    LinearLayout linLayout_Photo_Size_divider = new LinearLayout(this);
    linLayout_Photo_Processing_Method_divider.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Photo_Processing_Method_divider.setPadding(5, 9, 5, 9);

    // Масштаб фото
    tv_Photo_Size_h = new TextView(this);
    tv_Photo_Size_h.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Photo_Size_h.setTextSize(14);
    tv_Photo_Size_h.setTextColor(Color.BLACK);
    tv_Photo_Size_h.setText(getResources().getString(R.string.photo_scale));
    // tv_Photo_Size_h.setWidth((screenWidth - padding) / 100 * 80);
    tv_Photo_Size_h.setLayoutParams(lpView_photo_size);

    lpView_m3.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Size_h.getId());
    lpView_m3.width = (screenWidth - padding) / 100 * 60;
    tv_Photo_Size_h.setLayoutParams(lpView_m3);
    linLayout_Photo_Size.addView(tv_Photo_Size_h);

    // Коэффициенты масштабирования
    ArrayList<String> spinnerArray_Hardware = new ArrayList<String>();
    spinnerArray_Hardware.add("1/16");
    spinnerArray_Hardware.add("1/8");
    spinnerArray_Hardware.add("1/4");
    spinnerArray_Hardware.add("1/2");
    spinnerArray_Hardware.add("1");

    spinner_Hardware = new Spinner(this);
    spinnerArrayAdapter_Hardware =
        new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray_Hardware);
    spinner_Hardware.setAdapter(spinnerArrayAdapter_Hardware);
    spinner_Hardware.setSelection(getIndex(spinner_Hardware, fb.Image_Scale));
    //  spinner_Hardware.setMinimumWidth((screenWidth - padding) / 100 * 20);
    // spinner_Hardware.setGravity(Gravity.RIGHT);

    lpView_m4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_Hardware.getId());
    lpView_m4.width = (screenWidth - padding) / 100 * 40;
    spinner_Hardware.setLayoutParams(lpView_m4);
    linLayout_Photo_Size.addView(spinner_Hardware);

    // Размер фото
    tv_Photo_Size_s = new TextView(this);
    tv_Photo_Size_s.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Photo_Size_s.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_Photo_Size_s.setTextColor(Color.BLACK);
    tv_Photo_Size_s.setText(getResources().getString(R.string.photo_resolution));
    //  tv_Photo_Size_s.setWidth((screenWidth - padding) / 100 * 80);
    tv_Photo_Size_s.setLayoutParams(lpView_photo_size);

    lpView_m5.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Photo_Size_s.getId());
    lpView_m5.width = (screenWidth - padding) / 100 * 60;
    tv_Photo_Size_s.setLayoutParams(lpView_m5);
    linLayout_Photo_Size.addView(tv_Photo_Size_s);

    // Доступные разрешения
    ArrayList<String> spinnerArray = new ArrayList<String>();

    Camera.Size mSize = null;

    int fe_w = (int) fb.camera_resolutions.get(0).width;
    int fe_h = (int) fb.camera_resolutions.get(0).height;
    float fe_s, fe_z;

    fe_z = (float) fe_w / (float) fe_h;

    for (Camera.Size size : fb.camera_resolutions) {
      fe_w = (int) size.width;
      fe_h = (int) size.height;
      fe_s = (float) fe_w / (float) fe_h;

      if (Math.abs(fe_s - fe_z) < 0.01f) {
        spinnerArray.add(size.width + "x" + size.height);
      }
    }

    spinner_Software = new Spinner(this);
    spinnerArrayAdapter1 = new ArrayAdapter<String>(this, R.layout.spinner_item, spinnerArray);
    spinner_Software.setAdapter(spinnerArrayAdapter1);

    spinner_Software.setSelection(getIndex(spinner_Software, fb.Image_Size));
    //   spinner_Software.setMinimumWidth((screenWidth - padding) / 100 * 20);
    //  spinner_Software.setGravity(Gravity.RIGHT);

    lpView_m6.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, spinner_Software.getId());
    lpView_m6.width = (screenWidth - padding) / 100 * 40;
    spinner_Software.setLayoutParams(lpView_m6);

    linLayout_Photo_Size.addView(spinner_Software);

    // Заметка для Hardware
    TextView tv_Photo_Size_h_note = new TextView(this);
    tv_Photo_Size_h_note.setTypeface(null, Typeface.NORMAL);
    tv_Photo_Size_h_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_Photo_Size_h_note.setTextColor(Color.BLACK);
    tv_Photo_Size_h_note.setText("Hardware");
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_Photo_Size_h_note.setLayoutParams(lpView);
    // tv_Photo_Size_h_note.setTextColor(Color.GRAY);
    tv_Photo_Size_h_note.setPadding(5, 9, 5, 9);
    linLayout_Photo_Size_h_notes.addView(tv_Photo_Size_h_note);

    // Заметка для Software
    TextView tv_Photo_Size_s_note = new TextView(this);
    tv_Photo_Size_s_note.setTypeface(null, Typeface.NORMAL);
    tv_Photo_Size_s_note.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size - 2);
    tv_Photo_Size_s_note.setTextColor(Color.BLACK);
    tv_Photo_Size_s_note.setText("Software");
    // tv_Channels_notes.setWidth((screenWidth - padding) / 100 * 99);
    tv_Photo_Size_s_note.setLayoutParams(lpView);
    //   tv_Photo_Size_s_note.setTextColor(Color.GRAY);
    tv_Photo_Size_s_note.setPadding(5, 9, 5, 9);
    linLayout_Photo_Size_s_notes.addView(tv_Photo_Size_s_note);

    // Разделитель
    View line_Photo_Size = new View(this);
    line_Photo_Size.setLayoutParams(
        new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 1));
    line_Photo_Size.setBackgroundColor(Color.rgb(210, 210, 210));
    line_Photo_Size.getLayoutParams().height = 3;
    linLayout_Photo_Size_divider.addView(line_Photo_Size);

    // ------------------------------------------------------------------------------------------------

    // Вспышка

    // Flash Container
    RelativeLayout linLayout_Flash = new RelativeLayout(this);
    // linLayout_Flash.setOrientation(LinearLayout.HORIZONTAL);
    RelativeLayout.LayoutParams lpView_Flash =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    RelativeLayout.LayoutParams lpView_Flash_m =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams lpView_et_Flash =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    linLayout_Flash.setBackgroundColor(Color.rgb(192, 192, 192));

    // Flash TextView
    TextView tv_Flash = new TextView(this);
    tv_Flash.setText(getResources().getString(R.string.flash));
    tv_Flash.setWidth((screenWidth - padding) / 100 * 90);
    tv_Flash.setLayoutParams(lpView_Flash);
    tv_Flash.setTypeface(Typeface.DEFAULT_BOLD);
    tv_Flash.setTextSize(TypedValue.COMPLEX_UNIT_SP, fb.Config_Font_Size);
    tv_Flash.setTextColor(Color.BLACK);

    lpView_Flash.addRule(RelativeLayout.ALIGN_PARENT_LEFT, tv_Flash.getId());
    tv_Flash.setLayoutParams(lpView_Flash);
    linLayout_Flash.addView(tv_Flash);

    // CheckBox
    checkBox_Flash = new CheckBox(this);
    checkBox_Flash.setChecked(fb.Use_Flash);

    lpView_Flash_m.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, checkBox_Flash.getId());
    checkBox_Flash.setLayoutParams(lpView_Flash_m);
    linLayout_Flash.addView(checkBox_Flash);

    // Second Container (Horizontal LinearLayout)
    LinearLayout linLayout2 = new LinearLayout(this);
    linLayout2.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams lpView2 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams lpViewbutton =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    linLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER);

    // linLayout2.setLayoutParams(lpView2);

    // ------------------------------------------------------------------------------------------------

    // Buttons

    // Container
    LinearLayout linLayout_Buttons = new LinearLayout(this);
    linLayout_Buttons.setOrientation(LinearLayout.HORIZONTAL);
    linLayout_Buttons.setGravity(Gravity.BOTTOM | Gravity.CENTER);
    LinearLayout.LayoutParams lpViewbutton1 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
    LinearLayout.LayoutParams lpViewbutton2 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
    lpViewbutton1.setMargins(0, 0, 5, 0);
    LinearLayout.LayoutParams lpView3 =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT);
    linLayout_Buttons.setLayoutParams(lpView3);
    linLayout_Buttons.setBackgroundColor(Color.rgb(192, 192, 192));
    linLayout_Buttons.setPadding(15, 15, 15, 15);

    linLayout_Buttons.setBaselineAligned(false);
    linLayout_Buttons.setGravity(Gravity.BOTTOM);

    // Apply Button
    btn = new Button(this);
    btn.setText(getResources().getString(R.string.apply_button));
    btn.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    btn.setBackgroundColor(Color.rgb(90, 89, 91));
    btn.setTextColor(Color.rgb(250, 250, 250));
    btn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);

    btn.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              btn.setBackgroundColor(Color.rgb(90, 90, 90));
            } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
              btn.setBackgroundColor(Color.rgb(128, 128, 128));
            }
            return false;
          }
        });

    btn.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            SharedPreferences pref =
                getApplicationContext().getSharedPreferences("MyPref", MODE_PRIVATE);
            SharedPreferences.Editor editor = pref.edit();

            if (checkBox_Flash.isChecked()) {
              editor.putBoolean("Use_Flash", true);
            } else {
              editor.putBoolean("Use_Flash", false);
            }

            String input = editText_JPEG_Compression.getText().toString();
            editor.putString(
                "Photo_Post_Processing_Method", spinner_ppm.getSelectedItem().toString());
            editor.putInt(
                "JPEG_Compression",
                Integer.parseInt(editText_JPEG_Compression.getText().toString()));
            editor.putString("Image_Scale", spinner_Hardware.getSelectedItem().toString());
            editor.putString("Image_Size", spinner_Software.getSelectedItem().toString());

            // Save the changes in SharedPreferences
            editor.commit(); // commit changes
          }
        });

    // GoTo Main Page Button
    btn_mp = new Button(this);
    btn_mp.setText(getResources().getString(R.string.back_button));
    btn_mp.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL);
    btn_mp.setBackgroundColor(Color.rgb(90, 89, 91));
    btn_mp.setTextColor(Color.rgb(250, 250, 250));
    // lpViewbutton2.setMargins(5,5,5,5);
    btn_mp.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);

    btn_mp.setOnTouchListener(
        new View.OnTouchListener() {

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP) {
              btn_mp.setBackgroundColor(Color.rgb(90, 90, 90));
            } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
              btn_mp.setBackgroundColor(Color.rgb(128, 128, 128));
            }
            return false;
          }
        });

    btn_mp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent intent;
            intent = new Intent(v.getContext(), MainActivity.class);
            startActivity(intent);
          }
        });

    linLayout_Buttons.addView(btn, lpViewbutton1);
    linLayout_Buttons.addView(btn_mp, lpViewbutton2);

    FullFrame.addView(linLayout_JPEG_Compression);
    FullFrame.addView(linLayout_JPEG_Compression_notes);
    //   FullFrame.addView(linLayout_JPEG_Compression_divider);

    FullFrame.addView(linLayout_Photo_Processing_Method);
    FullFrame.addView(linLayout_Photo_Processing_Method_notes);

    FullFrame.addView(linLayout_Photo_Size);
    FullFrame.addView(linLayout_Photo_Size_h_notes);
    FullFrame.addView(linLayout_Photo_Size_s_notes);
    //        FullFrame.addView(linLayout_Photo_Size_divider);

    FullFrame.addView(linLayout_Flash);

    FullFrame.addView(linLayout_Buttons);

    ScrollView m_Scroll = new ScrollView(this);
    m_Scroll.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    m_Scroll.addView(
        FullFrame,
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    setContentView(m_Scroll);
  }
  private void initRight(Context context) {
    RelativeLayout layout_right = new RelativeLayout(context);
    LinearLayout.LayoutParams param_layout_right =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    int margin = 35;
    param_layout_right.setMargins(margin, margin, margin, margin);
    layout_right.setLayoutParams(param_layout_right);

    text_filmName = new AlwaysMarqueeTextView(context);
    text_filmName.setId(text_filmName_id);
    text_filmName.setMarquee(true);
    text_filmName.setTextColor(Color.WHITE);
    text_filmName.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 8);
    RelativeLayout.LayoutParams param_text_filmName =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_text_filmName.addRule(RelativeLayout.CENTER_HORIZONTAL);
    param_text_filmName.bottomMargin = 5;
    text_filmName.setLayoutParams(param_text_filmName);
    layout_right.addView(text_filmName);

    text_year_mins_area_type = new TextView(context);
    text_year_mins_area_type.setId(text_year_mins_area_type_id);
    text_year_mins_area_type.setTextColor(Color.WHITE);
    text_year_mins_area_type.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_text_year_mins_area_type =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_year_mins_area_type.addRule(RelativeLayout.BELOW, text_filmName_id);
    param_text_year_mins_area_type.bottomMargin = 5;
    text_year_mins_area_type.setLayoutParams(param_text_year_mins_area_type);
    layout_right.addView(text_year_mins_area_type);

    TextView text_movie_class = new TextView(context); // 电影分类
    text_movie_class.setId(text_movie_class_id);

    barginPrice = new TextView(context);
    barginPrice.append("¥0");
    barginPrice.setTextColor(Color.parseColor("#00c1ea"));
    barginPrice.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 5);
    RelativeLayout.LayoutParams barginPriceParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    barginPriceParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    barginPriceParams.addRule(RelativeLayout.ALIGN_BOTTOM, text_year_mins_area_type_id);
    barginPrice.setLayoutParams(barginPriceParams);
    barginPrice.setId(price_id);
    layout_right.addView(barginPrice);

    TextView barginPriceTextView = new TextView(context);
    barginPriceTextView.setText(" 促销价: ");
    barginPriceTextView.setTextColor(Color.GRAY);
    barginPriceTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_price =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_price.addRule(RelativeLayout.LEFT_OF, price_id);
    param_price.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    barginPriceTextView.setLayoutParams(param_price);
    barginPriceTextView.setId(price_tv_id);
    layout_right.addView(barginPriceTextView);

    price = new TextView(context);
    price.setText("¥0 ");
    price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
    price.setId(10012);
    price.setTextColor(Color.GRAY);
    price.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    price.setId(bargin_id);
    RelativeLayout.LayoutParams priceParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    priceParams.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    priceParams.addRule(RelativeLayout.LEFT_OF, price_tv_id);
    price.setLayoutParams(priceParams);
    layout_right.addView(price);

    TextView priceTextView = new TextView(context);
    priceTextView.setText("原价:");
    priceTextView.setId(10012);
    priceTextView.setTextColor(Color.GRAY);
    priceTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    RelativeLayout.LayoutParams param_barginPrice =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    //		param_barginPrice.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    param_barginPrice.addRule(RelativeLayout.ALIGN_BOTTOM, price_id);
    param_barginPrice.addRule(RelativeLayout.LEFT_OF, bargin_id);
    priceTextView.setLayoutParams(param_barginPrice);
    layout_right.addView(priceTextView);

    text_introduce = new TextView(context);
    text_introduce.setTextColor(Color.WHITE);
    text_introduce.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_introduce.setEllipsize(TruncateAt.END);
    text_introduce.setId(text_introduce_id);
    text_introduce.setMaxLines(3);
    text_introduce.setLineSpacing(3f, 1f);
    RelativeLayout.LayoutParams param_text_introduce =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_introduce.addRule(RelativeLayout.BELOW, text_year_mins_area_type_id);
    text_introduce.setLayoutParams(param_text_introduce);
    layout_right.addView(text_introduce);

    text_director = new AlwaysMarqueeTextView(context);
    text_director.setId(text_director_id);
    text_director.setTextColor(Color.WHITE);
    text_director.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_director.setMarquee(false);
    RelativeLayout.LayoutParams param_text_director =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_director.addRule(RelativeLayout.BELOW, text_introduce_id);
    param_text_director.topMargin = 4;
    text_director.setLayoutParams(param_text_director);
    layout_right.addView(text_director);

    text_actor = new AlwaysMarqueeTextView(context);
    text_actor.setId(text_actor_id);
    text_actor.setTextColor(Color.WHITE);
    text_actor.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    text_director.setMarquee(false);
    RelativeLayout.LayoutParams param_text_actor =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_actor.addRule(RelativeLayout.BELOW, text_director_id);
    param_text_actor.topMargin = 4;
    text_actor.setLayoutParams(param_text_actor);
    layout_right.addView(text_actor);

    text_dl_info = new TextView(context);
    text_dl_info.setText(R.string.watch_worning_for4k);
    text_dl_info.setTextColor(Color.parseColor("#FFC125"));
    text_dl_info.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 2);
    RelativeLayout.LayoutParams param_text_dl_info =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_text_dl_info.addRule(RelativeLayout.BELOW, text_actor_id);
    param_text_dl_info.topMargin = textSize - 10;
    text_dl_info.setLayoutParams(param_text_dl_info);
    layout_right.addView(text_dl_info);
    if (F4kDownResourceUtils.getDownLoadFlag() == null
        || !F4kDownResourceUtils.getDownLoadFlag().equals("1")) {
      text_dl_info.setVisibility(View.INVISIBLE);
    }

    layout_btn = new RelativeLayout(context);
    layout_btn.setId(layout_btn_id);
    RelativeLayout.LayoutParams param_layout_btn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_layout_btn.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    //		param_layout_btn.addRule(RelativeLayout.CENTER_HORIZONTAL);
    param_layout_btn.bottomMargin = 10;
    layout_btn.setLayoutParams(param_layout_btn);

    leftBtn = new FocusAbleButton(context);
    leftBtn.setTextSize(textSize);
    leftBtn.setTextColor(Color.WHITE);
    leftBtn.setGravity(Gravity.CENTER);
    leftBtn.setTextSize(textSize);
    leftBtn.setId(detail_left_btn_id);

    leftBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null) {
              listener.onPlay(film);
            }
          }
        });
    RelativeLayout.LayoutParams param_leftBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_leftBtn.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    param_leftBtn.rightMargin = 45;
    leftBtn.setLayoutParams(param_leftBtn);
    layout_btn.addView(leftBtn);

    leftBtn_playlow = new FocusAbleButton(context);
    leftBtn_playlow.setTextSize(textSize);
    leftBtn_playlow.setTextColor(Color.WHITE);
    leftBtn_playlow.setGravity(Gravity.CENTER);
    leftBtn_playlow.setTextSize(textSize);
    leftBtn_playlow.setId(ID.MovieDetaiView.DETAIL_LEFT_BTN_ID);

    leftBtn_playlow.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null) {
              if (info instanceof F4kFilmAndPageInfo) {
                F4kFilmAndPageInfo info4k = (F4kFilmAndPageInfo) info;
                if (info4k.getFilmListLowRate().size() > index) {
                  listener.onPlay(((F4kFilmAndPageInfo) info).getFilmListLowRate().get(index));
                } else {
                  Log.d("can not play l080p case no fid for it");
                }
              }
            }
          }
        });
    RelativeLayout.LayoutParams leftBtn_playlowBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    leftBtn_playlowBtn.addRule(RelativeLayout.RIGHT_OF, detail_left_btn_id);
    leftBtn_playlowBtn.rightMargin = 45;
    leftBtn_playlow.setLayoutParams(leftBtn_playlowBtn);
    layout_btn.addView(leftBtn_playlow);

    middleBtn = new FocusAbleButton(context);
    middleBtn.setTextColor(Color.WHITE);
    middleBtn.setGravity(Gravity.CENTER);
    middleBtn.setTextSize(textSize);
    middleBtn.setId(middleBtn_id);
    middleBtn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (listener != null && film != null) {
              listener.onDwonload(film);
            }
          }
        });
    RelativeLayout.LayoutParams param_middleBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_middleBtn.addRule(RelativeLayout.RIGHT_OF, ID.MovieDetaiView.DETAIL_LEFT_BTN_ID);
    middleBtn.setLayoutParams(param_middleBtn);
    layout_btn.addView(middleBtn);

    rightBtn = new FocusAbleButton(context);
    rightBtn.setTextColor(Color.WHITE);
    rightBtn.setGravity(Gravity.CENTER);
    rightBtn.setTextSize(textSize);
    rightBtn.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            if (listener != null && film != null) {
              listener.onCancel(film);
            }
          }
        });
    rightBtn.setId(rightBtn_id);
    RelativeLayout.LayoutParams param_rightBtn =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    param_rightBtn.leftMargin = 45;
    param_rightBtn.addRule(RelativeLayout.RIGHT_OF, middleBtn_id);
    rightBtn.setLayoutParams(param_rightBtn);
    layout_btn.addView(rightBtn);
    layout_right.addView(layout_btn);

    RelativeLayout layout_love = new RelativeLayout(context);
    layout_love.setId(layout_love_id);
    RelativeLayout.LayoutParams param_layout_lov =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    param_layout_lov.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    layout_love.setLayoutParams(param_layout_lov);
    layout_right.addView(layout_love);

    addView(layout_right);
    leftBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    leftBtn_playlow.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    middleBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
    rightBtn.setPadding(textSize, textSize - 10, textSize, textSize - 10);
  }
Example #22
0
  public void addButton(ViewGroup layout, final String description, final CommandBuilder builder) {
    Button button = new Button(this);
    button.setGravity(Gravity.LEFT);
    button.setTransformationMethod(null); // or else button text is all upper case
    button.setText(description);
    button.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
    button.setPadding(10, 5, 10, 2);

    layout.addView(button);
    button.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            builder.play();
            if (description.startsWith("(11.1)")) {
              if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get()
                  == 0) {
                Toast.makeText(
                        TestVoiceActivity.this,
                        AbstractPrologCommandPlayer.btScoInit
                            + "\nBT SCO init delay:  "
                            + ((OsmandApplication) getApplication())
                                .getSettings()
                                .BT_SCO_DELAY
                                .get()
                            + " ms",
                        Toast.LENGTH_LONG)
                    .show();
              } else {
                Toast.makeText(
                        TestVoiceActivity.this,
                        "Action only available for Phone Call Audio",
                        Toast.LENGTH_LONG)
                    .show();
              }
            }
            if (description.startsWith("(11.2)")) {
              if (((OsmandApplication) getApplication()).getSettings().AUDIO_STREAM_GUIDANCE.get()
                  == 0) {
                if (((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.get()
                    == 1000) {
                  ((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.set(1500);
                } else if (((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.get()
                    == 1500) {
                  ((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.set(2000);
                } else if (((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.get()
                    == 2000) {
                  ((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.set(2500);
                } else if (((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.get()
                    == 2500) {
                  ((OsmandApplication) getApplication()).getSettings().BT_SCO_DELAY.set(1000);
                }
                Toast.makeText(
                        TestVoiceActivity.this,
                        "BT SCO init delay changed to "
                            + ((OsmandApplication) getApplication())
                                .getSettings()
                                .BT_SCO_DELAY
                                .get()
                            + " ms",
                        Toast.LENGTH_LONG)
                    .show();
              } else {
                Toast.makeText(
                        TestVoiceActivity.this,
                        "Action only available for Phone Call Audio",
                        Toast.LENGTH_LONG)
                    .show();
              }
            }
            if (description.startsWith("(11.3)")) {
              final String systemVoiceUsed =
                  AbstractPrologCommandPlayer.getCurrentVersion() > 99
                      ? TTSCommandPlayerImpl.getTtsVoiceName()
                      : "Recorded voice";
              Toast.makeText(
                      TestVoiceActivity.this,
                      "System's language availability status and voice actually used:\n\n"
                          + systemVoiceUsed,
                      Toast.LENGTH_LONG)
                  .show();
            }
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sp = getSharedPreferences("prefs", MODE_PRIVATE);
    ScrollView sv = new ScrollView(this);
    sv.setFillViewport(true);
    LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.setBackgroundColor(Color.parseColor("#000000"));
    sv.addView(ll);

    setContentView(sv);

    Button name, status;
    name = new Button(this);
    status = new Button(this);
    name.setText(sp.getString("name", "null"));
    name.setBackgroundColor(Color.parseColor("#43FFFD"));
    name.setTextColor(Color.parseColor("#ff0000"));
    name.setGravity(View.TEXT_ALIGNMENT_GRAVITY);

    status.setText("Current Percent Stats");
    status.setBackgroundColor(Color.parseColor("#43FFFD"));
    status.setTextColor(Color.parseColor("#ff0000"));
    status.setGravity(View.TEXT_ALIGNMENT_GRAVITY);
    LinearLayout.LayoutParams p =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    p.setMargins(10, 10, 10, 10);
    ll.addView(name, p);
    ll.addView(status, p);

    TableRow.LayoutParams lp =
        new TableRow.LayoutParams(
            TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.MATCH_PARENT);
    lp.setMargins(20, 20, 20, 20);

    TableLayout tl = new TableLayout(this);
    tl.setStretchAllColumns(true);
    tl.setShrinkAllColumns(true);
    // tl.setBackgroundColor(Color.parseColor("#ffff00"));
    ll.addView(tl);
    int i, n, num, den;
    double ans;
    n = Integer.parseInt(sp.getString("noofsubj", "1"));
    TableRow tr[] = new TableRow[n];

    for (i = 0; i < n; i++) {
      tr[i] = new TableRow(this);
      TextView sntv = new TextView(this);

      TextView per = new TextView(this);
      sntv.setText(sp.getString("subject" + (i + 1), "null"));

      num = sp.getInt("p" + (i + 1), 0);
      den = sp.getInt("t" + (i + 1), 0);
      if (den == 0) ans = 0.0;
      else ans = num * 100.0 / den;

      ans = (Math.rint(ans * 100)) / 100;

      per.setText(ans + "%");
      // sntv.setLayoutParams(lp);
      // per.setLayoutParams(lp);
      sntv.setBackgroundColor(Color.parseColor("#ffff00"));
      per.setBackgroundColor(Color.parseColor("#ffff00"));
      sntv.setTextSize(20);
      per.setTextSize(20);
      tr[i].addView(sntv, lp);
      tr[i].addView(per, lp);

      tl.addView(tr[i]);
    }
    Button btnFin = new Button(this);
    btnFin.setText("FINISH");
    // btnFin.setText(sp.getString("initialized","null").equals("true")+"-"+"ABCabc");
    btnFin.setTextColor(Color.parseColor("#000000"));
    btnFin.setBackgroundColor(Color.parseColor("#00ff00"));
    tl.addView(btnFin);
    btnFin.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            action();
          }
        });
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    this.inflater = inflater;
    View rootView = inflater.inflate(R.layout.fragment_room_builder, container, false);

    btn = new Button(getActivity().getApplicationContext());
    btn.setBackgroundColor(0);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1);
    params.rightMargin = AppState.convertToDp(16);
    btn.setLayoutParams(params);
    btn.setText("Done");
    btn.setTextColor(getResources().getColor(R.color.base_gold));
    btn.setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
    btn.setId(1);
    btn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            sendData();
          }
        });

    ((MaterialNavigationDrawer) getActivity()).getToolbar().addView(btn);

    btnMinus = (ImageButton) rootView.findViewById(R.id.btn_minus_fragment_room_builder);
    btnPlus = (ImageButton) rootView.findViewById(R.id.btn_plus_fragment_room_builder);
    btnAddChild = (Button) rootView.findViewById(R.id.btn_add_child_fragment_room_builder);

    listView = (ListView) rootView.findViewById(R.id.lv_children_fragment_room_builder);

    final ChildrenListAdapter adapter =
        new ChildrenListAdapter(
            getActivity().getApplicationContext(), childrenSOArrayList, this, position);
    listView.setAdapter(adapter);

    tvAdults = (TextView) rootView.findViewById(R.id.tv_adults_fragment_room_builder);
    tvAdults.setText(adultCount + "");
    tvTitleAdults = (TextView) rootView.findViewById(R.id.tv_title_adults_fragment_room_builder);
    tvTitleAdults.setText("x " + adultCount);
    tvTitleChilds = (TextView) rootView.findViewById(R.id.tv_title_children_fragment_room_builder);
    tvTitleChilds.setText("x " + childrenSOArrayList.size());

    btnMinus.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            minusAdultsCount();
          }
        });

    btnPlus.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            plusAdultsCount();
          }
        });

    btnAddChild.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (Integer.valueOf(tvTitleChilds.getText().toString().replaceAll("[^0-9]", "")) < 6) {
              childrenSOArrayList.add(new RoomQueryGuestSO(true, 0));
              plusChildCount();
              adapter.notifyDataSetChanged();
            } else {
              Toast.makeText(
                      getActivity().getApplicationContext(),
                      "Can`t be more than 6 children in one room",
                      Toast.LENGTH_SHORT)
                  .show();
            }
          }
        });

    // Inflate the layout for this fragment
    return rootView;
  }
  private void GetAnswers(Integer _id) {

    openDatabaseConnection();

    String WhereStatement = "QUESTIONITEM " + "= " + String.valueOf(_id);
    String[] Columns = {"CORRECT", "ANSWERTEXT", "REASON"};

    Cursor c = myDbHelper.query("ANSWERS", Columns, WhereStatement, null, null, null, null);

    if (c.getCount() > 0) {

      c.moveToFirst();

      List<Answer> list = new ArrayList<Answer>();
      CorrectAnswerList = new ArrayList<Answer>();
      CorrectAnswerInHTMLList = new ArrayList<String>();
      do {
        Answer ans = new Answer();
        ans.set_Correct(c.getInt(c.getColumnIndex("CORRECT")));
        ans.set_AnswerText(c.getString(c.getColumnIndex("ANSWERTEXT")));
        ans.set_Reason(c.getString(c.getColumnIndex("REASON")));
        list.add(ans);
        // if the answer is correct keep the string in HTML
        if (ans.get_Correct() == 1) {
          String CorrectAnswerInHTML = ans.get_AnswerText();
          CorrectAnswerReasonInHTML = ans.get_Reason();
          CorrectAnswerList.add(ans); // Collection of correct answers
          CorrectAnswerInHTMLList.add(CorrectAnswerInHTML);
          CorrectAnswerInHTMLListCounter++;
        }
      } while (c.moveToNext());

      c.close();
      myDbHelper.close();

      // Add the number of Answer to the CorrectAnswerListCounter
      CorrectAnswerListCounter = CorrectAnswerList.size();

      // Initialize button array
      ButtonArray = new ArrayList<Button>();

      for (int current = 0; current < list.size(); current++) {
        Answer ThisAns = list.get(current);
        // Create a table row
        TableRow tr = new TableRow(this);
        tr.setId(1000 + current);
        tr.setGravity(Gravity.CENTER);

        tr.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

        /*TextView Tv = new TextView(this);
        Tv.setId(1000+current);
        Tv.setText(Html.fromHtml(ThisAns.get_AnswerText()));
        Tv.setTextColor(Color.WHITE);

           tr.addView(Tv);

           Table.addView(tr);*/

        // Configure each button and add to row and then add row to table
        Button bt = new Button(this);
        bt.setId(1000 + current);
        bt.setText(Html.fromHtml(ThisAns.get_AnswerText()));
        bt.setTextColor(Color.BLACK);
        bt.setGravity(Gravity.CENTER);
        bt.setWidth(420);
        bt.setHeight(LayoutParams.WRAP_CONTENT);
        bt.setTextSize(12);
        // Add the correct answer to the button
        bt.setTag(ThisAns.get_Correct());

        bt.setOnClickListener(this);
        // Add button the button array
        ButtonArray.add(bt);

        tr.addView(bt);

        Table.addView(tr);
      }
    }
  }
Example #26
0
  @SuppressWarnings("static-access")
  private void init() {

    this.setBackgroundResource(R.drawable.cs_recommend_bg);
    this.setOrientation(LinearLayout.VERTICAL);
    RelativeLayout contentLayout = new RelativeLayout(context);
    LayoutParams layoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    contentLayout.setLayoutParams(layoutParams);
    this.addView(contentLayout);

    TextView titleTextView = new TextView(context);
    titleTextView.setText(R.string.download_manager);
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize + 3);
    titleTextView.setTextColor(Color.WHITE);
    int titleMargin = 20;
    RelativeLayout.LayoutParams titleParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    titleParams.leftMargin = titleMargin;
    titleParams.rightMargin = titleMargin;
    titleParams.topMargin = titleMargin;
    titleParams.bottomMargin = titleMargin;
    titleTextView.setLayoutParams(titleParams);
    contentLayout.addView(titleTextView);

    LinearLayout managerLayout = new LinearLayout(context);
    managerLayout.setId(MANAGERLAYOUT_ID);
    managerLayout.setOrientation(LinearLayout.VERTICAL);
    int managerPad = 10;
    managerLayout.setPadding(managerPad, managerPad, managerPad, managerPad);
    int height = DisplayManager.getInstance(context).getScreenHeight() - 150;
    int width = DisplayManager.getInstance(context).getScreenWidth() - 200;
    RelativeLayout.LayoutParams managerLayoutParams =
        new RelativeLayout.LayoutParams(width, height);
    managerLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    managerLayout.setLayoutParams(managerLayoutParams);
    managerLayout.setBackgroundResource(R.drawable.bg_downmanger_content);
    // managerLayout.setBackgroundColor(Color.parseColor("#99000000"));
    contentLayout.addView(managerLayout);

    LinearLayout managerPathLayout = new LinearLayout(context);
    managerPathLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams managerPathParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50);
    managerPathLayout.setLayoutParams(managerPathParams);
    managerPathLayout.setPadding(managerPad, 0, managerPad, managerPad);

    TextView pathText = new TextView(context);
    pathText.setText(R.string.present_path);
    pathText.setGravity(Gravity.CENTER);
    pathText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3);
    pathText.setTextColor(Color.parseColor("#ffffff"));
    pathTextParams.setMargins(0, 0, 0, 0);
    pathTextParams.gravity = Gravity.CENTER;
    pathText.setLayoutParams(pathTextParams);
    managerPathLayout.addView(pathText);

    final CheckDownDialogView checkDialog = new CheckDownDialogView(context);
    String present_edit = "";
    if (checkDialog.DetectionDisk() != null) {
      present_edit = checkDialog.getDownPathname();
    }
    pathEdit = new EditText(context);
    pathEdit.setText(present_edit);
    pathEdit.setFocusable(false);
    pathEdit.setGravity(Gravity.CENTER_VERTICAL);
    pathEdit.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathEditParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 12);
    pathEdit.setTextColor(Color.parseColor("#ffffff"));
    pathEdit.setBackgroundResource(R.drawable.present_path);
    pathEditParams.gravity = Gravity.CENTER_VERTICAL;
    pathEdit.setLayoutParams(pathEditParams);
    managerPathLayout.addView(pathEdit);

    Button pathButton = new FocusAbleButton(context);
    pathButton.setText(R.string.present_sele);
    pathButton.setTextColor(Color.parseColor("#ffffff"));
    pathButton.setGravity(Gravity.CENTER);
    pathButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize - 3);
    LayoutParams pathButtonViewParams =
        new LinearLayout.LayoutParams(0, layoutParams.WRAP_CONTENT, 2);
    pathButtonViewParams.gravity = Gravity.CENTER;
    pathButtonViewParams.setMargins(35, 0, 0, 0);
    pathButton.setLayoutParams(pathButtonViewParams);
    managerPathLayout.addView(pathButton);
    pathButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            //				Map<String, String> labMap = checkDialog.DetectionDisk();
            List<String> pathsStr = DownloadResourceManager.getInstance().getFileDir();
            if (pathsStr != null) {
              checkDialog.choiceUsbDialog();
              checkDialog.setListener(
                  new PathChoiceClickListener() {
                    @Override
                    public void onClick(View v) {
                      // 下载进度保存
                      LinkedHashMap<String, FilmDownLoad4k> downStatus =
                          DownloadResourceManager.getInstance().getDLStatus();
                      if (downStatus != null) {
                        DownloadResourceManager.getInstance().writeDownStatus(downStatus);
                      }
                      DownloadResourceManager.getInstance().clearDLData();
                      String path = (String) v.getTag();
                      DownloadResourceManager.getInstance().initDownPath(path);
                      // Log.e(dlStatus +" "+dlStatus.size());
                      if (context instanceof DownManagerActivity) {
                        ((DownManagerActivity) context).setData(true);
                      }

                      String present_edit = checkDialog.getDownPathname();
                      pathEdit.setText(present_edit);

                      // 初始化新路径后  检测U盘下载 更新UI
                      //							LinkedHashMap<String, FilmDownLoad4k> downStatu =
                      // DownloadResourceManager.getInstance().getDLStatus();
                      //							String path_dir =
                      // DownloadResourceManager.getInstance().getDownLoadPath();
                      //							if(downStatu != null){
                      //								if((path+"/voole_video").equalsIgnoreCase(path_dir)){

                      //									File downPath = new File(path_dir);
                      //									if (TextUtils.isEmpty(DownloadResourceManager.getInstance()
                      //											.getDownLoadPath())
                      //									|| !downPath.getParentFile().exists() || !downPath.exists()){
                      //										if(clickNum == 0){
                      //											managerAct.updateDownItem();
                      //										}
                      //										clickNum ++;
                      //									}
                      if (context instanceof DownManagerActivity) {
                        if (!((DownManagerActivity) context).isAlive) { // 如果下载线程停止
                          ((DownManagerActivity) context).setData(true); // 存放数据
                          ((DownManagerActivity) context).updateDownItem(); // 启动下载线程
                        }
                      }
                    }
                  });

            } else {
              // 没插入U盘
              TVAlertDialog tvDialog = new TVAlertDialog(context);
              tvDialog.showInspectDialog(context);
            }
          }
        });

    LayoutParams parmsPath = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    parmsPath.weight = 1;
    parmsPath.topMargin = 20;
    parmsPath.leftMargin = 40;
    parmsPath.rightMargin = 90;
    managerLayout.addView(managerPathLayout, parmsPath);

    LinearLayout managerTitleLayout = new LinearLayout(context);
    managerTitleLayout.setOrientation(LinearLayout.HORIZONTAL);
    managerTitleLayout.setBackgroundResource(R.drawable.bg_down_title);
    LayoutParams managerTitleLayoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, textSize + 50);
    managerTitleLayout.setLayoutParams(managerTitleLayoutParams);
    managerTitleLayout.setPadding(managerPad, managerPad - 4, managerPad, managerPad + 4);

    TextView nameText = new TextView(context);
    nameText.setText(R.string.filename);
    nameText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams nameTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 3);
    nameText.setTextColor(Color.parseColor("#d5ac84"));
    nameText.setGravity(Gravity.CENTER);
    nameText.setLayoutParams(nameTextParams);
    managerTitleLayout.addView(nameText);

    TextView progressText = new TextView(context);
    LayoutParams progressTextParams =
        new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 4);
    progressText.setText(R.string.progress);
    progressText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    progressText.setTextColor(Color.parseColor("#d5ac84"));
    progressText.setGravity(Gravity.CENTER);
    progressText.setLayoutParams(progressTextParams);
    managerTitleLayout.addView(progressText);

    TextView speedText = new TextView(context);
    speedText.setText(R.string.speed);
    speedText.setTextColor(Color.parseColor("#d5ac84"));
    speedText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams speedTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2);
    speedText.setGravity(Gravity.CENTER);
    speedText.setLayoutParams(speedTextParams);
    managerTitleLayout.addView(speedText);

    TextView sizeText = new TextView(context);
    sizeText.setText(R.string.size);
    sizeText.setTextColor(Color.parseColor("#d5ac84"));
    sizeText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams sizeTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1);
    sizeText.setGravity(Gravity.CENTER);
    sizeText.setLayoutParams(sizeTextParams);
    managerTitleLayout.addView(sizeText);

    TextView handleText = new TextView(context);
    handleText.setText(R.string.operation);
    handleText.setTextColor(Color.parseColor("#d5ac84"));
    handleText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams handleTextParams = new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2);
    handleText.setGravity(Gravity.CENTER);
    handleText.setLayoutParams(handleTextParams);
    managerTitleLayout.addView(handleText);
    LayoutParams parms = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    parms.weight = 1;
    parms.leftMargin = 30;
    parms.rightMargin = 30;
    parms.topMargin = managerPad - 5;
    managerLayout.addView(managerTitleLayout, parms);

    adapterLinearLayout = new FilmLinearLayout(context);
    LayoutParams adapterLinearLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    adapterLinearLayoutParams.weight = 6;
    managerLayout.addView(adapterLinearLayout, adapterLinearLayoutParams);
    adapterLinearLayout.setId(FilmLinearLayout.ADAPTERLINEARLAYOUT_ID);

    int pading = 20;
    LinearLayout pageIndexLayout = new LinearLayout(context);
    pageIndexLayout.setOrientation(LinearLayout.HORIZONTAL);
    LayoutParams pageIndexLayoutLayoutParams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    pageIndexLayout.setLayoutParams(pageIndexLayoutLayoutParams);
    pageIndexLayoutLayoutParams.setMargins(0, pading, 0, 0);
    pageIndexLayout.setGravity(Gravity.CENTER);

    Button preButton = new FocusAbleButton(context);
    preButton.setText(R.string.pre_page);
    preButton.setTextColor(Color.WHITE);
    preButton.setGravity(Gravity.CENTER);
    preButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams preButtonViewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    preButton.setLayoutParams(preButtonViewParams);
    pageIndexLayout.addView(preButton);
    preButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            adapterLinearLayout.showPrePage();
            pageIndexTextview.setText(
                adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
          }
        });
    preButton.setPadding(pading, 0, pading, 0);

    Button nextButton = new FocusAbleButton(context);
    nextButton.setText(R.string.next_page);
    nextButton.setTextColor(Color.WHITE);
    nextButton.setGravity(Gravity.CENTER);
    nextButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams nextButtonViewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    nextButtonViewParams.leftMargin = textSize - 5;
    nextButton.setLayoutParams(nextButtonViewParams);
    pageIndexLayout.addView(nextButton);
    nextButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            adapterLinearLayout.showNextPage();
            pageIndexTextview.setText(
                adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
          }
        });
    nextButton.setPadding(pading, 0, pading, 0);

    pageIndexTextview = new TextView(context);
    pageIndexTextview.setText(
        adapterLinearLayout.getCurrentPage() + "/" + adapterLinearLayout.getTotalPage());
    pageIndexTextview.setTextColor(Color.WHITE);
    pageIndexTextview.setGravity(Gravity.CENTER);
    pageIndexTextview.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    LayoutParams pageIndexTextviewParams =
        new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pageIndexTextviewParams.leftMargin = textSize - 5;
    pageIndexTextview.setLayoutParams(pageIndexTextviewParams);
    pageIndexLayout.addView(pageIndexTextview);
    LayoutParams pageIndexLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    pageIndexLayoutParams.weight = 1;
    managerLayout.addView(pageIndexLayout, pageIndexLayoutParams);

    TextView warnInfoTextView = new TextView(getContext());
    warnInfoTextView.setText(R.string.down_manager_warn_info);
    warnInfoTextView.setTextColor(Color.WHITE);
    warnInfoTextView.setGravity(Gravity.CENTER);
    warnInfoTextView.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
    android.widget.RelativeLayout.LayoutParams warnInfoLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    warnInfoLayoutParams.addRule(RelativeLayout.BELOW, MANAGERLAYOUT_ID);
    warnInfoLayoutParams.addRule(RelativeLayout.ALIGN_LEFT, MANAGERLAYOUT_ID);
    warnInfoLayoutParams.topMargin = textSize - 10;
    contentLayout.addView(warnInfoTextView, warnInfoLayoutParams);
  }
Example #27
0
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      RelativeLayout root = new RelativeLayout(mActivity);
      RelativeLayout.LayoutParams rootParams =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      root.setPadding(30, 0, 30, 0);
      root.setLayoutParams(rootParams);

      LinearLayout container = new LinearLayout(mActivity);
      container.setOrientation(LinearLayout.VERTICAL);
      LinearLayout.LayoutParams containerParams =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      containerParams.setMargins(30, 0, 30, 0);
      container.setLayoutParams(containerParams);
      container.setPadding(30, 20, 30, 20);

      TextView descView = new TextView(mActivity);
      LinearLayout.LayoutParams descViewParams =
          new LinearLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      descViewParams.setMargins(0, 20, 0, 20);
      descView.setLayoutParams(descViewParams);
      descView.setGravity(Gravity.CENTER);
      descView.setTextColor(Color.parseColor("#ffffff"));
      descView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
      descView.setText(mActivity.getString(R.string.pg_sdk_edit_quit_edit));
      container.addView(descView);

      ImageView vDivider = new ImageView(mActivity);
      LinearLayout.LayoutParams vDividerParams =
          new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1);
      vDividerParams.setMargins(0, 20, 0, 0);
      vDivider.setLayoutParams(vDividerParams);
      container.addView(vDivider);

      RelativeLayout buttonContainer = new RelativeLayout(mActivity);
      RelativeLayout.LayoutParams buttonContainerParams =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      buttonContainerParams.setMargins(0, 20, 0, 0);
      buttonContainer.setLayoutParams(buttonContainerParams);

      float density = mActivity.getResources().getDisplayMetrics().density;
      int width = mActivity.getResources().getDisplayMetrics().widthPixels;
      ImageView hDivider = new ImageView(mActivity);
      RelativeLayout.LayoutParams hDividerParams =
          new RelativeLayout.LayoutParams(1, Math.round(48 * density));
      hDividerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      hDivider.setLayoutParams(hDividerParams);
      buttonContainer.addView(hDivider);

      float[] outerR = new float[] {10, 10, 10, 10, 10, 10, 10, 10};

      RoundRectShape roundRectShape = new RoundRectShape(outerR, null, null);
      ShapeDrawable drawable = new ShapeDrawable(roundRectShape);
      drawable.getPaint().setColor(Color.parseColor("#404040"));
      drawable.getPaint().setStyle(Paint.Style.FILL);

      Button confirmButton = new Button(mActivity);
      RelativeLayout.LayoutParams confirmButtonParams =
          new RelativeLayout.LayoutParams(
              (width - Math.round(80 * density)) / 2, ViewGroup.LayoutParams.WRAP_CONTENT);
      confirmButtonParams.addRule(RelativeLayout.LEFT_OF, hDivider.getId());
      confirmButtonParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
      confirmButton.setLayoutParams(confirmButtonParams);
      confirmButton.setGravity(Gravity.CENTER);
      confirmButton.setTextColor(Color.parseColor("#FFFFFF"));
      confirmButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
      confirmButton.setText(mActivity.getString(R.string.pg_sdk_edit_ok));
      confirmButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (null != mListener) {
                mListener.onQuitDialogConfirm();
              }
            }
          });
      confirmButton.setBackgroundDrawable(drawable);
      buttonContainer.addView(confirmButton);

      Button closeButton = new Button(mActivity);
      RelativeLayout.LayoutParams closeButtonParams =
          new RelativeLayout.LayoutParams(
              (width - Math.round(80 * density)) / 2, ViewGroup.LayoutParams.WRAP_CONTENT);
      closeButtonParams.addRule(RelativeLayout.RIGHT_OF, hDivider.getId());
      closeButtonParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
      closeButton.setLayoutParams(closeButtonParams);
      closeButton.setGravity(Gravity.CENTER);
      closeButton.setTextColor(Color.parseColor("#9f9f9f"));
      closeButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
      closeButton.setText(mActivity.getString(R.string.pg_sdk_edit_quit));
      closeButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              dismiss();
            }
          });
      closeButton.setBackgroundDrawable(drawable);
      buttonContainer.addView(closeButton);

      container.addView(buttonContainer);
      root.addView(container);

      outerR = new float[] {20, 20, 20, 20, 20, 20, 20, 20};

      roundRectShape = new RoundRectShape(outerR, null, null);
      drawable = new ShapeDrawable(roundRectShape);
      drawable.getPaint().setColor(Color.parseColor("#343434"));
      drawable.getPaint().setStyle(Paint.Style.FILL);
      container.setBackgroundDrawable(drawable);

      setContentView(root);

      getWindow()
          .setLayout(
              WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);

      setCanceledOnTouchOutside(false);
    }