GithubHelp home page GithubHelp logo

jsramraj / flags Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 3.0 3.17 MB

Simple no nonsense library for getting flag icon for any country

License: MIT License

Java 100.00%
android android-library country flags jitpack maven

flags's Introduction

Hi there ๐Ÿ‘‹

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป About Me

  • I am a software engineer who loves programming, reading, driving and playing games.
  • I am specialized in building mobile apps.
  • I am a great team player with a growth mindset.
  • I have bachelor's degree engineering. But I strongly feel that all your academic degree and certificates doesn't matter unless you keep learning.
  • I am currently working as a Software Engineering Lead at Trimble, Inc in Chennai, India

๐Ÿ›  Tech Stack

Programming Languages

Tech Stack

๐Ÿ“ซ Reach Me

flags's People

Contributors

ivanvatov avatar jsramraj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flags's Issues

About the sprite

May i ask why the sprite is wasting a lot of empty space? All the flags could be put together, to make a smaller and lighter file..

Flags should not be storing context in the static reference. Potential to m/m leaks!

Hey @jsramraj,
Long time no see. Just got to see this library. Great attempt to solve this problem!
I am raising one issue which I saw while skimming through the code.

public static void init(final Context ctx) {

  1. Instead of storing the activity context, it should passed into the method calls every time, if it relies on Activity context.
  2. If it relies of application context, then we can use this approach but the caveat is you will not be able to take the benefits of localisation, application contexts do not give you localised strings, they will fallback to english.

Solving the existing code, requires something like a builder.
Flags.with(context).forCountry()

To make it even better and testable, separate out the user API forCountry in some

interface FlagDrawableProvider {
   public BitmapDrawable forCountry(enum or @StringDef countryCode);
}

When, user calls with(), library returns a concrete implementation of FlagDrawableProviderie Flags. This makes sure that user is not able to access any other method apart from API and we can get rid of all static keywords in the methods, and you can mock them in unit tests.
and if context is null or not an instance of AppCompatActivity, library can throw an exception.

Edit:

public static FlagDrawableProvider with(@NonNull final Context ctx) {'
        if(!ctx instanceof AppCompatActivity ) {
              throw new IllegalArgumentException("Some Message");
         }
        return new Flags();      // In real time, you might want to initialise only for the first time and for 
                                              // next calls reuse the same Flags instance.
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.