RPI with power supply alternating between Li-ion battery pack and DC 5V
It seems you are making this overly complicated.  Have the battery power the Pi always.  When you have wall power available, it powers the battery charger.  During that time the battery is getting charged since presumably the charger produces more current than the Pi draws.  If not, get a different charger.

Nothing needs to be specifically switched.  Whether the battery is being charged or not, either way the battey voltage is used to run the Pi.