/** * Called when the activity is first created. * * @param savedInstanceState the saved instance state */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.act_generic_list); setUpActionBar(); createBreadcrumb(getResources().getString(R.string.title_explore), (BreadCrumbHolder[]) null); mAdapter = new ExploreArrayAdapter(this); mContentObserver = new LQFBContentObserver(new Handler()); fillData(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); }
@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (isP(_P.secrecy) && !ENC) { setTitle("Initializing " + Main.name + "..."); return; } Intent caller = getIntent(); if (caller != null) { try { String tmp = caller.getStringExtra(_I.Main_setAbsoluteFolder.name()); if (tmp == null) { finish(); return; } setAbsoluteFolder(tmp); tmp = caller.getStringExtra(_I.Main_setFolderShowname.name()); if (tmp == null) { finish(); return; } setFolderShowname(tmp); } catch (Exception e) { e.printStackTrace(); return; } } WatchImpl.enable = false; l1 = new RelativeLayout(this); int xi = 0; while (true) { if (!checkFiles(xi)) break; xi++; } if (xi > max) max = xi; thetexts = new Vector<InnerEdit>(max + 5); ScrollView sv = new ScrollView(this); l1.addView(sv); RelativeLayout.LayoutParams sv_lp = (RelativeLayout.LayoutParams) sv.getLayoutParams(); sv_lp.width = RelativeLayout.LayoutParams.MATCH_PARENT; sv_lp.height = RelativeLayout.LayoutParams.WRAP_CONTENT; sv_lp.addRule(RelativeLayout.ALIGN_PARENT_TOP); sv.setLayoutParams(sv_lp); l2 = new LinearLayout(this); l2.setOrientation(LinearLayout.VERTICAL); l2.setLayoutParams( new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); sv.addView(l2); ArrayList<String> vals = null; ArrayList<Integer> ids = null; int newone = -1; int focusone = -1; if (caller != null) { if (caller.getBooleanExtra("OKAY", false)) { vals = caller.getStringArrayListExtra("vals"); ids = caller.getIntegerArrayListExtra("ids"); newone = caller.getIntExtra("newone", -1); focusone = caller.getIntExtra("curfocus", -1); } } if (newone > 0) max = newone + 1; setTitle(title(max)); for (int i = 0; i < max; i++) { EditText t2 = new EditText(this); t2.setId(i); t2.setOnFocusChangeListener( new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) curfocus = (EditText) v; } }); t2.setImeOptions(EditorInfo.IME_ACTION_DONE); t2.setOnEditorActionListener(one); InnerEdit in = new InnerEdit(t2); thetexts.add(in); t2.addTextChangedListener(new WatchImpl(in)); l2.addView(t2, 0); if (ids != null && ids.contains(i)) { String tmp = vals.get(ids.indexOf(i)); if (tmp != null) t2.setText(tmp); else t2.setText("err"); in.changed = true; } else { if (checkFiles(i)) { String x = loadFiles(i); t2.setText(x); } else { t2.setText(""); } } if (focusone >= 0) { if (i == focusone) t2.requestFocus(); } else { if (i == max - 1) t2.requestFocus(); } } WatchImpl.enable = true; Button b1 = new Button(this); b1.setText(" Save "); b1.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { int ctr = 0; for (int i = 0; i < max; i++) { if (thetexts.get(i).changed || !checkFiles(i)) { storeFiles(i, thetexts.get(i).edit.getText().toString()); ctr++; thetexts.get(i).changed = false; } } Toast.makeText(me, "Saved (" + ctr + ")", Toast.LENGTH_SHORT).show(); } }); Button b2 = new Button(this); b2.setText(" Add "); b2.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { EditText t2 = new EditText(me); t2.setOnFocusChangeListener( new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) curfocus = (EditText) v; } }); t2.setImeOptions(EditorInfo.IME_ACTION_DONE); t2.setOnEditorActionListener(one); l2.addView(t2, 0); t2.setId(max); max++; InnerEdit in = new InnerEdit(t2, true); thetexts.add(in); t2.addTextChangedListener(new WatchImpl(in)); setTitle(title(max)); t2.requestFocus(); } }); Button b3 = new Button(this); b3.setText("Save & Exit"); b3.setOnClickListener( new OnClickListener() { // TODO: reduce redundancy @Override public void onClick(View v) { int ctr = 0; for (int i = 0; i < max; i++) { if (thetexts.get(i).changed || !checkFiles(i)) { storeFiles(i, thetexts.get(i).edit.getText().toString()); ctr++; thetexts.get(i).changed = false; } } if (ctr > 0) Toast.makeText(me, "Saved (" + ctr + ")", Toast.LENGTH_SHORT).show(); else Toast.makeText(me, "Quick Exit", Toast.LENGTH_SHORT).show(); finish(); } }); Button b4 = new Button(this); b4.setText("Return"); b4.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { for (int i = 0; i < max; i++) { if (thetexts.get(i).changed || !checkFiles(i)) { Toast.makeText(me, "unsaved data", Toast.LENGTH_SHORT).show(); return; } } startActivity(new Intent(me, Startup.class)); finish(); } }); HorizontalScrollView hori = new HorizontalScrollView(this); LinearLayout ll_hori = new LinearLayout(this); ll_hori.setOrientation(LinearLayout.HORIZONTAL); ll_hori.addView(b1); ll_hori.addView(b3); ll_hori.addView(b2); ll_hori.addView(b4); hori.addView(ll_hori); l1.addView(hori); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); hori.setLayoutParams(lp); hori.setId(121232); sv_lp = (RelativeLayout.LayoutParams) sv.getLayoutParams(); sv_lp.addRule(RelativeLayout.ABOVE, hori.getId()); sv.setLayoutParams(sv_lp); BitmapDrawable bd = new BitmapDrawable( getResources(), BitmapFactory.decodeResource(getResources(), R.drawable.back_base)); bd.setTileModeXY(TileMode.MIRROR, TileMode.REPEAT); l1.setBackgroundDrawable(bd); setContentView(l1); }