List of usage examples for android.util TypedValue COMPLEX_UNIT_DIP
int COMPLEX_UNIT_DIP
To view the source code for android.util TypedValue COMPLEX_UNIT_DIP.
Click Source Link
From source file:com.esprit.droidcon.corruption.AutreListActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maillist_layout); imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(this)); retry = (Button) findViewById(R.id.retry); ButterKnife.bind(this); mBackground = mImageView;//from w ww.j a va 2 s .c o m moveBackground(); initToolbar(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); connexionlay = (RelativeLayout) findViewById(R.id.connexionlay); mang = new ArrayList<>(); final ListView listView = (ListView) findViewById(R.id.list_view); final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { connexionlay.setVisibility(View.GONE); // notify user you are online final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption"); query.whereEqualTo("Type", "Autre"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> conThus, ParseException e) { if (e == null) { //Log.d("score", "Retrieved " + scoreList.size() + " scores"); for (int i = conThus.size() - 1; i > 0; i--) { ParseObject dong = conThus.get(i); //System.out.println(dong.getParseFile("ImageFile").toString()); if (dong.getParseFile("AudioFile") != null) { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); /* SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView);*/ } else { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); } } } else { Log.d("score", "Error: " + e.getMessage()); Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Corruption corp = (Corruption) parent.getItemAtPosition(position); SwipeImageAdapter.img1 = corp.getImage1(); SwipeImageAdapter.img2 = corp.getImage2(); SwipeImageAdapter.img3 = corp.getImage3(); SwipeImageAdapter.title = corp.getTitle(); SwipeImageAdapter.desc = corp.getDesc(); //prodimg = prod.getProductImage(); Intent i = new Intent(AutreListActivity.this, SingleCorruptionActivity.class); i.putExtra("audiourl", corp.getAudiofile()); i.putExtra("longi", corp.getLongi()); i.putExtra("lat", corp.getLat()); i.putExtra("date", corp.getDate()); i.putExtra("title", corp.getTitle()); i.putExtra("desc", corp.getDesc()); i.putExtra("heure", corp.getHeure()); i.putExtra("ville", corp.getVille()); i.putExtra("usernom", corp.getUserNom()); i.putExtra("useradress", corp.getUserAdress()); i.putExtra("usertel", corp.getUserTel()); i.putExtra("usermail", corp.getUserMail()); i.putExtra("type", corp.getType()); i.putExtra("videocode", corp.getVideo()); i.putExtra("etat", corp.getEtat()); startActivity(i); finish(); } }); } else { // notify user you are not online connexionlay.setVisibility(View.VISIBLE); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // fabProgressCircle.show(); // startYourAsynchronousJob(); Intent refresh = new Intent(AutreListActivity.this, AutreListActivity.class); startActivity(refresh); finish(); } }); } }
From source file:com.amitupadhyay.aboutexample.ui.widget.FabOverlapTextView.java
private void recompute(int width) { if (text != null) { // work out the top padding and line height to align text to a 4dp grid final float fourDip = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); // ensure that the first line's baselines sits on 4dp grid by setting the top padding final Paint.FontMetricsInt fm = paint.getFontMetricsInt(); final int gridAlignedTopPadding = (int) (fourDip * (float) Math.ceil((unalignedTopPadding + Math.abs(fm.ascent)) / fourDip) - Math.ceil(Math.abs(fm.ascent))); super.setPadding(getPaddingLeft(), gridAlignedTopPadding, getPaddingTop(), getPaddingBottom()); // ensures line height is a multiple of 4dp final int fontHeight = Math.abs(fm.ascent - fm.descent) + fm.leading; final int baselineAlignedLineHeight = (int) (fourDip * (float) Math.ceil(lineHeightHint / fourDip)); // before we can workout indents we need to know how many lines of text there are; // so we need to create a temporary layout :( layout = StaticLayout.Builder.obtain(text, 0, text.length(), paint, width) .setLineSpacing(baselineAlignedLineHeight - fontHeight, 1f).setBreakStrategy(breakStrategy) .build();/*ww w .j a va 2 s . com*/ final int preIndentedLineCount = layout.getLineCount(); // now we can calculate the indents required for the given fab gravity final boolean gravityTop = (fabGravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP; final boolean gravityLeft = (fabGravity & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.LEFT; // we want to iterate forward/backward over the lines depending on whether the fab // overlap vertical gravity is top/bottom int currentLine = gravityTop ? 0 : preIndentedLineCount - 1; int remainingHeightOverlap = fabOverlapHeight - (gravityTop ? getPaddingTop() : getPaddingBottom()); final int[] leftIndents = new int[preIndentedLineCount]; final int[] rightIndents = new int[preIndentedLineCount]; do { if (remainingHeightOverlap > 0) { // still have overlap height to consume, set the appropriate indent leftIndents[currentLine] = gravityLeft ? fabOverlapWidth : 0; rightIndents[currentLine] = gravityLeft ? 0 : fabOverlapWidth; remainingHeightOverlap -= baselineAlignedLineHeight; } else { // have consumed the overlap height: no indent leftIndents[currentLine] = 0; rightIndents[currentLine] = 0; } if (gravityTop) { // iterate forward over the lines currentLine++; } else { // iterate backward over the lines currentLine--; } } while (gravityTop ? currentLine < preIndentedLineCount : currentLine >= 0); // now that we know the indents, create the actual layout layout = StaticLayout.Builder.obtain(text, 0, text.length(), paint, width) .setLineSpacing(baselineAlignedLineHeight - fontHeight, 1f) .setIndents(leftIndents, rightIndents).setBreakStrategy(breakStrategy).build(); // ensure that the view's height sits on the grid (as we've changed padding etc). final int height = getPaddingTop() + layout.getHeight() + getPaddingBottom(); final float overhang = height % fourDip; if (overhang != 0) { super.setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), unalignedBottomPadding + (int) (fourDip - overhang)); } } }
From source file:com.esprit.droidcon.corruption.SiteWebListActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maillist_layout); imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(this)); retry = (Button) findViewById(R.id.retry); ButterKnife.bind(this); mBackground = mImageView;// w ww. j a v a 2s.c o m moveBackground(); initToolbar(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); connexionlay = (RelativeLayout) findViewById(R.id.connexionlay); mang = new ArrayList<>(); final ListView listView = (ListView) findViewById(R.id.list_view); final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { connexionlay.setVisibility(View.GONE); // notify user you are online final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption"); query.whereEqualTo("Type", "Site Web"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> conThus, ParseException e) { if (e == null) { //Log.d("score", "Retrieved " + scoreList.size() + " scores"); for (int i = conThus.size() - 1; i > 0; i--) { ParseObject dong = conThus.get(i); //System.out.println(dong.getParseFile("ImageFile").toString()); if (dong.getParseFile("AudioFile") != null) { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); /* SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView);*/ } else { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); } } } else { Log.d("score", "Error: " + e.getMessage()); Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Corruption corp = (Corruption) parent.getItemAtPosition(position); SwipeImageAdapter.img1 = corp.getImage1(); SwipeImageAdapter.img2 = corp.getImage2(); SwipeImageAdapter.img3 = corp.getImage3(); SwipeImageAdapter.title = corp.getTitle(); SwipeImageAdapter.desc = corp.getDesc(); //prodimg = prod.getProductImage(); Intent i = new Intent(SiteWebListActivity.this, SingleCorruptionActivity.class); i.putExtra("audiourl", corp.getAudiofile()); i.putExtra("longi", corp.getLongi()); i.putExtra("lat", corp.getLat()); i.putExtra("date", corp.getDate()); i.putExtra("heure", corp.getHeure()); i.putExtra("title", corp.getTitle()); i.putExtra("desc", corp.getDesc()); i.putExtra("ville", corp.getVille()); i.putExtra("usernom", corp.getUserNom()); i.putExtra("useradress", corp.getUserAdress()); i.putExtra("usertel", corp.getUserTel()); i.putExtra("usermail", corp.getUserMail()); i.putExtra("type", corp.getType()); i.putExtra("videocode", corp.getVideo()); i.putExtra("etat", corp.getEtat()); startActivity(i); finish(); } }); } else { // notify user you are not online connexionlay.setVisibility(View.VISIBLE); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // fabProgressCircle.show(); // startYourAsynchronousJob(); Intent refresh = new Intent(SiteWebListActivity.this, SiteWebListActivity.class); startActivity(refresh); finish(); } }); } }
From source file:com.esprit.droidcon.corruption.EtatCivileListActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maillist_layout); imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(this)); retry = (Button) findViewById(R.id.retry); ButterKnife.bind(this); mBackground = mImageView;//from w w w.ja v a2s .com moveBackground(); initToolbar(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); connexionlay = (RelativeLayout) findViewById(R.id.connexionlay); mang = new ArrayList<>(); final ListView listView = (ListView) findViewById(R.id.list_view); final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { connexionlay.setVisibility(View.GONE); // notify user you are online final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption"); query.whereEqualTo("Type", "Etat Civil"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> conThus, ParseException e) { if (e == null) { //Log.d("score", "Retrieved " + scoreList.size() + " scores"); for (int i = conThus.size() - 1; i > 0; i--) { ParseObject dong = conThus.get(i); //System.out.println(dong.getParseFile("ImageFile").toString()); if (dong.getParseFile("AudioFile") != null) { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); /* SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView);*/ } else { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); } } } else { Log.d("score", "Error: " + e.getMessage()); Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Corruption corp = (Corruption) parent.getItemAtPosition(position); SwipeImageAdapter.img1 = corp.getImage1(); SwipeImageAdapter.img2 = corp.getImage2(); SwipeImageAdapter.img3 = corp.getImage3(); SwipeImageAdapter.title = corp.getTitle(); SwipeImageAdapter.desc = corp.getDesc(); //prodimg = prod.getProductImage(); Intent i = new Intent(EtatCivileListActivity.this, SingleCorruptionActivity.class); i.putExtra("audiourl", corp.getAudiofile()); i.putExtra("longi", corp.getLongi()); i.putExtra("lat", corp.getLat()); i.putExtra("title", corp.getTitle()); i.putExtra("desc", corp.getDesc()); i.putExtra("date", corp.getDate()); i.putExtra("heure", corp.getHeure()); i.putExtra("ville", corp.getVille()); i.putExtra("usernom", corp.getUserNom()); i.putExtra("useradress", corp.getUserAdress()); i.putExtra("usertel", corp.getUserTel()); i.putExtra("usermail", corp.getUserMail()); i.putExtra("type", corp.getType()); i.putExtra("videocode", corp.getVideo()); i.putExtra("etat", corp.getEtat()); startActivity(i); finish(); } }); } else { // notify user you are not online connexionlay.setVisibility(View.VISIBLE); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // fabProgressCircle.show(); // startYourAsynchronousJob(); Intent refresh = new Intent(EtatCivileListActivity.this, EtatCivileListActivity.class); startActivity(refresh); finish(); } }); } }
From source file:com.esprit.droidcon.corruption.RelationListActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maillist_layout); imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(this)); retry = (Button) findViewById(R.id.retry); ButterKnife.bind(this); mBackground = mImageView;/*from w ww .j ava2 s . c o m*/ moveBackground(); initToolbar(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); connexionlay = (RelativeLayout) findViewById(R.id.connexionlay); mang = new ArrayList<>(); final ListView listView = (ListView) findViewById(R.id.list_view); final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { connexionlay.setVisibility(View.GONE); // notify user you are online final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption"); query.whereEqualTo("Type", "Relation Avec Le Cityoen"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> conThus, ParseException e) { if (e == null) { //Log.d("score", "Retrieved " + scoreList.size() + " scores"); for (int i = conThus.size() - 1; i > 0; i--) { ParseObject dong = conThus.get(i); //System.out.println(dong.getParseFile("ImageFile").toString()); if (dong.getParseFile("AudioFile") != null) { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); /* SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView);*/ } else { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); } } } else { Log.d("score", "Error: " + e.getMessage()); Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Corruption corp = (Corruption) parent.getItemAtPosition(position); SwipeImageAdapter.img1 = corp.getImage1(); SwipeImageAdapter.img2 = corp.getImage2(); SwipeImageAdapter.img3 = corp.getImage3(); SwipeImageAdapter.title = corp.getTitle(); SwipeImageAdapter.desc = corp.getDesc(); //prodimg = prod.getProductImage(); Intent i = new Intent(RelationListActivity.this, SingleCorruptionActivity.class); i.putExtra("audiourl", corp.getAudiofile()); i.putExtra("longi", corp.getLongi()); i.putExtra("lat", corp.getLat()); i.putExtra("date", corp.getDate()); i.putExtra("heure", corp.getHeure()); i.putExtra("ville", corp.getVille()); i.putExtra("title", corp.getTitle()); i.putExtra("desc", corp.getDesc()); i.putExtra("usernom", corp.getUserNom()); i.putExtra("useradress", corp.getUserAdress()); i.putExtra("usertel", corp.getUserTel()); i.putExtra("usermail", corp.getUserMail()); i.putExtra("type", corp.getType()); i.putExtra("videocode", corp.getVideo()); i.putExtra("etat", corp.getEtat()); startActivity(i); finish(); } }); } else { // notify user you are not online connexionlay.setVisibility(View.VISIBLE); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // fabProgressCircle.show(); // startYourAsynchronousJob(); Intent refresh = new Intent(RelationListActivity.this, RelationListActivity.class); startActivity(refresh); finish(); } }); } }
From source file:com.dictionary.activity.ArticleCollectionActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Application app = (Application) getApplication(); app.installTheme(this); requestWindowFeature(Window.FEATURE_PROGRESS); setContentView(R.layout.activity_article_collection_loading); app.push(this); final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setSubtitle("..."); final Intent intent = getIntent(); final int position = intent.getIntExtra("position", 0); AsyncTask<Void, Void, ArticleCollectionPagerAdapter> createAdapterTask = new AsyncTask<Void, Void, ArticleCollectionPagerAdapter>() { @Override/*from w w w .j av a2 s . c o m*/ protected ArticleCollectionPagerAdapter doInBackground(Void... params) { ArticleCollectionPagerAdapter result; Uri articleUrl = intent.getData(); if (articleUrl != null) { result = createFromUri(app, articleUrl); } else { String action = intent.getAction(); if (action == null) { result = createFromLastResult(app); } else if (action.equals("showRandom")) { result = createFromRandom(app); } else if (action.equals("showBookmarks")) { result = createFromBookmarks(app); } else if (action.equals("showHistory")) { result = createFromHistory(app); } else { result = createFromIntent(app, intent); } } return result; } @Override protected void onPostExecute(ArticleCollectionPagerAdapter adapter) { if (isFinishing() || onDestroyCalled) { return; } articleCollectionPagerAdapter = adapter; if (articleCollectionPagerAdapter == null || articleCollectionPagerAdapter.getCount() == 0) { int messageId; if (articleCollectionPagerAdapter == null) { messageId = R.string.article_collection_invalid_link; } else { messageId = R.string.article_collection_nothing_found; } Toast.makeText(ArticleCollectionActivity.this, messageId, Toast.LENGTH_SHORT).show(); finish(); return; } if (position > articleCollectionPagerAdapter.getCount() - 1) { Toast.makeText(ArticleCollectionActivity.this, R.string.article_collection_selected_not_available, Toast.LENGTH_SHORT).show(); finish(); return; } setContentView(R.layout.activity_article_collection); findViewById(R.id.pager_title_strip).setVisibility( articleCollectionPagerAdapter.getCount() == 1 ? ViewGroup.GONE : ViewGroup.VISIBLE); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(articleCollectionPagerAdapter); viewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrollStateChanged(int arg0) { } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageSelected(final int position) { updateTitle(position); runOnUiThread(new Runnable() { @Override public void run() { ArticleFragment fragment = (ArticleFragment) articleCollectionPagerAdapter .getItem(position); fragment.applyTextZoomPref(); } }); } }); viewPager.setCurrentItem(position); PagerTitleStrip titleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); titleStrip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10); updateTitle(position); articleCollectionPagerAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { if (articleCollectionPagerAdapter.getCount() == 0) { finish(); } } }); } }; createAdapterTask.execute(); }
From source file:com.esprit.droidcon.corruption.MusicNewsActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.maillist_layout); imageLoader = ImageLoader.getInstance(); imageLoader.init(ImageLoaderConfiguration.createDefault(this)); retry = (Button) findViewById(R.id.retry); ButterKnife.bind(this); mBackground = mImageView;// w w w . j av a 2 s . c o m moveBackground(); initToolbar(); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); connexionlay = (RelativeLayout) findViewById(R.id.connexionlay); mang = new ArrayList<>(); final ListView listView = (ListView) findViewById(R.id.list_view); final ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetwork = conMgr.getActiveNetworkInfo(); if (activeNetwork != null && activeNetwork.isConnected()) { connexionlay.setVisibility(View.GONE); // notify user you are online final ParseQuery<ParseObject> query = ParseQuery.getQuery("Corruption"); query.whereEqualTo("Type", "Bureau d ordre"); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> conThus, ParseException e) { if (e == null) { //Log.d("score", "Retrieved " + scoreList.size() + " scores"); for (int i = conThus.size() - 1; i > 0; i--) { ParseObject dong = conThus.get(i); //System.out.println(dong.getParseFile("ImageFile").toString()); if (dong.getParseFile("AudioFile") != null) { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getParseFile("AudioFile").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); /* SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( new SwipeDismissAdapter(mGoogleCardsAdapter, this)); swingBottomInAnimationAdapter.setAbsListView(listView);*/ } else { mang.add(new Corruption(dong.getString("Title"), dong.getString("Description"), dong.getString("Date"), dong.getString("Adress"), dong.getParseFile("Photo1").getUrl(), dong.getParseFile("Photo2").getUrl(), dong.getParseFile("Photo3").getUrl(), dong.getDouble("Long"), dong.getDouble("Lat"), dong.getString("Heure"), dong.getString("Ville"), dong.getString("UserNom"), dong.getString("UserAdress"), dong.getString("UserTel"), dong.getString("UserMail"), dong.getString("Type"), dong.getString("VideoCode"), dong.getString("Etat") )); mGoogleCardsAdapter = new GoogleCardsTravelAdapter(getApplicationContext(), mang); SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter( mGoogleCardsAdapter); swingBottomInAnimationAdapter.setAbsListView(listView); assert swingBottomInAnimationAdapter.getViewAnimator() != null; swingBottomInAnimationAdapter.getViewAnimator() .setInitialDelayMillis(INITIAL_DELAY_MILLIS); listView.setClipToPadding(false); listView.setDivider(null); Resources r = getResources(); int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, r.getDisplayMetrics()); listView.setDividerHeight(px); listView.setFadingEdgeLength(0); listView.setFitsSystemWindows(true); px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, r.getDisplayMetrics()); listView.setPadding(px, px, px, px); listView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY); listView.setAdapter(swingBottomInAnimationAdapter); } } } else { Log.d("score", "Error: " + e.getMessage()); Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG) .show(); } } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Corruption corp = (Corruption) parent.getItemAtPosition(position); SwipeImageAdapter.img1 = corp.getImage1(); SwipeImageAdapter.img2 = corp.getImage2(); SwipeImageAdapter.img3 = corp.getImage3(); SwipeImageAdapter.title = corp.getTitle(); SwipeImageAdapter.desc = corp.getDesc(); //prodimg = prod.getProductImage(); Intent i = new Intent(MusicNewsActivity.this, SingleCorruptionActivity.class); i.putExtra("audiourl", corp.getAudiofile()); i.putExtra("longi", corp.getLongi()); i.putExtra("title", corp.getTitle()); i.putExtra("desc", corp.getDesc()); i.putExtra("photourl", corp.getImage1()); i.putExtra("lat", corp.getLat()); i.putExtra("date", corp.getDate()); i.putExtra("heure", corp.getHeure()); i.putExtra("ville", corp.getVille()); i.putExtra("usernom", corp.getUserNom()); i.putExtra("useradress", corp.getUserAdress()); i.putExtra("usertel", corp.getUserTel()); i.putExtra("usermail", corp.getUserMail()); i.putExtra("type", corp.getType()); i.putExtra("videocode", corp.getVideo()); i.putExtra("etat", corp.getEtat()); startActivity(i); finish(); } }); } else { // notify user you are not online connexionlay.setVisibility(View.VISIBLE); retry.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // fabProgressCircle.show(); // startYourAsynchronousJob(); Intent refresh = new Intent(MusicNewsActivity.this, MusicNewsActivity.class); startActivity(refresh); finish(); } }); } }
From source file:eu.trentorise.smartcampus.widget.shortcuts.StackWidgetService.java
@Override public RemoteViews getViewAt(int position) { // position will always range from 0 to getCount() - 1. // We construct a remote views item based on our widget item xml // file, and set the // text based on the position. RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item); ShapeDrawable sd1 = new ShapeDrawable(new RectShape()); sd1.getPaint().setColor(0xFFFFFFFF); sd1.getPaint().setStyle(Style.STROKE); sd1.getPaint().setStrokeWidth(1);//from w w w .ja v a 2 s . c om Canvas c = new Canvas(); sd1.draw(c); Bitmap b = Bitmap.createBitmap(120, 120, Bitmap.Config.ARGB_8888); c.drawBitmap(b, 0, 0, sd1.getPaint()); // Next, we set a fill-intent which will be used to fill-in the // pending intent template // which is set on the collection view in StackWidgetProvider. if (ALLPREFERENCES != null && ALLPREFERENCES[position] != null) { //ALLPREFERENCES dimensionato come le preferenze selezionate BookmarkDescriptor myDescriptor = ALLPREFERENCES[position]; // set the widgetbutton if (WidgetHelper.PARAM_TYPE.equals(myDescriptor.params.get(0).name)) { //controllare con gli input da config activity? String type = myDescriptor.params.get(0).value; if (WidgetHelper.TYPE_DT.equals(type)) { // dt -> put icons and hide text rv.setViewVisibility(R.id.text_widget_item, View.GONE); rv.setImageViewResource(R.id.image_widget_item, Integer.parseInt(myDescriptor.params.get(2).value)); rv.setInt(R.id.image_widget_item, "setBackgroundResource", R.drawable.rounded_border_dt); } else if (WidgetHelper.TYPE_JP.equals(type)) { // jp -> put text and hide icon rv.setViewVisibility(R.id.image_widget_item, View.GONE); // rv.setImageViewBitmap(R.id.text_widget_item, // getBackground(Color.parseColor("#6EB046"))); if (!("0".equals(myDescriptor.params.get(2).value))) { //bus rv.setTextViewTextSize(R.id.text_widget_item, TypedValue.COMPLEX_UNIT_DIP, 80); rv.setTextViewText(R.id.text_widget_item, RoutesHelper.getShortNameByRouteIdAndAgencyID( myDescriptor.params.get(4).value, myDescriptor.params.get(3).value)); //4,3 rv.setTextColor(R.id.text_widget_item, Integer.parseInt(myDescriptor.params.get(2).value));//rv.setInt(R.id.text_widget_item, "setBackgroundColor", //Integer.parseInt(myDescriptor.params.get(2).value)); rv.setInt(R.id.text_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp); } else { //train rv.setTextViewTextSize(R.id.text_widget_item, TypedValue.COMPLEX_UNIT_DIP, 12); //controllo contesto getRouteDescriptor i vari parametri rv.setTextViewText(R.id.text_widget_item, mContext.getString( RoutesHelper.getRouteDescriptorByRouteId(myDescriptor.params.get(3).value, myDescriptor.params.get(4).value).getNameResource())); rv.setTextColor(R.id.text_widget_item, Color.BLACK);//Int(R.id.text_widget_item, "setBackgroundColor",Color.BLACK); rv.setInt(R.id.text_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp); } } else if (WidgetHelper.TYPE_JP_PARKINGS.equals(type)) { // jp parcheggio -> put text and hide icon rv.setViewVisibility(R.id.text_widget_item, View.GONE); rv.setImageViewResource(R.id.image_widget_item, Integer.parseInt(myDescriptor.params.get(2).value)); rv.setInt(R.id.image_widget_item, "setBackgroundResource", R.drawable.rounded_border_jp); } BookmarkDescriptor bookmark = myDescriptor; Bundle extras = new Bundle(); extras.putString(StackWidgetProvider.EXTRA_INTENT, bookmark.getIntent()); if (bookmark.getParams() != null) { for (Param param : bookmark.getParams()) { extras.putString(param.name, param.value); } } Intent fillInIntent = new Intent(bookmark.getIntent()); fillInIntent.putExtras(extras); rv.setOnClickFillInIntent(R.id.layout, fillInIntent); } } // Return the remote views object. // AppWidgetManager manager = AppWidgetManager.getInstance(mContext); // manager.updateAppWidget(thisWidget, rv); return rv; }
From source file:com.b44t.ui.PasscodeActivity.java
@Override public View createView(Context context) { actionBar/*from w ww.j a v a 2s . c om*/ .setBackButtonImage(screen == SCREEN0_SETTINGS ? R.drawable.ic_ab_back : R.drawable.ic_close_white); actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } else if (id == pin_item) { currentPasswordType = 0; updateDropDownTextView(); } else if (id == password_item) { currentPasswordType = 1; updateDropDownTextView(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; if (screen != SCREEN0_SETTINGS) { ActionBarMenu menu = actionBar.createMenu(); menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); titleTextView = new TextView(context); titleTextView.setTextColor(0xff757575); if (screen == SCREEN1_ENTER_CODE1) { if (UserConfig.passcodeHash.length() != 0) { titleTextView .setText(LocaleController.getString("EnterNewPasscode", R.string.EnterNewPasscode)); } else { titleTextView.setText( LocaleController.getString("EnterNewFirstPasscode", R.string.EnterNewFirstPasscode)); } } else { titleTextView .setText(LocaleController.getString("EnterCurrentPasscode", R.string.EnterCurrentPasscode)); } titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); frameLayout.addView(titleTextView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER_HORIZONTAL; layoutParams.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); if (screen == SCREEN1_ENTER_CODE1) { passcodeSetStep = 0; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT); } else { passcodeSetStep = 1; passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE); } passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); frameLayout.addView(passwordEditText); layoutParams = (FrameLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams.topMargin = AndroidUtilities.dp(90); layoutParams.height = AndroidUtilities.dp(36); layoutParams.leftMargin = AndroidUtilities.dp(40); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (passcodeSetStep == 0) { processNext(); return true; } else if (passcodeSetStep == 1) { processDone(); return true; } return false; } }); passwordEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { if (passwordEditText.length() == 4) { if (screen == SCREEN2_ENTER_CODE2 && UserConfig.passcodeType == 0) { processDone(); } else if (screen == SCREEN1_ENTER_CODE1 && currentPasswordType == 0) { if (passcodeSetStep == 0) { processNext(); } else if (passcodeSetStep == 1) { processDone(); } } } } }); passwordEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() { public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; } public void onDestroyActionMode(ActionMode mode) { } public boolean onCreateActionMode(ActionMode mode, Menu menu) { return false; } public boolean onActionItemClicked(ActionMode mode, MenuItem item) { return false; } }); if (screen == SCREEN1_ENTER_CODE1) { dropDownContainer = new ActionBarMenuItem(context, menu, 0); dropDownContainer.setSubMenuOpenSide(1); dropDownContainer.addSubItem(pin_item, LocaleController.getString("PasscodePIN", R.string.PasscodePIN), 0); dropDownContainer.addSubItem(password_item, LocaleController.getString("PasscodePassword", R.string.PasscodePassword), 0); actionBar.addView(dropDownContainer); layoutParams = (FrameLayout.LayoutParams) dropDownContainer.getLayoutParams(); layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.rightMargin = AndroidUtilities.dp(40); layoutParams.leftMargin = AndroidUtilities.isTablet() ? AndroidUtilities.dp(64) : AndroidUtilities.dp(56); layoutParams.gravity = Gravity.TOP | Gravity.LEFT; dropDownContainer.setLayoutParams(layoutParams); dropDownContainer.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dropDownContainer.toggleSubMenu(); } }); dropDown = new TextView(context); dropDown.setGravity(Gravity.LEFT); dropDown.setSingleLine(true); dropDown.setLines(1); dropDown.setMaxLines(1); dropDown.setEllipsize(TextUtils.TruncateAt.END); dropDown.setTextColor(0xffffffff); dropDown.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_arrow_drop_down, 0); dropDown.setCompoundDrawablePadding(AndroidUtilities.dp(4)); dropDown.setPadding(0, 0, AndroidUtilities.dp(10), 0); dropDownContainer.addView(dropDown); layoutParams = (FrameLayout.LayoutParams) dropDown.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.leftMargin = AndroidUtilities.dp(16); layoutParams.gravity = Gravity.CENTER_VERTICAL; layoutParams.bottomMargin = AndroidUtilities.dp(1); dropDown.setLayoutParams(layoutParams); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); } updateDropDownTextView(); } else { actionBar.setTitle(LocaleController.getString("Passcode", R.string.Passcode)); frameLayout.setBackgroundColor(0xfff0f0f0); listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == changePasscodeRow) { presentFragment(new PasscodeActivity(SCREEN1_ENTER_CODE1)); } else if (i == passcodeOnOffRow) { TextCheckCell cell = (TextCheckCell) view; if (UserConfig.passcodeHash.length() != 0) { UserConfig.passcodeHash = ""; UserConfig.appLocked = false; UserConfig.saveConfig(false); int count = listView.getChildCount(); for (int a = 0; a < count; a++) { View child = listView.getChildAt(a); if (child instanceof TextSettingsCell) { TextSettingsCell textCell = (TextSettingsCell) child; textCell.setTextColor(0xffc6c6c6); break; } } cell.setChecked(UserConfig.passcodeHash.length() != 0); NotificationCenter.getInstance() .postNotificationName(NotificationCenter.didSetPasscode); } else { presentFragment(new PasscodeActivity(SCREEN1_ENTER_CODE1)); } } else if (i == autoLockRow) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AutoLock", R.string.AutoLock)); final NumberPicker numberPicker = new NumberPicker(getParentActivity()); numberPicker.setMinValue(0); numberPicker.setMaxValue(4); if (UserConfig.autoLockIn == 0) { numberPicker.setValue(0); } else if (UserConfig.autoLockIn == 60) { numberPicker.setValue(1); } else if (UserConfig.autoLockIn == 60 * 5) { numberPicker.setValue(2); } else if (UserConfig.autoLockIn == 60 * 60) { numberPicker.setValue(3); } else if (UserConfig.autoLockIn == 60 * 60 * 5) { numberPicker.setValue(4); } numberPicker.setFormatter(new NumberPicker.Formatter() { @Override public String format(int value) { if (value == 0) { return LocaleController.getString("Disabled", R.string.Disabled); } else if (value == 1) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Minutes, 1, 1); } else if (value == 2) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Minutes, 5, 5); } else if (value == 3) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Hours, 1, 1); } else if (value == 4) { return ApplicationLoader.applicationContext.getResources() .getQuantityString(R.plurals.Hours, 5, 5); } return ""; } }); numberPicker.setWrapSelectorWheel(false); builder.setView(numberPicker); builder.setNegativeButton(LocaleController.getString("Done", R.string.Done), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { which = numberPicker.getValue(); if (which == 0) { UserConfig.autoLockIn = 0; } else if (which == 1) { UserConfig.autoLockIn = 60; } else if (which == 2) { UserConfig.autoLockIn = 60 * 5; } else if (which == 3) { UserConfig.autoLockIn = 60 * 60; } else if (which == 4) { UserConfig.autoLockIn = 60 * 60 * 5; } listView.invalidateViews(); UserConfig.saveConfig(false); } }); showDialog(builder.create()); } else if (i == fingerprintRow) { UserConfig.useFingerprint = !UserConfig.useFingerprint; UserConfig.saveConfig(false); ((TextCheckCell) view).setChecked(UserConfig.useFingerprint); } } }); } return fragmentView; }
From source file:com.nextgis.maplibui.formcontrol.DoubleCombobox.java
@Override public void init(JSONObject element, List<Field> fields, Bundle savedState, Cursor featureCursor, SharedPreferences preferences) throws JSONException { mSubCombobox = new Spinner(getContext()); JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY); mFieldName = attributes.getString(JSON_FIELD_LEVEL1_KEY); mSubFieldName = attributes.getString(JSON_FIELD_LEVEL2_KEY); mIsShowLast = ControlHelper.isSaveLastValue(attributes); setEnabled(ControlHelper.isEnabled(fields, mFieldName)); String lastValue = null;/* w w w.j ava 2s .c o m*/ String subLastValue = null; if (ControlHelper.hasKey(savedState, mFieldName) && ControlHelper.hasKey(savedState, mSubFieldName)) { lastValue = savedState.getString(ControlHelper.getSavedStateKey(mFieldName)); subLastValue = savedState.getString(ControlHelper.getSavedStateKey(mSubFieldName)); } else if (null != featureCursor) { int column = featureCursor.getColumnIndex(mFieldName); int subColumn = featureCursor.getColumnIndex(mSubFieldName); if (column >= 0) lastValue = featureCursor.getString(column); if (subColumn >= 0) subLastValue = featureCursor.getString(subColumn); } else if (mIsShowLast) { lastValue = preferences.getString(mFieldName, null); subLastValue = preferences.getString(mSubFieldName, null); } JSONArray values = attributes.optJSONArray(JSON_VALUES_KEY); int defaultPosition = 0; int lastValuePosition = -1; int subLastValuePosition = -1; mAliasValueMap = new HashMap<>(); mSubAliasValueMaps = new HashMap<>(); mAliasSubListMap = new HashMap<>(); final ArrayAdapter<String> comboboxAdapter = new ArrayAdapter<>(getContext(), R.layout.formtemplate_double_spinner); setAdapter(comboboxAdapter); if (values != null) { for (int j = 0; j < values.length(); j++) { JSONObject keyValue = values.getJSONObject(j); String value = keyValue.getString(JSON_VALUE_NAME_KEY); String valueAlias = keyValue.getString(JSON_VALUE_ALIAS_KEY); Map<String, String> subAliasValueMap = new HashMap<>(); AliasList subAliasList = new AliasList(); mAliasValueMap.put(valueAlias, value); mSubAliasValueMaps.put(valueAlias, subAliasValueMap); mAliasSubListMap.put(valueAlias, subAliasList); comboboxAdapter.add(valueAlias); if (keyValue.has(JSON_DEFAULT_KEY) && keyValue.getBoolean(JSON_DEFAULT_KEY)) defaultPosition = j; if (null != lastValue && lastValue.equals(value)) // if modify data lastValuePosition = j; JSONArray subValues = keyValue.getJSONArray(JSON_VALUES_KEY); for (int k = 0; k < subValues.length(); k++) { JSONObject subKeyValue = subValues.getJSONObject(k); String subValue = subKeyValue.getString(JSON_VALUE_NAME_KEY); String subValueAlias = subKeyValue.getString(JSON_VALUE_ALIAS_KEY); subAliasValueMap.put(subValueAlias, subValue); subAliasList.aliasList.add(subValueAlias); if (subKeyValue.has(JSON_DEFAULT_KEY) && subKeyValue.getBoolean(JSON_DEFAULT_KEY)) subAliasList.defaultPosition = k; if (null != subLastValue && subLastValue.equals(subValue)) { // if modify data lastValuePosition = j; subLastValuePosition = k; } } } } setSelection(lastValuePosition >= 0 ? lastValuePosition : defaultPosition); final int subLastValuePositionFinal = subLastValuePosition; // The drop down view comboboxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); float minHeight = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 14, getResources().getDisplayMetrics()); setPadding(0, (int) minHeight, 0, (int) minHeight); mSubCombobox.setPadding(0, (int) minHeight, 0, (int) minHeight); setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String selectedValueAlias = comboboxAdapter.getItem(position); AliasList subAliasList = mAliasSubListMap.get(selectedValueAlias); ArrayAdapter<String> subComboboxAdapter = new ArrayAdapter<>(view.getContext(), R.layout.formtemplate_double_spinner, subAliasList.aliasList); subComboboxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSubCombobox.setAdapter(subComboboxAdapter); mSubCombobox.setSelection(mFirstShow && subLastValuePositionFinal >= 0 ? subLastValuePositionFinal : subAliasList.defaultPosition); if (mFirstShow) { mFirstShow = false; } } public void onNothingSelected(AdapterView<?> arg0) { } }); }