Skip to content

Instantly share code, notes, and snippets.

View TheLittleNaruto's full-sized avatar
🎯
Focusing

TheLittleNaruto TheLittleNaruto

🎯
Focusing
View GitHub Profile
@TheLittleNaruto
TheLittleNaruto / DynamicStateListDrawable
Last active August 29, 2015 14:01
Dynamically assign colors in StateListDrawable
/*I am sharing if you want to assign dynamically colors of buttons from the users for normal as well as pressed state. then you can just call this function :*/
public static StateListDrawable convertColorIntoBitmap(String pressedColor, String normalColor){
/*Creating bitmap for color which will be used at pressed state*/
Rect rectPressed = new Rect(0, 0, 1, 1);
Bitmap imagePressed = Bitmap.createBitmap(rectPressed.width(), rectPressed.height(), Config.ARGB_8888);
Canvas canvas = new Canvas(imagePressed);

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@TheLittleNaruto
TheLittleNaruto / android23.tag
Created January 5, 2016 11:20 — forked from rekire/android23.tag
External Android documentation for any doxygen project that should link to the orginal Android documentation. Just link that file in the expert tab under external as TAGFILES entry.
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="UTF-8"?><tagfile>
<compound kind="class">
<name>org::apache::harmony::tests::java::util::support::A</name>
<filename>http://developer.android.com/reference/org/apache/harmony/tests/java/util/support/A.html</filename>
<base>org::apache::harmony::tests::java::util::support::I</base>
</compound>
<compound kind="class">
<name>com::android::settingslib::bluetooth::A2dpProfile</name>
<filename>http://developer.android.com/reference/com/android/settingslib/bluetooth/A2dpProfile.html</filename>
<base>com::android::settingslib::bluetooth::LocalBluetoothProfile</base>
import android.graphics.Bitmap;
import android.util.LruCache;
import com.android.volley.toolbox.ImageLoader;
/**
* Created by BabyNaruto on 3/31/2015.
*/
public class BitmapLruCache extends LruCache<String, Bitmap>
implements ImageLoader.ImageCache {
import android.content.Context;
import android.graphics.Bitmap;
import android.support.v4.util.LruCache;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
/**
import android.content.Context;
import android.net.Uri;
import android.util.Log;
import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.fussy.R;
private void chooseImageFromGallery() {
Intent intent = new Intent();
// Show only images, no videos or anything else
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
// Always show the chooser (if there are multiple options available)
startActivityForResult(Intent.createChooser(intent, "Select Picture"), USER_IMG_GALLERY_REQ);
}
private String getRealPathFromURI(Uri contentURI) {
@TheLittleNaruto
TheLittleNaruto / CustomTabsActivity.java
Last active May 12, 2016 11:29
PagerAdapter with custom tabs
mPager = (ViewPager) findViewById(R.id.pager);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
mPager.setOffscreenPageLimit(NUM_PAGES);
footerView = findViewById(R.id.footer);
errorView = findViewById(R.id.errorMessage);
footerView.setVisibility(View.GONE);
initializeTabs();
mPager.requestTransparentRegion(mPager);
@TheLittleNaruto
TheLittleNaruto / CopyUtils.java
Last active October 4, 2016 11:45
Copy one bean properties to another bean by using Gson lib
import com.google.gson.Gson;
import android.util.Log;
/**
* Created by Baby Naruto on 04-10-2016.
*/
public class CopyUtils {
private static final String TAG = CopyUtils.class.getName();
import pandas as pd
pd.__version__
city_names = pd.Series(['San Francisco', 'San Jose', 'Sacramento'])
population = pd.Series([852469, 1015785, 485199])
cities = pd.DataFrame({ 'City name': city_names, 'Population': population })
cities['Area square miles'] = pd.Series([46.87, 176.53, 97.92])
cities['Population density'] = cities['Population'] / cities['Area square miles']
cities