(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| package com.pantos27.www.lesson17_asynctask; | |
| import android.os.AsyncTask; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.view.View; | |
| import android.widget.Toast; | |
| import java.net.URL; |
| viewPager = new ViewPager(this){ | |
| @Override | |
| public boolean dispatchKeyEvent(KeyEvent event) { | |
| View nextFocus = findFocus(); | |
| if(event.getAction() == KeyEvent.ACTION_DOWN) { | |
| if(event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) | |
| Log.d("TestFocus", "" + (nextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus(), FOCUS_RIGHT))); | |
| else if(event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) | |
| Log.d("TestFocus", "" + (nextFocus = FocusFinder.getInstance().findNextFocus(this, findFocus(), FOCUS_LEFT))); |
| Picasso.with( context ) | |
| .load( your_path ) | |
| .error( R.drawable.ic_error ) | |
| .placeholder( R.drawable.progress_animation ) | |
| .into( image_view ); |
| //once created, set the position to the middle | |
| listViewObject.setSelectionFromTop(nameOfAdapterObject.MIDDLE, 0); |
| static void openStream(final Context context){ | |
| final InputStream stream = context.getResources().openRawResource(R.raw.messages); | |
| String string=convertStreamToString(stream); | |
| try { | |
| stream.close(); | |
| } catch (IOException e) { | |
| e.printStackTrace(); | |
| } | |
| } | |
| static String convertStreamToString(java.io.InputStream is) { |
| static <T> T[] joinArrays(T[] first,T[] second){ | |
| T[] joined = (T[]) Array.newInstance(second.getClass(),first.length+second.length); | |
| for (int i = 0; i < first.length; i++) { | |
| joined[i] = first[i]; | |
| } | |
| for (int i = 0; i < second.length; i++) { | |
| joined[i+first.length] = second[i]; | |
| } |
| public static byte[] hexStringToByteArray(String s) { | |
| int len = s.length(); | |
| byte[] data = new byte[len / 2]; | |
| for (int i = 0; i < len; i += 2) { | |
| data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) | |
| + Character.digit(s.charAt(i+1), 16)); | |
| } | |
| return data; | |
| } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import org.simpleframework.xml.Element; | |
| import org.simpleframework.xml.ElementList; | |
| import org.simpleframework.xml.Root; | |
| import java.util.List; | |
| @Root(name = "channel",strict = false) | |
| class Feed { | |
| @Element(name = "channel") | |
| Channel channel; |